/* Рабочий документ, а не дашборд: тёплая бумага, один акцент.
   Принцип Granola: то, что написала ПМ, — чёрным; то, что дописал ИИ, — серым. */

:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --sunken: #efece5;
  --ink: #1d1b18;
  --ink-ai: #5d5850;
  --muted: #8b857a;
  --line: #e3dfd5;
  --accent: #2f5d50;
  --accent-ink: #ffffff;
  --accent-soft: #e2ece7;
  --rec: #c8452f;
  --rec-soft: #f7e3de;
  --warn: #9a6514;
  --warn-soft: #f6ead3;
  --ok: #3b7a4a;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --surface: #1f1e1b;
    --sunken: #1a1917;
    --ink: #eeeae2;
    --ink-ai: #aea89d;
    --muted: #7f7a70;
    --line: #2f2d29;
    --accent: #7fb5a2;
    --accent-ink: #10201b;
    --accent-soft: #21302b;
    --rec: #e8705b;
    --rec-soft: #3a221d;
    --warn: #d9a650;
    --warn-soft: #33291a;
    --ok: #7fbf8c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
button, input, textarea, select { font: inherit; color: inherit; }
.mono, .tc { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

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

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); cursor: pointer; white-space: nowrap;
  font-weight: 550; font-size: 14px;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.rec { background: var(--rec); border-color: var(--rec); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: var(--sunken); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.big { height: 44px; padding: 0 22px; font-size: 16px; border-radius: 10px; }

.field { display: grid; gap: 4px; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 550; }
.input, textarea.input, select.input {
  width: 100%; padding: 8px 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 64px; line-height: 1.45; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600;
  background: var(--sunken); color: var(--muted); white-space: nowrap;
}
.chip.rec { background: var(--rec-soft); color: var(--rec); }
.chip.ok { background: var(--accent-soft); color: var(--accent); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- каркас ---------- */

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px 80px; }
.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 18px 0 14px;
}
.topbar .grow { flex: 1; min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--ink); }
.brand img { width: 26px; height: 26px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

/* ---------- список созвонов ---------- */

.home-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 28px 0 18px; }
.home-head h1 { font-size: 28px; }
.sessions { display: grid; gap: 10px; }
.srow {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 16px;
  padding: 14px 16px; color: inherit;
}
.srow:hover { text-decoration: none; border-color: var(--muted); }
.srow .t { font-weight: 650; }
.srow .m { color: var(--muted); font-size: 13px; }
.srow .sum { grid-column: 1 / -1; color: var(--ink-ai); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }

.newform { padding: 18px; display: grid; gap: 14px; margin-bottom: 18px; }
.newform .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode {
  display: grid; gap: 2px; padding: 12px 14px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.mode input { display: none; }
.mode b { font-weight: 650; }
.mode small { color: var(--muted); }
.sources { grid-template-columns: repeat(3, 1fr); }
.setup .mode { display: grid; align-items: start; gap: 2px; }
.mode.off { opacity: .55; cursor: default; }
.mode:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- страница созвона ---------- */

.s-title {
  font-size: 22px; font-weight: 700; border: 0; background: transparent; padding: 2px 4px; margin-left: -4px;
  border-radius: 6px; width: 100%; outline: none;
}
.s-title:hover { background: var(--sunken); }
.s-title:focus { background: var(--surface); box-shadow: 0 0 0 2px var(--accent-soft); }
.s-meta { color: var(--muted); font-size: 13px; padding-left: 0; }

.control {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 14px; margin: 6px 0 16px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
}
.timer { font-family: var(--mono); font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 92px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--rec); animation: pulse 1.4s infinite; flex: none; }
.dot.paused { animation: none; background: var(--muted); }
@keyframes pulse { 50% { opacity: .25; } }
.meters { display: grid; gap: 4px; min-width: 150px; }
.meter { display: grid; grid-template-columns: 62px 1fr; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.meter .bar { height: 6px; border-radius: 3px; background: var(--sunken); overflow: hidden; }
.meter .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .08s linear; }
.control .grow { flex: 1; }
.pipeline { font-size: 13px; color: var(--muted); }
.pipeline b { color: var(--ink); font-weight: 600; }

.setup { padding: 22px; margin: 6px 0 18px; display: grid; gap: 16px; }
.setup ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.setup .opts { display: flex; gap: 18px; flex-wrap: wrap; }
.setup label { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.alert { padding: 10px 14px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-size: 14px; }
.alert.err { background: var(--rec-soft); color: var(--rec); }
.alert .btn { margin-left: 8px; }

.grid { display: grid; grid-template-columns: 360px 1fr; gap: 18px; align-items: start; }
.panel { padding: 16px; }
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.notes-panel { position: sticky; top: 76px; max-height: calc(100vh - 96px); display: flex; flex-direction: column; }
.notes-panel .list { overflow: auto; flex: 1; margin: 0 -6px; padding: 0 6px; }
.note-input { margin-bottom: 8px; }
.note-input textarea { min-height: 76px; font-size: 15px; }
.hint { font-size: 12px; color: var(--muted); margin: 4px 0 12px; }
kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: var(--surface); }

.note {
  display: grid; grid-template-columns: 46px 1fr auto; gap: 8px; align-items: start;
  padding: 7px 6px; border-radius: 8px;
}
.note:hover { background: var(--sunken); }
.note .tc { font-size: 12px; color: var(--muted); padding-top: 2px; }
.note .txt { color: var(--ink); white-space: pre-wrap; word-break: break-word; }
.note.is-task .txt { font-weight: 600; }
.note .acts { display: flex; gap: 2px; opacity: 0; }
.note:hover .acts { opacity: 1; }
.flag { cursor: pointer; border: 0; background: none; padding: 2px 4px; border-radius: 5px; color: var(--muted); font-size: 13px; }
.flag:hover { background: var(--line); color: var(--ink); }
.note.is-task .flag.t { color: var(--accent); opacity: 1; }
.note .badge { font-size: 11px; color: var(--accent); font-weight: 650; }
.note.pending .tc::after { content: " ·"; color: var(--warn); }

/* ---------- документ ---------- */

.doc { padding: 22px 26px; }
.doc section + section { margin-top: 22px; }
.doc h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; margin-bottom: 8px; display: flex; gap: 8px; align-items: center; }
.doc h2 .n { font-family: var(--mono); color: var(--muted); font-weight: 500; }
.doc .summary { font-size: 16px; line-height: 1.55; color: var(--ink-ai); }
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 10px; color: var(--ink-ai); }
.item.pm { color: var(--ink); }
.item .meta { font-size: 12px; color: var(--muted); }
.item.revised .text { text-decoration: line-through; text-decoration-color: var(--muted); opacity: .7; }
.tcl { font-family: var(--mono); font-size: 12px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tcl:hover { color: var(--accent); text-decoration: underline; }
.placeholder { color: var(--muted); font-style: italic; font-size: 14px; }

.tasks { display: grid; gap: 8px; }
.task {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  display: grid; gap: 4px; background: var(--surface);
  border-left: 3px solid var(--line);
}
.task.pm { border-left-color: var(--ink); }
.task.accepted { border-left-color: var(--ok); background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.task .head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.task .title { font-weight: 650; color: var(--ink); flex: 1; min-width: 200px; }
.task:not(.pm) .title { color: var(--ink); }
.task .desc { color: var(--ink-ai); font-size: 14px; white-space: pre-wrap; }
.task .row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.task .row .grow { flex: 1; }
.prio-high { background: var(--rec-soft); color: var(--rec); }
.prio-low { opacity: .8; }
.task.editing { gap: 8px; }
.task .edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
details.rejected summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-top: 6px; }
details.rejected .task { opacity: .6; }

.spec { color: var(--ink); line-height: 1.6; }
.spec h3, .spec h4 { font-size: 16px; margin: 18px 0 6px; }
.spec h3:first-child { margin-top: 0; }
.spec p { margin: 6px 0; }
.spec ul, .spec ol { margin: 6px 0; padding-left: 22px; }
.spec code { font-family: var(--mono); font-size: 13px; background: var(--sunken); padding: 1px 4px; border-radius: 4px; }

.exportbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 16px; margin-bottom: 14px; }
.exportbar .grow { flex: 1; }

.transcript { margin-top: 18px; }
.transcript summary { cursor: pointer; padding: 12px 16px; font-weight: 600; list-style: none; display: flex; gap: 8px; align-items: center; }
.transcript summary::-webkit-details-marker { display: none; }
.transcript summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
.transcript[open] summary::before { transform: rotate(90deg); }
.ttools { display: flex; align-items: center; gap: 6px; padding: 0 16px 10px; flex-wrap: wrap; }
.ttools .grow { flex: 1; }
.seg { display: inline-flex; background: var(--sunken); border-radius: 8px; padding: 2px; }
.seg button { border: 0; background: transparent; padding: 4px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 550; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .08); }
.traw { white-space: pre-wrap; }
.tlines { padding: 0 16px 16px; display: grid; gap: 3px; max-height: 520px; overflow: auto; font-size: 14px; }
.tblock { display: grid; grid-template-columns: 60px 1fr; gap: 10px; padding: 6px 0; border-top: 1px dashed var(--line); }
.tblock:first-child { border-top: 0; }
.tline b { font-weight: 650; }
.tblock.err { color: var(--rec); }

.player { position: sticky; bottom: 12px; z-index: 6; padding: 8px 12px; margin-top: 16px; display: flex; gap: 10px; align-items: center; }
.player audio { width: 100%; height: 34px; }

.dropzone {
  display: block;
  border: 2px dashed var(--line); border-radius: 12px; padding: 34px 20px; text-align: center;
  color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.dropzone b { color: var(--ink); }
.progress { height: 6px; background: var(--sunken); border-radius: 3px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .3s; }

.spinner { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.pip { display: grid; gap: 8px; padding: 10px; height: 100vh; grid-template-rows: auto auto 1fr; }
.pip-head { display: flex; align-items: center; gap: 10px; }
.pip-head .timer { font-size: 18px; min-width: 0; }
.pip-head .pipeline { font-size: 11px; margin-left: auto; }
.pip textarea { min-height: 70px; resize: none; }
.pip-last { overflow: auto; font-size: 13px; }
.pip-last .note { grid-template-columns: 40px 1fr; padding: 3px 0; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 8px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%); }

.login { max-width: 340px; margin: 18vh auto 0; padding: 26px; display: grid; gap: 14px; }

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .notes-panel { position: static; max-height: none; }
  .newform .row2, .modes, .sources { grid-template-columns: 1fr; }
  .doc { padding: 18px 16px; }
  .wrap { padding: 0 16px 80px; }
  .task .edit-grid { grid-template-columns: 1fr; }
}
