:root {
  color-scheme: light dark;
  --bg: #111318;
  --surface: #191c23;
  --surface-2: #222630;
  --surface-3: #2a303b;
  --border: #353b47;
  --text: #f4f6f8;
  --muted: #a6afbc;
  --accent: #8ea9ff;
  --accent-strong: #6e8fff;
  --danger: #ff8a8a;
  --shadow: 0 18px 40px rgba(0,0,0,.22);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }

.app-shell {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 38px 0 60px;
}

.site-header { margin-bottom: 28px; }
.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(2rem, 4vw, 3.4rem); line-height: 1.05; }
h2 { margin-bottom: 4px; font-size: 1.08rem; }
.subtitle, .panel-heading p, .workspace-toolbar p { color: var(--muted); }
.subtitle { max-width: 760px; margin-bottom: 0; }
.panel-heading p, .workspace-toolbar p { margin-bottom: 0; font-size: .9rem; line-height: 1.4; }

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.sidebar { display: grid; gap: 18px; }
.panel, .workspace {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.panel { padding: 20px; }
.panel-heading { margin-bottom: 18px; }
.with-action { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }

.field-label, legend {
  display: block;
  margin: 14px 0 7px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
}

input[type="text"], input[type="number"], textarea, select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}

input:focus, textarea:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

textarea { resize: vertical; }

.size-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 56px;
  align-items: center;
  gap: 10px;
}

.size-control output {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 10px;
  font-weight: 800;
}

.field-message { min-height: 1.1em; margin: 6px 0 0; color: var(--danger); font-size: .8rem; }

.toggle-row, .radio-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
}
.toggle-row { margin-top: 17px; }
.radio-row { margin: 8px 0; font-size: .92rem; }

fieldset { border: 0; padding: 0; margin: 0; }
.nested-options {
  margin-top: 12px;
  padding: 12px 14px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,.015);
}

.button {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 750;
}
.button.primary { background: var(--accent-strong); color: #fff; }
.button.secondary { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.button.tertiary { background: transparent; border-color: var(--border); color: var(--muted); }
.button.small { padding: 7px 10px; font-size: .82rem; }
.full-width { width: 100%; margin-top: 9px; }

.item-list { display: grid; gap: 10px; margin-top: 14px; }
.item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 12px;
}
.item-main { min-width: 0; }
.item-image-controls { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.image-upload-label {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
}
.image-upload-label input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.item-preview-wrap { position: relative; width: 60px; min-height: 60px; }
.item-preview { width: 60px; height: 60px; object-fit: cover; border-radius: 9px; border: 1px solid var(--border); }
.icon-button {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
}

.workspace { padding: 20px; min-width: 0; }
.workspace-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

.board-export-area {
  display: grid;
  place-items: center;
  overflow: auto;
  padding: clamp(10px, 3vw, 24px);
  background: #fff;
  border-radius: 14px;
}

.board {
  display: grid;
  width: min(100%, 900px);
  aspect-ratio: 1 / 1;
  border: 3px solid #111;
  background: #111;
  gap: 2px;
}

.board-cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #fff;
  color: #111;
  text-align: center;
  padding: clamp(4px, .7vw, 10px);
  font-weight: 800;
  line-height: 1.08;
  overflow-wrap: anywhere;
  cursor: pointer;
  user-select: none;
}
.board-cell .cell-text {
  display: block;
  width: 100%;
  max-height: 100%;
  line-height: 1.08;
  overflow-wrap: anywhere;
}
.board-cell.marked::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(17, 19, 24, .52);
  pointer-events: none;
  z-index: 3;
}
.board-cell .mark-indicator {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: clamp(1.3rem, 5vw, 4rem);
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  z-index: 4;
  text-shadow: 0 2px 8px rgba(0,0,0,.45);
}
.board-cell.marked .mark-indicator { opacity: 1; }
.board-cell.free-space { background: #eceff8; }
.board-cell img { width: 100%; height: 100%; display: block; }
.board-cell img.cover { object-fit: cover; }
.board-cell img.contain { object-fit: contain; padding: 5%; }
.board-cell .cell-label {
  position: absolute;
  left: 5%;
  right: 5%;
  bottom: 5%;
  padding: 5px 7px;
  border-radius: 7px;
  background: rgba(0,0,0,.78);
  color: #fff;
  font-size: clamp(.42rem, .8vw, .8rem);
  opacity: 0;
  transition: opacity .15s ease;
  pointer-events: none;
  z-index: 2;
}
.board-cell.has-image:focus .cell-label,
.board-cell.has-image.show-label .cell-label { opacity: 1; }

.hidden { display: none !important; }

@media (hover:hover) and (pointer:fine) {
  .board-cell.has-image:hover .cell-label { opacity: 1; }
}

@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar .panel:first-child { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .app-shell { width: min(100% - 20px, 1500px); padding-top: 24px; }
  .sidebar { grid-template-columns: 1fr; }
  .sidebar .panel:first-child { grid-column: auto; }
  .workspace-toolbar { flex-direction: column; }
  .actions { justify-content: flex-start; width: 100%; }
  .actions .button { flex: 1 1 130px; }
  .panel, .workspace { border-radius: 14px; }
}

@media print {
  body { background: #fff; }
  .site-header, .sidebar, .workspace-toolbar { display: none !important; }
  .app-shell, .layout, .workspace { width: 100%; margin: 0; padding: 0; display: block; border: 0; box-shadow: none; }
  .board-export-area { padding: 0; }
  .board { width: 100%; max-width: none; }
}
