/* Каркас приложения: экраны, вкладки, общие элементы. Цвета и формы — только из tokens.css. */
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; }
html, body { min-height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--studio); font-size: 16px; line-height: 1.4; overscroll-behavior-y: none; -webkit-tap-highlight-color: transparent; }
img { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
svg.i { width: 22px; height: 22px; flex: none; }
svg.i.flip { transform: rotate(180deg); }

.app { position: relative; max-width: 480px; min-height: 100vh; min-height: var(--app-h, 100dvh); margin: 0 auto; background: var(--page-bg); overflow-x: hidden; }
.view { min-height: 100vh; min-height: var(--app-h, 100dvh); padding-bottom: calc(68px + env(safe-area-inset-bottom)); outline: none; }
.app.no-tabs .view { padding-bottom: 0; }
.app.no-tabs .tabs { display: none; }

/* вкладки */
.tabs { position: fixed; z-index: 40; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; display: grid; grid-template-columns: repeat(5, 1fr); padding: 8px 6px calc(8px + env(safe-area-inset-bottom)); background: var(--tab-bg); border-top: 1px solid var(--line); }
.tabs a { display: grid; justify-items: center; gap: 3px; padding: 4px 0; font-size: 11.5px; font-weight: 600; color: #858580; }
.tabs a.on { color: var(--ink); }
.tabs a svg { width: 24px; height: 24px; }

/* типографика */
.label { font-size: 13px; font-weight: 600; color: var(--muted); }
.h1 { font-size: 34px; line-height: 1; font-weight: 800; letter-spacing: -0.045em; text-wrap: balance; }
.h2 { font-size: 24px; line-height: 1.05; font-weight: 800; letter-spacing: var(--tight); text-wrap: balance; }
.h3 { font-size: 18px; line-height: 1.15; font-weight: 750; letter-spacing: -0.02em; }
.p { font-size: 15px; line-height: 1.45; color: #2b2b29; }
.fire-word { background: var(--fire); -webkit-background-clip: text; background-clip: text; color: transparent; }
.mark { background: linear-gradient(transparent 60%, var(--lime) 60%, var(--lime) 92%, transparent 92%); padding: 0 2px; }

/* кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 12px 18px; border-radius: var(--r-btn); background: var(--cta-bg); color: var(--cta-ink); font-size: 15px; font-weight: 700; white-space: nowrap; transition: transform .12s ease, opacity .2s; }
.btn:active { transform: scale(.98); }
.btn.accent { background: var(--accent-bg); color: var(--accent-ink); }
.btn.soft { background: var(--surface-2); color: var(--ink); }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn svg { width: 20px; height: 20px; }
.link { font-size: 15px; font-weight: 700; color: var(--blue); }

/* верх внутренних экранов */
.top { padding: calc(18px + env(safe-area-inset-top)) 20px 10px; }
.top .back { display: inline-flex; align-items: center; gap: 4px; margin: -4px 0 10px -6px; padding: 4px 6px; font-size: 15px; font-weight: 600; color: var(--muted); }
.top .back svg { width: 20px; height: 20px; }
.top .h1 { margin-top: 6px; }
.top .p { margin-top: 8px; }
.section { padding: 8px 20px 20px; }
.section + .section { padding-top: 4px; }
.sec-title { margin: 14px 0 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.surface { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow); }
.pad { padding: 16px 18px; }

/* шкалы огонь/огнестойкость */
.meters { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.meter span { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; font-weight: 600; color: var(--muted); }
.meter b { font-size: 15px; font-weight: 800; color: var(--ink); }
.bar { margin-top: 7px; height: 8px; border-radius: 99px; background: #E3E3DF; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 99px; transition: width .8s cubic-bezier(.2,.8,.2,1); }
.bar.fire i { background: var(--fire); }
.bar.proof i { background: var(--lime); }

/* главная: сцена-кадр */
.home { display: flex; flex-direction: column; min-height: calc(var(--app-h, 100dvh) - 68px - env(safe-area-inset-bottom)); }
.scene { position: relative; flex: 1 0 auto; min-height: 400px; overflow: hidden; background: #DADAD7 var(--scene-bg) 50% 100% / cover no-repeat; isolation: isolate; }
.scene .flames { position: absolute; z-index: 1; left: -4%; width: 108%; bottom: 18px; height: calc(var(--fire-level, 0) * 0.78%); object-fit: fill; transform-origin: 50% 100%; animation: flick 2.6s ease-in-out infinite; pointer-events: none; }
.scene.calm::after { content: ""; position: absolute; inset: auto 0 0 0; height: 46%; background: radial-gradient(60% 70% at 50% 100%, rgba(200, 242, 58, .45), transparent 70%); z-index: 1; pointer-events: none; }
@keyframes flick { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(1.05) translateX(-.5%); } }
.scene .hero { position: absolute; z-index: 2; right: 5%; bottom: 14px; height: min(84%, 520px); width: auto; filter: drop-shadow(0 16px 18px rgba(40, 30, 20, .16)); animation: breathe 4.2s ease-in-out infinite; transform-origin: 50% 100%; }
.scene .hero.emo-begom { height: min(70%, 440px); right: 2%; }
.scene .hero.emo-otdyh { height: min(56%, 360px); right: 0; }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.012, 1.006); } }
.scene .head { position: absolute; z-index: 3; left: 20px; top: calc(20px + env(safe-area-inset-top)); width: 52%; }
.scene .head .h1 { margin-top: 8px; font-size: clamp(34px, 10.5vw, 44px); line-height: .95; letter-spacing: -0.05em; }
.scene .head .p { margin-top: 12px; font-size: 16px; font-weight: 500; }
.scene .money { position: absolute; z-index: 3; right: 16px; top: calc(16px + env(safe-area-inset-top)); padding: 7px 12px; border-radius: var(--r-chip); background: var(--ink); color: var(--lime); font-size: 14px; font-weight: 800; }
.sheet { position: relative; z-index: 4; margin-top: -26px; padding: 18px 20px 18px; background: var(--surface); border-radius: var(--r-sheet) var(--r-sheet) 0 0; }
.next { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 18px; }
.next .h3 { margin-top: 3px; }
.next .btn { flex: none; }

[data-theme="studiya"] .scene, [data-theme="agentstvo"] .scene { margin: calc(12px + env(safe-area-inset-top)) 16px 0; border-radius: var(--r-card); min-height: 360px; flex: 0 0 auto; }
[data-theme="studiya"] .sheet, [data-theme="agentstvo"] .sheet { margin: 12px 16px 0; border-radius: var(--r-card); box-shadow: var(--shadow); }
[data-theme="studiya"] .scene .head, [data-theme="agentstvo"] .scene .head { top: 16px; }

/* уведомление сверху */
.notif { position: absolute; z-index: 6; left: 12px; right: 12px; top: calc(10px + env(safe-area-inset-top)); display: grid; grid-template-columns: 38px 1fr; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 18px; background: rgba(247, 247, 245, .94); box-shadow: 0 14px 28px -16px rgba(60, 60, 50, .55); transform: translateY(-130%); transition: transform .5s cubic-bezier(.2, .9, .2, 1.1); text-align: left; }
.notif.on { transform: translateY(0); }
.notif img { width: 38px; height: 38px; object-fit: contain; }
.notif small { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.notif p { font-size: 14px; line-height: 1.3; font-weight: 500; }

/* списки-ряды */
.rows { display: grid; }
.rowi { display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); text-align: left; width: 100%; }
.rowi:last-child { border-bottom: 0; }
.rowi img { width: 52px; height: 52px; object-fit: contain; }
.rowi .label, .rowi .h3, .rowi .sub { display: block; }
.rowi .h3 { margin-top: 2px; font-size: 17px; }
.rowi .sub { font-size: 14px; color: var(--muted); margin-top: 2px; }
.rowi .st { font-size: 13px; font-weight: 700; white-space: nowrap; }
.rowi .st.done { color: var(--lime-ink); }
.rowi .st svg { width: 20px; height: 20px; }
.rowi.locked img { filter: grayscale(1) opacity(.55); }
.rowi.locked .h3 { color: #6f6f6a; }
.glass-blue { filter: var(--glass-blue); }
.glass-lime { filter: var(--glass-lime); }

/* тренажёр */
.steps { display: grid; gap: 10px; }
.step { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow); overflow: hidden; }
.step > button { width: 100%; display: grid; grid-template-columns: 30px 1fr 20px; gap: 12px; align-items: center; padding: 14px 16px; text-align: left; }
.step .num { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: 14px; font-weight: 800; }
.step.done .num { background: var(--lime); }
.step .h3 { font-size: 16px; }
.step .chev { transition: transform .2s; color: var(--muted); }
.step.open .chev { transform: rotate(90deg); }
.step .body { display: none; padding: 0 16px 16px; }
.step.open .body { display: grid; gap: 12px; }
.prompt { padding: 12px 14px; border-radius: 14px; background: var(--surface-2); font-size: 15px; line-height: 1.45; white-space: pre-wrap; }
.field { display: grid; gap: 8px; }
.field label { font-size: 14px; font-weight: 700; }
.field textarea, .field input { width: 100%; min-height: 160px; padding: 12px 14px; border-radius: 14px; border: 1.5px solid #CFCFCA; background: #fff; font-size: 16px; line-height: 1.45; resize: vertical; }
.field textarea:focus, .field input:focus { outline: none; border-color: var(--blue); }
.field .help { font-size: 13px; color: var(--muted); }
.verdict { padding: 16px; border-radius: var(--r-card); background: var(--surface); border: 2px solid var(--line); display: grid; gap: 10px; }
.verdict.ok { border-color: var(--lime); }
.verdict.no { border-color: #FFB38A; }
.verdict ul { list-style: none; display: grid; gap: 8px; }
.verdict li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; font-size: 14px; line-height: 1.35; }
.verdict li svg { width: 20px; height: 20px; }
.verdict li.yes svg { color: #4C7A00; }
.verdict li.nope svg { color: var(--fire-1); }
.verdict li.skip svg { color: #9A9A95; }
.verdict .src { font-size: 12.5px; color: var(--muted); }

/* рой */
.plate { display: grid; grid-template-columns: 48px 1fr; gap: 12px; align-items: center; padding: 14px 16px; border-radius: var(--r-card); background: var(--lime); }
.plate img { width: 48px; height: 48px; object-fit: contain; }
.plate b { display: block; font-size: 15px; }
.plate span { font-size: 14px; line-height: 1.35; }
.bots { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.botc { display: grid; gap: 4px; justify-items: start; padding: 14px; border-radius: var(--r-card); background: var(--surface); box-shadow: var(--shadow); text-align: left; }
.botc img { height: 64px; width: auto; margin-bottom: 6px; }
.botc b { font-size: 16px; letter-spacing: -0.02em; }
.botc small { font-size: 13px; color: var(--muted); line-height: 1.3; }
.botc .lvl { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: var(--r-chip); background: var(--surface-2); }
.botc.new { outline: 2px solid var(--lime); }
.botc.locked { background: transparent; box-shadow: none; border: 1.5px dashed #BDBDB8; }
.botc.locked img { filter: grayscale(1) opacity(.4); }

/* чат */
.seg { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: var(--r-chip); background: var(--surface-2); }
.seg button { padding: 9px 0; border-radius: var(--r-chip); font-size: 14px; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 2px 8px -4px rgba(0, 0, 0, .25); }
.msgs { display: grid; gap: 10px; padding: 14px 20px 120px; }
.msg { max-width: 86%; padding: 10px 13px; border-radius: 18px; font-size: 15px; line-height: 1.4; background: var(--surface); }
.msg small { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 2px; }
.msg.mod small { color: var(--blue); }
.msg.me { justify-self: end; background: var(--ink); color: var(--paper); border-bottom-right-radius: 6px; }
.msg.mod { border-bottom-left-radius: 6px; }
.compose { position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; bottom: calc(68px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: 1fr 46px; gap: 8px; padding: 10px 14px; background: var(--page-bg); }
.compose input { min-width: 0; height: 46px; padding: 0 16px; border-radius: var(--r-chip); border: 1.5px solid #CFCFCA; background: #fff; font-size: 16px; }
.compose input:focus { outline: none; border-color: var(--blue); }
.compose button { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--paper); }
.locked-box { margin: 18px 20px; padding: 18px; border-radius: var(--r-card); background: var(--surface); display: grid; gap: 10px; justify-items: start; }

/* подписка */
.plans { display: grid; gap: 10px; }
.plan { display: grid; grid-template-columns: 22px 1fr auto; gap: 12px; align-items: center; padding: 14px 16px; border-radius: var(--r-card); background: var(--surface); border: 2px solid transparent; text-align: left; width: 100%; }
.plan .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #BDBDB8; }
.plan.on { border-color: var(--ink); }
.plan.on .dot { border: 7px solid var(--ink); }
.plan b { display: block; font-size: 17px; letter-spacing: -0.02em; }
.plan small { font-size: 13px; color: var(--muted); }
.plan .price { font-size: 19px; font-weight: 800; letter-spacing: -0.03em; white-space: nowrap; }
.plan .tag { display: inline-block; margin-top: 4px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: var(--r-chip); background: var(--lime); color: var(--ink); }
.facts { display: grid; gap: 10px; margin-top: 14px; }
.fact { display: grid; grid-template-columns: 40px 1fr; gap: 12px; align-items: center; font-size: 14px; line-height: 1.4; }
.fact img { width: 40px; height: 40px; object-fit: contain; }

/* всплывашки */
.toast { position: fixed; z-index: 60; left: 50%; top: calc(14px + env(safe-area-inset-top)); transform: translateX(-50%); max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 16px; background: var(--ink); color: var(--paper); font-size: 14px; font-weight: 600; box-shadow: 0 14px 30px -18px rgba(0, 0, 0, .6); }
.modal { position: fixed; z-index: 70; inset: 0; display: grid; align-items: end; background: rgba(14, 14, 14, .45); }
.modal .sheetm { width: 100%; max-width: 480px; margin: 0 auto; padding: 22px 20px calc(20px + env(safe-area-inset-bottom)); border-radius: var(--r-sheet) var(--r-sheet) 0 0; background: var(--surface); display: grid; gap: 12px; animation: up .3s cubic-bezier(.2, .9, .2, 1); }
.modal .sheetm img.big { height: 180px; width: auto; justify-self: center; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

.skeleton { margin: 20px; height: 60vh; border-radius: var(--r-card); background: linear-gradient(90deg, #E4E4E0, #EEEEEA, #E4E4E0); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }
.err { margin: 40px 20px; display: grid; gap: 12px; justify-items: start; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
}
