:root {
  --paper: #F4F1EA; --card: #FBFAF6; --ink: #1B1A17; --ink2: #4A4740; --mute: #6F6A60; --line: #E2DDD1;
  --red: #E0482C; --red-ink: #B8361E; --green: #2E7A57; --amber: #B7791F; --blue: #2F5D8A;
  --serif: 'Instrument Serif', 'Spectral', Georgia, serif;
  --sans: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --r: 18px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; overscroll-behavior-y: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; padding: calc(var(--safe-t) + 14px) 20px calc(var(--safe-b) + 24px); display: flex; flex-direction: column; }
@media (min-width: 900px) { #app { max-width: 640px; padding-top: 40px; } }

/* типографика */
.serif { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; }
h1 { font: 400 44px/1.02 var(--serif); letter-spacing: -0.02em; margin: 0; }
h2 { font: 400 30px/1.08 var(--serif); margin: 0; }
h3 { font: 600 13px/1.2 var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--mute); margin: 0 0 10px; }
.it { font-style: italic; }
.mute { color: var(--mute); } .ink2 { color: var(--ink2); }
.small { font-size: 13px; } .tiny { font-size: 11.5px; letter-spacing: .02em; }
.ru { color: var(--ink2); font-size: 14.5px; }

/* шапка */
.top { display: flex; align-items: center; justify-content: space-between; min-height: 44px; margin-bottom: 8px; }
.brand { font: italic 400 24px var(--serif); letter-spacing: -0.01em; }
.brand b { font-style: normal; color: var(--red); font-weight: 400; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: var(--ink2); }
.icon-btn:active { background: var(--line); }
.icon-btn svg { width: 22px; height: 22px; }
.back { display: inline-flex; align-items: center; gap: 4px; height: 44px; color: var(--ink2); font-weight: 500; }

/* главный экран */
.context { font: 400 27px/1.15 var(--serif); margin: 18px 0 6px; min-height: 62px; }
.context em { color: var(--red-ink); }
.hero { flex: 1; display: grid; place-items: center; padding: 18px 0 10px; }
.big-btn { position: relative; width: min(62vw, 270px); aspect-ratio: 1; border-radius: 50%; background: var(--red); color: #fff;
  display: grid; place-items: center; text-align: center; box-shadow: 0 18px 40px -18px rgba(176, 52, 28, .55), inset 0 -6px 0 rgba(0,0,0,.08); transition: transform .15s; }
.big-btn:active { transform: scale(.97); }
.big-btn .l1 { font: italic 400 46px/1 var(--serif); display: block; }
.big-btn .l2 { font-size: 13.5px; opacity: .9; letter-spacing: .04em; display: block; margin-top: 8px; }
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 14px 13px; text-align: left; min-height: 74px; display: flex; flex-direction: column; justify-content: space-between; }
.chip:active { background: #F0ECE3; }
.chip b { font-weight: 600; font-size: 15px; } .chip span { font-size: 12.5px; color: var(--mute); }
.chip.wide { grid-column: span 2; flex-direction: row; align-items: center; min-height: 56px; }
.foot { margin-top: 18px; display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.week { display: flex; gap: 6px; }
.dot { width: 22px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 10.5px; color: var(--mute); }
.dot i { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--line); display: block; }
.dot.on i { background: var(--ink); border-color: var(--ink); }
.dot.today i { border-color: var(--red); }
.stat { text-align: right; } .stat b { font: 400 26px/1 var(--serif); display: block; } .stat span { font-size: 11.5px; color: var(--mute); }

/* карточки и списки */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); text-align: left; width: 100%; }
.list-item:last-child { border-bottom: 0; }
.tag { display: inline-block; width: fit-content; align-self: flex-start; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; padding: 3px 8px; border-radius: 99px; background: #ECE7DC; color: var(--ink2); }
.tag.tone { background: #F6E1DA; color: var(--red-ink); } .tag.phrases { background: #E3ECF4; color: var(--blue); }
.tag.glue { background: #EFE6D3; color: #8A5A12; } .tag.flow { background: #E2EFE8; color: var(--green); } .tag.grammar, .tag.accuracy { background: #ECE4F3; color: #6A3F8F; }
.tag.numbers { background: #E8E8E8; color: #333; }

/* кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 52px; padding: 0 22px; border-radius: 99px; font-weight: 600; background: var(--ink); color: var(--paper); }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn.sm svg { width: 17px; height: 17px; }
.btn:active { opacity: .85; } .btn[disabled] { opacity: .4; }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--ink); }
.btn.soft { background: #E9E4D9; color: var(--ink); }
.btn.red { background: var(--red); color: #fff; }
.btn.block { width: 100%; }
.btn.sm { height: 40px; padding: 0 16px; font-size: 14px; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; }
.btns .btn { flex: 1; }
.link { color: var(--ink2); text-decoration: underline; text-underline-offset: 3px; font-size: 14px; }

/* разговор */
.talk { flex: 1; display: flex; flex-direction: column; }
.talk-head { display: flex; justify-content: space-between; align-items: center; }
.timer { font-variant-numeric: tabular-nums; color: var(--mute); font-size: 14px; }
.persona { margin: 10px 0 4px; }
.persona .name { font: 400 34px/1 var(--serif); }
.persona .meta { color: var(--mute); font-size: 13.5px; margin-top: 4px; }
.goal summary { cursor: pointer; list-style: none; } .goal summary::-webkit-details-marker { display: none; }
.goal:not([open]) { padding: 8px 12px; }
.goal { font-size: 14px; color: var(--ink2); background: #EDE8DE; border-radius: 12px; padding: 10px 12px; margin-top: 12px; }
.feed { flex: 1; overflow-y: auto; margin: 14px -4px 10px; padding: 0 4px; display: flex; flex-direction: column; gap: 10px; min-height: 120px; max-height: 46dvh; scroll-behavior: smooth; }
.bubble { max-width: 88%; padding: 10px 14px; border-radius: 18px; font-size: 16px; line-height: 1.4; }
.bubble.ai { background: var(--card); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 6px; }
.bubble.me { background: var(--ink); color: var(--paper); align-self: flex-end; border-bottom-right-radius: 6px; }
.bubble.me .lat { display: block; font-size: 11px; opacity: .6; margin-top: 4px; }
.bubble.pending { opacity: .55; }
.feed.hidden-text .bubble.ai .t { filter: blur(5px); transition: filter .2s; } .feed.hidden-text .bubble.ai.show .t { filter: none; }
.mic-zone { display: grid; place-items: center; padding: 6px 0 4px; gap: 10px; }
.mic { position: relative; width: 104px; height: 104px; border-radius: 50%; background: var(--ink); color: var(--paper); display: grid; place-items: center; transition: background .2s, transform .1s; }
.mic svg { width: 34px; height: 34px; }
.mic:active { transform: scale(.96); }
.mic.rec { background: var(--red); }
.mic.busy { background: #6F6A60; }
.mic.speaking { background: var(--ink2); }
.spinner.light { border-color: rgba(255,255,255,.35); border-top-color: #fff; }
.mic .ring { position: absolute; inset: -10px; border-radius: 50%; border: 3px solid var(--red); opacity: 0; transform: scale(var(--lv, 1)); transition: transform .08s linear, opacity .2s; }
.mic.rec .ring { opacity: .45; }
.mic-hint { font-size: 13.5px; color: var(--mute); min-height: 20px; text-align: center; }
.talk-tools { display: flex; justify-content: space-between; gap: 8px; width: 100%; }
.talk-tools button { font-size: 13.5px; color: var(--ink2); min-height: 44px; padding: 0 10px; border-radius: 12px; }
.talk-tools button:active { background: var(--line); }
.talk-tools button[disabled] { opacity: .35; }
.talk-tools #finish { color: var(--ink); font-weight: 600; }

/* разбор */
.progress-bar { display: flex; gap: 6px; margin: 4px 0 14px; } .progress-bar i { flex: 1; height: 3px; border-radius: 3px; background: var(--line); } .progress-bar i.on { background: var(--ink); }
.moment { display: flex; flex-direction: column; gap: 14px; }
.said { font: 400 25px/1.2 var(--serif); }
.said s { text-decoration-color: var(--red); text-decoration-thickness: 2px; color: var(--ink2); }
.native { font: 400 28px/1.18 var(--serif); color: var(--ink); }
.native mark { background: #F6E1DA; color: inherit; padding: 0 2px; border-radius: 3px; }
.hint { background: #F3EBD9; border-radius: 12px; padding: 12px 14px; font-size: 14.5px; color: #6E4E14; }
.why { font-size: 14.5px; color: var(--ink2); border-left: 3px solid var(--red); padding-left: 12px; }
.alts { font-size: 14px; color: var(--mute); }
.verdict { border-radius: 12px; padding: 10px 14px; font-size: 14.5px; }
.verdict.nailed { background: #E2EFE8; color: var(--green); } .verdict.close { background: #F3EBD9; color: #6E4E14; } .verdict.miss { background: #F6E1DA; color: var(--red-ink); }
.melody { width: 100%; height: 84px; display: block; }
.melody .mel-me { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.melody .mel-ref { fill: none; stroke: var(--red); stroke-width: 2.5; stroke-linecap: round; opacity: .75; stroke-dasharray: 1 0; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--mute); } .legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
.good-list li { margin-bottom: 6px; } .good-list { padding-left: 18px; margin: 0; }

/* повторения */
.rep-cue { font: 400 27px/1.2 var(--serif); }
.rep-answer { font: 400 26px/1.2 var(--serif); color: var(--green); }
.rep-clock { font: 400 18px var(--serif); color: var(--mute); font-variant-numeric: tabular-nums; }

/* прогресс */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.kpi b { font: 400 32px/1 var(--serif); display: block; } .kpi span { font-size: 12.5px; color: var(--mute); }
.kpi .delta { font-size: 12.5px; font-weight: 600; } .delta.up { color: var(--green); } .delta.down { color: var(--red-ink); }
.spark { width: 100%; height: 36px; margin-top: 6px; } .spark path { fill: none; stroke: var(--ink); stroke-width: 2; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 28px; gap: 10px; align-items: center; font-size: 14px; margin: 8px 0; }
.bar-row .bar { height: 8px; background: var(--line); border-radius: 8px; overflow: hidden; } .bar-row .bar i { display: block; height: 100%; background: var(--ink); }

/* формы */
.field { display: block; } .field span { display: block; font-size: 13px; color: var(--mute); margin-bottom: 6px; }
.input, textarea.input { width: 100%; border: 1.5px solid var(--line); background: var(--card); border-radius: 14px; padding: 14px; font-size: 16px; outline: none; resize: vertical; }
.input:focus { border-color: var(--ink); }
.seg { display: flex; background: #E9E4D9; border-radius: 99px; padding: 4px; } .seg button { flex: 1; height: 38px; border-radius: 99px; font-size: 14px; font-weight: 500; color: var(--ink2); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.switch { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--line); gap: 12px; }
.switch input { width: 46px; height: 28px; appearance: none; background: #D8D2C5; border-radius: 99px; position: relative; transition: background .2s; flex: none; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--ink); } .switch input:checked::after { left: 21px; }

/* логин и пусто */
.center { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.code-input { font: 400 40px var(--serif); letter-spacing: .3em; text-align: center; }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.thinking { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; flex: 1; text-align: center; color: var(--ink2); }
.thinking .serif { font-size: 26px; color: var(--ink); }
.skeleton { background: linear-gradient(90deg, #ECE7DC 0, #F4F0E7 50%, #ECE7DC 100%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; height: 14px; }
@keyframes sk { to { background-position: -200% 0; } }

#toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 24px); transform: translate(-50%, 30px); background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: 14px; font-size: 14.5px; opacity: 0; pointer-events: none; transition: .25s; max-width: calc(100% - 40px); z-index: 50; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
.sheet-bg { position: fixed; inset: 0; background: rgba(27,26,23,.35); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.sheet { background: var(--paper); width: 100%; max-width: 560px; border-radius: 22px 22px 0 0; padding: 22px 20px calc(var(--safe-b) + 22px); max-height: 88dvh; overflow-y: auto; animation: up .25s; }
@keyframes fade { from { opacity: 0; } } @keyframes up { from { transform: translateY(40px); opacity: .6; } }
.fade-in { animation: fade .3s; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.stack > .chip.wide { width: 100%; justify-content: space-between; }

.big-link { display: flex; align-items: center; justify-content: center; min-height: 48px; font-weight: 600; color: var(--ink); border-radius: 14px; }
.big-link:active { background: var(--line); }
.keep-row { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); font-size: 14.5px; }
.keep-row input { width: 22px; height: 22px; accent-color: var(--ink); }
.sticky-bar { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--paper) 18px); padding-top: 22px; margin-top: auto; }
