@import url("fonts.css");

/* ===== Токены ===== */
:root {
  --bg: #F8F5EE;
  --surface: #FFFFFF;
  --surface-2: #F0EBE1;
  --ink: #1D201B;
  --ink-2: #5E5A51;
  --ink-3: #9A9488;
  --red: #9B0103;
  --red-ink: #7E0103;
  --red-soft: rgba(155, 1, 3, .07);
  --green: #7A9163;
  --green-soft: rgba(122, 145, 99, .13);
  --gold: #EAAF4A;
  --gold-soft: rgba(234, 175, 74, .16);
  --hair: rgba(29, 32, 27, .09);
  --shadow: 0 1px 1px rgba(29, 32, 27, .03), 0 6px 20px -8px rgba(29, 32, 27, .10);
  --shadow-lg: 0 2px 4px rgba(29, 32, 27, .04), 0 24px 48px -16px rgba(29, 32, 27, .22);
  --material: rgba(248, 245, 238, .72);
  --radius: 20px;
  --serif: "Prata", Georgia, serif;
  --sans: "Mulish", -apple-system, system-ui, sans-serif;
  --tab-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --press: 100ms ease-out;
}
:root[data-theme="dark"] {
  --bg: #121411; --surface: #1C1F1A; --surface-2: #252822;
  --ink: #F2EEE5; --ink-2: #B9B2A3; --ink-3: #847E71;
  --red: #E2474A; --red-ink: #FF6B6D; --red-soft: rgba(226, 71, 74, .13);
  --green-soft: rgba(122, 145, 99, .2); --hair: rgba(255, 255, 255, .08);
  --shadow: 0 1px 1px rgba(0, 0, 0, .3), 0 6px 20px -8px rgba(0, 0, 0, .5);
  --material: rgba(18, 20, 17, .72);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
html, body { overflow-x: clip; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
img { display: block; max-width: 100%; }
#app { min-height: 100dvh; padding-bottom: calc(var(--tab-h) + var(--safe-b) + 20px); }
.screen { padding: 14px 20px 8px; animation: enter .42s cubic-bezier(.2, .9, .25, 1) both; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== Типографика: трекинг и интерлиньяж зависят от кегля ===== */
.eyebrow { font-size: 13px; font-weight: 700; letter-spacing: .005em; color: var(--ink-3); line-height: 1.35; }
.eyebrow::first-letter { text-transform: uppercase; }
.display { font-family: var(--serif); font-weight: 400; font-size: clamp(34px, 9.6vw, 44px); line-height: 1.04; letter-spacing: -.025em; margin: 8px 0 14px; }
.h1 { font-family: var(--serif); font-weight: 400; font-size: 30px; line-height: 1.08; letter-spacing: -.02em; margin: 6px 0 10px; }
.h1 em, .display em { font-style: normal; color: var(--red); }
.h2 { font-family: var(--serif); font-weight: 400; font-size: 22px; line-height: 1.18; letter-spacing: -.012em; margin: 30px 0 12px; }
.h3 { font-weight: 800; font-size: 16.5px; line-height: 1.3; letter-spacing: -.005em; margin: 0 0 4px; }
.lead { font-size: 16.5px; line-height: 1.5; color: var(--ink-2); margin: 0 0 18px; }
.muted { color: var(--ink-2); }
.small { font-size: 13.5px; line-height: 1.45; letter-spacing: .005em; }
.tiny { font-size: 12px; letter-spacing: .01em; color: var(--ink-3); }
.center { text-align: center; }
.num { font-family: var(--serif); letter-spacing: -.02em; line-height: 1; }

/* ===== Шапка ===== */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px 0; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 34px; height: 34px; border-radius: 50%; }
.brand b { font-family: var(--serif); font-weight: 400; font-size: 14px; color: var(--red); letter-spacing: .03em; line-height: 1.12; }
.lang { display: flex; padding: 3px; border-radius: 999px; background: var(--surface-2); }
.lang button { height: 28px; min-width: 38px; border-radius: 999px; font-size: 12.5px; font-weight: 800; letter-spacing: .04em; color: var(--ink-3); transition: background var(--press), color var(--press); }
.lang button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.streak { display: inline-flex; align-items: center; gap: 5px; height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--hair); font-weight: 800; font-size: 14px; color: var(--ink); }
.streak svg { color: var(--red); }

/* ===== Поверхности ===== */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--hair); padding: 18px; }
.card + .card { margin-top: 12px; }
.stat-grid > .card + .card, .grid2 > .card + .card, .grid2 > .card { margin-top: 0; }
.grid2 { display: grid; gap: 12px; }
.press { transition: transform var(--press), opacity var(--press); }
.press:active, .press.is-pressed { transform: scale(.975); }
.list { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--hair); box-shadow: var(--shadow); overflow: hidden; }
.row-link { display: flex; align-items: center; gap: 14px; width: 100%; padding: 15px 16px; text-align: left; border-bottom: 1px solid var(--hair); transition: background var(--press); }
.row-link:last-child { border-bottom: 0; }
.row-link:active { background: var(--surface-2); }
.row-link .t { flex: 1; font-weight: 700; font-size: 15.5px; }
.row-link .t small { display: block; font-weight: 500; font-size: 13px; color: var(--ink-2); margin-top: 1px; }
.chev { color: var(--ink-3); flex: none; }
.ico { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--red-soft); color: var(--red); flex: none; }

/* Герой на фото */
.hero { position: relative; overflow: hidden; border-radius: 26px; min-height: 360px; color: #fff; box-shadow: var(--shadow-lg); isolation: isolate; }
.hero > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; transform: scale(1.02); }
.hero::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(10, 8, 6, .05) 20%, rgba(10, 8, 6, .72) 100%); }
.hero .inner { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px; }
.hero .eyebrow { color: rgba(255, 255, 255, .78); }
.hero .display { color: #fff; font-size: 34px; margin: 8px 0 10px; }
.hero p { margin: 0 0 18px; color: rgba(255, 255, 255, .86); font-size: 15px; max-width: 30ch; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.stat { display: flex; flex-direction: column; justify-content: space-between; min-height: 150px; }
.wod .hanzi { font-size: 44px; margin: 10px 0 2px; }

/* Кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 52px; padding: 0 24px; border-radius: 15px; font-weight: 800; font-size: 16px; letter-spacing: -.005em; transition: transform var(--press), background var(--press), opacity var(--press); }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:active { background: var(--red-ink); }
.btn-white { background: #fff; color: var(--ink); }
.btn-ghost { background: var(--surface-2); color: var(--ink); }
.btn-line { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--hair); }
.btn-green { background: var(--green); color: #fff; }
.btn-block { display: flex; width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .btn { flex: 1; }
.btn-text { color: var(--ink-2); font-weight: 700; height: 44px; }

/* Чипсы и бейджи */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 20px 8px; margin: 0 -20px; scrollbar-width: none; overscroll-behavior-x: contain; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 36px; padding: 0 15px; border-radius: 999px; background: var(--surface); border: 1px solid var(--hair); font-weight: 700; font-size: 14px; white-space: nowrap; transition: transform var(--press), background var(--press); }
.chip:active { transform: scale(.95); }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.badge { display: inline-block; padding: 3px 8px; border-radius: 7px; font-size: 11.5px; font-weight: 800; letter-spacing: .02em; background: var(--gold-soft); color: #8A5A08; margin: 0 4px 4px 0; }
:root[data-theme="dark"] .badge { color: var(--gold); }
.badge.g { background: var(--green-soft); color: var(--green); }
.badge.r { background: var(--red-soft); color: var(--red); }

/* Поиск */
.search { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--hair); border-radius: 14px; padding: 0 14px; height: 46px; margin: 4px 0 12px; }
.search input { border: 0; outline: 0; background: none; flex: 1; font-size: 16px; }
.search svg { color: var(--ink-3); }

/* Вузы */
.uni { display: flex; gap: 14px; align-items: center; padding: 12px; }
.uni .ph { width: 78px; height: 78px; border-radius: 16px; flex: none; overflow: hidden; background: var(--surface-2); }
.uni .ph img { width: 100%; height: 100%; object-fit: cover; }
.uni .meta { min-width: 0; flex: 1; }
.uni .name { font-weight: 800; font-size: 15.5px; line-height: 1.25; letter-spacing: -.005em; }
.uni .sub { font-size: 13px; color: var(--ink-2); margin: 2px 0 6px; }
.price { font-weight: 800; color: var(--red); font-size: 14px; }
.star { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: var(--ink-3); flex: none; transition: transform var(--press), color var(--press); }
.star:active { transform: scale(.85); }
.star.on { color: var(--gold); }

.cover { position: relative; margin: -14px -20px 0; height: 280px; overflow: hidden; }
.cover img.bg { width: 100%; height: 100%; object-fit: cover; }
.cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 45%, var(--bg) 100%); }
.cover .logo { position: absolute; z-index: 2; left: 20px; bottom: -24px; width: 70px; height: 70px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-lg); object-fit: contain; padding: 6px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--hair); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--hair); }
.fact { background: var(--surface); padding: 14px 15px; }
.fact .k { font-size: 11px; font-weight: 800; color: var(--ink-3); text-transform: uppercase; letter-spacing: .1em; }
.fact .v { font-weight: 700; font-size: 14.5px; margin-top: 5px; line-height: 1.4; }
.fact.wide { grid-column: span 2; }
.prog { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--hair); font-size: 14.5px; }
.prog:last-child { border: 0; }
.prog .p { color: var(--red); font-weight: 800; white-space: nowrap; }
details summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-weight: 800; }
details summary::-webkit-details-marker { display: none; }

/* Анкета */
.progress { height: 3px; border-radius: 99px; background: var(--hair); overflow: hidden; margin: 10px 0 26px; }
.progress i { display: block; height: 100%; background: var(--red); transition: width .45s cubic-bezier(.2, .9, .25, 1); }
.opts { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.opt { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 16px; border-bottom: 1px solid var(--hair); transition: background var(--press); }
.opt:last-child { border-bottom: 0; }
.opt:active, .opt.sel { background: var(--red-soft); }
.opt .t { flex: 1; font-weight: 700; font-size: 15.5px; line-height: 1.3; }
.opt .t small { display: block; font-weight: 500; color: var(--ink-2); font-size: 13px; margin-top: 3px; line-height: 1.4; }
.radio { width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--ink-3); flex: none; display: grid; place-items: center; transition: box-shadow var(--press), background var(--press); }
.opt.sel .radio { background: var(--red); box-shadow: none; }
.opt.sel .radio::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fff; }
.range-val { font-family: var(--serif); font-size: 40px; letter-spacing: -.02em; color: var(--ink); text-align: center; margin: 22px 0 8px; }
input[type=range] { width: 100%; accent-color: var(--red); height: 36px; }
.cities { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.city { position: relative; height: 112px; border-radius: 18px; overflow: hidden; text-align: left; color: #fff; isolation: isolate; box-shadow: var(--shadow); transition: transform var(--press); }
.city:active { transform: scale(.97); }
.city img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; }
.city::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(0,0,0,.05), rgba(0,0,0,.66)); }
.city b { position: absolute; left: 12px; bottom: 26px; font-size: 16px; letter-spacing: -.01em; }
.city small { position: absolute; left: 12px; right: 10px; bottom: 9px; font-size: 11.5px; opacity: .88; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.city .chk { position: absolute; right: 10px; top: 10px; width: 26px; height: 26px; border-radius: 50%; background: rgba(255,255,255,.3); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.8); display: grid; place-items: center; }
.city.sel { box-shadow: 0 0 0 3px var(--red), var(--shadow); }
.city.sel .chk { background: var(--red); box-shadow: none; }
.city .fit { position: absolute; left: 10px; top: 10px; font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; background: rgba(255,255,255,.88); color: var(--green); padding: 3px 7px; border-radius: 6px; }
.sticky-cta { position: sticky; bottom: calc(var(--tab-h) + var(--safe-b) + 10px); margin-top: 18px; z-index: 5; }

/* Результаты */
.group-h { display: flex; align-items: baseline; justify-content: space-between; margin: 28px 0 10px; }
.group-h .h2 { margin: 0; }
.pick { padding: 0; overflow: hidden; }
.pick .ph { height: 150px; position: relative; }
.pick .ph img { width: 100%; height: 100%; object-fit: cover; }
.pick .role { position: absolute; left: 12px; top: 12px; background: var(--material); backdrop-filter: blur(14px) saturate(160%); -webkit-backdrop-filter: blur(14px) saturate(160%); color: var(--ink); padding: 5px 11px; border-radius: 999px; font-weight: 800; font-size: 12px; letter-spacing: .01em; }
.pick .body { padding: 14px 16px 16px; }
.pick .ex { margin: 10px 0 8px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: 13.5px; line-height: 1.5; }
.pick .ex b { display: block; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 2px; }

/* Учёба */
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; margin: 4px 0 18px; }
.seg button { flex: 1; height: 36px; border-radius: 10px; font-weight: 800; font-size: 14px; color: var(--ink-2); transition: background var(--press); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.ring { --p: 0; width: 92px; height: 92px; border-radius: 50%; flex: none; display: grid; place-items: center; background: conic-gradient(var(--red) calc(var(--p) * 1%), var(--surface-2) 0); }
.ring > div { width: 76px; height: 76px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; text-align: center; font-weight: 800; font-size: 18px; line-height: 1.1; }
.ring small { display: block; font-size: 10.5px; color: var(--ink-3); font-weight: 700; }
.levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.levels button { height: 42px; border-radius: 12px; border: 1px solid var(--hair); background: var(--surface); font-weight: 800; transition: transform var(--press); }
.levels button:active { transform: scale(.95); }
.levels button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.flash { perspective: 1200px; height: 340px; margin: 10px 0 18px; }
.flash .inner { position: relative; width: 100%; height: 100%; transition: transform .6s cubic-bezier(.2, .9, .25, 1); transform-style: preserve-3d; }
.flash.flip .inner { transform: rotateY(180deg); }
.flash .side { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: var(--surface); border: 1px solid var(--hair); border-radius: 26px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; }
.flash .back { transform: rotateY(180deg); }
.hanzi { font-size: 78px; line-height: 1.1; font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif; font-weight: 400; }
.pinyin { font-size: 22px; color: var(--red); font-weight: 700; margin: 6px 0 10px; }
.meaning { font-size: 19px; font-weight: 700; line-height: 1.35; }
.grade { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grade .btn { height: 54px; font-size: 14.5px; }
.timeline .ev { display: flex; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--hair); }
.timeline .ev:last-child { border: 0; }
.timeline .d { width: 54px; flex: none; text-align: center; border: 1px solid var(--hair); border-radius: 12px; padding: 6px 0; font-weight: 800; line-height: 1.1; }
.timeline .d b { display: block; font-family: var(--serif); font-weight: 400; font-size: 21px; color: var(--red); }
.timeline .d small { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.countdown { font-family: var(--serif); font-size: 48px; letter-spacing: -.03em; color: var(--red); line-height: 1; }

/* Чат */
.chat { display: flex; flex-direction: column; gap: 10px; padding-bottom: 92px; }
.msg { max-width: 86%; padding: 11px 14px; border-radius: 20px; font-size: 15px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; animation: enter .3s cubic-bezier(.2, .9, .25, 1) both; }
.msg.me { align-self: flex-end; background: var(--red); color: #fff; border-bottom-right-radius: 6px; }
.msg.ai { align-self: flex-start; background: var(--surface); border: 1px solid var(--hair); border-bottom-left-radius: 6px; }
.msg.ai b { color: var(--red); }
.typing span { display: inline-block; width: 6px; height: 6px; margin: 0 2px; border-radius: 50%; background: var(--ink-3); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.composer { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + var(--safe-b)); padding: 10px 14px; background: var(--material); backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%); display: flex; gap: 8px; z-index: 20; }
.composer input { flex: 1; height: 46px; border-radius: 23px; border: 1px solid var(--hair); padding: 0 16px; background: var(--surface); outline: 0; font-size: 16px; }
.composer button { width: 46px; height: 46px; border-radius: 50%; background: var(--red); color: #fff; display: grid; place-items: center; flex: none; transition: transform var(--press); }
.composer button:active { transform: scale(.9); }

/* Таб-бар — полупрозрачный материал, контент прокручивается под ним */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b); display: grid; grid-template-columns: repeat(5, 1fr); background: var(--material); backdrop-filter: saturate(180%) blur(22px); -webkit-backdrop-filter: saturate(180%) blur(22px); box-shadow: 0 -1px 0 var(--hair); z-index: 30; }
.tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 10.5px; font-weight: 700; letter-spacing: .01em; color: var(--ink-3); transition: color var(--press), transform var(--press); }
.tabbar button:active { transform: scale(.92); }
.tabbar button.on { color: var(--red); }

/* Шторка: управляется пружиной из JS */
.scrim { position: fixed; inset: 0; background: rgba(12, 10, 8, .38); z-index: 50; opacity: 0; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; background: var(--bg); border-radius: 24px 24px 0 0; padding: 8px 20px calc(24px + var(--safe-b)); max-height: 90vh; overflow: auto; box-shadow: 0 -10px 40px rgba(0,0,0,.18); transform: translateY(100%); will-change: transform; touch-action: none; }
.sheet .grab { width: 38px; height: 5px; border-radius: 9px; background: var(--hair); margin: 4px auto 14px; }
.field { display: block; width: 100%; height: 52px; border-radius: 13px; border: 1px solid var(--hair); background: var(--surface); padding: 0 14px; margin-bottom: 10px; outline: 0; font-size: 16px; transition: box-shadow var(--press); }
.field:focus { box-shadow: 0 0 0 3px var(--red-soft); border-color: var(--red); }
textarea.field { height: 88px; padding: 12px 14px; resize: none; }
.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 26px); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 700; z-index: 60; animation: enter .3s both; white-space: nowrap; }
.empty { text-align: center; padding: 32px 10px; color: var(--ink-2); }
.skeleton { height: 108px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.3s infinite; margin-bottom: 12px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ===== Доступность ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .12s !important; }
  .press:active, .btn:active, .chip:active, .city:active { transform: none; opacity: .7; }
  .flash .inner { transition: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .tabbar, .composer { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .pick .role { background: var(--surface); backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  :root { --hair: rgba(29, 32, 27, .35); --ink-2: #3a3832; --ink-3: #5e5a51; }
}

/* ---------- Аккаунт: вход, аватар, кабинет ---------- */
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); box-shadow: 0 0 0 1px var(--hair); color: var(--ink); font-weight: 800; font-size: 14px; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.big { width: 72px; height: 72px; font-size: 26px; }
.login { min-height: 100dvh; display: flex; flex-direction: column; }
.login .hero { flex: 1; min-height: 46vh; border-radius: 0 0 32px 32px; margin: 0; }
.login .panel { padding: 24px 20px calc(28px + var(--safe-b)); }
.btn-google { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--hair); }
.btn-google svg, .btn-tg svg { flex: none; }
.btn-tg { background: #2AABEE; color: #fff; }
.tgw { display: flex; justify-content: center; min-height: 0; }
.tgw:empty { display: none; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; }
.kv + .kv { box-shadow: 0 -1px 0 var(--hair); }
.kv .k { color: var(--ink-2); font-size: 14px; }
.kv .v { font-weight: 700; text-align: right; overflow: hidden; text-overflow: ellipsis; }
.ok { color: var(--green); font-weight: 800; display: inline-flex; align-items: center; gap: 4px; }
.link { color: var(--red); font-weight: 800; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
select.field { appearance: none; -webkit-appearance: none; }
.consent { font-size: 12px; color: var(--ink-2); line-height: 1.5; text-align: center; }
.consent a { color: inherit; }

a.btn { text-decoration: none; }
.hero-top { position: absolute; top: calc(16px + env(safe-area-inset-top, 0px)); left: 20px; right: 20px; display: flex; justify-content: space-between; align-items: center; z-index: 2; }
.hero-top > img { width: 44px; height: 44px; border-radius: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.tabbar[hidden], .topnav[hidden] { display: none !important; }
@media (max-width: 400px) { .topbar .brand b { display: none; } }

/* ===== Полировка (аудит по Hallmark / Impeccable / taste) ===== */
.display, .h1, .h2, .h3 { text-wrap: balance; }
.lead, .small, p { text-wrap: pretty; }
.price, .countdown, .num, .range-val, .prog .p, .streak, .timeline .d b { font-variant-numeric: tabular-nums lining-nums; }
.lead { max-width: 60ch; }
/* Фокус для клавиатуры — появляется мгновенно */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; transition: none; }
.field:focus-visible, .search input:focus-visible, .composer input:focus-visible { outline: none; }
.search:focus-within { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
/* Бумажная фактура вместо стерильной заливки */
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 100; opacity: .035; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
:root[data-theme="dark"] body::before { mix-blend-mode: screen; opacity: .025; }
/* Наведение мышью — только на устройствах с курсором, одно свойство на элемент */
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { background: var(--red-ink); }
  .btn-line:hover, .btn-ghost:hover { background: var(--surface-2); }
  .btn-white:hover { background: #F3EFE6; }
  .btn-google:hover { box-shadow: 0 0 0 1px var(--ink-3); }
  .card.press:hover, .city:hover { box-shadow: var(--shadow-lg); }
  .row-link:hover, .opt:hover { background: var(--surface-2); }
  .chip:hover { border-color: var(--ink-3); }
  .tabbar button:hover, .topnav nav button:hover { color: var(--ink); }
  .link:hover { text-decoration: underline; text-underline-offset: 3px; }
  .card.press, .city, .btn, .row-link, .opt, .chip { transition: transform var(--press), background .18s ease, box-shadow .2s ease, border-color .18s ease; }
}

/* ===== Верхняя навигация (сайт на компьютере) ===== */
.topnav { display: none; }
@media (min-width: 980px) {
  body { background: var(--bg); }
  .topnav { display: flex; align-items: center; gap: 28px; position: sticky; top: 0; z-index: 40; height: 68px; padding: 0 max(40px, calc((100vw - 1120px) / 2));
    background: var(--material); backdrop-filter: saturate(180%) blur(22px); -webkit-backdrop-filter: saturate(180%) blur(22px); box-shadow: 0 1px 0 var(--hair); }
  .topnav .brand { cursor: pointer; }
  .topnav .brand b { display: block; }
  .topnav nav { display: flex; gap: 4px; margin-left: 12px; }
  .topnav nav button { height: 38px; padding: 0 14px; border-radius: 10px; font-weight: 700; font-size: 15px; color: var(--ink-2); transition: color .15s ease, background .15s ease; }
  .topnav nav button.on { color: var(--ink); background: var(--surface-2); }
  .topnav .right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
  .tabbar { display: none; }
  #app { max-width: 1120px; margin: 0 auto; padding: 0 40px 64px; }
  .screen { padding: 36px 0 8px; }
  #app[data-view="home"] .topbar { display: none; }
  /* Узкая колонка для чтения и форм */
  #app:not([data-view="home"]):not([data-view="unis"]):not([data-view="result"]) .screen { max-width: 720px; margin: 0 auto; }
  .display { font-size: 60px; }
  .h1 { font-size: 40px; }
  .h2 { font-size: 26px; }
  /* Главная: герой слева, сводка справа */
  .home-grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: 20px; align-items: stretch; }
  .home-grid .hero { min-height: 520px; }
  .home-grid .hero .display { font-size: 48px; }
  .home-grid .side { display: flex; flex-direction: column; gap: 12px; }
  .home-grid .side .stat-grid, .home-grid .side .list { margin-top: 0 !important; }
  .home-grid .side .list { flex: 1; }
  /* Каталог и подборка — две колонки */
  .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .grid2 > .card + .card { margin-top: 0; }
  .pick .ph { height: 190px; }
  .catalog { display: grid; grid-template-columns: 300px 1fr; gap: 32px; align-items: start; }
  .filters { position: sticky; top: 88px; max-height: calc(100dvh - 108px); overflow: auto; padding-right: 4px; scrollbar-width: thin; }
  .filters .chips { flex-wrap: wrap; overflow: visible; margin: 0 0 6px; padding: 0 0 10px; box-shadow: 0 1px 0 var(--hair); gap: 6px; }
  .filters .chips:last-child { box-shadow: none; }
  .filters .chip { height: 32px; padding: 0 12px; font-size: 13.5px; }
  .catalog #list { margin-top: 0 !important; }
  .cities { grid-template-columns: repeat(3, 1fr); }
  .city { height: 140px; }
  .cover { margin: -36px 0 0; height: 380px; border-radius: 0 0 28px 28px; }
  .sticky-cta { bottom: 20px; }
  .composer { left: 50%; right: auto; width: 720px; transform: translateX(-50%); bottom: 20px; border-radius: 26px; box-shadow: var(--shadow-lg); }
  .chat { padding-bottom: 110px; }
  .toast { bottom: 32px; }
  .sheet { left: 50%; right: auto; width: 520px; margin-left: -260px; bottom: 24px; border-radius: 26px; padding-bottom: 24px; }
  .flash { height: 380px; }
  /* Вход: фото слева, форма справа */
  #app[data-view="login"] { max-width: none; padding: 0; }
  .login { flex-direction: row; }
  .login .hero { flex: 1.3; min-height: 100dvh; border-radius: 0; }
  .login .hero .display { font-size: 52px; max-width: 14ch; }
  .login .panel { flex: 1; max-width: 520px; display: flex; flex-direction: column; justify-content: center; padding: 48px 56px; }
}
@media (min-width: 700px) and (max-width: 979px) {
  #app { max-width: 640px; margin: 0 auto; }
  .tabbar, .composer { left: 50%; right: auto; width: 640px; transform: translateX(-50%); }
  .sheet { left: 50%; right: auto; width: 640px; margin-left: -320px; }
}

/* ===== Связь с менеджером: тихая плавающая кнопка ===== */
.fab { position: fixed; right: 16px; bottom: calc(var(--tab-h) + var(--safe-b) + 14px); z-index: 35; height: 46px; padding: 0 16px 0 13px; border-radius: 23px;
  display: inline-flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 800; font-size: 14.5px;
  background: var(--material); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 0 0 1px var(--hair), var(--shadow-lg); transition: padding .28s cubic-bezier(.2, .9, .25, 1), transform var(--press); }
.fab svg { color: var(--red); flex: none; }
.fab span { max-width: 140px; overflow: hidden; white-space: nowrap; transition: max-width .28s cubic-bezier(.2, .9, .25, 1), opacity .2s ease; }
.fab.mini { padding: 0 12px; }
.fab.mini span { max-width: 0; opacity: 0; }
.fab:active { transform: scale(.94); }
.fab[hidden] { display: none; }
@media (hover: hover) and (pointer: fine) { .fab:hover { box-shadow: 0 0 0 1px var(--ink-3), var(--shadow-lg); } }
@media (min-width: 980px) { .fab { right: max(24px, calc((100vw - 1120px) / 2 - 72px)); bottom: 28px; } }
@media (prefers-reduced-transparency: reduce) { .fab { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; } }

.handoff { align-self: stretch; display: flex; flex-direction: column; gap: 12px; margin-top: 4px; padding: 14px 16px; border-radius: 18px; background: var(--surface-2); }
.handoff b { display: block; font-size: 15px; }
.handoff span { display: block; font-size: 13.5px; color: var(--ink-2); line-height: 1.45; margin-top: 2px; }
.handoff .btn { height: 44px; align-self: flex-start; padding: 0 16px; font-size: 14.5px; }
.seg.via { margin: 0 0 10px; }
.seg.via button { font-size: 13px; }
.field-err { min-height: 1lh; margin: 0 2px 8px; font-size: 13px; color: var(--red); line-height: 1.4; }
.field-err:empty { min-height: 0; margin: 0; }

/* ===== Сегментный переключатель (язык, разделы, способ связи) — подложка едет, как в iOS ===== */
.seg, .lang { position: relative; isolation: isolate; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.seg > .thumb, .lang > .thumb { position: absolute; top: 3px; bottom: 3px; left: 0; z-index: 0; background: var(--surface); box-shadow: var(--shadow); pointer-events: none;
  transition: transform .34s cubic-bezier(.25, 1, .3, 1), opacity .15s ease; will-change: transform; }
.seg > .thumb { border-radius: 10px; }
.lang > .thumb { border-radius: 999px; }
.seg button, .lang button { position: relative; z-index: 1; background: transparent !important; box-shadow: none !important; }
.seg button.on, .lang button.on { cursor: grab; }
@media (prefers-reduced-motion: reduce) { .seg > .thumb, .lang > .thumb { transition: opacity .15s ease; } }

/* ===== Закрытый контент для гостей: видно, что внутри, но размыто ===== */
.lockwrap { position: relative; margin-top: 12px; }
.locked { filter: blur(7px) saturate(.9); opacity: .8; pointer-events: none; user-select: none; -webkit-user-select: none; max-height: 640px; overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, #000 55%, transparent); mask-image: linear-gradient(180deg, #000 55%, transparent); }
.lock-cta { position: absolute; left: 50%; top: 48px; transform: translateX(-50%); width: min(380px, calc(100% - 16px)); z-index: 3;
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 22px 20px 20px; border-radius: 22px;
  background: var(--surface); box-shadow: 0 0 0 1px var(--hair), var(--shadow-lg); }
.lock-cta b { font-size: 16px; line-height: 1.35; text-wrap: balance; }
.lock-cta .ico { width: 44px; height: 44px; border-radius: 14px; }
.composer .btn-block { height: 46px; }
.or { display: flex; align-items: center; gap: 12px; margin: 0 0 12px; color: var(--ink-3); font-size: 12.5px; font-weight: 700; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--hair); }
.field.code { text-align: center; font-size: 26px; letter-spacing: .4em; font-variant-numeric: tabular-nums; height: 60px; }
@media (prefers-reduced-transparency: reduce) { .locked { filter: none; opacity: .15; } }
.ticks { list-style: none; padding: 0; margin: 4px 0 12px; }
.ticks li { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; font-size: 15px; line-height: 1.4; }
.ticks li svg { color: var(--green); flex: none; margin-top: 3px; }
