:root {
  --bg: #0b0b0d;
  --panel: #151519;
  --panel-2: #1d1d23;
  --panel-3: #26262e;
  --line: #2b2b33;
  --text: #f5f5f6;
  --muted: #9b9ba6;
  --faint: #6c6c77;
  --yellow: #ffd400;
  --yellow-ink: #141100;
  --red: #ff5a47;
  --green: #3ddc84;
  --blue: #5aa9ff;
  --orange: #ffa133;
  --radius: 16px;
  --tabh: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg .fill { fill: currentColor; stroke: none; }

/* ---------- layout */
#app { min-height: 100vh; min-height: 100dvh; }
main {
  padding: calc(var(--safe-t) + 14px) 16px calc(var(--tabh) + var(--safe-b) + 24px);
  max-width: 720px; margin: 0 auto; outline: none;
}
.tabs {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
  height: calc(var(--tabh) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; background: rgba(16, 16, 19, .92); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}
.tabs .brand { display: none; }
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--faint); font-size: 11px; font-weight: 600; position: relative;
}
.tabs a.on { color: var(--yellow); }
.tabs a .dot {
  position: absolute; top: 8px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: 10.5px; line-height: 17px; text-align: center;
}

@media (min-width: 820px) {
  main { margin-left: 240px; max-width: 1080px; padding: 28px 36px 48px; }
  .tabs {
    top: 0; right: auto; width: 240px; height: auto; flex-direction: column; justify-content: flex-start;
    padding: 22px 14px; gap: 4px; border-top: 0; border-right: 1px solid var(--line); background: #0f0f12;
  }
  .tabs .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; }
  .tabs .brand img { border-radius: 9px; }
  .tabs .brand b { display: block; font-size: 15px; letter-spacing: .04em; }
  .tabs .brand span { display: block; font-size: 12px; color: var(--muted); }
  .tabs a { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 11px 12px; border-radius: 11px; font-size: 15px; }
  .tabs a.on { background: var(--panel-2); }
  .tabs a .dot { position: static; margin-left: auto; }
  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; margin-top: 26px; }
  .grid-2 > section { margin-top: 0; }
  .detail .grid-2 { margin-top: 0; }
}

/* ---------- headings */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 16px; }
.top h1 { margin: 0; font-size: 30px; line-height: 1.1; letter-spacing: -.02em; }
.top .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.kicker { font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--yellow); }
section { margin-top: 26px; }
section > h2 { font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
section > h2 .count { background: var(--panel-3); color: var(--text); border-radius: 10px; padding: 0 8px; font-size: 12px; letter-spacing: 0; }

/* ---------- cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 10px; }
.stack > * + * { margin-top: 10px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13.5px; }
.empty { color: var(--muted); text-align: center; padding: 26px 16px; border: 1px dashed var(--line); border-radius: var(--radius); font-size: 15px; }

.hazard {
  height: 6px; border-radius: 3px; margin: -2px 0 14px;
  background: repeating-linear-gradient(-45deg, var(--yellow) 0 10px, #111 10px 20px);
}
.status-card { position: relative; overflow: hidden; }
.status-card .state { display: flex; align-items: center; gap: 12px; }
.status-card .big { font-size: 21px; font-weight: 700; line-height: 1.2; }
.status-card .what { color: var(--muted); margin-top: 2px; }
.pulse { width: 12px; height: 12px; border-radius: 50%; background: var(--faint); flex: none; }
.pulse.working { background: var(--blue); box-shadow: 0 0 0 0 rgba(90,169,255,.6); animation: pulse 1.8s infinite; }
.pulse.paused { background: var(--orange); }
.pulse.idle { background: var(--green); }
@keyframes pulse { 70% { box-shadow: 0 0 0 12px rgba(90,169,255,0); } 100% { box-shadow: 0 0 0 0 rgba(90,169,255,0); } }
.progress { height: 4px; background: var(--panel-3); border-radius: 2px; overflow: hidden; margin-top: 14px; }
.progress i { display: block; height: 100%; width: 35%; background: var(--blue); border-radius: 2px; animation: slide 1.6s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; min-width: 0; text-decoration: none; display: block; }
.tile b { display: block; font-size: 24px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile span { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
.tile.alert b { color: var(--yellow); }

.banner { display: flex; gap: 12px; align-items: flex-start; border-radius: 14px; padding: 13px 14px; margin-top: 10px; font-size: 14.5px; }
.banner.red { background: rgba(255,90,71,.1); border: 1px solid rgba(255,90,71,.35); }
.banner.orange { background: rgba(255,161,51,.1); border: 1px solid rgba(255,161,51,.35); }
.banner.yellow { background: rgba(255,212,0,.08); border: 1px solid rgba(255,212,0,.3); }
.banner .grow { flex: 1; min-width: 0; }
.banner b { display: block; }
.banner .err { color: var(--muted); font-size: 13px; margin-top: 3px; word-break: break-word; }

/* ---------- short rows */
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; text-decoration: none; min-height: 72px;
}
.row + .row { margin-top: 8px; }
.row:active { background: var(--panel-2); }
.thumb {
  width: 46px; height: 64px; border-radius: 9px; flex: none; background: var(--panel-3) center/cover no-repeat;
  display: grid; place-items: center; color: var(--faint); font-weight: 800; font-size: 13px; overflow: hidden;
}
.row .info { flex: 1; min-width: 0; }
.row .title { font-weight: 650; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row .meta { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin-top: 5px; font-size: 12.5px; color: var(--muted); }
.row .chev { color: var(--faint); flex: none; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; white-space: nowrap; background: var(--panel-3); color: var(--muted); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.needs { background: rgba(255,212,0,.14); color: var(--yellow); }
.pill.working { background: rgba(90,169,255,.14); color: var(--blue); }
.pill.ready { background: rgba(61,220,132,.13); color: var(--green); }
.pill.posted { color: #8fd9ae; }
.pill.failed { background: rgba(255,90,71,.14); color: var(--red); }
.pill.queued, .pill.skipped { color: var(--muted); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 6px; margin: 0 -16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 7px 14px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
.chip.on { background: var(--yellow); border-color: var(--yellow); color: var(--yellow-ink); }

/* ---------- buttons */
.btn {
  appearance: none; border: 0; border-radius: 13px; padding: 13px 18px; min-height: 48px; font-weight: 700; font-size: 16px;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
  background: var(--panel-3); color: var(--text); transition: transform .08s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.primary { background: var(--yellow); color: var(--yellow-ink); }
.btn.go { background: var(--green); color: #04150b; }
.btn.danger { background: transparent; color: var(--red); box-shadow: inset 0 0 0 1.5px rgba(255,90,71,.45); }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.small { min-height: 38px; padding: 8px 13px; font-size: 14px; border-radius: 11px; }
.btn.block { width: 100%; }
.btn svg { width: 19px; height: 19px; }
.iconbtn { appearance: none; border: 0; background: var(--panel-2); width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; cursor: pointer; color: var(--text); flex: none; }
.iconbtn svg { width: 21px; height: 21px; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; }
.btnrow .btn { flex: 1 1 0; }
.spin { animation: rot 1s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- detail */
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-weight: 600; margin: 0 0 12px -4px; padding: 6px 4px; }
.back svg { width: 20px; height: 20px; }
.detail h1 { font-size: 26px; line-height: 1.2; margin: 8px 0 6px; letter-spacing: -.015em; }
.stepper { display: flex; gap: 4px; margin: 16px 0 4px; }
.stepper div { flex: 1; text-align: center; font-size: 11px; color: var(--faint); font-weight: 600; }
.stepper div::before { content: ""; display: block; height: 5px; border-radius: 3px; background: var(--panel-3); margin-bottom: 6px; }
.stepper .done { color: var(--muted); }
.stepper .done::before { background: #5a5a20; }
.stepper .cur { color: var(--yellow); }
.stepper .cur::before { background: var(--yellow); }
.stepper .cur.failed { color: var(--red); }
.stepper .cur.failed::before { background: var(--red); }
.stepper .cur.working::before { background: var(--blue); }
.stepper .cur.working { color: var(--blue); }

.player { margin-top: 16px; background: #000; border-radius: var(--radius); overflow: hidden; display: flex; justify-content: center; border: 1px solid var(--line); }
.player video, .player img { display: block; width: 100%; max-width: 380px; aspect-ratio: 9 / 16; object-fit: contain; background: #000; }
.voice { white-space: pre-wrap; font-size: 17px; line-height: 1.55; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 14.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.checks { display: grid; gap: 8px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14.5px; }
.check i { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 13px; font-weight: 800; flex: none; }
.check.met i { background: rgba(61,220,132,.16); color: var(--green); }
.check.missed i { background: rgba(255,90,71,.16); color: var(--red); }
.check.unchecked i { background: var(--panel-3); color: var(--muted); }
.copybox { background: var(--panel-2); border-radius: 12px; padding: 12px 12px 12px 14px; display: flex; gap: 10px; align-items: flex-start; }
.copybox + .copybox { margin-top: 8px; }
.copybox .lbl { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.copybox .txt { white-space: pre-wrap; word-break: break-word; margin-top: 2px; font-size: 15px; }
.copybox .grow { flex: 1; min-width: 0; }
.sources a { color: var(--blue); text-decoration: none; display: block; font-size: 14px; padding: 3px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actionbar {
  position: sticky; bottom: calc(var(--tabh) + var(--safe-b) + 10px); z-index: 5; margin-top: 18px;
  background: rgba(21,21,25,.94); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line); border-radius: 18px; padding: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.actionbar .hint { font-size: 13px; color: var(--muted); padding: 2px 4px 8px; }
@media (min-width: 820px) { .actionbar { bottom: 16px; } }

/* ---------- ideas */
.idea { cursor: pointer; display: flex; gap: 12px; align-items: flex-start; transition: border-color .15s, background .15s; }
.idea.on { border-color: var(--yellow); background: #1c1a0c; }
.idea .num { width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 800; font-size: 14px; background: var(--panel-3); color: var(--muted); }
.idea.on .num { background: var(--yellow); color: var(--yellow-ink); }
.idea .q { font-weight: 700; line-height: 1.3; }
.idea .facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.tag { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 7px; background: var(--panel-3); color: var(--muted); }
.tag.score { color: var(--text); }
.tag.hot { color: var(--orange); background: rgba(255,161,51,.12); }
.tag.win { color: var(--green); background: rgba(61,220,132,.12); }
.idea .core { color: var(--muted); font-size: 14px; margin-top: 7px; }
.idea .follow { color: var(--green); font-size: 13.5px; margin-top: 6px; }
.closed .idea { cursor: default; }

/* ---------- stats */
.tablewrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { border-collapse: collapse; font-size: 14px; min-width: 100%; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
td:first-child { min-width: 180px; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.statcards { display: grid; gap: 10px; }
.statcard .head { font-weight: 700; line-height: 1.3; }
.statcard .nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.statcard .nums b { display: block; font-size: 19px; font-variant-numeric: tabular-nums; }
.statcard .nums span { font-size: 11.5px; color: var(--muted); }
.statcard .verdict { margin-top: 10px; font-size: 14px; color: var(--muted); }
.statcard .verdict strong { color: var(--green); }
ol.lessons { margin: 0; padding-left: 22px; }
ol.lessons li { margin-bottom: 10px; }
ol.lessons li::marker { color: var(--yellow); font-weight: 800; }

/* ---------- settings */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; }
.setting + .setting { border-top: 1px solid var(--line); }
.setting .lbl b { display: block; }
.setting .lbl span { font-size: 13.5px; color: var(--muted); }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-top: 10px; }
.days button { border: 0; border-radius: 10px; padding: 10px 0; background: var(--panel-2); font-weight: 700; font-size: 13px; color: var(--muted); cursor: pointer; }
.days button.on { background: var(--yellow); color: var(--yellow-ink); }
input[type=time], input[type=password], input[type=text], textarea {
  background: var(--panel-2); border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 13px; outline: none; width: 100%;
}
input[type=time] { width: auto; min-width: 116px; font-variant-numeric: tabular-nums; }
input:focus, textarea:focus { border-color: var(--yellow); }
textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--panel-3); transition: background .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(20px); }

/* ---------- sheet (modal) */
.sheet-bg { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet {
  width: 100%; max-width: 560px; background: var(--panel); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 22px 22px 0 0; padding: 10px 18px calc(18px + var(--safe-b)); animation: up .22s cubic-bezier(.2,.9,.3,1);
  max-height: 92vh; overflow-y: auto;
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--panel-3); margin: 0 auto 14px; }
.sheet h3 { margin: 0 0 6px; font-size: 20px; }
.sheet p { margin: 0 0 14px; color: var(--muted); font-size: 14.5px; }
.sheet .btnrow { margin-top: 14px; }
@media (min-width: 820px) { .sheet-bg { align-items: center; } .sheet { border-radius: 22px; border-bottom: 1px solid var(--line); } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

#toast {
  position: fixed; z-index: 60; left: 50%; bottom: calc(var(--tabh) + var(--safe-b) + 16px); transform: translate(-50%, 20px);
  background: #f4f4f5; color: #111; padding: 12px 16px; border-radius: 14px; font-weight: 600; font-size: 14.5px;
  width: max-content; max-width: calc(100vw - 32px); box-shadow: 0 10px 30px rgba(0,0,0,.5);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--red); color: #fff; }
@media (min-width: 820px) { #toast { bottom: 24px; left: calc(50% + 120px); } }

/* ---------- login */
.login { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; max-width: 380px; margin: 0 auto; }
.login img { width: 84px; height: 84px; border-radius: 20px; margin-bottom: 18px; }
.login h1 { margin: 0; font-size: 30px; }
.login p { color: var(--muted); margin: 6px 0 22px; }
.login .btn { margin-top: 12px; }
.skeleton { background: linear-gradient(90deg, var(--panel) 0, var(--panel-2) 50%, var(--panel) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius); height: 110px; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
