/* #867 «Память для работы» — Дворец памяти. Стиль #841: тёплая бумага, бордо, золото. Без внешних шрифтов и трекеров. */
:root {
  --bg: #F7F2EA; --card: #FFFFFF; --text: #26201B; --hint: #6F655B; --line: #E4DACB; --soft: #EFE6D8;
  --wine: #7A2E3B; --wine-ink: #FFFFFF; --gold: #C9972B; --gold-ink: #2B1E06; --sage: #2E6F6B;
  --ok: #2E7D4F; --bad: #B23A3A; --shadow: 0 6px 18px rgba(50,30,20,.09);
  --nav-h: 62px;
}
:root[data-theme="dark"] {
  --bg: #1B1A1F; --card: #26242B; --text: #F1ECE4; --hint: #A89F94; --line: #3A3740; --soft: #2E2B33;
  --wine: #B0566A; --wine-ink: #FFFFFF; --gold: #D8A842; --sage: #4C9A95; --ok: #5DBB84; --bad: #E06A6A;
  --shadow: 0 6px 18px rgba(0,0,0,.4);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Armenian", "Helvetica Neue", Arial, sans-serif;
  font-size: 17px; line-height: 1.45; }
body { min-height: 100vh; overscroll-behavior: none; }
#app { max-width: 560px; margin: 0 auto; padding: 10px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); }
h1, h2, h3, .serif { font-family: Georgia, "Times New Roman", "Noto Serif", "Noto Serif Armenian", serif; }
h1 { font-size: 23px; margin: 4px 0 2px; font-weight: 700; letter-spacing: .2px; line-height: 1.2; }
h2 { font-size: 20px; margin: 14px 0 8px; font-weight: 700; line-height: 1.25; }
h3 { font-size: 17px; margin: 10px 0 6px; }
p { margin: 8px 0; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; background: none; }
input { font: inherit; }
.muted { color: var(--hint); font-size: 14px; }
.small { font-size: 13px; }
.center { text-align: center; }
.mt { margin-top: 12px; } .mt2 { margin-top: 20px; }
.row { display: flex; gap: 10px; } .row > * { flex: 1; }
.hide { display: none !important; }

/* кнопки */
.btn { display: block; width: 100%; min-height: 52px; padding: 13px 16px; border-radius: 14px; font-weight: 700; font-size: 17px;
  background: var(--wine); color: var(--wine-ink); box-shadow: var(--shadow); transition: transform .08s; text-align: center; }
.btn:active { transform: scale(.98); }
.btn.gold { background: var(--gold); color: var(--gold-ink); }
.btn.ghost { background: var(--card); color: var(--text); border: 1.5px solid var(--line); box-shadow: none; }
.btn.danger { background: transparent; color: var(--bad); border: 1.5px solid var(--line); box-shadow: none; font-weight: 600; }
.btn.sm { min-height: 42px; padding: 9px 12px; font-size: 15px; }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.link { color: var(--sage); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* шапка */
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 2px 0 10px; }
.brand { display: flex; flex-direction: column; min-width: 0; }
.brand b { font-family: Georgia, "Noto Serif", "Noto Serif Armenian", serif; font-size: 18px; color: var(--wine); line-height: 1.15; }
.brand span { font-size: 12px; color: var(--hint); }
.langs { display: flex; gap: 4px; flex: none; }
.langs button { min-width: 40px; height: 34px; padding: 0 8px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--card);
  font-size: 13px; font-weight: 700; color: var(--hint); }
.langs button[aria-pressed="true"] { border-color: var(--wine); color: var(--wine); }

/* карточки */
.card { background: var(--card); border: 1.5px solid var(--line); border-radius: 18px; padding: 14px 16px; margin: 10px 0; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card.accent { border-color: var(--gold); }
.card .eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--hint); font-weight: 700; }
.card .title { font-family: Georgia, "Noto Serif", "Noto Serif Armenian", serif; font-size: 20px; font-weight: 700; margin: 4px 0 8px; line-height: 1.25; }
.banner { background: var(--soft); border: 1px dashed var(--gold); border-radius: 14px; padding: 10px 12px; font-size: 14px; margin: 8px 0; }
.demo { display: inline-block; background: var(--gold); color: var(--gold-ink); font-size: 12px; font-weight: 700; border-radius: 999px; padding: 3px 10px; }

/* ведущий */
.host { display: flex; align-items: flex-start; gap: 12px; margin: 6px 0 12px; }
.host img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; object-position: 50% 8%;
  border: 3px solid var(--gold); flex: none; background: #e9dcc8; }
.host .who { font-size: 12px; color: var(--hint); margin-top: 4px; text-align: center; width: 64px; line-height: 1.2; }
.bubble { position: relative; background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; border-top-left-radius: 4px;
  padding: 12px 14px; font-size: 17px; box-shadow: var(--shadow); flex: 1; min-width: 0; }
.bubble .name { font-weight: 700; color: var(--wine); font-size: 14px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.ai-tag { display: inline-block; font-size: 11px; color: var(--hint); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; font-weight: 600; }
.plain { background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: 12px 14px; margin: 6px 0 12px; }

/* прогресс недели */
.weekbar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 8px 0 4px; }
.weekbar i { height: 10px; border-radius: 5px; background: var(--line); display: block; }
.weekbar i.done { background: var(--gold); }
.weekbar i.today { background: var(--wine); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; font-size: 13px; white-space: nowrap; }
.chip b { color: var(--wine); }
.stepbar { display: flex; gap: 4px; margin: 4px 0 12px; }
.stepbar i { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.stepbar i.on { background: var(--wine); }

/* упражнение */
.stage { min-height: 52vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 10px 0; }
.word-big { font-family: Georgia, "Noto Serif", "Noto Serif Armenian", serif; font-size: 44px; font-weight: 700; line-height: 1.12; user-select: none; -webkit-user-select: none; word-break: break-word; }
.place-tag { font-size: 15px; color: var(--sage); font-weight: 700; margin-bottom: 8px; }
.num-big { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 38px; font-weight: 700; letter-spacing: 2px; color: var(--wine); word-break: break-all; }
.count-big { font-size: 64px; font-weight: 700; color: var(--gold); line-height: 1; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--hint); font-size: 14px; }
.tbar { width: 100%; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin: 8px 0 12px; }
.tbar i { display: block; height: 100%; background: var(--gold); width: 100%; transition: width 1s linear; }
.dots { display: flex; justify-content: center; gap: 6px; margin: 16px 0 0; flex-wrap: wrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.dot.done { background: var(--gold); } .dot.now { background: var(--wine); transform: scale(1.3); }
.hintline { font-size: 14px; color: var(--sage); font-weight: 600; margin: 6px 0; }

/* карточка человека */
.person { display: flex; gap: 14px; align-items: center; text-align: left; background: var(--card); border: 1.5px solid var(--line);
  border-radius: 18px; padding: 12px 14px; width: 100%; box-shadow: var(--shadow); }
.person svg { width: 92px; height: 104px; flex: none; border-radius: 14px; background: var(--soft); }
.person .pn { font-family: Georgia, "Noto Serif", "Noto Serif Armenian", serif; font-size: 30px; font-weight: 700; color: var(--wine); line-height: 1.1; }
.person .pj { font-size: 15px; margin-top: 4px; }
.person .pl { font-size: 14px; color: var(--hint); margin-top: 2px; }
.person.compact svg { width: 64px; height: 72px; }
.person.compact { padding: 10px 12px; gap: 12px; margin: 8px 0; box-shadow: none; flex-wrap: wrap; }
.person.compact .pbody { flex: 1; min-width: 150px; }
.drawn { font-size: 11px; color: var(--hint); }
.nfield { display: flex; flex-direction: column; align-items: stretch; gap: 4px; margin-top: 8px; }
.nfield input { width: 100%; font-size: 18px; padding: 11px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--bg); color: var(--text); outline: none; }
.nfield input:focus { border-color: var(--sage); }
.hintbtn { align-self: flex-start; font-size: 13px; color: var(--sage); font-weight: 600; padding: 4px 2px; text-decoration: underline; text-underline-offset: 3px; }
.hintbtn:disabled { color: var(--hint); text-decoration: none; }

/* тезисы */
.theses { width: 100%; text-align: left; counter-reset: th; margin: 0; padding: 0; list-style: none; }
.theses li { counter-increment: th; background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 12px 10px 46px;
  margin: 8px 0; position: relative; font-size: 17px; }
.theses li::before { content: counter(th); position: absolute; left: 12px; top: 9px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--wine); color: #fff; font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.theses li small { display: block; color: var(--sage); font-weight: 700; font-size: 13px; }
.pairs { width: 100%; display: grid; gap: 8px; }

/* ввод */
.inp { display: flex; gap: 8px; margin-top: 8px; }
.inp input, .field input { flex: 1; min-width: 0; font-size: 18px; padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--card); color: var(--text); outline: none; }
.inp input:focus, .field input:focus { border-color: var(--sage); }
.inp button { flex: none; padding: 0 16px; border-radius: 14px; background: var(--sage); color: #fff; font-weight: 700; min-width: 56px; min-height: 50px; }
.typed { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; min-height: 40px; }
.typed .w { background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; padding: 6px 6px 6px 12px; display: flex; gap: 4px; align-items: center; font-weight: 600; }
.typed .w em { font-style: normal; color: var(--hint); font-size: 12px; }
.typed .w button { color: var(--hint); font-size: 20px; line-height: 1; padding: 2px 6px; }
.field { margin: 8px 0; }
.field label { display: block; font-size: 13px; color: var(--hint); margin: 0 0 4px 4px; font-weight: 600; }
.field .with { display: flex; gap: 8px; }
.field .with button { flex: none; border: 1.5px solid var(--line); border-radius: 12px; padding: 0 10px; font-size: 13px; color: var(--hint); background: var(--card); }

/* результат */
.score { font-size: 46px; font-weight: 800; text-align: center; color: var(--wine); line-height: 1; margin-top: 6px; }
.score small { font-size: 20px; color: var(--hint); font-weight: 600; }
.reslist { margin: 10px 0; padding: 0; list-style: none; }
.reslist li { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 1px dashed var(--line); padding: 8px 0; font-size: 15px; flex-wrap: wrap; }
.reslist li .a { font-weight: 700; }
.reslist li .y { color: var(--hint); font-size: 13px; }
.mark { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.mark.ok { color: var(--ok); border: 1px solid var(--ok); }
.mark.miss { color: var(--bad); border: 1px solid var(--bad); }
.mark.hint { color: var(--gold); border: 1px solid var(--gold); }
.acc { font-size: 12px; color: var(--sage); border: 1px solid var(--sage); border-radius: 999px; padding: 2px 9px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 8px; margin-top: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 6px; text-align: center; }
.stat .v { font-size: 22px; font-weight: 800; }
.stat .k { font-size: 12px; color: var(--hint); }

/* программа */
.week { margin: 12px 0; }
.week .wh { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.week .wh b { font-family: Georgia, "Noto Serif", "Noto Serif Armenian", serif; font-size: 17px; }
.week .wh span { font-size: 12px; color: var(--hint); white-space: nowrap; }
.week .wg { font-size: 13px; color: var(--hint); margin: 2px 0 8px; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.days button { aspect-ratio: 1 / 1; min-height: 42px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card);
  font-weight: 700; font-size: 15px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; padding: 0; }
.days button small { font-size: 10px; font-weight: 600; color: var(--hint); margin-top: 3px; }
.days button.done { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.days button.done small { color: var(--gold-ink); }
.days button.open { border-color: var(--wine); color: var(--wine); }
.days button.locked, .days button.pay { opacity: .45; }  /* #869: pay — после старта без оплаты */
.days button.m { border-style: dashed; }

/* замеры */
.mchart { background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: 10px 12px; margin: 10px 0; }
.mchart .mh { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.mchart .mh b { font-size: 16px; }
.mchart .mh span { font-size: 13px; color: var(--hint); }
.mchart canvas { width: 100%; height: 150px; display: block; margin-top: 6px; }
.mgrid { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 720px) { .mgrid { grid-template-columns: 1fr 1fr; } }
.fine { font-size: 12px; color: var(--hint); margin-top: 14px; line-height: 1.5; background: var(--card); border: 1px dashed var(--line); border-radius: 12px; padding: 10px 12px; }

/* настройки */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--card);
  border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 14px; margin: 10px 0; }
.switch .lbl { font-size: 16px; }
.switch .lbl small { display: block; color: var(--hint); font-size: 12px; }
.tgl { width: 52px; height: 32px; border-radius: 16px; background: var(--line); position: relative; flex: none; transition: background .15s; }
.tgl::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: left .15s; }
.tgl[aria-checked="true"] { background: var(--sage); }
.tgl[aria-checked="true"]::after { left: 23px; }
details { background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 14px; margin: 10px 0; }
summary { font-weight: 700; cursor: pointer; min-height: 28px; }
.route-list { display: grid; gap: 6px; margin-top: 8px; }
.route-list label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--hint); }
.route-list input { flex: 1; min-width: 0; font-size: 15px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.codegrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 8px 0; }
.codegrid div { background: var(--soft); border-radius: 10px; padding: 6px 4px; text-align: center; font-size: 12px; line-height: 1.25; }
.codegrid div b { display: block; font-size: 18px; color: var(--wine); }
.routeview { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.routeview span { background: var(--soft); border-radius: 999px; padding: 3px 10px; font-size: 13px; }

/* нижнее меню */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--card); border-top: 1px solid var(--line);
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); }
.nav .in { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); }
.nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 54px; font-size: 11px;
  color: var(--hint); font-weight: 600; border-radius: 12px; padding: 2px; line-height: 1.1; text-align: center; }
.nav button svg { width: 24px; height: 24px; }
.nav button[aria-current="page"] { color: var(--wine); }
.nav button .badge { position: absolute; transform: translate(14px, -10px); background: var(--wine); color: #fff; border-radius: 999px; font-size: 10px; padding: 1px 5px; }
.nav button span.ic { position: relative; display: inline-flex; }

.foot { margin-top: 18px; font-size: 12px; color: var(--hint); text-align: center; line-height: 1.5; }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 20; max-width: 90vw; box-shadow: var(--shadow); }
.gate { min-height: 86vh; display: flex; flex-direction: column; justify-content: center; }
.gate .hero { display: flex; justify-content: center; margin: 6px 0 10px; }
.gate .hero img { width: 150px; height: 180px; object-fit: cover; object-position: 50% 0; border-radius: 24px; border: 3px solid var(--gold); background: #e9dcc8; }

.fade { animation: fade .25s ease-out; }
@keyframes fade { from { transform: translateY(4px); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media (min-width: 900px) {
  body { font-size: 17px; }
  #app { padding-top: 24px; }
  .word-big { font-size: 52px; }
}
@media (max-width: 370px) {
  .word-big { font-size: 36px; } .num-big { font-size: 30px; } .langs button { min-width: 34px; padding: 0 5px; }
  .person svg { width: 76px; height: 86px; } .person .pn { font-size: 26px; }
}

/* армянский: длинные слова в меню, без капса в подзаголовках */
html[lang="hy"] .nav button { font-size: 10px; letter-spacing: -.1px; }
html[lang="hy"] .card .eyebrow, html[lang="hy"] .eyebrow { text-transform: none; letter-spacing: 0; font-size: 13px; }

h1, h2, h3, .serif, .card .title, .week .wh b, .brand b, .word-big, .person .pn { font-variant-numeric: lining-nums; }
