@font-face { font-family: "Unbounded"; src: url(fonts/Unbounded.woff?v=5) format("woff"), url(fonts/Unbounded.ttf?v=5) format("truetype"); font-weight: 200 900; font-display: swap; }
@font-face { font-family: "Oranienbaum"; src: url(fonts/Oranienbaum-Regular.woff?v=5) format("woff"), url(fonts/Oranienbaum-Regular.ttf?v=5) format("truetype"); font-display: swap; }
@font-face { font-family: "Cormorant"; src: url(fonts/CormorantItalic.woff?v=5) format("woff"), url(fonts/CormorantItalic.ttf?v=5) format("truetype"); font-display: swap; }
@font-face { font-family: "Manrope"; src: url(fonts/Manrope.woff?v=5) format("woff"), url(fonts/Manrope.ttf?v=5) format("truetype"); font-weight: 200 800; font-display: swap; }

/* темы: КОД (день 06–18) · МЕЛАТОНИН (вечер 18–23) · ГЛУБОКИЙ СОН (ночь 23–06) */
:root, [data-theme="kod"] {
  --bg: #0B0B0C; --grid: rgba(255,255,255,0.035); --glow: rgba(227,30,36,0.22);
  --text: #FFFFFF; --sub: rgba(255,255,255,0.7); --surface: #151518; --bubble: #1C1C20;
  --acc: #E31E24; --acc-text: #FFFFFF; --acc-glow: rgba(227,30,36,0.55);
  --dot: #FFFFFF; --dot-lit: #E31E24;
  --poster: #E31E24; --poster-text: #0B0B0C; --poster-kick: #FFFFFF;
  --sticker: #FFFFFF; --sticker-text: #0B0B0C; --sticker-shadow: rgba(0,0,0,0.9);
}
[data-theme="melatonin"] {
  --bg: #140D0A; --grid: rgba(255,190,120,0.035); --glow: rgba(240,145,62,0);
  --text: #F6E7D4; --sub: rgba(246,231,212,0.72); --surface: #22170F; --bubble: #22170F;
  --acc: #F0913E; --acc-text: #140D0A; --acc-glow: rgba(240,145,62,0.45);
  --dot: #D9B48C; --dot-lit: #F0913E;
  --poster: linear-gradient(100deg, #4A1E2E 0%, #B5482B 45%, #F0913E 80%, #F7C26B 100%); --poster-text: #140D0A; --poster-kick: #F6E7D4;
  --sticker: #F6E7D4; --sticker-text: #140D0A; --sticker-shadow: rgba(181,72,43,0.95);
}
[data-theme="night"] {
  --bg: #050202; --grid: rgba(255,80,60,0.025); --glow: rgba(150,20,20,0.18);
  --text: #EBCFC9; --sub: rgba(235,207,201,0.74); --surface: #180A0A; --bubble: #1C0B0B;
  --acc: #9E1A1F; --acc-text: #F2D6D0; --acc-glow: rgba(158,26,31,0.45);
  --dot: #86554F; --dot-lit: #D23B37;
  --poster: #3A1012; --poster-text: #EBCFC9; --poster-kick: #E0605A;
  --sticker: #3A1012; --sticker-text: #EBCFC9; --sticker-shadow: rgba(0,0,0,1);
}

[hidden] { display: none !important; }
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: "Manrope", system-ui, sans-serif; overflow: hidden; }
body { display: flex; flex-direction: column; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input { font: inherit; }

#bg, #bg > div { position: fixed; inset: 0; pointer-events: none; }
#bg .grid { background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 26px 26px; }
#bg .glow { background: radial-gradient(circle at 50% 30%, var(--glow), transparent 60%); }
[data-theme="melatonin"] #bg .fx { background:
  radial-gradient(circle at 50% 33%, rgba(247,194,107,0.30) 0%, rgba(240,145,62,0.14) 22%, transparent 42%),
  linear-gradient(180deg, #1A0F18 0%, rgba(20,13,10,0) 45%, rgba(58,26,16,0.85) 100%); }
[data-theme="night"] #bg .fx { background: radial-gradient(circle at 85% 4%, rgba(235,207,201,0.10), transparent 12%); }

#top { position: relative; z-index: 3; height: 44px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand { display: flex; align-items: baseline; gap: 6px; }
.brand b { font-family: "Unbounded"; font-size: 12px; font-weight: 800; }
.brand i { color: var(--acc); font-style: normal; font-weight: 800; font-size: 12px; }
.brand em { font-family: "Oranienbaum"; font-style: normal; font-size: 18px; color: var(--acc); }

#screen { position: relative; z-index: 2; flex: 1; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; padding-bottom: 12px; }
.view { display: flex; flex-direction: column; flex: 1; min-height: 100%; animation: in .35s ease; }
@keyframes in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.grow { flex: 1; }

#tabs { position: relative; z-index: 3; height: 64px; display: flex; justify-content: space-around; align-items: center; border-top: 1px solid var(--surface); background: var(--bg); flex-shrink: 0; padding-bottom: env(safe-area-inset-bottom); }
#tabs button { display: flex; flex-direction: column; align-items: center; font-size: 12px; font-weight: 800; color: var(--sub); }
#tabs button span { font-size: 20px; }
#tabs button.on { color: var(--acc); }

/* общие элементы */
.lenya { display: flex; gap: 10px; align-items: flex-end; padding: 10px 18px 0; }
.lenya img { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; border: 2px solid var(--acc); flex-shrink: 0; }
.lenya div { background: var(--bubble); border-radius: 16px 16px 16px 4px; padding: 9px 13px; font-size: 14px; line-height: 1.35; }
.kick { font-family: "Cormorant"; font-style: italic; font-size: 28px; color: var(--sub); transform: rotate(-3deg); transform-origin: left; }
.big { font-family: "Oranienbaum"; color: var(--acc); line-height: .95; font-size: 60px; transform: scaleX(.78); transform-origin: left; white-space: nowrap; text-shadow: 0 0 24px var(--acc-glow); }
.sticker { display: inline-block; background: var(--sticker); color: var(--sticker-text); font-family: "Unbounded"; font-weight: 800; font-size: 13px; padding: 7px 12px; transform: rotate(-3deg); box-shadow: 4px 4px 0 var(--sticker-shadow); white-space: nowrap; }
.sticker.hot { background: var(--acc); color: var(--acc-text); }
.cta { margin: 0 18px 10px; height: 58px; border-radius: 16px; background: var(--acc); color: var(--acc-text); display: flex; align-items: center; justify-content: center;
  font-family: "Unbounded"; font-weight: 800; font-size: 16px; letter-spacing: 1px; box-shadow: 0 0 30px var(--acc-glow); width: calc(100% - 36px); flex-shrink: 0; transition: transform .1s; }
.cta:active { transform: scale(.97); }
.cta[disabled] { opacity: .5; }
.ghost { margin: 0 18px 12px; height: 50px; border-radius: 16px; border: 2px solid var(--surface); font-weight: 800; font-size: 15px; width: calc(100% - 36px); flex-shrink: 0; }
.link { text-align: center; font-size: 14px; color: var(--sub); font-weight: 700; padding: 6px; }
.p { font-size: 15px; line-height: 1.45; color: var(--sub); }
.pad { padding: 0 20px; }
.brainbox { position: relative; display: flex; justify-content: center; }
.brainbox canvas { display: block; }
.brainbox .sticker { position: absolute; }

/* онбординг */
.dots { display: flex; justify-content: center; gap: 8px; margin: 10px 0 14px; }
.dots i { width: 8px; height: 8px; border-radius: 4px; background: var(--surface); transition: width .3s; }
.dots i.on { width: 26px; background: var(--acc); }
.skip { position: absolute; top: 4px; right: 18px; font-size: 13px; color: var(--sub); z-index: 5; }
.pieces { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; padding: 0 20px; }
.posterbox { background: var(--poster); color: var(--poster-text); font-family: "Unbounded"; font-weight: 900; font-size: 40px; padding: 14px 26px; transform: rotate(-2deg); box-shadow: 6px 6px 0 var(--sticker-shadow); }

/* главный: мозг = меню */
.zone-tag { position: absolute; width: max-content; z-index: 1; }
.zone-tag .sticker { font-size: 11px; padding: 5px 8px; }
.zone-tag small { display: block; font-family: "Cormorant"; font-style: italic; font-size: 14px; color: var(--sub); margin-top: 4px; }
.zone-tag.soon .sticker { opacity: .75; transform: rotate(2deg); }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px 18px 0; }
.card { background: var(--surface); border-radius: 14px; padding: 12px; border: 2px solid transparent; text-align: left; }
.card.ready { border-color: var(--acc); }
.card.soon { opacity: .6; }
.card b { display: block; font-family: "Unbounded"; font-weight: 800; font-size: 12px; }
.card span { display: block; font-size: 11px; color: var(--sub); margin-top: 3px; }

/* ввод */
.field { margin: 18px 20px 0; background: var(--sticker); color: var(--sticker-text); box-shadow: 6px 6px 0 var(--acc); }
.field input { width: 100%; border: none; outline: none; background: transparent; color: inherit; padding: 16px; font-size: 18px; font-weight: 700; }
.field input::placeholder { color: inherit; opacity: .45; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; padding: 16px 20px 0; align-items: center; }
.chips em { font-family: "Cormorant"; font-size: 17px; color: var(--sub); }
.chips button { border: 1.5px solid var(--sub); border-radius: 20px; padding: 5px 12px; font-size: 13px; font-weight: 700; }
.meta { text-align: center; font-size: 13px; color: var(--sub); margin-bottom: 10px; }

/* шаги */
.head { background: var(--poster); padding: 16px 20px 26px; clip-path: polygon(0 0, 100% 0, 100% 86%, 0 100%); }
.head .kick { color: var(--poster-kick); font-size: 26px; }
.head h1 { font-family: "Unbounded"; font-weight: 900; font-size: 40px; color: var(--poster-text); letter-spacing: -2px; line-height: 1; word-break: break-word; }
.head .sticker { margin-top: 10px; transform: rotate(2deg); }
.why { margin: 6px 18px 10px; border-left: 3px solid var(--acc); padding: 4px 12px; }
.why b { display: block; font-family: "Cormorant"; font-style: italic; font-weight: 400; font-size: 20px; color: var(--acc); }
.why p { font-size: 13px; line-height: 1.45; color: var(--sub); }
.step { margin: 0 18px 8px; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 2px solid transparent; text-align: left; width: calc(100% - 36px); }
.step .n { font-family: "Oranienbaum"; font-size: 34px; color: var(--acc); width: 40px; flex-shrink: 0; }
.step .t { font-size: 15px; flex: 1; }
.step.done { opacity: .5; }
.step.done .n { color: var(--sub); }
.step.done .t { text-decoration: line-through; }
.step.next { border-color: var(--acc); box-shadow: 0 0 22px var(--acc-glow); }
.step .sticker { font-size: 11px; padding: 5px 8px; transform: rotate(3deg); }

/* таймер */
.ring { position: relative; width: 300px; height: 300px; margin: 6px auto 0; }
.ring svg { position: absolute; inset: 0; }
.ring .t { position: absolute; left: 0; right: 0; top: 175px; text-align: center; font-family: "Unbounded"; font-weight: 800; font-size: 58px; }
.ring canvas { position: absolute; left: 50px; top: 52px; }  /* мозг внутри круга, не задевает обводку */
.step.paused { cursor: pointer; }
.step.paused small { display: block; font-size: 12px; color: var(--sub); margin-top: 3px; }

/* прогресс */
.nums { display: flex; justify-content: space-around; padding: 0 10px; }
.nums div { text-align: center; }
.nums .big { font-size: 60px; transform: scaleX(.8); transform-origin: center; }
.nums small { font-size: 13px; color: var(--sub); }
.bars { display: flex; align-items: flex-end; gap: 9px; justify-content: center; height: 76px; margin-top: 14px; }
.bars div { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: var(--sub); }
.bars i { width: 26px; background: var(--surface); display: block; }
.bars i.on { background: var(--acc); }

/* стиль */
.auto { margin: 6px 18px 10px; border-radius: 16px; padding: 14px 16px; background: var(--surface); border: 3px solid transparent; text-align: left; width: calc(100% - 36px); }
.auto.on { border-color: var(--acc); }
.auto .row { display: flex; justify-content: space-between; align-items: center; }
.auto b { font-family: "Unbounded"; font-weight: 800; font-size: 16px; }
.auto em { font-family: "Cormorant"; font-size: 16px; color: var(--sub); }
/* переключатель напоминаний */
.rem { margin-top: 14px; }
.rem em { flex: 1; text-align: right; margin-right: 12px; }
.sw-tg { width: 46px; height: 26px; border-radius: 13px; background: var(--bubble); position: relative; flex-shrink: 0; transition: background .2s; }
.sw-tg i { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--sub); transition: transform .2s, background .2s; }
.sw-tg.on { background: var(--acc); }
.sw-tg.on i { transform: translateX(20px); background: var(--acc-text); }
.line { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin-top: 12px; }
.ticks { display: flex; justify-content: space-between; font-size: 11px; color: var(--sub); margin-top: 6px; }
.th { margin: 8px 18px; border-radius: 16px; overflow: hidden; display: flex; align-items: center; min-height: 92px; cursor: pointer; border: 3px solid transparent; box-shadow: 0 6px 16px rgba(0,0,0,.2); width: calc(100% - 36px); text-align: left; }
.th.on { border-color: var(--acc); }
.th .sw { width: 84px; align-self: stretch; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.th .sw i { width: 50px; height: 50px; border-radius: 50%; display: block; }
.th .tx { flex: 1; padding: 14px 14px 14px 4px; display: flex; flex-direction: column; justify-content: center; }
.th .tx b { font-family: "Unbounded"; font-weight: 800; font-size: 17px; }
.th .tx em { font-family: "Cormorant"; font-size: 16px; }
.th .now { font-family: "Unbounded"; font-style: normal; font-size: 10px; padding: 2px 6px; margin-right: 6px; }

/* подписка */
.gate-ava { width: 110px; height: 110px; border-radius: 50%; object-fit: cover; border: 4px solid var(--acc); box-shadow: 0 0 30px var(--acc-glow); }

#burn { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#toast { position: fixed; left: 18px; right: 18px; bottom: 90px; z-index: 20; background: var(--sticker); color: var(--sticker-text); padding: 14px 16px; font-weight: 700; font-size: 14px; box-shadow: 4px 4px 0 var(--acc); transform: rotate(-1deg); }
.spin { width: 46px; height: 46px; border: 4px solid var(--surface); border-top-color: var(--acc); border-radius: 50%; animation: sp 0.8s linear infinite; margin: 20px auto; }
@keyframes sp { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) { .view { animation: none; } }
.th .tx em b.now { font-size: 10px; }

/* ввод: пока открыта клавиатура — только заголовок, поле и кнопка */
.view.typing .brainbox, .view.typing .lenya, .view.typing .kick, .view.typing .meta { display: none; }
.view.typing .big { font-size: 40px; margin-top: 8px; }
.view.typing .field { margin-top: 12px; }
.zone-tag, .auto { cursor: pointer; }
.zone-tag .sticker { font-size: 10px; padding: 5px 8px; }