/* Spell — дизайн-токены и компоненты. Цвета — только через токены. */
:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f0eee8;
  --line: #e3e0d8;
  --ink: #1d1c1a;
  --ink-2: #5c5953;
  --ink-3: #8b877f;
  --accent: #3b5bdb;
  --accent-ink: #ffffff;
  --accent-soft: #e7ecfd;
  --rec: #e03131;
  --ok: #2b8a3e;
  --ok-soft: #e6f4ea;
  --warn: #b35c00;
  --warn-soft: #fff1e0;
  --bad: #c92a2a;
  --bad-soft: #fdeaea;
  --shadow: 0 1px 2px rgba(20, 18, 14, .06), 0 4px 16px rgba(20, 18, 14, .05);
  --r: 14px;
  --r-s: 10px;
  --tap: 44px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141413; --surface: #1d1d1b; --surface-2: #262623; --line: #33322e;
    --ink: #ecebe6; --ink-2: #b3b0a8; --ink-3: #85827a;
    --accent: #7c95f5; --accent-ink: #0d1330; --accent-soft: #232b4a;
    --rec: #ff6b6b; --ok: #69db7c; --ok-soft: #1b3122; --warn: #ffa94d; --warn-soft: #3a2a15;
    --bad: #ff8787; --bad-soft: #3d1f1f;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141413; --surface: #1d1d1b; --surface-2: #262623; --line: #33322e;
  --ink: #ecebe6; --ink-2: #b3b0a8; --ink-3: #85827a;
  --accent: #7c95f5; --accent-ink: #0d1330; --accent-soft: #232b4a;
  --rec: #ff6b6b; --ok: #69db7c; --ok-soft: #1b3122; --warn: #ffa94d; --warn-soft: #3a2a15;
  --bad: #ff8787; --bad-soft: #3d1f1f;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; }

/* ---- каркас ---- */
.top {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.2) blur(6px); border-bottom: 1px solid var(--line);
}
.top-in { max-width: 1080px; margin: auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.logo { font-weight: 750; font-size: 19px; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.logo i { width: 26px; height: 26px; border-radius: 8px; background: var(--accent); display: inline-grid; place-items: center; color: var(--accent-ink); font-style: normal; font-size: 15px; }
.top .sp { flex: 1; }
.nav { display: flex; gap: 4px; }
.nav a { text-decoration: none; color: var(--ink-2); padding: 8px 12px; border-radius: var(--r-s); font-size: 15px; }
.nav a.on { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.wrap { max-width: 1080px; margin: auto; padding: 20px 16px 96px; }
.narrow { max-width: 440px; }

/* ---- карточки и кнопки ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 8px; letter-spacing: -.015em; }
h2 { font-size: 19px; margin: 0 0 10px; }
h3 { font-size: 16px; margin: 0 0 6px; }
.btn {
  min-height: var(--tap); padding: 0 16px; border-radius: var(--r-s); border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: 15px; text-decoration: none; color: var(--ink); white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.block { width: 100%; }
.btn.sm { min-height: 34px; padding: 0 10px; font-size: 14px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.field { display: block; width: 100%; min-height: var(--tap); padding: 10px 12px; border-radius: var(--r-s); border: 1px solid var(--line); background: var(--surface); }
.field:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea.field { min-height: 120px; resize: vertical; line-height: 1.55; }
label.lbl { display: block; font-size: 13px; color: var(--ink-2); margin: 12px 0 6px; font-weight: 600; }

.note { padding: 10px 12px; border-radius: var(--r-s); font-size: 14px; }
.note.ok { background: var(--ok-soft); color: var(--ok); }
.note.bad { background: var(--bad-soft); color: var(--bad); }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.acc { background: var(--accent-soft); color: var(--accent); }

/* ---- вход ---- */
.hero { text-align: center; padding: 40px 0 8px; }
.hero h1 { font-size: 32px; }
.hero p { color: var(--ink-2); max-width: 520px; margin: 0 auto; }
.feats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 28px 0; }
.feat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; font-size: 14px; color: var(--ink-2); }
.feat b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: 13px; margin: 16px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---- модальное окно (вместо alert/confirm) ---- */
.ov { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 100; padding: 16px; }
.ov .box { background: var(--surface); border-radius: var(--r); padding: 20px; width: min(440px, 100%); box-shadow: var(--shadow); border: 1px solid var(--line); }
.ov .box h3 { font-size: 18px; margin-bottom: 8px; }
.ov .acts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: 14px; z-index: 120; max-width: calc(100% - 32px); }

/* ---- нижняя навигация на телефоне ---- */
.tabbar { display: none; }
@media (max-width: 720px) {
  .nav { display: none; }
  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--surface);
    border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { flex: 1; text-align: center; text-decoration: none; color: var(--ink-3); font-size: 11px; padding: 4px 0; display: flex; flex-direction: column; align-items: center; gap: 2px; }
  .tabbar a span { font-size: 20px; line-height: 1; }
  .tabbar a.on { color: var(--accent); font-weight: 600; }
  .feats { grid-template-columns: 1fr; }
  .hero { padding-top: 20px; }
  .hero h1 { font-size: 26px; }
  h1 { font-size: 22px; }
  .card { padding: 16px; }
}

/* ---- новая запись ---- */
.new-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.new-grid .card + .card { margin-top: 0; }
.dim { opacity: .45; pointer-events: none; }
.rec-ui { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 12px 0 4px; text-align: center; }
.rec-btn {
  width: 96px; height: 96px; border-radius: 50%; border: 4px solid var(--line); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; transition: transform .15s;
}
.rec-btn span { width: 44px; height: 44px; border-radius: 50%; background: var(--rec); transition: all .2s; }
.rec-btn:hover { transform: scale(1.04); }
.rec-btn.live { border-color: color-mix(in srgb, var(--rec) 35%, transparent); animation: pulse 1.6s infinite; }
.rec-btn.live span { width: 34px; height: 34px; border-radius: 8px; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--rec) 35%, transparent); } 50% { box-shadow: 0 0 0 12px transparent; } }
.rec-time { font-size: 34px; font-weight: 700; letter-spacing: .02em; }
.level { width: 70%; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.level i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .1s; }
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 190px;
  border: 2px dashed var(--line); border-radius: var(--r); cursor: pointer; text-align: center; padding: 16px;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-ic { font-size: 28px; color: var(--accent); }
.pbar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 8px; }
.pbar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }

/* ---- список ---- */
.list { display: flex; flex-direction: column; gap: 10px; }
.item { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; text-decoration: none; color: var(--ink); }
.item:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.item-h { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 2px; }
.item-h b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-snip { color: var(--ink-2); font-size: 14px; margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.empty { text-align: center; padding: 40px 20px; }
.empty-ic { font-size: 40px; }

/* ---- карточка записи ---- */
.rec-head { margin: 8px 0 14px; }
.rec-head h1 { margin-bottom: 4px; }
.editable { cursor: text; }
.editable:hover { text-decoration: underline dotted var(--ink-3); }
.rec-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; align-items: start; }
.rec-layout .card + .card { margin-top: 14px; }
.side { position: sticky; top: 72px; }
.tr { font-size: 16px; line-height: 1.65; }
.seg { margin: 0 0 12px; padding: 2px 6px; margin-left: -6px; border-radius: 8px; }
.seg.on { background: var(--accent-soft); }
.tc { border: 0; background: var(--surface-2); color: var(--ink-2); border-radius: 6px; font-size: 12px; padding: 2px 6px; margin-right: 8px; cursor: pointer; vertical-align: 1px; }
.tc:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); }
.tc:disabled { cursor: default; }
.tr-plain { white-space: pre-wrap; }

@media (max-width: 720px) {
  .new-grid { grid-template-columns: 1fr; }
  .rec-layout { grid-template-columns: 1fr; }
  .side { position: static; }
  .rec-time { font-size: 30px; }
}

/* ---- вкладки, итоги, чат ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -6px 0 14px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 10px 12px; font-weight: 600; color: var(--ink-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; min-height: var(--tap); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.tabs button:disabled { opacity: .4; cursor: default; }
.cnt { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--surface-2); color: var(--ink-2); font-size: 11px; text-align: center; }
.tpl-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tpl { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-s); padding: 10px 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; min-height: 64px; text-align: center; }
.tpl span { font-size: 20px; }
.tpl:hover { border-color: var(--accent); background: var(--accent-soft); }
.sum { border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; margin-bottom: 12px; }
.sum-h { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.md { line-height: 1.6; }
.md h2, .md h3, .md h4 { margin: 14px 0 6px; font-size: 16px; }
.md h2:first-child, .md h3:first-child { margin-top: 0; }
.md p { margin: 0 0 8px; }
.md ul { margin: 0 0 8px; padding-left: 20px; }
.md li { margin-bottom: 4px; }
.chk { color: var(--accent); }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: sp .8s linear infinite; vertical-align: -2px; }
@keyframes sp { to { transform: rotate(360deg); } }
.chat { max-height: 60vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.msg { padding: 10px 14px; border-radius: 14px; max-width: 88%; line-height: 1.55; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.msg.assistant p:last-child { margin-bottom: 0; }
.sugg { display: flex; flex-wrap: wrap; gap: 8px; }
.ask-form { display: flex; gap: 8px; }
.ask-form .field { flex: 1; }
.acts-col { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.acts-col .btn { justify-content: flex-start; }
.fmt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.fmt-grid .btn { flex-direction: column; min-height: 64px; gap: 0; }
.sh-row { border: 1px solid var(--line); border-radius: var(--r-s); padding: 8px 10px; margin-bottom: 8px; }
.sh-url { word-break: break-all; margin-bottom: 6px; }
.search { margin-bottom: 10px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 12px; font-size: 14px; cursor: pointer; min-height: 34px; color: var(--ink); }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip.on .cnt { background: transparent; color: inherit; }
.chip.ghost { border-style: dashed; color: var(--ink-2); }
mark { background: color-mix(in srgb, var(--accent) 25%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.tr .tc, .md .tc { cursor: pointer; }
button.badge { border: 0; cursor: pointer; }
@media (max-width: 720px) {
  .tpl-grid { grid-template-columns: repeat(2, 1fr); }
  .msg { max-width: 94%; }
}

/* ---- тарифы ---- */
.big { font-size: 26px; font-weight: 700; }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.plans .card + .card { margin-top: 0; }
.plan.cur { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.plan-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.plan-buy { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.price { font-size: 20px; font-weight: 700; }
.cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cmp > div { border: 1px solid var(--line); border-radius: var(--r-s); padding: 12px; font-size: 14px; color: var(--ink); }
/* ---- экран владельца ---- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.kpi b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 13px; color: var(--ink-2); }
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { color: var(--ink-2); font-weight: 600; font-size: 12px; }
.tbl td.num, .tbl th.num { text-align: right; }
.bad-txt { color: var(--bad); font-weight: 600; }
@media (max-width: 720px) {
  .plans, .cmp { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
}
.legal h2 { font-size: 17px; margin: 18px 0 8px; }
.legal h2:first-child { margin-top: 0; }
.legal p, .legal li { line-height: 1.6; }
.oauth-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn.oauth { justify-content: flex-start; gap: 10px; }
.oi { width: 24px; height: 24px; border-radius: 6px; display: inline-grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff; flex: none; }
.oauth.google .oi { background: #4285f4; }
.oauth.yandex .oi { background: #fc3f1d; }
.oauth.telegram .oi { background: #2aabee; }
.oauth.vk .oi { background: #0077ff; font-size: 10px; }
.link-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); color: var(--ink); font-size: 15px; }
.diar { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.diar input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.spk { font-weight: 700; }
.spk0 { color: var(--accent); } .spk1 { color: #c2410c; } .spk2 { color: var(--ok); } .spk3 { color: #9333ea; } .spk4 { color: #0e7490; } .spk5 { color: #be185d; }
:root[data-theme="dark"] .spk1 { color: #fb923c; } :root[data-theme="dark"] .spk3 { color: #c084fc; } :root[data-theme="dark"] .spk4 { color: #22d3ee; } :root[data-theme="dark"] .spk5 { color: #f472b6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .spk1 { color: #fb923c; } :root:not([data-theme="light"]) .spk3 { color: #c084fc; } :root:not([data-theme="light"]) .spk4 { color: #22d3ee; } :root:not([data-theme="light"]) .spk5 { color: #f472b6; } }
