/* Личный архив — спокойный светлый интерфейс с тёмной темой. Размеры в rem: учитывается масштаб текста системы. */
:root {
  --bg: #f6f4ef;
  --bg-elev: #ffffff;
  --bg-soft: #efece4;
  --text: #1f2421;
  --text-soft: #5d645f;
  --text-faint: #8a908b;
  --line: #e2ded4;
  --accent: #2f6f5e;
  --accent-soft: #dcebe5;
  --accent-text: #ffffff;
  --rec: #c4473a;
  --rec-soft: #f6dfdb;
  --warn: #9a6a12;
  --warn-soft: #f6ead0;
  --ok: #2f6f45;
  --ok-soft: #dcefe1;
  --info-soft: #e3ebf6;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.05);
  --radius: 16px;
  --radius-sm: 10px;
  --nav-h: 4.25rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "PT Serif", Georgia, "Times New Roman", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151615; --bg-elev: #1e201f; --bg-soft: #262927; --text: #ecefec; --text-soft: #b1b8b3; --text-faint: #858c87; --line: #333735;
    --accent: #6bb59c; --accent-soft: #23362f; --accent-text: #0e1512; --rec: #e57265; --rec-soft: #3a2623; --warn: #e2b85c; --warn-soft: #3a3020;
    --ok: #7cc99a; --ok-soft: #213328; --info-soft: #222b38; --shadow: 0 1px 2px rgba(0, 0, 0, 0.3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151615; --bg-elev: #1e201f; --bg-soft: #262927; --text: #ecefec; --text-soft: #b1b8b3; --text-faint: #858c87; --line: #333735;
  --accent: #6bb59c; --accent-soft: #23362f; --accent-text: #0e1512; --rec: #e57265; --rec-soft: #3a2623; --warn: #e2b85c; --warn-soft: #3a3020;
  --ok: #7cc99a; --ok-soft: #213328; --info-soft: #222b38; --shadow: 0 1px 2px rgba(0, 0, 0, 0.3); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 1rem/1.5 var(--font); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
img, video { max-width: 100%; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--bg-elev); padding: 0.5rem 1rem; z-index: 100; }
.skip-link:focus { left: 0.5rem; }
.boot { padding: 3rem; text-align: center; color: var(--text-soft); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* каркас */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 1rem; padding-top: max(0.6rem, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar .brand { font-weight: 650; font-size: 1.05rem; text-decoration: none; color: var(--text); display: flex; gap: 0.5rem; align-items: center; }
.topbar .spacer { flex: 1; }
.topbar .who { width: 2.4rem; height: 2.4rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; text-decoration: none; }
.sidenav { display: none; }
main { flex: 1; width: 100%; max-width: 860px; margin: 0 auto; padding: 1rem 1rem calc(var(--nav-h) + 1.5rem + env(safe-area-inset-bottom)); }
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--bg-elev);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.bottomnav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.1rem; min-height: var(--nav-h); text-decoration: none; color: var(--text-soft); font-size: 0.75rem; }
.bottomnav a .ico { font-size: 1.35rem; line-height: 1; }
.bottomnav a[aria-current="page"] { color: var(--accent); font-weight: 650; }
@media (min-width: 900px) {
  .shell { flex-direction: row; }
  .sidenav { display: flex; flex-direction: column; gap: 0.25rem; position: sticky; top: 0; height: 100vh; width: 15rem; padding: 1rem; border-right: 1px solid var(--line); background: var(--bg-elev); }
  .sidenav a { display: flex; gap: 0.75rem; align-items: center; padding: 0.7rem 0.9rem; border-radius: var(--radius-sm); text-decoration: none; color: var(--text); }
  .sidenav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
  .sidenav .brand { font-weight: 700; font-size: 1.1rem; padding: 0.5rem 0.9rem 1rem; }
  .bottomnav { display: none; }
  .topbar .brand { display: none; }
  .content { flex: 1; min-width: 0; }
  main { padding-bottom: 2rem; }
}

/* типографика */
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0.5rem 0 1rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 0.75rem; }
h3 { font-size: 1.05rem; margin: 1rem 0 0.5rem; }
p { margin: 0 0 0.75rem; }
.muted { color: var(--text-soft); }
.faint { color: var(--text-faint); font-size: 0.875rem; }
.small { font-size: 0.875rem; }
.serif { font-family: var(--font-serif); }
.pre { white-space: pre-wrap; word-wrap: break-word; }
.row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 0.75rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }

/* карточки */
.card { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 0.75rem; }
.card.soft { background: var(--bg-soft); box-shadow: none; }
.card.warn { background: var(--warn-soft); border-color: transparent; }
.card.info { background: var(--info-soft); border-color: transparent; }
.card.ok { background: var(--ok-soft); border-color: transparent; }
.card.danger { background: var(--rec-soft); border-color: transparent; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }

/* кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; min-height: 2.75rem; padding: 0.55rem 1rem; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg-elev); color: var(--text); cursor: pointer; text-decoration: none; font-weight: 550; line-height: 1.2; }
.btn:hover { border-color: var(--text-faint); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--rec); border-color: var(--rec); background: transparent; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn.small { min-height: 2.2rem; padding: 0.35rem 0.7rem; font-size: 0.9rem; }
.btn.block { width: 100%; }
.bigbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.bigbtn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.4rem; min-height: 7.5rem; border-radius: 20px; border: 1px solid var(--line);
  background: var(--bg-elev); color: var(--text); text-decoration: none; font-weight: 650; font-size: 1.05rem; box-shadow: var(--shadow); cursor: pointer; text-align: center; padding: 0.75rem; }
.bigbtn .ico { font-size: 2.2rem; }
.bigbtn.rec { background: var(--rec-soft); border-color: transparent; color: var(--rec); }
.bigbtn.accent { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

/* формы */
label.field { display: block; margin-bottom: 0.9rem; }
label.field > span { display: block; font-size: 0.9rem; color: var(--text-soft); margin-bottom: 0.3rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="number"], input[type="date"], input[type="datetime-local"], input[type="month"], select, textarea {
  width: 100%; min-height: 2.75rem; padding: 0.6rem 0.75rem; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-elev); }
textarea { min-height: 8rem; resize: vertical; line-height: 1.5; }
textarea.big { min-height: 14rem; font-size: 1.05rem; }
.check { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.45rem 0; cursor: pointer; }
.check input { width: 1.25rem; height: 1.25rem; margin-top: 0.15rem; flex: none; accent-color: var(--accent); }
.hint { font-size: 0.85rem; color: var(--text-soft); margin-top: 0.25rem; }
.error-text { color: var(--rec); font-size: 0.9rem; }

/* бейджи и чипы */
.badge { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.78rem; background: var(--bg-soft); color: var(--text-soft); white-space: nowrap; }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.rec { background: var(--rec-soft); color: var(--rec); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.chip { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.15rem 0.6rem; border-radius: 999px; border: 1px solid var(--line); background: var(--bg-elev);
  font-size: 0.82rem; text-decoration: none; color: var(--accent); cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }

/* лента */
.entry-card { display: flex; gap: 0.9rem; text-decoration: none; color: inherit; align-items: flex-start; }
.entry-card .thumb { width: 4rem; height: 4rem; border-radius: 12px; background: var(--bg-soft); flex: none; display: grid; place-items: center; font-size: 1.6rem; overflow: hidden; }
.entry-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.entry-card .body { min-width: 0; flex: 1; }
.entry-card .title { font-weight: 620; margin-bottom: 0.15rem; overflow-wrap: anywhere; }
.entry-card .snippet { color: var(--text-soft); font-size: 0.93rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.entry-card .meta { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.35rem; font-size: 0.8rem; color: var(--text-faint); }
.list > .card { margin: 0 0 0.6rem; }
.day-sep { margin: 1.25rem 0 0.5rem; font-size: 0.85rem; font-weight: 650; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.03em; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.5rem; margin: 0.5rem 0 1rem; }

/* календарь */
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.3rem; }
.calendar .dow { text-align: center; font-size: 0.75rem; color: var(--text-faint); }
.calendar button { aspect-ratio: 1; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-elev); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 0.9rem; padding: 0; }
.calendar button.has { background: var(--accent-soft); color: var(--accent); font-weight: 650; border-color: transparent; }
.calendar button.sel { outline: 2px solid var(--accent); }
.calendar button .n { font-size: 0.65rem; }
.calendar .empty { visibility: hidden; }

/* запись */
.recorder { text-align: center; }
.recorder .timer { font-size: 3rem; font-variant-numeric: tabular-nums; font-weight: 300; margin: 1rem 0; }
.recorder .level { height: 0.6rem; border-radius: 999px; background: var(--bg-soft); overflow: hidden; margin: 0 auto 1rem; max-width: 20rem; }
.recorder .level > div { height: 100%; background: var(--accent); transition: width 0.08s linear; }
.recbtn { width: 6.5rem; height: 6.5rem; border-radius: 50%; border: 0; background: var(--rec); color: #fff; font-size: 1rem; font-weight: 700; cursor: pointer; box-shadow: 0 6px 20px rgba(196, 71, 58, 0.35); }
.recbtn.stop { border-radius: 24px; }
.preview-video { width: 100%; max-height: 60vh; border-radius: var(--radius); background: #000; }
.state-line { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; margin-bottom: 0.75rem; }

/* расшифровка */
.transcript { line-height: 1.7; }
.seg { display: flex; gap: 0.6rem; padding: 0.3rem 0.4rem; border-radius: 8px; }
.seg.active { background: var(--accent-soft); }
.seg .ts { font-variant-numeric: tabular-nums; color: var(--accent); background: none; border: 0; cursor: pointer; padding: 0; font-size: 0.85rem; min-width: 3rem; text-align: left; }
.seg .tx { flex: 1; }
.seg.unclear .tx { color: var(--text-faint); font-style: italic; }
.seg textarea { min-height: 3rem; }
.player { width: 100%; }
.media-box { margin: 0.5rem 0 1rem; }
.media-box video { width: 100%; border-radius: var(--radius); background: #000; max-height: 70vh; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: 0.5rem; }
.photo-grid img { width: 100%; border-radius: 12px; aspect-ratio: 1; object-fit: cover; }

/* чат */
.chat { display: flex; flex-direction: column; gap: 0.75rem; }
.msg { max-width: 92%; padding: 0.75rem 1rem; border-radius: 18px; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 6px; }
.msg.assistant { align-self: flex-start; background: var(--bg-elev); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg .meta { font-size: 0.75rem; color: var(--text-faint); margin-top: 0.4rem; display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.msg.user .meta { color: color-mix(in srgb, var(--accent-text) 75%, transparent); }
.msg p { margin: 0 0 0.5rem; }
.msg p:last-child { margin: 0; }
.msg ul { margin: 0 0 0.5rem; padding-left: 1.2rem; }
.cite { display: inline-block; padding: 0 0.35rem; margin: 0 0.1rem; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-size: 0.8em; font-weight: 650; text-decoration: none; vertical-align: 1px; }
.composer { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); background: var(--bg); padding: 0.75rem 0; display: flex; gap: 0.5rem; align-items: flex-end; }
@media (min-width: 900px) { .composer { bottom: 0; } }
.composer textarea { min-height: 3rem; max-height: 12rem; }
.sources-panel { font-size: 0.88rem; }
.sources-panel li { margin-bottom: 0.4rem; }

/* цели */
.timeline { border-left: 2px solid var(--line); margin-left: 0.5rem; padding-left: 1rem; }
.tl-item { position: relative; padding: 0.4rem 0 0.8rem; }
.tl-item::before { content: ""; position: absolute; left: -1.43rem; top: 0.75rem; width: 0.7rem; height: 0.7rem; border-radius: 50%; background: var(--accent); }
.tl-item.proposed::before { background: var(--bg-elev); border: 2px dashed var(--accent); }
.tabs { display: flex; gap: 0.3rem; overflow-x: auto; margin-bottom: 1rem; border-bottom: 1px solid var(--line); }
.tabs button, .tabs a { border: 0; background: none; padding: 0.7rem 0.9rem; cursor: pointer; color: var(--text-soft); border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none; }
.tabs [aria-selected="true"], .tabs [aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 650; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 5rem; }
.bars > div { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; opacity: 0.8; }

/* книга */
.para { position: relative; padding: 0.6rem 0.75rem; border-radius: 10px; margin-bottom: 0.4rem; border: 1px solid transparent; }
.para:hover { border-color: var(--line); }
.para.pinned { background: var(--accent-soft); }
.para.flagged { background: var(--warn-soft); }
.para .ptext { font-family: var(--font-serif); font-size: 1.05rem; line-height: 1.65; white-space: pre-wrap; }
.para .ptools { display: flex; gap: 0.3rem; flex-wrap: wrap; margin-top: 0.4rem; }
.steps { display: flex; gap: 0.4rem; overflow-x: auto; padding-bottom: 0.25rem; margin-bottom: 1rem; }
.steps a { white-space: nowrap; }
.concept { border: 2px solid var(--line); }
.concept.chosen { border-color: var(--accent); }

/* диалоги и уведомления */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 640px) { .overlay { align-items: center; } }
.dialog { background: var(--bg-elev); border-radius: 20px 20px 0 0; width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; padding: 1.25rem; padding-bottom: max(1.25rem, env(safe-area-inset-bottom)); }
@media (min-width: 640px) { .dialog { border-radius: 20px; } }
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 1rem + env(safe-area-inset-bottom)); z-index: 60; display: flex; flex-direction: column; gap: 0.5rem; width: min(92vw, 30rem); }
.toast { background: var(--text); color: var(--bg); padding: 0.75rem 1rem; border-radius: 12px; box-shadow: var(--shadow); }
.toast.error { background: var(--rec); color: #fff; }
.progress { height: 0.5rem; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); }
.empty { text-align: center; color: var(--text-soft); padding: 2rem 1rem; }
table.simple { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.simple th, table.simple td { text-align: left; padding: 0.45rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; font-size: 0.92rem; }
.kv dt { color: var(--text-soft); }
.kv dd { margin: 0; }
.diff-old { background: var(--rec-soft); }
.diff-new { background: var(--ok-soft); }
code, .code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85em; background: var(--bg-soft); padding: 0.1rem 0.35rem; border-radius: 6px; overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
