/* Pomedero Peak — Stage 1 styles */

:root {
  --bg: #0e1014;
  --surface: #151920;
  --surface-2: #1c212a;
  --line: #262c37;
  --text: #e9ecf2;
  --muted: #8a93a4;
  --accent: #7c9cff;
  --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent);
  --warm: #ff7a45;
  --radius: 16px;
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --glide: cubic-bezier(.2, .8, .2, 1);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "SF Pro Text", Roboto, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "SF Pro Display", Roboto, sans-serif;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #efeee9;
  --line: #e2e0d9;
  --text: #1b1e24;
  --muted: #6c7280;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  transition: background-color .35s ease, color .35s ease;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

.ico {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: 16px; padding: 14px 24px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font: 600 16px/1 var(--font-display); letter-spacing: -.01em; }
.brand-ico { width: 24px; height: 24px; color: var(--accent); transition: color .6s ease; }

.tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); padding: 4px; border-radius: 999px; }
.tab {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 999px;
  color: var(--muted); font-weight: 500; font-size: 14px;
  transition: color .2s ease, background-color .3s ease;
}
.tab .ico { width: 18px; height: 18px; }
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); background: var(--surface-2); }

.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 12px; color: var(--muted);
  transition: color .2s ease, background-color .2s ease;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }

.today-badge {
  display: flex; align-items: baseline; gap: 8px;
  padding: 6px 12px; margin-right: 6px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
}
.today-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.today-count { font: 700 17px/1 var(--font-display); font-variant-numeric: tabular-nums; color: var(--accent); transition: color .6s ease; display: inline-block; }

/* ---------- Views ---------- */
main { max-width: 1120px; margin: 0 auto; padding: 28px 24px 120px; }
.view { display: none; }
.view.is-active { display: block; }

.focus-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 36px; align-items: start; }
.timer-col { display: flex; flex-direction: column; align-items: center; padding-top: 8px; }
.side-col { display: flex; flex-direction: column; gap: 18px; }

/* Mode switch with springy pill */
.modes {
  position: relative; display: flex; gap: 2px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px;
}
.modes-pill {
  position: absolute; top: 4px; bottom: 4px; left: 0; width: 0;
  border-radius: 999px; background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent);
  transition: transform .55s var(--spring), width .55s var(--spring), background-color .5s ease, box-shadow .5s ease;
}
.mode { position: relative; z-index: 1; padding: 8px 16px; border-radius: 999px; font-size: 14px; font-weight: 500; color: var(--muted); transition: color .25s ease; }
.mode.is-active { color: var(--text); }

/* Ring */
.ring-wrap {
  position: relative; width: min(78vw, 360px); aspect-ratio: 1;
  margin: 30px 0 18px; transform-origin: 50% 60%;
}
.ring { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring-track { fill: none; stroke: var(--surface-2); stroke-width: 9; }
.ring-prog {
  fill: none; stroke: var(--accent); stroke-width: 9; stroke-linecap: round;
  filter: drop-shadow(0 0 10px color-mix(in srgb, var(--accent) 35%, transparent));
}
.ring-prog.refill { transition: stroke-dashoffset .9s var(--glide); }
.ring-knob { fill: var(--bg); stroke: var(--accent); stroke-width: 3; }
.ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; pointer-events: none;
}
.ring-mode { font-size: 13px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }
.ring-time {
  font: 300 clamp(56px, 15vw, 84px)/1 var(--font-display);
  font-variant-numeric: tabular-nums; letter-spacing: -.03em; margin: 8px 0 10px;
}
.ring-subject {
  font-size: 14px; font-weight: 500; color: var(--accent);
  max-width: 70%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color .5s ease;
}

.cycle { display: flex; gap: 8px; height: 10px; margin-bottom: 22px; }
.cycle i {
  width: 10px; height: 10px; border-radius: 50%;
  border: 1.5px solid var(--line); background: transparent;
  transition: background-color .4s ease, border-color .4s ease, transform .5s var(--spring);
}
.cycle i.on { background: var(--accent); border-color: var(--accent); }

.controls { display: flex; align-items: center; gap: 16px; }
.ctl { display: grid; place-items: center; border-radius: 999px; transition: background-color .2s ease, transform .35s var(--spring); }
.ctl:active { transform: scale(.94); }
.ctl-sm { width: 48px; height: 48px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); }
.ctl-sm:hover { color: var(--text); }
.ctl-main {
  display: flex; gap: 10px; padding: 0 30px; height: 58px; min-width: 150px; justify-content: center;
  background: var(--accent); color: #0b0d11; font-weight: 600; font-size: 16px;
  box-shadow: 0 8px 22px -12px rgb(0 0 0 / .55);
  transition: background-color .5s ease, box-shadow .5s ease, transform .35s var(--spring);
}
.ctl-main .ico { stroke-width: 2.1; }
.ctl-main:hover { filter: brightness(1.06); }
.hint { margin: 14px 0 0; font-size: 12px; color: var(--muted); }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.card h2 { margin: 0; font: 600 15px/1.2 var(--font-display); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  --c: var(--muted);
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--line); color: var(--text); background: transparent;
  transition: background-color .25s ease, border-color .25s ease, transform .4s var(--spring);
}
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.chip:hover { border-color: color-mix(in srgb, var(--c) 60%, var(--line)); }
.chip.is-active { background: color-mix(in srgb, var(--c) 18%, transparent); border-color: var(--c); }
.chip .lvl { font-size: 10px; letter-spacing: .06em; color: var(--muted); }

.field {
  width: 100%; padding: 11px 13px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid transparent; outline: none;
  transition: border-color .2s ease;
}
.field:focus { border-color: var(--accent); }
.field::placeholder { color: var(--muted); }

.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 13px; }
.bar-row .track { grid-column: 1 / -1; height: 6px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bar-row .fill { width: 100%; height: 100%; border-radius: 6px; transform-origin: left; transition: transform .7s var(--spring); }

.sessions { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; }
.sessions li { display: grid; grid-template-columns: auto 10px 1fr auto; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13px; }
.sessions .t { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 62px; }
.sessions .dot { width: 8px; height: 8px; border-radius: 50%; }
.sessions .what { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sessions .what em { font-style: normal; color: var(--muted); }
.sessions .len { color: var(--muted); font-variant-numeric: tabular-nums; }
.empty { margin: 4px 0 0; font-size: 13px; color: var(--muted); }

/* Placeholder views */
.soon { max-width: 460px; margin: 12vh auto 0; text-align: center; }
.soon-ico { width: 40px; height: 40px; color: var(--accent); stroke-width: 1.4; }
.soon h2 { font: 600 22px/1.2 var(--font-display); margin: 12px 0 6px; }
.soon p { color: var(--muted); margin: 0; }

/* ---------- Settings sheet ---------- */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgb(0 0 0 / .45); opacity: 0; transition: opacity .3s ease; }
.scrim.show { opacity: 1; }
.sheet {
  position: fixed; z-index: 50; top: 0; right: 0; height: 100dvh; width: min(420px, 100vw);
  background: var(--surface); border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  transform: translateX(105%); visibility: hidden;
  transition: transform .55s var(--spring), visibility 0s linear .55s;
}
.sheet.open { transform: none; visibility: visible; transition: transform .55s var(--spring), visibility 0s; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 10px; }
.sheet-head h2 { margin: 0; font: 600 18px/1 var(--font-display); }
.sheet-body { overflow-y: auto; padding: 0 20px 40px; }
.sheet h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; margin: 22px 0 10px; }

.set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: 14px; }
.set-grid .set-row { flex-direction: column; align-items: flex-start; gap: 4px; }
.set-grid .set-row > span:first-child { font-size: 12px; color: var(--muted); }
.stepper { display: flex; align-items: baseline; gap: 6px; }
.stepper input { width: 58px; background: none; border: 0; outline: none; font: 600 20px/1 var(--font-display); font-variant-numeric: tabular-nums; padding: 0; }
.stepper em { font-style: normal; color: var(--muted); font-size: 12px; }

.toggle-row { position: relative; display: flex; align-items: center; justify-content: space-between; padding: 12px 2px; font-size: 14px; cursor: pointer; border-bottom: 1px solid var(--line); }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch { position: relative; width: 40px; height: 24px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); transition: background-color .25s ease; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform .45s var(--spring), background-color .25s ease; }
.toggle-row input:checked + .switch { background: var(--accent); border-color: var(--accent); }
.toggle-row input:checked + .switch::after { transform: translateX(16px); background: #0b0d11; }
.toggle-row input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }

.vol-row, .notif-row { margin-top: 10px; }
.vol-row input[type=range] { flex: 1; accent-color: var(--accent); }
.btn-ghost { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 10px; border: 1px solid var(--line); font-size: 13px; font-weight: 500; transition: background-color .2s ease; }
.btn-ghost:hover { background: var(--surface); }

.subj-list { list-style: none; margin: 10px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.subj-list li { display: grid; grid-template-columns: 28px 1fr auto auto; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 12px; background: var(--surface-2); }
.subj-list input[type=color] { width: 26px; height: 26px; border: 0; padding: 0; background: none; border-radius: 50%; cursor: pointer; }
.subj-list input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
.subj-list input[type=color]::-webkit-color-swatch { border: 0; border-radius: 50%; }
.subj-list input[type=text] { background: none; border: 0; outline: none; padding: 6px 2px; min-width: 0; }
.lvl-toggle { font-size: 11px; font-weight: 700; letter-spacing: .06em; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line); color: var(--muted); min-width: 40px; }
.lvl-toggle[data-lvl="HL"] { color: var(--text); border-color: var(--muted); }
.lvl-toggle[data-lvl=""] { opacity: .5; }
.subj-del { color: var(--muted); padding: 4px; border-radius: 8px; }
.subj-del:hover { color: var(--warm); }
.subj-del .ico { width: 17px; height: 17px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 60;
  padding: 11px 16px; border-radius: 12px; font-size: 14px;
  background: var(--text); color: var(--bg);
  transform: translate(-50%, 140%); opacity: 0; pointer-events: none;
  transition: transform .5s var(--spring), opacity .25s ease;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* Flying dot (block finished) */
.fly-dot { position: fixed; left: 0; top: 0; z-index: 70; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; pointer-events: none; will-change: transform; }
.fly-trail { position: fixed; left: 0; top: 0; z-index: 69; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; pointer-events: none; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .focus-layout { grid-template-columns: minmax(0, 1fr); gap: 26px; }
  /* backdrop-filter would trap the fixed tab bar inside the header */
  .topbar { grid-template-columns: 1fr auto; backdrop-filter: none; background: var(--bg); }
  .tabs {
    position: fixed; z-index: 30; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
    justify-content: space-around; padding: 6px;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px);
    box-shadow: 0 10px 30px -12px rgb(0 0 0 / .5);
  }
  .tab { flex-direction: column; gap: 3px; padding: 7px 4px; font-size: 11px; flex: 1; border-radius: 14px; }
  .tab .ico { width: 21px; height: 21px; }
  .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
}
@media (max-width: 520px) {
  .topbar { padding: 10px 14px; gap: 8px; }
  .brand span { font-size: 15px; }
  .today-label { display: none; }
  .today-badge { margin-right: 0; padding: 6px 10px; }
  main { padding: 18px 14px 130px; }
  .mode { padding: 8px 12px; font-size: 13px; }
  .ring-wrap { margin: 22px 0 14px; }
}

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

/* =================== Stage 2: Tasks =================== */
.tab { position: relative; }
.tab-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; font-style: normal;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
}
.tab-badge.is-late { background: var(--warm); border-color: var(--warm); color: #1a0d06; }

.pill-select {
  appearance: none; -webkit-appearance: none;
  padding: 7px 30px 7px 12px; border-radius: 999px; font-size: 13px; font-weight: 500;
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a93a4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 9px center / 14px;
  border: 1px solid var(--line); color: var(--text); outline: none; max-width: 100%;
}
input.pill-select { background-image: none; padding-right: 12px; }
.pill-select:focus { border-color: var(--accent); }
.pill-select option { background: var(--surface); color: var(--text); }

.btn-primary {
  padding: 9px 18px; border-radius: 12px; font-weight: 600; font-size: 14px;
  background: var(--accent); color: #0b0d11; transition: transform .35s var(--spring), filter .2s ease;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:active { transform: scale(.95); }

.tasks-wrap { max-width: 760px; margin: 0 auto; }
.add-task { padding: 12px 12px 12px 16px; }
.add-row { display: flex; align-items: center; gap: 10px; }
.add-ico { color: var(--muted); }
.add-row input { flex: 1; min-width: 0; background: none; border: 0; outline: none; font-size: 16px; padding: 8px 0; }
.add-row input::placeholder { color: var(--muted); }
.add-opts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.due-quick { display: flex; gap: 6px; }
.due-quick button, .date-pill, .prio-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 500; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--line);
  transition: color .2s ease, border-color .2s ease, background-color .2s ease;
}
.due-quick button:hover, .prio-btn:hover { color: var(--text); }
.due-quick .is-active { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.date-pill { cursor: pointer; padding: 3px 6px 3px 10px; }
.date-pill .ico { width: 16px; height: 16px; }
.date-pill input { background: none; border: 0; outline: none; color: inherit; font-size: 13px; padding: 4px 0; }
.prio-btn .ico { width: 16px; height: 16px; }
.prio-btn[data-p="1"] { color: #f2b84b; border-color: color-mix(in srgb, #f2b84b 50%, var(--line)); }
.prio-btn[data-p="2"] { color: var(--warm); border-color: color-mix(in srgb, var(--warm) 55%, var(--line)); }

.task-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 22px 0 6px; flex-wrap: wrap; }
.seg { position: relative; display: inline-flex; gap: 2px; padding: 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.seg button { position: relative; z-index: 1; padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--muted); transition: color .25s ease; }
.seg button.is-active { color: var(--text); }
.seg-pill { position: absolute; top: 4px; bottom: 4px; left: 0; border-radius: 999px; background: var(--surface-2); transition: transform .5s var(--spring), width .5s var(--spring); }
.seg-sm button { padding: 5px 11px; font-size: 12px; }
.seg-sm button.is-active { background: var(--surface); }

.overdue-banner {
  display: flex; align-items: center; gap: 10px; margin: 14px 0 0; padding: 11px 14px; border-radius: 12px; font-size: 14px;
  background: color-mix(in srgb, var(--warm) 13%, transparent); border: 1px solid color-mix(in srgb, var(--warm) 40%, transparent);
}
.overdue-banner .ico { color: var(--warm); width: 18px; height: 18px; }

.tgroup { margin-top: 22px; }
.tgroup header { display: flex; align-items: baseline; gap: 8px; margin: 0 4px 8px; }
.tgroup header .btn-ghost { margin-left: auto; padding: 4px 10px; }
.tgroup h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
.g-overdue h3 { color: var(--warm); }
.tlist { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }

.task { border-top: 1px solid var(--line); overflow: hidden; }
.task:first-child { border-top: 0; }
.task.is-linked { box-shadow: inset 3px 0 0 var(--c); }
.task-line { display: flex; align-items: center; gap: 4px; padding: 6px 8px 6px 10px; }
.tcheck {
  flex: none; width: 24px; height: 24px; margin: 0 6px 0 2px; border-radius: 8px;
  border: 2px solid color-mix(in srgb, var(--c) 70%, var(--line)); display: grid; place-items: center;
  transition: background-color .25s ease, border-color .25s ease;
}
.tcheck .ico { width: 16px; height: 16px; stroke-width: 2.6; color: #0b0d11; stroke-dasharray: 20; stroke-dashoffset: 20; transition: stroke-dashoffset .3s cubic-bezier(.6,0,.4,1) .08s; }
.tcheck:hover { background: color-mix(in srgb, var(--c) 15%, transparent); }
.is-done .tcheck { background: var(--c); border-color: var(--c); }
.is-done .tcheck .ico { stroke-dashoffset: 0; }
.tbody { flex: 1; min-width: 0; text-align: left; padding: 8px 6px; border-radius: 10px; display: flex; flex-direction: column; gap: 4px; }
.tbody:hover { background: var(--surface-2); }
.ttitle { font-size: 15px; font-weight: 500; overflow-wrap: anywhere; transition: color .3s ease; }
.is-done .ttitle { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.tmeta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 12px; color: var(--muted); }
.tsub { display: inline-flex; align-items: center; gap: 6px; }
.tsub i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.ttype { padding: 1px 7px; border-radius: 6px; border: 1px solid var(--line); font-size: 11px; font-weight: 600; letter-spacing: .03em; }
.tdue.is-late { color: var(--warm); font-weight: 600; }
.tdue.is-today { color: var(--text); font-weight: 600; }
.tprio { display: inline-flex; align-items: center; gap: 3px; }
.tprio .ico { width: 13px; height: 13px; }
.tprio.p1 { color: #f2b84b; }
.tprio.p2 { color: var(--warm); }
.tfocus { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: var(--muted); transition: color .2s ease, background-color .2s ease, transform .35s var(--spring); }
.tfocus:hover { color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
.tfocus:active { transform: scale(.9); }

.tedit { padding: 4px 16px 16px 50px; display: flex; flex-direction: column; gap: 10px; }
.tedit textarea { resize: vertical; min-height: 60px; font: inherit; font-size: 14px; }
.tedit-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.tedit-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; min-width: 0; }
.tedit-grid .pill-select { width: 100%; text-transform: none; letter-spacing: 0; border-radius: 10px; }
.tedit-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tdel { color: var(--muted); }
.tdel:hover { color: var(--warm); }
.tdel .ico { width: 16px; height: 16px; }
.tasks-empty { margin-top: 8vh; }

/* Focus view: task picker */
.task-pick { position: relative; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; padding: 0 0 0 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid transparent; }
.task-pick .ico { width: 17px; height: 17px; color: var(--muted); }
.task-pick.has-task { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.task-pick.has-task .ico { color: var(--accent); }
.task-pick select { flex: 1; min-width: 0; width: 100%; appearance: none; -webkit-appearance: none; background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a93a4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 12px center / 14px; border: 0; outline: none; padding: 11px 34px 11px 0; font-size: 14px; text-overflow: ellipsis; }
.task-pick select option { background: var(--surface); }

@media (max-width: 900px) {
  .tab-badge { position: absolute; top: 2px; right: calc(50% - 22px); min-width: 16px; height: 16px; font-size: 10px; }
}
@media (max-width: 520px) {
  .tedit { padding-left: 12px; }
  .tedit-grid { grid-template-columns: 1fr 1fr; }
  .task-bar .pill-select { flex: 1; }
  .due-quick { flex-wrap: wrap; }
}
.task-pick.has-task + .field { display: none; }

/* =================== Stage 3: Alarms =================== */
.alarms-wrap { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; }
.alarm-hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px; }
.hero-time { font: 300 34px/1.15 var(--font-display); letter-spacing: -.02em; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.hero-time small, .al-time small, .ro-time small { font-size: .45em; font-weight: 500; margin-left: .25em; letter-spacing: .02em; color: var(--muted); }
.hero-add { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.hero-add .ico { width: 18px; height: 18px; stroke-width: 2.2; }

.sound-warn {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  padding: 12px 14px; border-radius: 12px; font-size: 14px;
  background: color-mix(in srgb, #f2b84b 12%, transparent); border: 1px solid color-mix(in srgb, #f2b84b 45%, transparent);
}
.sound-warn .ico { color: #f2b84b; }

.alarm-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.alarm {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px 8px 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  transition: opacity .35s ease, border-color .3s ease;
}
.alarm.is-editing { border-color: var(--accent); }
.al-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 18px; text-align: left; padding: 10px 12px; border-radius: 12px; }
.al-main:hover { background: var(--surface-2); }
.al-time { display: inline-block; font: 300 38px/1 var(--font-display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; min-width: 150px; transition: color .3s ease; }
.al-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.al-label { display: flex; align-items: center; gap: 7px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.al-label .ico { width: 16px; height: 16px; color: var(--c); flex: none; }
.al-label em { font-style: normal; color: var(--muted); font-weight: 400; }
.al-days { font-size: 13px; color: var(--muted); }
.alarm.is-off .al-time, .alarm.is-off .al-label { color: var(--muted); }
.alarm.is-off .al-label .ico { color: var(--muted); }
.al-switch { position: relative; display: flex; cursor: pointer; padding: 8px; }
.al-switch input { position: absolute; opacity: 0; pointer-events: none; }
.al-switch input:checked + .switch { background: var(--accent); border-color: var(--accent); }
.al-switch input:checked + .switch::after { transform: translateX(16px); background: #0b0d11; }
.al-switch input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }

.al-editor { display: flex; flex-direction: column; gap: 12px; padding: 18px; border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.ae-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ae-time {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; outline: none;
  padding: 6px 14px; font: 300 40px/1.1 var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.ae-time:focus { border-color: var(--accent); }
.ae-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; }
.ae-row.stack { align-items: flex-start; }
.ae-row > span:first-child { color: var(--muted); padding-top: 2px; }
.ae-days { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.days { display: flex; gap: 6px; }
.day {
  width: 38px; height: 38px; border-radius: 50%; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
  transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}
.day.is-on { background: var(--accent); border-color: var(--accent); color: #0b0d11; }
.quick { display: flex; gap: 6px; }
.quick button { font-size: 12px; color: var(--muted); padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line); }
.quick button:hover { color: var(--text); }
.ae-sound { display: flex; gap: 8px; align-items: center; }
.ae-out { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--line); }
.ae-out .ico { width: 16px; height: 16px; }
a.btn-ghost { text-decoration: none; color: inherit; }
.ae-foot { display: flex; align-items: center; gap: 8px; }
.ae-foot .grow { flex: 1; }
.ae-del { color: var(--muted); }
.ae-del:hover { color: var(--warm); }
.ae-del .ico { width: 16px; height: 16px; }

.note { margin: 2px 4px 0; font-size: 13px; color: var(--muted); line-height: 1.55; }
.note b { color: var(--text); font-weight: 600; }
.section-h { font: 600 18px/1.2 var(--font-display); margin: 18px 4px 0; }

.rem-card { padding: 6px 18px 14px; }
.rem-body { transition: opacity .3s ease; }
.rem-body.is-off { opacity: .4; pointer-events: none; }
.rem-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 2px; font-size: 14px; border-bottom: 1px solid var(--line); }
.rem-row.stack { flex-direction: column; align-items: flex-start; gap: 10px; }
.rem-row:last-child { border-bottom: 0; }
.day-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.dchip { padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--muted); border: 1px solid var(--line); background: var(--surface-2); transition: background-color .25s ease, color .25s ease, border-color .25s ease; }
.dchip.is-on { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }

.upcoming { list-style: none; margin: 0; padding: 0; }
.upcoming li { display: grid; grid-template-columns: 92px 10px 1fr; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.upcoming li:first-child { border-top: 0; }
.u-when { display: flex; flex-direction: column; font-weight: 500; }
.u-when small { color: var(--muted); font-size: 12px; font-weight: 400; }
.upcoming .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.u-what { display: flex; flex-direction: column; min-width: 0; }
.u-what em { font-style: normal; font-size: 12px; color: var(--muted); }
.card-head .btn-ghost .ico { width: 16px; height: 16px; }

/* Ringing overlay */
.ring-overlay {
  --ro-c: var(--accent);
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(16px);
}
.ring-overlay[hidden] { display: none; }
.ro-inner { display: flex; flex-direction: column; align-items: center; text-align: center; width: min(420px, 100%); }
.ro-pulse { position: relative; width: 150px; height: 150px; display: grid; place-items: center; margin-bottom: 18px; }
.ro-pulse i {
  position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--ro-c);
  animation: ro-wave 2.1s cubic-bezier(.2,.7,.3,1) infinite; opacity: 0;
}
.ro-pulse i:nth-child(2) { animation-delay: .7s; }
.ro-pulse i:nth-child(3) { animation-delay: 1.4s; }
@keyframes ro-wave { 0% { transform: scale(.45); opacity: .7; } 70% { opacity: .15; } 100% { transform: scale(1.25); opacity: 0; } }
.ro-bell { width: 64px; height: 64px; color: var(--ro-c); stroke-width: 1.4; transform-origin: 50% 12%; animation: ro-swing 1.9s ease-in-out infinite; }
/* pendulum swing that dies down, rests, then swings again */
@keyframes ro-swing {
  0% { transform: rotate(0); } 8% { transform: rotate(20deg); } 18% { transform: rotate(-16deg); }
  28% { transform: rotate(11deg); } 38% { transform: rotate(-7deg); } 47% { transform: rotate(3.5deg); }
  55% { transform: rotate(-1.5deg); } 62%, 100% { transform: rotate(0); }
}
.ro-time { font: 200 clamp(64px, 18vw, 96px)/1 var(--font-display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.ro-label { font: 600 22px/1.25 var(--font-display); margin-top: 10px; }
.ro-sub { color: var(--muted); margin-top: 6px; min-height: 1.4em; }
.ro-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 30px; }
.ro-main { padding: 16px; font-size: 17px; border-radius: 16px; background: var(--ro-c); }
.ro-snooze { justify-content: center; padding: 14px; font-size: 16px; border-radius: 16px; }
.ro-link { color: var(--muted); font-size: 14px; padding: 8px; text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 520px) {
  .alarm-hero { flex-direction: column; align-items: stretch; }
  .hero-add { justify-content: center; }
  .al-main { gap: 12px; }
  .al-time { font-size: 28px; min-width: 0; flex: none; }
  .alarm { padding-right: 8px; }
  .al-main { padding: 10px 8px; }
  .al-label em { display: none; }
  .ae-row.stack { flex-direction: column; }
  .ae-days { align-items: flex-start; }
  .day { width: 36px; height: 36px; }
  .days { gap: 5px; }
}

/* =================== Stage 4: IB tracker =================== */
.ib-wrap { max-width: 880px; margin: 0 auto; }
.ib-nav { margin-bottom: 18px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.ib-page { display: none; flex-direction: column; gap: 14px; }
.ib-page.is-active { display: flex; }
.ib-intro { margin: 0 4px; }

.ib-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding: 24px; flex-wrap: wrap; }
.cd-num { display: flex; align-items: baseline; gap: 10px; margin: 6px 0 4px; }
.cd-num b { font: 200 72px/1 var(--font-display); letter-spacing: -.04em; font-variant-numeric: tabular-nums; color: var(--accent); }
.cd-num span { font-size: 18px; color: var(--muted); }
.cd-empty { font: 300 30px/1.2 var(--font-display); margin: 8px 0 6px; }
.cd-date { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.cd-list { list-style: none; margin: 0 0 10px; padding: 0; }
.cd-list li { display: grid; grid-template-columns: 1fr auto 100px 30px; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.cd-list li:first-child { border-top: 0; }
.cd-d { color: var(--muted); font-size: 13px; }
.cd-n { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.cd-n.soon { color: var(--warm); }
.cd-add { display: flex; gap: 8px; }
.cd-add .field { flex: 1; min-width: 0; padding: 8px 12px; }
.cd-add .btn-ghost .ico { width: 16px; height: 16px; }

.ov-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.ov-card { display: flex; flex-direction: column; gap: 8px; }
.ov-card .card-head { margin-bottom: 4px; }
.btn-ghost.small { padding: 4px 10px; font-size: 12px; }
.ov-total { display: flex; align-items: baseline; gap: 6px; }
.ov-total b { font: 200 54px/1 var(--font-display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.ov-total span { color: var(--muted); }
.ov-status { font-size: 13px; padding: 7px 10px; border-radius: 10px; background: var(--surface-2); color: var(--muted); }
.ov-status.ok { color: #5cc8a0; background: color-mix(in srgb, #5cc8a0 12%, transparent); }
.ov-status.bad { color: var(--warm); background: color-mix(in srgb, var(--warm) 12%, transparent); }
.ov-ms { list-style: none; margin: 0; padding: 0; }
.ov-ms li { display: grid; grid-template-columns: 8px 1fr auto; align-items: center; gap: 10px; padding: 7px 0; font-size: 13px; border-top: 1px solid var(--line); }
.ov-ms li:first-child { border-top: 0; }
.ov-ms i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.ov-ms span { display: flex; flex-direction: column; min-width: 0; }
.ov-ms em { font-style: normal; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-ms b { font-weight: 600; font-size: 12px; }
.ov-ms b.late { color: var(--warm); }
.ov-cas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ov-cas div { display: flex; flex-direction: column; padding: 10px; border-radius: 12px; background: color-mix(in srgb, var(--c) 12%, transparent); }
.ov-cas b { font: 300 30px/1 var(--font-display); color: var(--c); }
.ov-cas span { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* projects */
.proj-list { display: flex; flex-direction: column; gap: 10px; }
.proj { padding: 0; overflow: hidden; }
.proj-head { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 16px 18px 12px; }
.proj-head:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.proj-kind { flex: none; font-size: 11px; font-weight: 700; letter-spacing: .06em; padding: 4px 8px; border-radius: 8px; color: var(--c); background: color-mix(in srgb, var(--c) 15%, transparent); min-width: 42px; text-align: center; }
.proj-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.proj-title b { font-weight: 600; }
.proj-title em { font-style: normal; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-count { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; font-weight: 600; }
.is-complete .proj-count { color: var(--c); }
.pbar { height: 4px; margin: 0 18px 14px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.pbar i, .wbar i { display: block; height: 100%; width: 100%; border-radius: inherit; background: var(--c); transform-origin: left; transition: transform .6s var(--spring); }
.proj-body { padding: 0 18px 18px; display: flex; flex-direction: column; gap: 10px; }
.ms-list { list-style: none; margin: 0; padding: 0; }
.ms { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.ms:first-child { border-top: 0; }
.ms .tcheck { margin: 0 4px 0 0; }
.ms-name { background: none; border: 0; outline: none; padding: 8px 4px; border-radius: 8px; min-width: 0; font-size: 14px; }
.ms-name:focus { background: var(--surface-2); }
.ms.is-done .ms-name { color: var(--muted); text-decoration: line-through; }
.ms-date { padding: 5px 10px; font-size: 12px; }
.ms-date.late { color: var(--warm); border-color: color-mix(in srgb, var(--warm) 50%, var(--line)); }
.add-ms { align-self: flex-start; }
.add-ms .ico { width: 16px; height: 16px; }
.proj-meta { display: grid; grid-template-columns: 2fr 1.4fr 1fr 1fr; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.proj-meta label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; min-width: 0; }
.proj-meta .pill-select { border-radius: 10px; width: 100%; text-transform: none; letter-spacing: 0; }
.words { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.wbar { height: 6px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.words.over { color: var(--warm); }
.words.over .wbar i { background: var(--warm); }
.proj-foot { display: flex; justify-content: flex-end; }
.proj-add { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* CAS */
.cas-sum { display: flex; flex-direction: column; gap: 18px; }
.cas-strands { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.cs-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; font-size: 14px; }
.cs-top b { font: 300 28px/1 var(--font-display); color: var(--c); }
.cs .wbar i { background: var(--c); }
.cas-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cas-facts div { display: flex; flex-direction: column; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.cas-facts b { font: 500 20px/1.1 var(--font-display); }
.cas-facts span { font-size: 12px; color: var(--muted); margin-top: 3px; }
.out-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.oc { font-size: 12px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); transition: background-color .25s ease, color .25s ease, border-color .25s ease; }
.oc.on { color: var(--text); border-color: #5cc8a0; background: color-mix(in srgb, #5cc8a0 14%, transparent); }
.cas-new { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; }
.cas-new .ico { width: 18px; height: 18px; stroke-width: 2.2; }
.cas-list { display: flex; flex-direction: column; gap: 10px; }
.casx { padding: 0; overflow: hidden; }
.casx-head { width: 100%; text-align: left; display: flex; flex-direction: column; gap: 6px; padding: 14px 18px; }
.casx-head:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.casx-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.casx-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 12px; color: var(--muted); }
.ctag { --c: var(--muted); font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; color: var(--c); background: color-mix(in srgb, var(--c) 15%, transparent); }
.proj-tag { --c: #e27ad2; }
.casx-body { padding: 0 18px 18px; display: flex; flex-direction: column; gap: 12px; }
.strand-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.strand-pick .dchip.is-on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.casx-body .tedit-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.out-chips.pick .oc { cursor: pointer; }
.refls { display: flex; flex-direction: column; gap: 8px; }
.refl { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.refl-d { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--muted); }
.refl p { margin: 4px 0 0; font-size: 14px; white-space: pre-wrap; }
.refls textarea { resize: vertical; font: inherit; font-size: 14px; }
.refls .btn-ghost { align-self: flex-start; }

/* grades */
.g-total { display: flex; gap: 28px; align-items: center; padding: 22px; }
.g-ring { position: relative; width: 190px; flex: none; }
.g-ring svg { width: 100%; transform: rotate(-90deg); }
.g-track { fill: none; stroke: var(--surface-2); stroke-width: 9; }
.g-prog { fill: none; stroke: var(--accent); stroke-width: 9; stroke-linecap: round; }
.g-num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.g-num b { font: 200 60px/1 var(--font-display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.g-num span { color: var(--muted); font-size: 13px; }
.g-break { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.g-line { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.g-line b { font: 500 20px/1 var(--font-display); }
.g-line small { color: var(--muted); font-size: 12px; margin-left: 2px; }
.conds { list-style: none; margin: 4px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font-size: 13px; }
.conds li { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.conds i { width: 14px; height: 14px; flex: none; border-radius: 50%; border: 1.5px solid var(--line); }
.conds li.ok { color: var(--text); }
.conds li.ok i { border-color: #5cc8a0; background: #5cc8a0; box-shadow: inset 0 0 0 3px var(--surface); }
.conds li.bad { color: var(--warm); }
.conds li.bad i { border-color: var(--warm); background: var(--warm); box-shadow: inset 0 0 0 3px var(--surface); }
.g-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.card .g-row:first-of-type { border-top: 0; }
.g-name { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; min-width: 0; }
.g-name i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.g-name em { font-style: normal; font-size: 11px; color: var(--muted); font-weight: 600; }
.g-pick { display: flex; gap: 4px; flex: none; }
.g-pick button {
  width: 34px; height: 34px; border-radius: 10px; font-weight: 600; font-size: 14px; color: var(--muted);
  border: 1px solid var(--line); background: var(--surface-2); transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}
.g-pick button.fill { border-color: color-mix(in srgb, var(--c, var(--accent)) 45%, var(--line)); color: var(--text); }
.g-pick button.is-on { background: var(--c, var(--accent)); border-color: var(--c, var(--accent)); color: #0b0d11; }
.core-rows { margin-bottom: 14px; }
.matrix { border-collapse: separate; border-spacing: 4px; font-size: 13px; margin: 0 0 6px -4px; }
.matrix th { color: var(--muted); font-weight: 600; padding: 4px 8px; }
.matrix td { width: 40px; height: 32px; text-align: center; border-radius: 8px; background: var(--surface-2); font-variant-numeric: tabular-nums; transition: background-color .3s ease, color .3s ease; }
.matrix td.f { color: var(--warm); }
.matrix td.hit { background: var(--accent); color: #0b0d11; font-weight: 700; }

@media (max-width: 900px) {
  .ov-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .g-total { flex-direction: column; align-items: stretch; }
  .g-ring { align-self: center; width: 170px; }
  .conds { grid-template-columns: 1fr; }
  .g-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .g-pick { width: 100%; justify-content: space-between; }
  .g-pick button { flex: 1; width: auto; }
  .proj-meta { grid-template-columns: 1fr 1fr; }
  .ms { grid-template-columns: auto 1fr auto; }
  .ms .ms-date { grid-column: 2 / 3; justify-self: start; }
  .ms .subj-del { grid-row: 1; grid-column: 3; }
  .cas-strands, .cas-facts { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .casx-body .tedit-grid { grid-template-columns: 1fr 1fr; }
  .cd-list li { grid-template-columns: 1fr auto 30px; }
  .cd-list .cd-d { display: none; }
  .cd-add { flex-wrap: wrap; }
  .cd-num b { font-size: 60px; }
  .ib-nav button { padding: 7px 11px; }
}

/* =================== Stage 5: Stats =================== */
.stats-wrap { max-width: 980px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.st-bar { display: flex; align-items: center; gap: 10px; }
.st-range { display: flex; flex-direction: column; min-width: 150px; }
.st-range b { font: 600 18px/1.2 var(--font-display); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 6px; }
.tile b { font: 300 32px/1.1 var(--font-display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

.wk-chart { position: relative; width: 100%; }
.wk-chart svg { display: block; overflow: visible; }
.wk-chart .grid { stroke: var(--line); stroke-width: 1; }
.wk-chart .grid.base { stroke: color-mix(in srgb, var(--muted) 50%, transparent); }
.wk-chart .ax { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.wk-chart .ax.today { fill: var(--text); font-weight: 700; }
.wk-chart .peak { fill: var(--text); font-size: 12px; font-weight: 600; }
.wk-chart .hit { fill: transparent; }
.wk-chart .hit:hover { fill: color-mix(in srgb, var(--text) 4%, transparent); }
.wk-chart .bar { transform-box: fill-box; transform-origin: 50% 100%; }
.wk-chart .bar rect { transition: opacity .15s ease; }
.wk-chart svg:has(.bar rect:hover) .bar rect:not(:hover) { opacity: .55; }
.chart-empty { position: absolute; inset: 0 0 26px 36px; display: grid; place-items: center; margin: 0; color: var(--muted); font-size: 14px; pointer-events: none; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; 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; }
.tbl-wrap { overflow-x: auto; }
.st-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.st-table th, .st-table td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.st-table th:first-child { text-align: left; }
.st-table thead th { color: var(--muted); font-weight: 600; font-size: 12px; }
.st-table tbody th { font-weight: 500; }

.st-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.lvl-tag { font-style: normal; font-size: 10px; color: var(--muted); font-weight: 600; }

.heat { --h1: #0f4a96; --h2: #1b64be; --h3: #338ced; --h4: #84b9f3; }
[data-theme="light"] .heat, [data-theme="light"] .heat-key { --h1: #cce3fd; --h2: #84b9f3; --h3: #338ced; --h4: #1757ac; }
.heat-key { --h1: #0f4a96; --h2: #1b64be; --h3: #338ced; --h4: #84b9f3; }
.heat-months { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.heat-grid { display: grid; grid-template-columns: repeat(12, 1fr); grid-template-rows: repeat(7, auto); grid-auto-flow: column; gap: 4px; }
.heat-grid i, .heat-key i { display: block; aspect-ratio: 1; border-radius: 4px; background: var(--surface-2); }
.heat-grid .future { background: transparent; }
.heat-grid i.is-today { outline: 1.5px solid var(--text); outline-offset: 1px; }
.h1 { background: var(--h1) !important; } .h2 { background: var(--h2) !important; } .h3 { background: var(--h3) !important; } .h4 { background: var(--h4) !important; }
.heat-key { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 12px; font-size: 11px; color: var(--muted); }
.heat-key i { width: 12px; }
.heat-key span { margin: 0 4px; }

.tip {
  position: fixed; left: 0; top: 0; z-index: 80; pointer-events: none;
  padding: 8px 11px; border-radius: 10px; font-size: 12px; line-height: 1.5; max-width: 240px;
  background: var(--text); color: var(--bg); box-shadow: 0 10px 26px -10px rgb(0 0 0 / .5);
}
.tip b { font-weight: 700; }
.tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.tip span { opacity: .7; }

.subj-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.file-btn { position: relative; cursor: pointer; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.restore-confirm { margin-top: 12px; padding: 12px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--warm) 50%, var(--line)); background: color-mix(in srgb, var(--warm) 8%, transparent); font-size: 14px; }
.restore-confirm p { margin: 0 0 6px; }

@media (max-width: 760px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .st-grid { grid-template-columns: 1fr; }
  .tile b { font-size: 26px; }
}
@media (hover: none) and (pointer: coarse) { .hint { display: none; } }
