:root {
  color-scheme: dark;
  --ground: #06080d;
  --card: #0f1420;
  --ink: #dde3ef;
  --head: #eef2fa;
  --on-ink: #0a0c11;
  --muted: #8d97ab;
  --line: #1f2840;
  --bline: #27324d;
  --field: #34405e;
  --input: #0a0e17;
  --blue: #4f7df5;
  --accent: #8fb0ff;
  --pearl: linear-gradient(180deg, #5b8cff 0%, #3d6bf0 100%);
  --pearl-soft: linear-gradient(115deg, rgba(120,150,230,.12), rgba(120,150,230,.04));
  --sheen: inset 0 1px 0 rgba(160,185,255,.07);
  --on-accent: #ffffff;
  --seg-off: #1c2438;
  --tile: #151c2c;
  --warn-bg: #1d1709;
  --warn-ink: #ffcf7a;
  --bad-bg: #2a1816;
  --bad-ink: #eaa59d;
  --ok-bg: #12261b;
  --ok-ink: #8fe0a8;
  --danger: #f0a198;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--ground); }
html {
  background:
    radial-gradient(520px 380px at 92% -2%, rgba(80,115,190,.20), transparent 70%),
    radial-gradient(1px 1px at 40px 110px, rgba(220,228,240,.5), transparent),
    radial-gradient(1px 1px at 330px 300px, rgba(220,228,240,.4), transparent),
    var(--ground);
  background-attachment: fixed;
}
body { background: transparent; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* Фоновая сетка: тонкие линии, затухают книзу, медленно «дрейфуют» */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(120,150,215,.075) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120,150,215,.075) 1px, transparent 1px);
  background-size: 36px 36px;
  -webkit-mask-image: radial-gradient(ellipse 130% 75% at 50% 0%, #000 25%, transparent 78%);
  mask-image: radial-gradient(ellipse 130% 75% at 50% 0%, #000 25%, transparent 78%);
  animation: grid-drift 60s linear infinite;
}
@keyframes grid-drift { to { background-position: 36px 36px, 36px 36px; } }

.screen { position: relative; z-index: 1; min-height: 100dvh; display: flex; flex-direction: column; }
.content {
  flex: 1;
  padding: 32px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}
.center { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px 24px; text-align: center; color: var(--muted); font-size: 16px; line-height: 22px; }

h1 { margin: 0; font-size: 26px; line-height: 32px; font-weight: 700; font-weight: 400; letter-spacing: -.01em; background: linear-gradient(180deg, #f2f4f8 0%, #aeb5c2 55%, #d5d9e1 100%); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; width: fit-content; max-width: 100%; }
.sub { font-size: 15px; line-height: 22px; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 4px; }
.list { display: flex; flex-direction: column; gap: 16px; }
.eyebrow { font-size: 13px; line-height: 18px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }

.card { background: linear-gradient(165deg, #121a2b, #0a0e17); box-shadow: var(--sheen), 0 0 0 1px rgba(255,255,255,.03); border-radius: 20px; padding: 20px; display: flex; flex-direction: column; gap: 20px; border: 1px solid var(--bline); }
.card.tight { padding: 18px 20px; gap: 8px; }
.card.warn { background: linear-gradient(160deg, #221a0a, #130f06); border-color: rgba(255,176,40,.32); gap: 14px; }
.card.warn .eyebrow { color: var(--warn-ink); }
.card.selected { outline: 2px solid var(--accent); }

.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.row.top { align-items: flex-start; }
.grow { flex-grow: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }

.thumb { width: 56px; height: 56px; border-radius: 14px; border: 1px solid var(--bline); background: var(--tile); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--muted); }
.title { color: var(--head); font-size: 17px; line-height: 22px; font-weight: 600; overflow-wrap: anywhere; }
.meta { font-size: 14px; line-height: 20px; color: var(--muted); overflow-wrap: anywhere; }
.status { font-size: 16px; line-height: 22px; font-weight: 600; }
.small { font-size: 13px; line-height: 18px; color: var(--muted); }

.segs { display: flex; gap: 4px; }
.seg { flex-grow: 1; height: 6px; border-radius: 3px; background: var(--seg-off); }
.seg.done { background: #6d7586; }
.seg.now { background: linear-gradient(90deg, #aab3c5, #dfe4ee); box-shadow: 0 0 10px rgba(190,200,225,.3); }
.footline { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding-top: 16px; }

.badge { font-size: 13px; line-height: 18px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.badge.bad { background: var(--bad-bg); color: var(--bad-ink); }
.badge.ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge.dark { background: rgba(79,125,245,.16); color: #a9c4ff; border: 1px solid rgba(79,125,245,.4); }
.badge.plain { background: var(--tile); color: var(--ink); }

.btn { min-height: 48px; padding: 0 16px; border-radius: 12px; border: 1px solid transparent; font-size: 16px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; text-align: center; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--pearl); color: var(--on-accent); box-shadow: inset 0 1px 0 rgba(255,255,255,.28), 0 0 0 1px rgba(110,150,255,.35), 0 8px 28px rgba(60,105,245,.5); min-height: 52px; font-size: 17px; border-radius: 14px; }
.btn.dark { background: var(--pearl); color: var(--on-accent); box-shadow: inset 0 1px 0 rgba(255,255,255,.28), 0 0 0 1px rgba(110,150,255,.35), 0 8px 24px rgba(60,105,245,.4); }
.btn.outline { background: transparent; border-color: #3a4a70; color: var(--ink); }
.btn.text { background: transparent; color: var(--accent); min-height: 44px; font-weight: 500; font-size: 15px; }
.btn.danger { background: transparent; color: var(--danger); min-height: 44px; font-weight: 500; font-size: 15px; }
.btn.small-btn { min-height: 44px; font-size: 15px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .lbl { font-size: 14px; line-height: 20px; font-weight: 500; }
.input, .select {
  width: 100%; min-height: 48px; border: 1px solid var(--field); border-radius: 12px; background: var(--input); padding: 0 14px; font-size: 16px;
}
.input:focus, .select:focus, .btn:focus-visible, .chip:focus-visible, .switch:focus-visible, .tab:focus-visible, .card.click:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.hint { font-size: 13px; line-height: 18px; color: var(--muted); }
.err { font-size: 14px; line-height: 20px; color: var(--danger); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 14px; border-radius: 22px; border: 1px solid var(--field); background: var(--tile); font-size: 15px; font-weight: 600; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 0 16px rgba(79,125,245,.35); }
.chips.fill .chip { flex-grow: 1; border-radius: 12px; min-height: 48px; }

.check { display: flex; gap: 12px; align-items: flex-start; }
.check input { width: 24px; height: 24px; margin: 0; flex-shrink: 0; accent-color: var(--accent); }
.check label { font-size: 14px; line-height: 20px; color: var(--muted); }

.switch { width: 52px; height: 32px; border: 0; border-radius: 16px; background: var(--field); position: relative; flex-shrink: 0; cursor: pointer; padding: 0; transition: background .15s; }
.switch[aria-checked="true"] { background: var(--blue); }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

.tiles { display: flex; gap: 8px; }
.tile { flex: 1; background: linear-gradient(165deg, #121a2b, #0a0e17); box-shadow: var(--sheen); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 2px; border: 0; text-align: left; cursor: pointer; }
.tile[aria-pressed="true"] { outline: 2px solid var(--accent); }
.tile .n { font-size: 26px; line-height: 32px; font-weight: 700; }

.kv { background: linear-gradient(165deg, #121a2b, #0a0e17); box-shadow: var(--sheen); border-radius: 16px; padding: 4px 16px; }
.kv > div { padding: 12px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.kv > div:last-child { border-bottom: 0; }
.kv .v { font-size: 16px; line-height: 22px; overflow-wrap: anywhere; }

.result { background: var(--tile); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.result .t { font-size: 13px; line-height: 18px; font-weight: 600; color: var(--muted); }
.result .m { font-size: 15px; line-height: 22px; }

.empty { align-items: center; text-align: center; padding: 28px 20px; gap: 12px; }
.empty .big { width: 96px; height: 96px; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.empty .btns { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: 8px; }

.step { display: flex; gap: 12px; align-items: center; font-size: 16px; line-height: 22px; }
.step .n { width: 32px; height: 32px; border-radius: 50%; background: rgba(79,125,245,.18); color: #a9c4ff; border: 1px solid rgba(79,125,245,.4); display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; flex-shrink: 0; }

.tabbar {
  position: sticky; bottom: 0; display: flex; gap: 8px; background: rgba(8,11,18,.9); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-top: 1px solid var(--bline);
  padding: 6px 16px calc(14px + env(safe-area-inset-bottom));
  justify-content: center;
}
.tab { flex: 1; max-width: 200px; min-height: 56px; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); font-size: 13px; line-height: 16px; font-weight: 500; cursor: pointer; }
.tab[aria-current="page"] { color: var(--accent); font-weight: 600; }

.toast { position: fixed; left: 16px; right: 16px; bottom: 96px; max-width: 520px; margin: 0 auto; background: #17203a; color: var(--head); border: 1px solid #2f4170; padding: 12px 16px; border-radius: 12px; font-size: 15px; line-height: 22px; z-index: 10; }

.search { position: relative; }

svg { display: block; flex-shrink: 0; }

/* Экран загрузки */
.splash { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; }
.splash-mark { filter: drop-shadow(0 0 22px rgba(170,185,215,.28)); animation: splash-pulse 2.6s ease-in-out infinite; }
.splash-ring { transform-origin: 60px 60px; animation: splash-spin 1.9s linear infinite; }
.splash-title {
  font-size: 15px; line-height: 20px; font-weight: 600; letter-spacing: .32em; text-transform: uppercase;
  background: linear-gradient(100deg, #6d7586 0%, #6d7586 35%, #eceff4 50%, #6d7586 65%, #6d7586 100%);
  background-size: 250% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
  animation: splash-shine 2.4s ease-in-out infinite;
}
.splash-dots { display: flex; gap: 8px; }
.splash-dots i { width: 6px; height: 6px; border-radius: 50%; background: #8a91a0; opacity: .25; animation: splash-dot 1.2s ease-in-out infinite; }
.splash-dots i:nth-child(2) { animation-delay: .18s; }
.splash-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes splash-spin { to { transform: rotate(360deg); } }
@keyframes splash-pulse { 0%, 100% { opacity: .85; } 50% { opacity: 1; } }
@keyframes splash-shine { 0% { background-position: 130% 0; } 100% { background-position: -30% 0; } }
@keyframes splash-dot { 0%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) {
  body::before, .splash-mark, .splash-ring, .splash-title, .splash-dots i { animation: none; }
  .splash-ring { stroke-dasharray: 220 94; }
  .splash-dots i { opacity: .7; }
}

/* Статусы-индикаторы */
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 5px 13px 5px 10px; border-radius: 999px; font-size: 14px; line-height: 20px; font-weight: 600; border: 1px solid transparent; width: fit-content; }
.pill i { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.pill.wait { color: #aab3c6; background: rgba(150,162,190,.09); border-color: rgba(150,162,190,.26); }
.pill.wait i { background: #8d97ab; }
.pill.transit { color: #aac6ff; background: rgba(79,125,245,.14); border-color: rgba(79,125,245,.42); }
.pill.transit i { background: #5b8cff; box-shadow: 0 0 10px rgba(91,140,255,.9); }
.pill.action { color: #ffd27f; background: rgba(255,176,40,.12); border-color: rgba(255,176,40,.42); }
.pill.action i { background: #ffb028; box-shadow: 0 0 10px rgba(255,176,40,.8); }
.pill.done { color: #93e4ac; background: rgba(60,200,110,.12); border-color: rgba(60,200,110,.4); }
.pill.done i { background: #3ccf6e; box-shadow: 0 0 10px rgba(60,207,110,.7); }

/* Шкала этапов */
.stepper { display: flex; align-items: center; padding: 6px 2px; }
.stepper .node { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; box-sizing: border-box; }
.stepper .node.done { background: #4a5f94; }
.stepper .node.todo { background: var(--ground); border: 2px solid #2b3858; }
.stepper .node.now { width: 18px; height: 18px; background: #5b8cff; border: 3px solid #0f1420; box-shadow: 0 0 0 2px #5b8cff, 0 0 18px rgba(91,140,255,.85); }
.stepper .link { flex: 1; height: 2px; background: #1f2a44; }
.stepper .link.done { background: linear-gradient(90deg, #4a5f94, #5b8cff); }
.stepper.finished .node.done { background: #3ccf6e; }
.stepper.finished .link.done { background: #2a8f53; }

/* Грустное лицо */
.sad-face { transform-origin: 50px 50px; animation: sad-bob 3.6s ease-in-out infinite; }
.sad-eyes { transform-origin: 50px 46px; animation: sad-blink 4.4s infinite; }
.sad-tear { animation: sad-tear 2.8s ease-in infinite; }
@keyframes sad-bob { 0%, 100% { transform: translateY(0) rotate(-1.5deg); } 50% { transform: translateY(3px) rotate(1.5deg); } }
@keyframes sad-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes sad-tear { 0% { transform: translateY(-4px); opacity: 0; } 15% { opacity: 1; } 80% { transform: translateY(20px); opacity: .9; } 100% { transform: translateY(26px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sad-face, .sad-eyes, .sad-tear { animation: none; } }
.meta.due { color: #ffd27f; font-weight: 600; }
