/* Доска ретро: маркерная доска с бумажными стикерами.
   Вся смелость — в стикерах; рамки, шапка и кнопки тихие. */

:root {
  --board: #e9edf2;
  --dot: #c9d1db;
  --frame: #ffffff;
  --line: #d5dbe3;
  --ink: #1c2430;
  --ink-soft: #5b6676;
  --marker: #2f3fd0;
  --marker-ink: #ffffff;
  --danger: #c2372b;
  --note-ink: #1f2228;
  --shadow: 0 1px 1px rgba(28, 36, 48, 0.12), 0 6px 10px -6px rgba(28, 36, 48, 0.35);
  --ui: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --display: ui-rounded, 'SF Pro Rounded', 'Arial Rounded MT Bold', 'Nunito', var(--ui);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --board: #171b22;
    --dot: #2a313c;
    --frame: #1f252e;
    --line: #333c49;
    --ink: #e8ecf1;
    --ink-soft: #9aa5b5;
    --marker: #8c98ff;
    --marker-ink: #12162b;
    --danger: #ff8a7d;
    --shadow: 0 1px 1px rgba(0, 0, 0, 0.4), 0 6px 10px -6px rgba(0, 0, 0, 0.7);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  font: 15px/1.45 var(--ui);
  color: var(--ink);
  background: var(--board) radial-gradient(var(--dot) 1px, transparent 1.5px) 0 0 / 22px 22px;
}
h1, h2, h3, p { margin: 0; }
h1, h2 { font-family: var(--display); letter-spacing: -0.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--marker); outline-offset: 2px; }

/* ---------- кнопки и поля ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 7px 14px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--frame); color: var(--ink);
  font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-soft); }
.btn.primary { background: var(--marker); border-color: var(--marker); color: var(--marker-ink); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 13px; }

.icon {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; padding: 0;
  border: 0; border-radius: 6px; background: transparent; color: inherit;
  font-weight: 700; cursor: pointer;
}
.icon:hover:not(:disabled) { background: rgba(0, 0, 0, 0.1); }
.icon:disabled { opacity: 0.3; cursor: default; }
.icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

input[type='text'], input[type='number'], select, textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--frame);
}
textarea { resize: vertical; display: block; }
input[type='checkbox'] { width: 17px; height: 17px; margin: 0; accent-color: var(--marker); flex: none; }
.check { display: flex; flex-direction: row; align-items: center; gap: 8px; cursor: pointer; }
.empty { color: var(--ink-soft); font-size: 13px; }
.count { color: var(--ink-soft); font-size: 13px; font-variant-numeric: tabular-nums; }

/* ---------- список ретро ---------- */

.home { max-width: 1040px; margin: 0 auto; padding: 48px 20px 64px; }
.home-head h1 { font-size: 56px; line-height: 1; }
.home-head p { margin-top: 10px; color: var(--ink-soft); max-width: 46ch; }
.home-grid { display: grid; grid-template-columns: 340px 1fr; gap: 40px; margin-top: 40px; align-items: start; }

.create {
  display: grid; gap: 14px;
  padding: 22px 22px 24px;
  background: #ffe066; color: var(--note-ink);
  border-radius: 3px; box-shadow: var(--shadow);
  rotate: -0.8deg;
}
.create h2 { font-size: 22px; }
.create label:not(.check) { display: grid; gap: 4px; font-size: 13px; font-weight: 600; }
.create .check { font-size: 14px; }
.create input[type='text'], .create input[type='number'] { background: rgba(255, 255, 255, 0.75); border-color: rgba(0, 0, 0, 0.18); color: var(--note-ink); }
.create .row { display: grid; grid-template-columns: 1fr 172px; gap: 12px; align-items: end; }
.create .btn { justify-self: start; }

.boards h2 { font-size: 18px; margin-bottom: 12px; }
.board-row {
  display: grid; grid-template-columns: 10px 1fr auto; grid-template-areas: 'sw name tag' 'sw facts tag';
  column-gap: 14px; align-items: center;
  padding: 14px 16px; margin-bottom: 8px;
  background: var(--frame); border: 1px solid var(--line); border-radius: 10px;
  color: inherit; text-decoration: none;
}
.board-row:hover { border-color: var(--marker); }
.swatch { grid-area: sw; width: 10px; height: 100%; border-radius: 3px; background: var(--line); }
.swatch.ph-write { background: #9fc1ff; } .swatch.ph-read { background: #ffe066; }
.swatch.ph-vote { background: #ffb0c8; } .swatch.ph-discuss { background: #8fe3a0; }
.board-name { grid-area: name; font-family: var(--display); font-size: 18px; font-weight: 700; }
.board-name small { margin-left: 8px; font: 500 13px var(--ui); color: var(--ink-soft); }
.board-facts { grid-area: facts; color: var(--ink-soft); font-size: 13px; }
.phase-tag { grid-area: tag; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.phase-tag:not(.ph-done) { color: var(--marker); }

/* ---------- шапка доски ---------- */

.board-page { display: flex; flex-direction: column; min-height: 100vh; }
.loading { display: grid; gap: 14px; justify-items: start; padding: 64px 24px; color: var(--ink-soft); }

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--frame); border-bottom: 1px solid var(--line);
}
.back { color: var(--ink-soft); text-decoration: none; font-size: 20px; line-height: 1; padding: 4px; }
.back:hover { color: var(--ink); }
.title { font-size: 22px; margin-right: 6px; }
.facilitator .title, .facilitator .col header h2 { cursor: text; }

.steps { display: flex; gap: 2px; }
.step {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 6px;
  border: 0; border-radius: 999px; background: transparent;
  color: var(--ink-soft); font-size: 13px; font-weight: 600;
}
.step b {
  display: inline-grid; place-items: center; width: 20px; height: 20px;
  border-radius: 50%; border: 1.5px solid currentColor; font-size: 11px;
}
.step.past { color: var(--ink); }
.step.past b { background: var(--ink); border-color: var(--ink); color: var(--frame); }
.step.current { background: var(--marker); color: var(--marker-ink); }
.step.current b { border-color: transparent; background: var(--marker-ink); color: var(--marker); }
.step:not(:disabled) { cursor: pointer; }
.step:not(:disabled):not(.current):hover { background: var(--board); }

.timer { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.timer-text { font: 700 20px var(--display); font-variant-numeric: tabular-nums; }
.timer-text.soon { color: var(--danger); }
.timer-text.over { color: var(--danger); font-size: 15px; animation: blink 1s steps(2) 6; }
@keyframes blink { 50% { opacity: 0.25; } }
.timer-select { width: auto; padding: 5px 8px; font-size: 13px; }

.people { display: flex; }
.avatar {
  position: relative;
  display: inline-grid; place-items: center; width: 30px; height: 30px; margin-left: 4px;
  border-radius: 50%; border: 2px solid var(--frame);
  background: hsl(var(--hue) 62% 42%); color: #fff;
  font-size: 11px; font-weight: 700; cursor: default;
}
.avatar.away { opacity: 0.4; }
.avatar.lead { box-shadow: 0 0 0 2px var(--marker); }
.avatar i {
  position: absolute; right: -5px; bottom: -5px;
  min-width: 16px; height: 16px; padding: 0 3px;
  display: grid; place-items: center;
  border-radius: 8px; background: var(--ink); color: var(--frame);
  font-size: 10px; font-style: normal;
}

.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-body, .menu-group { display: grid; gap: 8px; }
.menu-body {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30;
  width: 240px; padding: 12px;
  background: var(--frame); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.4);
}
.menu-group { padding-top: 10px; border-top: 1px solid var(--line); }
.menu-group label:not(.check) { display: grid; gap: 4px; font-size: 13px; }
.menu-group .check { font-size: 14px; }

.hintbar {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 10px 20px;
}
.hint { flex: 1 1 320px; max-width: 76ch; color: var(--ink-soft); }
.linking .hint { color: var(--marker); font-weight: 600; }
.dots { letter-spacing: 2px; color: var(--marker); }
.dots em { font-style: normal; opacity: 0.25; }
.votes-left { font-weight: 600; font-size: 13px; }

.mood { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.mood-label, .mood-count { font-size: 13px; color: var(--ink-soft); margin-right: 6px; }
.mood-count { margin: 0 0 0 6px; }
.mood-btn {
  position: relative; width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: 50%; background: transparent;
  font-size: 19px; line-height: 1; cursor: pointer;
  filter: grayscale(1); opacity: 0.55;
}
.mood-btn:hover, .mood-btn.on { filter: none; opacity: 1; }
.mood-btn.on { background: var(--frame); box-shadow: 0 0 0 2px var(--marker); }
.mood-btn i {
  position: absolute; right: -3px; top: -4px; min-width: 15px; height: 15px;
  border-radius: 8px; background: var(--ink); color: var(--frame);
  font: normal 700 10px/15px var(--ui); text-align: center;
}

.offline .top::after {
  content: 'Нет связи с сервером — пробуем переподключиться';
  flex-basis: 100%; color: var(--danger); font-size: 13px; font-weight: 600;
}

/* ---------- доска ---------- */

.board {
  position: relative; flex: 1 0 auto; align-content: start;
  display: grid; grid-template-columns: repeat(4, minmax(230px, 1fr)) minmax(280px, 1.25fr);
  gap: 26px; align-items: stretch;
  padding: 6px 20px 48px;
  overflow-x: auto;
}
.col { min-width: 0; display: flex; flex-direction: column; }
.col > header { display: flex; align-items: baseline; gap: 8px; padding: 0 2px 6px; }
.col > header h2 { font-size: 17px; font-weight: 700; }
.frame {
  display: flex; flex-direction: column; gap: 14px;
  flex: 1; min-height: 300px; padding: 14px;
  background: var(--frame); border: 1px solid var(--line); border-radius: 4px;
}
.cards { display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 60px; }
.cards.drop-end::after { content: ''; height: 3px; border-radius: 2px; background: var(--marker); }

.c-blue { --note: #a6c5ff; } .c-yellow { --note: #ffe066; } .c-green { --note: #93e2a3; }
.c-teal { --note: #86ddd2; } .c-pink { --note: #ffb0c8; } .c-orange { --note: #ffc27d; } .c-violet { --note: #cdbbff; }

.note {
  position: relative; z-index: 6;
  padding: 12px 12px 6px;
  background: var(--note); color: var(--note-ink);
  border-radius: 2px 2px 10px 2px / 2px 2px 26px 2px;
  box-shadow: var(--shadow);
  transition: rotate 0.12s;
}
.note:nth-child(3n + 1) { rotate: -0.7deg; }
.note:nth-child(3n + 2) { rotate: 0.5deg; }
.note:hover, .note:focus-within { rotate: 0deg; z-index: 7; }
.note[draggable='true'] { cursor: grab; }
.note.dragging { opacity: 0.35; }
.note.drop-before::before {
  content: ''; position: absolute; left: 0; right: 0; top: -8px; height: 3px; border-radius: 2px; background: var(--marker);
}
.note.is-linking { outline: 3px solid var(--marker); outline-offset: 2px; }
.linking .note:not(.is-hidden) { cursor: crosshair; }

.note-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.35; min-height: 1.35em; }
.note-text:empty { display: none; }
.note-img { display: block; width: 100%; max-height: 240px; object-fit: contain; margin-bottom: 8px; border-radius: 2px; background: rgba(0, 0, 0, 0.06); }
.note-edit { background: rgba(255, 255, 255, 0.6); border-color: rgba(0, 0, 0, 0.2); color: var(--note-ink); padding: 4px 6px; }
.note footer { display: flex; align-items: center; gap: 8px; min-height: 28px; margin-top: 6px; }
.who { flex: 1; font-size: 12px; opacity: 0.62; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vote { display: inline-flex; align-items: center; gap: 2px; }
.vote .dots { color: var(--note-ink); font-size: 11px; }
.vote .plus { background: rgba(0, 0, 0, 0.12); border-radius: 50%; }
.tally {
  min-width: 24px; height: 24px; padding: 0 7px;
  display: inline-grid; place-items: center;
  border-radius: 12px; background: var(--note-ink); color: var(--note);
  font-weight: 700; font-size: 13px;
}
.tools {
  position: absolute; right: 4px; top: -14px;
  display: none; gap: 1px; padding: 2px;
  background: var(--note-ink); color: #fff; border-radius: 8px;
}
.tools .icon:hover { background: rgba(255, 255, 255, 0.2); }
.note:hover .tools, .note:focus-within .tools { display: flex; }
.linking .tools { display: none !important; }

.note.is-hidden { padding-bottom: 12px; }
.veil { display: grid; gap: 7px; }
.veil i { height: 8px; border-radius: 4px; background: rgba(0, 0, 0, 0.16); }
.veil i:nth-child(2) { width: 82%; } .veil i:nth-child(3) { width: 55%; }

.composer { display: grid; gap: 6px; }
.composer textarea { font-size: 14px; }
.composer-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.preview { position: relative; }
.preview:empty { display: none; }
.preview img { display: block; max-width: 100%; max-height: 120px; border-radius: 4px; }
.preview .icon { position: absolute; left: 4px; top: 4px; background: var(--frame); }

.links { position: absolute; left: 0; top: 0; z-index: 5; pointer-events: none; overflow: visible; }
.link-line { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; opacity: 0.7; }
.link-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
.link-hit:hover { stroke: color-mix(in srgb, var(--danger) 35%, transparent); }

/* ---------- действия ---------- */

.actions .frame { border-style: dashed; border-width: 2px; border-color: var(--ink-soft); }
.alist { display: grid; gap: 10px; flex: 1; align-content: start; }
.alist h3 { font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-top: 4px; }
.action { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: start; }
.action > input { margin-top: 3px; }
.action p { overflow-wrap: anywhere; }
.action.done p { text-decoration: line-through; color: var(--ink-soft); }
.action-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.owner { width: auto; max-width: 100%; padding: 2px 6px; font-size: 12px; border-radius: 999px; }
.from { font-size: 12px; color: var(--ink-soft); }
.action > .icon { opacity: 0; }
.action:hover > .icon, .action > .icon:focus-visible { opacity: 1; }
.aform { display: grid; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.aform select { width: auto; min-width: 0; flex: 1; font-size: 13px; padding: 5px 8px; }

/* ---------- диалоги и уведомления ---------- */

.dlg {
  width: min(380px, calc(100vw - 32px)); padding: 24px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--frame); color: var(--ink);
}
.dlg.wide { width: min(680px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(15, 20, 30, 0.5); }
.dlg form, .dlg { display: grid; gap: 12px; }
.dlg:not([open]) { display: none; }
.dlg p { color: var(--ink-soft); }
.dlg textarea { font: 13px/1.5 ui-monospace, 'SF Mono', Menlo, Consolas, monospace; }
.dlg-row { display: flex; gap: 8px; }

#toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 100;
  translate: -50% 20px; opacity: 0; pointer-events: none;
  padding: 10px 16px; border-radius: 10px;
  background: var(--ink); color: var(--board); font-weight: 600;
  transition: opacity 0.15s, translate 0.15s;
}
#toast.show { opacity: 1; translate: -50% 0; }

/* ---------- узкие экраны ---------- */

@media (max-width: 1180px) {
  .board { grid-template-columns: repeat(4, 250px) 300px; }
}
@media (max-width: 760px) {
  .home { padding-top: 28px; }
  .home-head h1 { font-size: 40px; }
  .home-grid { grid-template-columns: 1fr; gap: 28px; }
  .board-row { grid-template-areas: 'sw name tag' 'sw facts facts'; }
  .top { padding: 8px 16px; gap: 10px; }
  .steps { order: 10; flex-basis: 100%; overflow-x: auto; }
  .hintbar, .board { padding-left: 16px; padding-right: 16px; }
  .board { grid-template-columns: repeat(4, 82vw) 86vw; gap: 16px; scroll-snap-type: x mandatory; }
  .col { scroll-snap-align: center; }
  .tools { display: flex; position: static; margin: 6px -6px 0; background: transparent; color: inherit; justify-content: flex-end; }
  .tools .icon:hover { background: rgba(0, 0, 0, 0.1); }
  .action > .icon { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
