:root {
  --bg: #f6f5f2; --card: #ffffff; --ink: #1c1d22; --muted: #6b6f7a; --line: #e6e3dc;
  --accent: #4f46e5; --accent-ink: #fff; --ok: #16a34a; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --r: 16px; --nav: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14151a; --card: #1e2027; --ink: #ececf1; --muted: #9a9eab; --line: #2c2f38; --accent: #818cf8; --accent-ink: #14151a; --shadow: none; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
#view { max-width: 680px; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) 16px calc(var(--nav) + 32px + env(safe-area-inset-bottom)); }

/* Шапка */
.top { display: flex; align-items: flex-start; gap: 10px; margin: 8px 0 16px; }
.top-t { flex: 1; min-width: 0; }
.top h1 { font-size: 1.45rem; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
.top p { margin: 4px 0 0; color: var(--muted); font-size: .88rem; }
.gear, .back { text-decoration: none; color: var(--muted); font-size: 1.4rem; line-height: 1; padding: 6px; border-radius: 10px; }
.back { font-size: 2rem; margin: -6px 0 0 -8px; }

/* Герой */
.hero { display: flex; gap: 16px; align-items: center; background: var(--card); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 14px; border: 1px solid var(--line); }
.ring { --p: 0; flex: none; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--line) 0); }
.ring span { width: 52px; height: 52px; border-radius: 50%; background: var(--card); display: grid; place-items: center; font-weight: 700; font-size: 1.1rem; }
.ring small { font-size: .7rem; color: var(--muted); font-weight: 500; }
.ring span { display: flex; align-items: baseline; justify-content: center; }
.hero-t { font-size: .92rem; }
.budget b { color: var(--ink); }
.meta { color: var(--muted); margin-top: 4px; font-size: .86rem; }
.dot { color: var(--muted); margin: 0 2px; }

/* Задачи */
.task, .card, .bridge, .jentry, .debts { background: var(--card); border-radius: var(--r); padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.task { border-left: 4px solid var(--c, var(--line)); }
.task-h { display: flex; align-items: flex-start; gap: 10px; }
.task-h > div { flex: 1; min-width: 0; }
.task h3 { margin: 0 0 4px; font-size: 1rem; }
.task h3 small { color: var(--muted); font-weight: 400; font-size: .8rem; margin-left: 4px; }
.ico { font-size: 1.3rem; line-height: 1.3; }
.task-main { margin: 10px 0 6px; }
.tip { margin: 0 0 8px; color: var(--muted); font-size: .88rem; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.center { text-align: center; }
.opt { font-size: .72rem; padding: 1px 7px; border-radius: 99px; background: var(--line); color: var(--muted); vertical-align: middle; white-space: nowrap; }
.chip { display: inline-block; font-size: .75rem; padding: 2px 9px; border-radius: 99px; color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); font-weight: 600; white-space: nowrap; }
.check { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); background: transparent; color: #fff; font-size: 1rem; font-weight: 700; cursor: pointer; transition: .15s; }
.check.on { background: var(--ok); border-color: var(--ok); }
details { margin: 4px 0 10px; }
summary { cursor: pointer; color: var(--accent); font-size: .92rem; }
details ul { padding-left: 20px; margin: 8px 0; }
details li { margin-bottom: 4px; }
.why { font-size: .9rem; background: color-mix(in srgb, var(--c, var(--accent)) 8%, transparent); padding: 8px 10px; border-radius: 10px; margin: 6px 0 10px; }
textarea, input[type=time] { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; resize: vertical; }
input[type=time] { width: auto; }
.bridge { background: color-mix(in srgb, var(--accent) 9%, var(--card)); }
.bridge h3 { margin: 0 0 6px; font-size: 1rem; }
.bridge p { margin: 0; }
.note-ok { color: var(--ok); font-weight: 600; margin: -6px 0 12px; }

/* Кнопки */
.btn { display: inline-block; text-align: center; text-decoration: none; font: inherit; font-weight: 600; font-size: .92rem; border: 0; border-radius: 12px; padding: 9px 16px; background: var(--accent); color: var(--accent-ink); cursor: pointer; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn.big { display: block; width: 100%; padding: 14px; font-size: 1.05rem; margin: 8px 0; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.finish { margin: 20px 0; text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Карточки */
.flash { background: var(--card); border-radius: 20px; padding: 22px 20px; min-height: 240px; box-shadow: var(--shadow); border: 1px solid var(--line); border-top: 5px solid var(--c); margin-bottom: 14px; }
.flash .q { font-size: 1.25rem; font-weight: 650; line-height: 1.35; margin: 16px 0; }
.flash .a { font-size: 1.02rem; border-top: 1px dashed var(--line); padding-top: 14px; animation: fade .2s; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.g { border: 0; border-radius: 12px; padding: 12px 4px; font: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; color: #fff; }
.g b { font-size: .9rem; } .g small { font-size: .72rem; opacity: .85; min-height: 1em; }
.g0 { background: #e11d48; } .g1 { background: #d97706; } .g2 { background: #16a34a; } .g3 { background: #2563eb; }

/* План */
.wk { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 8px; }
.days { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; }
.drow { display: flex; gap: 12px; align-items: center; padding: 11px 14px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); }
.drow:last-child { border-bottom: 0; }
.drow.cur { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.dn { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: .85rem; font-weight: 700; background: var(--bg); }
.drow.done .dn { background: var(--ok); color: #fff; }
.drow.cur .dn { background: var(--accent); color: var(--accent-ink); }
.dt { flex: 1; min-width: 0; font-size: .92rem; }
.dm { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.dots i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); margin-right: 3px; }
.debts h3 { margin: 0; } .debts h3 small { color: var(--muted); font-weight: 400; }
.debt { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: .92rem; }

/* Темы */
.topic { display: flex; gap: 14px; align-items: center; background: var(--card); border-radius: var(--r); padding: 14px 16px; margin-bottom: 10px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); border: 1px solid var(--line); border-left: 4px solid var(--c); }
.temoji { font-size: 1.8rem; }
.tt { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.bar { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; margin: 4px 0 2px; }
.bar i { display: block; height: 100%; background: var(--c); border-radius: 99px; }
.card { border-left: 4px solid var(--c, var(--line)); }
.card h3 { margin: 14px 0 6px; font-size: 1rem; } .card h3:first-child { margin-top: 0; }
.card p { margin: 0 0 8px; }
.promise { font-style: italic; font-size: 1.05rem; }
.src { padding-left: 18px; margin: 0; } .src li { margin-bottom: 8px; }
.danger h3 { color: #e11d48; }
.method { padding-left: 18px; margin: 6px 0 12px; font-size: .92rem; } .method li { margin-bottom: 8px; }

/* Галерея */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.gitem { background: var(--card); border-radius: 14px; padding: 12px; border: 1px solid var(--line); font-size: .9rem; --c: #ef4444; }
.gitem[open] { grid-column: 1 / -1; }
.gitem summary { color: var(--ink); list-style: none; }
.gitem summary::-webkit-details-marker { display: none; }
.gitem.locked { text-align: center; opacity: .5; }

/* Журнал */
.jq { font-weight: 600; margin: 6px 0; }
.jentry p { margin: 6px 0 0; }

/* Экраны-заставки */
.done-screen, .intro { text-align: center; padding: 24px 4px; }
.big-emoji { font-size: 3.5rem; }
.done-screen h2 { margin: 8px 0; }
.intro h1 { font-size: 2rem; margin: 8px 0; letter-spacing: -.02em; }
.lead { font-size: 1.08rem; color: var(--muted); }
.tgrid { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 16px 0; }
.intro .method, .intro h3, .done-screen .next, .done-screen h3 { text-align: left; }
.budget-card, .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0; }
.budget-card div, .stats div { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 6px; display: flex; flex-direction: column; }
.budget-card b, .stats b { font-size: 1.2rem; }
.budget-card span, .stats span { font-size: .78rem; color: var(--muted); }

/* Навигация */
#nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
#nav[hidden] { display: none; }
#nav a { flex: 1; max-width: 136px; height: var(--nav); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: .7rem; font-weight: 600; }
#nav a span { font-size: 1.3rem; position: relative; filter: grayscale(1); opacity: .7; }
#nav a.on { color: var(--accent); }
#nav a.on span { filter: none; opacity: 1; }
#badge { position: absolute; top: -4px; right: -12px; background: #e11d48; color: #fff; font-size: .62rem; min-width: 18px; height: 18px; border-radius: 99px; display: grid; place-items: center; padding: 0 4px; font-style: normal; }
#badge[hidden] { display: none; }
