:root {
  --bg: #0c0a09;
  --surface: #161311;
  --raised: #1f1b18;
  --line: rgba(255, 236, 220, 0.08);
  --line-strong: rgba(255, 236, 220, 0.16);
  --text: #f4ede5;
  --muted: #9a8f85;
  --faint: #6b625a;
  --ember: #ff6a2b;
  --gold: #ffb454;
  --good: #86d993;
  --bad: #e5604d;
  --grad: linear-gradient(135deg, #ff5a1f 0%, #ff8a3d 55%, #ffc266 100%);
  --display: 'Unbounded', 'Onest', system-ui, sans-serif;
  --body: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --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; height: 100%; background: var(--bg); color: var(--text); font-family: var(--body); font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
body::before { content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(120% 60% at 50% -10%, rgba(255, 106, 43, 0.16), transparent 60%), radial-gradient(80% 40% at 100% 100%, rgba(255, 180, 84, 0.05), transparent 70%); }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
h1, h2, h3, p { margin: 0; }

#app { position: relative; z-index: 1; max-width: 520px; margin: 0 auto; padding: calc(var(--safe-t) + 18px) 18px calc(var(--safe-b) + 110px); min-height: 100%; }
.boot { display: grid; place-items: center; height: 80vh; }
.ember { width: 14px; height: 14px; border-radius: 50%; background: var(--grad); box-shadow: 0 0 40px 12px rgba(255, 106, 43, 0.45); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.5); opacity: 0.6; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.view > * { animation: rise 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.view > *:nth-child(2) { animation-delay: 0.05s; } .view > *:nth-child(3) { animation-delay: 0.1s; } .view > *:nth-child(4) { animation-delay: 0.15s; } .view > *:nth-child(n + 5) { animation-delay: 0.2s; }

/* шапка */
.top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; }
.eyebrow { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.title { font-family: var(--display); font-weight: 700; font-size: 26px; letter-spacing: -0.02em; margin-top: 6px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; background: var(--raised); border: 1px solid var(--line); font-size: 13px; font-weight: 600; white-space: nowrap; }
.pill b { font-family: var(--display); font-weight: 700; }
.pill.hot { border-color: rgba(255, 106, 43, 0.4); color: var(--gold); }
.pill svg { width: 14px; height: 14px; }

/* карточки */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 18px; margin-bottom: 14px; }
.card h3 { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 12px; }
.muted { color: var(--muted); } .small { font-size: 13px; }

.letter { position: relative; padding-left: 20px; cursor: pointer; }
.letter::before { content: ''; position: absolute; left: 0; top: 18px; bottom: 18px; width: 3px; border-radius: 3px; background: var(--grad); }
.letter .from { display: flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); font-weight: 700; margin-bottom: 8px; }
.letter .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ember); box-shadow: 0 0 10px var(--ember); }
.letter p { white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }

.hero { position: relative; overflow: hidden; border-radius: 26px; padding: 26px 22px; margin-bottom: 14px; background: linear-gradient(160deg, #2a170d 0%, #17110e 60%); border: 1px solid rgba(255, 106, 43, 0.22); }
.hero::after { content: ''; position: absolute; right: -60px; top: -60px; width: 200px; height: 200px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 106, 43, 0.35), transparent 70%); pointer-events: none; }
.hero .eyebrow { color: var(--gold); }
.hero .big { font-family: var(--display); font-weight: 800; font-size: 64px; line-height: 1; letter-spacing: -0.04em; margin: 14px 0 10px; }
.hero .word { font-family: var(--display); font-weight: 700; font-size: 24px; line-height: 1.25; letter-spacing: -0.02em; margin: 14px 0 12px; overflow-wrap: anywhere; }
.hero p { color: #d9cdc1; position: relative; }
.hero.done { background: linear-gradient(160deg, #13241a 0%, #121110 60%); border-color: rgba(134, 217, 147, 0.25); }
.hero.done::after { background: radial-gradient(circle, rgba(134, 217, 147, 0.25), transparent 70%); }
.hero.done .eyebrow { color: var(--good); }
.hero.broken { background: linear-gradient(160deg, #2a1310 0%, #121110 60%); border-color: rgba(229, 96, 77, 0.3); }
.hero.broken .eyebrow { color: var(--bad); }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 16px 18px; border-radius: 16px; font-weight: 700; font-size: 16px; background: var(--grad); color: #1a0d05; box-shadow: 0 10px 30px -10px rgba(255, 106, 43, 0.7); transition: transform 0.12s ease, opacity 0.2s; position: relative; }
.btn:active { transform: scale(0.97); }
.btn.ghost { background: var(--raised); color: var(--text); box-shadow: none; border: 1px solid var(--line-strong); }
.btn.quiet { background: none; color: var(--muted); box-shadow: none; font-weight: 600; padding: 12px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn + .btn { margin-top: 10px; }
.mt { margin-top: 16px; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 7px; font-weight: 500; }
input[type='text'], input[type='password'], input[type='time'], textarea { width: 100%; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 14px; padding: 14px; outline: none; resize: none; transition: border-color 0.2s; color-scheme: dark; }
input:focus, textarea:focus { border-color: rgba(255, 106, 43, 0.7); }
textarea { min-height: 84px; }
::placeholder { color: var(--faint); }

.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.choice button { padding: 16px 10px; border-radius: 16px; background: var(--bg); border: 1px solid var(--line-strong); font-weight: 700; transition: all 0.15s; }
.choice button.on.yes { background: rgba(134, 217, 147, 0.14); border-color: var(--good); color: var(--good); }
.choice button.on.no { background: rgba(229, 96, 77, 0.14); border-color: var(--bad); color: var(--bad); }
.scale { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; margin-bottom: 16px; }
.scale button { aspect-ratio: 1; border-radius: 10px; background: var(--bg); border: 1px solid var(--line-strong); font-weight: 700; font-size: 13px; }
.scale button.on { background: var(--grad); color: #1a0d05; border-color: transparent; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.check { display: flex; align-items: center; gap: 12px; }
.check i { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line-strong); display: grid; place-items: center; }
.check.ok i { background: var(--good); border-color: var(--good); }
.check.ok i::after { content: ''; width: 10px; height: 5px; border-left: 2.5px solid #0c1a10; border-bottom: 2.5px solid #0c1a10; transform: rotate(-45deg) translate(1px, -1px); }
.check.late i { border-color: var(--bad); }

/* путь */
.level { display: flex; align-items: center; gap: 18px; }
.ring { position: relative; width: 104px; height: 104px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .n { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--display); font-weight: 800; font-size: 34px; }
.rank { font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: -0.02em; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 16px; }
.stat b { display: block; font-family: var(--display); font-weight: 700; font-size: 30px; letter-spacing: -0.03em; line-height: 1.1; }
.stat span { font-size: 13px; color: var(--muted); }
.stages { position: relative; }
.stage { position: relative; display: flex; gap: 14px; padding-bottom: 18px; }
.stage:last-child { padding-bottom: 0; }
.stage::before { content: ''; position: absolute; left: 15px; top: 32px; bottom: 0; width: 2px; background: var(--line-strong); }
.stage:last-child::before { display: none; }
.stage .num { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-size: 13px; font-weight: 700; background: var(--raised); border: 1px solid var(--line-strong); color: var(--muted); }
.stage.now .num { background: var(--grad); color: #1a0d05; border-color: transparent; box-shadow: 0 0 22px rgba(255, 106, 43, 0.55); }
.stage.past .num { background: rgba(134, 217, 147, 0.16); color: var(--good); border-color: rgba(134, 217, 147, 0.4); }
.stage .name { font-weight: 700; } .stage.later { opacity: 0.5; }
.stage .txt { font-size: 14px; color: var(--muted); margin-top: 2px; }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.grid i { aspect-ratio: 1; border-radius: 9px; background: var(--raised); border: 1px solid var(--line); position: relative; }
.grid i.kept { background: var(--grad); border-color: transparent; }
.grid i.broken { background: rgba(229, 96, 77, 0.25); border-color: rgba(229, 96, 77, 0.5); }
.grid i.open { border-color: rgba(255, 180, 84, 0.6); }
.grid i.today { outline: 2px solid var(--text); outline-offset: 2px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 14px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* брат */
.chat { display: flex; flex-direction: column; gap: 10px; padding-bottom: 80px; }
.msg { max-width: 88%; padding: 13px 15px; border-radius: 20px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.brat { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.me { align-self: flex-end; background: #3a1f10; border: 1px solid rgba(255, 106, 43, 0.25); border-bottom-right-radius: 6px; }
.msg time { display: block; margin-top: 6px; font-size: 11px; color: var(--faint); }
.composer { position: fixed; left: 0; right: 0; bottom: calc(var(--safe-b) + 78px); z-index: 5; padding: 0 14px; }
.composer div { max-width: 492px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; background: var(--raised); border: 1px solid var(--line-strong); border-radius: 22px; padding: 6px 6px 6px 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6); }
.composer textarea { border: 0; background: none; padding: 9px 0; min-height: 40px; max-height: 120px; }
.composer button { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--grad); display: grid; place-items: center; }
.composer svg { width: 18px; height: 18px; }
.empty { text-align: center; color: var(--muted); padding: 50px 20px; }

/* таббар */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding: 8px 14px calc(var(--safe-b) + 10px); background: linear-gradient(to top, var(--bg) 62%, transparent); }
#tabs .bar { max-width: 492px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); background: rgba(31, 27, 24, 0.92); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--line-strong); border-radius: 22px; padding: 6px; }
#tabs button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 4px 7px; border-radius: 16px; color: var(--muted); font-size: 11px; font-weight: 600; transition: all 0.2s; }
#tabs button svg { width: 22px; height: 22px; }
#tabs button.on { color: var(--text); background: rgba(255, 106, 43, 0.14); }
#tabs button.on svg { color: var(--ember); }
#tabs .badge { position: absolute; top: 6px; left: calc(50% + 8px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--ember); color: #1a0d05; font-size: 10px; font-weight: 800; display: grid; place-items: center; }

/* шторка */
#sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex; align-items: flex-end; justify-content: center; animation: fade 0.2s both; }
#sheet[hidden], #tabs[hidden], #toast[hidden] { display: none; }
#sheet .panel { width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; background: var(--surface); border: 1px solid var(--line-strong); border-bottom: 0; border-radius: 28px 28px 0 0; padding: 12px 20px calc(var(--safe-b) + 24px); animation: up 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
#sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 0 auto 18px; }
#sheet h2 { font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: -0.02em; margin-bottom: 8px; }
#sheet .lead { color: var(--muted); margin-bottom: 18px; }
.timer { font-family: var(--display); font-weight: 800; font-size: 76px; letter-spacing: -0.04em; text-align: center; margin: 22px 0 6px; font-variant-numeric: tabular-nums; }
.steps { display: flex; gap: 6px; margin-bottom: 18px; } .steps i { height: 3px; flex: 1; border-radius: 2px; background: var(--line-strong); } .steps i.on { background: var(--grad); }
@keyframes fade { from { opacity: 0; } } @keyframes up { from { transform: translateY(40px); opacity: 0; } }

#toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 100px); transform: translateX(-50%); z-index: 30; background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 999px; font-weight: 700; font-size: 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); animation: rise 0.3s both; max-width: 90vw; text-align: center; }

/* вход */
.login { min-height: 82vh; display: flex; flex-direction: column; justify-content: center; }
.login .mark { width: 64px; height: 64px; margin-bottom: 26px; }
.login h1 { font-family: var(--display); font-weight: 800; font-size: 30px; letter-spacing: -0.03em; margin-bottom: 10px; }
.login p { color: var(--muted); margin-bottom: 26px; }
