/* OkDoc — тёмная тема по макету. Цвета только через токены ниже. */
:root {
  --page: #161616;
  --app: #2a2a2a;
  --side: #222222;
  --sunken: #1c1c1c;
  --sunken-2: #202020;
  --raised: #333333;
  --line: #383838;
  --text: #f3f3f3;
  --text-2: #c4c4c4;
  --muted: #8a8a8a;
  --ink: #0b0b0b;              /* текст на ярких плашках */
  --green: #13b300;
  --green-hover: #17c400;
  --green-text: #22c93a;
  --yellow: #d2bf06;
  --olive: #8b9500;
  --olive-hover: #97a200;
  --lime: #c5d300;
  --red: #e4000f;
  --red-text: #ff5a5f;
  --orange-text: #ff9f1a;
  --black: #050505;
  --dot-off: #3a3a3a;

  --r-app: 36px;
  --r-pill: 999px;
  --r-card: 26px;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: default; opacity: .5; }
a { color: var(--green-text); }
a.btn, a.open { text-decoration: none; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }
svg { display: block; flex: none; }

/* ---------- каркас ---------- */
.app {
  position: fixed;
  inset: 20px;
  display: grid;
  grid-template-columns: 340px 1fr;
  background: var(--app);
  border-radius: var(--r-app);
  overflow: hidden;
}
.side {
  background: var(--side);
  border-radius: var(--r-app);
  padding: 24px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  z-index: 3;
}
.side-list { display: flex; flex-direction: column; gap: 14px; overflow-y: auto; min-height: 0; }
.cond-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 10px 24px;
  background: var(--sunken);
  border-radius: var(--r-pill);
  font-size: 19px;
  text-align: left;
  color: var(--text);
  transition: background .15s;
}
.cond-item:hover { background: #181818; }
.cond-item.active { background: var(--black); box-shadow: inset 0 0 0 1px var(--line); }
.cond-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cond-item .mini-score { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.btn-add-cond {
  min-height: 48px;
  padding: 10px 24px;
  border-radius: var(--r-pill);
  background: var(--green);
  color: var(--ink);
  font-size: 19px;
  font-weight: 600;
  text-align: left;
  flex: none;
}
.btn-add-cond:hover { background: var(--green-hover); }
.side-foot { margin-top: auto; padding-top: 8px; }
.side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-radius: var(--r-pill);
  color: var(--text-2); font-size: 15px;
}
.side-link:hover, .side-link.active { background: var(--sunken); color: var(--text); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.mobile-bar { display: none; }
.scrim { display: none; }

/* ---------- общие элементы ---------- */
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2);
}
.icon-btn:hover { background: var(--raised); color: var(--text); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 26px;
  border-radius: var(--r-pill);
  font-size: 17px;
  white-space: nowrap;
}
.btn-black { background: var(--black); color: var(--text); }
.btn-black:hover { background: #111; }
.btn-red { background: var(--red); color: #fff; }
.btn-red:hover { background: #f5101f; }
.btn-green { background: var(--green); color: var(--ink); font-weight: 600; }
.btn-green:hover { background: var(--green-hover); }
.btn-ghost { background: var(--raised); color: var(--text); }
.btn-ghost:hover { background: #3c3c3c; }
.btn-sm { min-height: 36px; padding: 6px 18px; font-size: 15px; }
.btn-back { min-height: 46px; padding: 8px 28px; font-size: 18px; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  display: inline-block; flex: none;
}
.muted { color: var(--muted); }
.error-text { color: var(--red-text); }
.hidden { display: none !important; }

/* ---------- экран заболевания: шапка ---------- */
.cond-head {
  margin: 16px 16px 0;
  padding: 22px 26px 22px 40px;
  background: #262626;
  border-radius: 40px;
  display: flex; gap: 20px; align-items: flex-start; justify-content: space-between;
  flex: none;
}
.cond-info { min-width: 0; flex: 1; }
.cond-title-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cond-title {
  margin: 0; font-size: 26px; font-weight: 500; line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.score-line { margin-top: 8px; display: flex; align-items: baseline; gap: 12px; color: var(--muted); font-size: 16px; }
.score-val { font-size: 21px; font-variant-numeric: tabular-nums; }
.score-val.s-bad { color: var(--red-text); }
.score-val.s-mid { color: var(--orange-text); }
.score-val.s-ok { color: var(--yellow); }
.score-val.s-good { color: var(--green-text); }
.score-val.s-none { color: var(--muted); }
.dots { display: flex; gap: 8px; margin-top: 10px; }
.dot { width: 17px; height: 17px; border-radius: 50%; background: var(--dot-off); }
.memory-status {
  margin-top: 10px; display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted); min-height: 18px;
}
.memory-status.warn { color: var(--orange-text); }
.cond-actions { display: flex; flex-direction: column; gap: 12px; flex: none; }
.pill {
  display: flex; align-items: stretch;
  height: 46px;
  background: var(--olive);
  border-radius: var(--r-pill);
  overflow: hidden;
  min-width: 250px;
}
.pill-label {
  flex: 1; text-align: left; padding: 0 16px 0 28px;
  color: var(--ink); font-size: 17px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
}
.pill-label:hover { background: var(--olive-hover); }
.pill-count { font-size: 13px; opacity: .65; font-variant-numeric: tabular-nums; }
.pill-plus {
  width: 64px; background: var(--lime); color: var(--ink);
  border-radius: var(--r-pill);
  display: flex; align-items: center; justify-content: center;
}
.pill-plus:hover { filter: brightness(1.08); }

/* ---------- чат ---------- */
.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-scroll {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 24px 40px 12px 32px;
  display: flex; flex-direction: column; gap: 22px;
  scrollbar-gutter: stable;
}
.chat-scroll::before { content: ""; margin-top: auto; }  /* сообщения прижаты к низу */
.bubble {
  max-width: min(640px, 82%);
  padding: 20px 30px;
  border-radius: 34px;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.bubble.ai { background: var(--green); align-self: flex-start; }
.bubble.me { background: var(--yellow); align-self: flex-end; white-space: pre-wrap; }
.bubble p { margin: 0 0 .55em; }
.bubble p:last-child, .bubble ul:last-child, .bubble ol:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 0 0 .55em; padding-left: 1.25em; }
.bubble li + li { margin-top: .2em; }
.bubble .bubble-error {
  margin-top: 10px; padding: 8px 14px; border-radius: 16px;
  background: rgba(0, 0, 0, .78); color: var(--red-text); font-size: 15px;
}
.bubble-time { display: block; margin-top: 6px; font-size: 12px; opacity: .55; text-align: right; }
.typing { display: inline-flex; gap: 6px; padding: 6px 0; }
.typing span { width: 8px; height: 8px; border-radius: 50%; background: var(--ink); opacity: .35; }
.day-sep { align-self: center; font-size: 13px; color: var(--muted); padding: 2px 12px; }
.chat-more { align-self: center; }
.chat-empty {
  margin: auto; max-width: 460px; text-align: center; color: var(--muted);
  display: flex; flex-direction: column; gap: 14px; align-items: center; padding: 20px;
}
.chat-empty h2 { margin: 0; color: var(--text); font-weight: 500; font-size: 22px; }
.chat-empty p { margin: 0; }
.chat-form {
  margin: 8px 16px 16px;
  display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 8px 8px 36px;
  background: var(--sunken-2);
  border-radius: 34px;
  flex: none;
}
.chat-input {
  flex: 1; resize: none; border: 0; outline: none; background: transparent;
  font-size: 18px; line-height: 1.4; padding: 13px 0; max-height: 200px;
}
.chat-input::placeholder { color: var(--muted); }
.send-btn {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--green); color: var(--ink);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.send-btn:disabled { background: var(--raised); color: var(--muted); opacity: 1; }
.disclaimer { text-align: center; font-size: 12px; color: var(--muted); margin: -8px 0 10px; }
.setup-banner {
  margin: 12px 16px 0; padding: 14px 22px; border-radius: 22px;
  background: var(--sunken); color: var(--text-2);
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}

/* ---------- страницы разделов ---------- */
.page { flex: 1; min-height: 0; overflow-y: auto; padding: 22px 40px 32px 44px; scrollbar-gutter: stable; }
.page-head {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  margin-bottom: 22px;
}
.page-head h1 { grid-column: 2; margin: 0; font-size: 30px; font-weight: 500; text-align: center; }
.page-head .btn-back { grid-column: 3; justify-self: end; }
.page-sub { text-align: center; color: var(--muted); margin: -14px 0 20px; font-size: 14px; }

.summary-box {
  background: #2d2d2d;
  border-radius: 10px;
  padding: 26px 22px;
  max-height: 340px;
  overflow-y: auto;
  font-size: 17px;
  line-height: 1.45;
  white-space: pre-wrap;
  box-shadow: inset 0 0 0 1px #313131;
}
.summary-box.empty-summary { color: var(--muted); white-space: normal; }
.summary-meta { margin: 10px 4px 0; font-size: 13px; color: var(--muted); }

.add-bar {
  margin-top: 24px;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px 14px 32px;
  background: var(--sunken-2);
  border-radius: var(--r-pill);
}
.add-bar .label { flex: 1; font-size: 17px; }
.add-bar .btn { background: var(--app); min-width: 120px; }
.add-bar .btn:hover { background: var(--raised); }

.tabs { display: flex; gap: 6px; margin: 26px 0 14px; flex-wrap: wrap; }
.tab {
  padding: 8px 18px; border-radius: var(--r-pill); color: var(--muted); font-size: 15px;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--sunken); color: var(--text); }
.list { display: flex; flex-direction: column; gap: 14px; }
.list-title { margin: 26px 0 14px; font-size: 15px; color: var(--muted); font-weight: 400; }
.doc-row {
  display: grid; grid-template-columns: 150px 1fr auto; align-items: center;
  min-height: 60px;
  background: var(--sunken-2);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.doc-row .date { padding-left: 40px; color: var(--muted); font-size: 18px; font-variant-numeric: tabular-nums; }
.doc-row .title { padding: 8px 16px; font-size: 16px; min-width: 0; }
.doc-row .title .digest { display: block; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-row .open {
  align-self: stretch; min-width: 150px; padding: 0 30px;
  background: var(--sunken); border-radius: var(--r-pill);
  color: var(--green-text); font-size: 18px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.doc-row .open:hover { background: #161616; }
.doc-row .open.busy { color: var(--muted); cursor: default; }
.doc-row .open.err { color: var(--red-text); }
.doc-row.error .title .digest { color: var(--red-text); white-space: normal; }
.empty-list { color: var(--muted); padding: 18px 8px; }

/* показатели */
.labs { display: flex; flex-direction: column; gap: 2px; max-height: 380px; overflow-y: auto; }
.lab-row {
  display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) 110px 96px;
  gap: 12px; align-items: center; padding: 9px 6px; border-bottom: 1px solid #353535;
  font-size: 15px;
}
.lab-row:last-child { border-bottom: 0; }
.lab-row .ln { min-width: 0; }
.lab-row .ln small { display: block; color: var(--muted); font-size: 12px; }
.lab-row .lv { font-variant-numeric: tabular-nums; }
.lab-row .lv .trend { color: var(--muted); font-size: 13px; margin-left: 6px; }
.lab-row .ld { color: var(--muted); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.f-high, .f-low, .f-abnormal { color: var(--orange-text); }
.f-normal { color: var(--green-text); }
.spark { width: 110px; height: 28px; color: var(--text-2); }

/* хронология */
.timeline { display: flex; flex-direction: column; gap: 10px; }
.commit {
  background: var(--sunken-2); border-radius: 22px; padding: 14px 22px;
  display: grid; grid-template-columns: 96px 1fr auto; gap: 14px; align-items: baseline;
  text-align: left; width: 100%;
}
.commit:hover { background: #242424; }
.commit .cdate { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.commit .cmsg { font-size: 15px; }
.commit .ckind { font-size: 12px; color: var(--muted); margin-right: 8px; text-transform: uppercase; letter-spacing: .04em; }
.commit .cscore { font-size: 13px; padding: 2px 10px; border-radius: var(--r-pill); background: var(--sunken); font-variant-numeric: tabular-nums; }
.commit .changes { grid-column: 2 / -1; margin: 6px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--text-2); }
.commit .changes .op { display: inline-block; min-width: 92px; color: var(--muted); }
.score-chart { background: var(--sunken-2); border-radius: 22px; padding: 16px 20px 10px; margin-bottom: 14px; }
.score-chart svg { width: 100%; height: auto; max-height: 150px; }
.score-chart .cap { font-size: 13px; color: var(--muted); margin-bottom: 6px; }

/* факты */
.fact-group h3 { margin: 18px 0 8px; font-size: 14px; font-weight: 500; color: var(--muted); }
.fact {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px 10px 22px; background: var(--sunken-2); border-radius: 18px; margin-bottom: 8px;
  font-size: 15px;
}
.fact .ft { flex: 1; min-width: 0; }
.fact .ft small { color: var(--muted); margin-left: 6px; }
.fact.resolved { opacity: .6; }
.fact .star { color: var(--lime); }

/* ---------- документ ---------- */
.doc-top { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.doc-title { text-align: center; font-size: 30px; font-weight: 500; margin: 12px 0 30px; }
.digest-box {
  background: var(--sunken-2); border-radius: 22px; padding: 16px 24px; margin-bottom: 26px;
  font-size: 16px; color: var(--text-2);
}
.digest-box b { color: var(--text); font-weight: 500; }
.doc-content { font-size: 19px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.doc-meas { margin-top: 28px; }
.doc-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  margin-top: 36px;
}
.doc-foot .ddate { font-size: 22px; color: var(--text-2); }
.doc-foot .actions { display: flex; gap: 14px; }
.doc-foot .btn { min-width: 170px; min-height: 52px; font-size: 20px; }
.doc-state { display: flex; align-items: center; gap: 10px; justify-content: center; color: var(--muted); margin: 40px 0; }

/* ---------- формы ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 14px; color: var(--muted); }
.input, .textarea, .select {
  width: 100%;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 11px 16px;
  font-size: 16px;
  outline: none;
}
.input:focus, .textarea:focus, .select:focus { border-color: #5a5a5a; }
.textarea { resize: vertical; min-height: 160px; line-height: 1.45; }
.doc-edit .textarea { min-height: 50vh; font-size: 17px; }
.hint { font-size: 13px; color: var(--muted); }

.settings { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.card { background: #262626; border-radius: var(--r-card); padding: 22px 26px; display: flex; flex-direction: column; gap: 16px; }
.card h2 { margin: 0; font-size: 19px; font-weight: 500; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(210px, 1.5fr); gap: 14px; }
.seg { display: flex; background: var(--sunken); border: 1px solid var(--line); border-radius: 16px; padding: 3px; gap: 3px; }
.seg button { flex: 1; padding: 8px 10px; border-radius: 12px; color: var(--text-2); font-size: 15px; white-space: nowrap; }
.seg button.on { background: var(--raised); color: var(--text); }
.toggle-row { display: flex; gap: 16px; align-items: flex-start; }
.toggle-row .tt { flex: 1; }
.toggle-row .tt b { display: block; font-weight: 500; margin-bottom: 4px; }
.switch {
  width: 52px; height: 30px; border-radius: 99px; background: var(--raised); position: relative; flex: none;
  transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #cfcfcf; transition: transform .2s;
}
.switch[aria-checked="true"] { background: var(--green); }
.switch[aria-checked="true"]::after { transform: translateX(22px); background: #fff; }
.save-row { display: flex; gap: 12px; align-items: center; justify-content: flex-end; position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--app) 30%); }
.check-result { font-size: 14px; }
.check-result.ok { color: var(--green-text); }
.key-state { font-size: 13px; color: var(--green-text); }

/* выбор модели */
.combo { position: relative; }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 20;
  max-height: 320px; overflow-y: auto;
  background: #1a1a1a; border: 1px solid var(--line); border-radius: 16px; padding: 6px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, .5);
}
.combo-item { display: flex; gap: 10px; align-items: baseline; width: 100%; padding: 8px 12px; border-radius: 10px; text-align: left; font-size: 14px; }
.combo-item:hover, .combo-item.hl { background: var(--raised); }
.combo-item .cid { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-item .cmeta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.combo-note { padding: 10px 12px; color: var(--muted); font-size: 13px; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--raised); color: var(--text-2); }

/* ---------- модалки и тосты ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  width: min(620px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto;
  background: #262626; border-radius: 28px; padding: 26px 28px;
  display: flex; flex-direction: column; gap: 16px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}
.modal h2 { margin: 0; font-size: 22px; font-weight: 500; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.drop {
  border: 2px dashed var(--line); border-radius: 22px; padding: 30px 20px; text-align: center;
  color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.drop.over { border-color: var(--green); color: var(--text); }
.file-list { font-size: 14px; color: var(--text-2); }
.menu {
  position: fixed; z-index: 60; background: #1a1a1a; border: 1px solid var(--line); border-radius: 16px; padding: 6px;
  min-width: 220px; box-shadow: 0 20px 40px rgba(0, 0, 0, .5);
}
.menu button { display: block; width: 100%; text-align: left; padding: 10px 14px; border-radius: 10px; font-size: 15px; }
.menu button:hover { background: var(--raised); }
.menu button.danger { color: var(--red-text); }
.toasts { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #0d0d0d; color: var(--text); padding: 12px 22px; border-radius: 99px; font-size: 15px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); max-width: min(560px, 90vw); }
.toast.err { color: var(--red-text); }

.welcome { margin: auto; max-width: 520px; text-align: center; padding: 30px; display: flex; flex-direction: column; gap: 16px; align-items: center; }
.welcome h1 { margin: 0; font-size: 30px; font-weight: 500; }
.welcome p { margin: 0; color: var(--text-2); }

/* ---------- телефон и узкие окна ---------- */
@media (max-width: 1100px) {
  .app { grid-template-columns: 280px 1fr; }
  .cond-head { flex-direction: column; }
  .cond-actions { flex-direction: row; flex-wrap: wrap; width: 100%; }
  .pill { min-width: 0; flex: 1 1 220px; }
}
@media (max-width: 820px) {
  .app { inset: 0; border-radius: 0; grid-template-columns: 1fr; }
  .side {
    position: fixed; top: 0; bottom: 0; left: 0; width: min(320px, 86vw);
    border-radius: 0 28px 28px 0; transform: translateX(-102%); transition: transform .2s ease;
    padding-top: max(20px, env(safe-area-inset-top));
  }
  .app.menu-open .side { transform: none; }
  .app.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 2; }
  .mobile-bar {
    display: flex; align-items: center; gap: 8px; padding: max(8px, env(safe-area-inset-top)) 12px 4px;
    flex: none;
  }
  .mobile-title { font-size: 17px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cond-head { margin: 4px 10px 0; padding: 18px 20px; border-radius: 28px; }
  .cond-title { font-size: 22px; white-space: normal; }
  .dots { gap: 6px; }
  .dot { width: 15px; height: 15px; }
  .cond-head { gap: 14px; }
  .cond-actions { flex-direction: column; gap: 8px; }
  .pill { height: 40px; flex: none; }
  .pill-label { padding-left: 20px; font-size: 15px; }
  .pill-plus { width: 52px; }
  .memory-status { margin-top: 6px; }
  .chat-scroll { padding: 16px 12px 8px; }
  .bubble { max-width: 90%; padding: 14px 20px; border-radius: 26px; font-size: 16px; }
  .chat-form { margin: 6px 10px max(10px, env(safe-area-inset-bottom)); padding-left: 20px; }
  .chat-input { font-size: 16px; }
  .page { padding: 12px 16px 24px; }
  .page-head { grid-template-columns: 1fr auto; }
  .page-head h1 { grid-column: 1; text-align: left; font-size: 24px; }
  .page-head .btn-back { grid-column: 2; }
  .doc-row { grid-template-columns: 1fr auto; }
  .doc-row .date { grid-column: 1; grid-row: 1; padding: 10px 0 0 22px; font-size: 13px; }
  .doc-row .title { grid-column: 1; grid-row: 2; padding: 0 12px 10px 22px; }
  .doc-row .open { grid-column: 2; grid-row: 1 / 3; min-width: 110px; padding: 0 18px; font-size: 16px; }
  .add-bar { padding: 10px 10px 10px 20px; flex-wrap: wrap; border-radius: 26px; }
  .add-bar .label { flex-basis: 100%; }
  .add-bar .btn { flex: 1; min-width: 0; }
  .lab-row { grid-template-columns: minmax(0, 1fr) auto; }
  .lab-row .spark, .lab-row .ld { display: none; }
  .commit { grid-template-columns: 1fr auto; }
  .commit .cdate { grid-column: 1 / -1; }
  .commit .changes { grid-column: 1 / -1; }
  .doc-title { font-size: 24px; }
  .doc-content { font-size: 17px; }
  .doc-foot .btn { min-width: 0; flex: 1; font-size: 17px; }
  .doc-foot .actions { flex: 1; }
  .grid-4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 > :last-child { grid-column: 1 / -1; }
  .grid-2 { grid-template-columns: 1fr; }
  .input, .textarea, .select { font-size: 16px; }  /* меньше 16px — iOS зумит страницу */
}

/* ---------- вход ---------- */
.login-page { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--page); }
.login-card {
  width: min(380px, 100%); background: var(--app); border-radius: 30px; padding: 34px 30px;
  display: flex; flex-direction: column; gap: 14px;
}
.login-card h1 { margin: 0; font-size: 30px; font-weight: 500; }
.login-card .btn { width: 100%; }
