/* ================= WhatNXT styles ================= */

:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f0eee8;
  --text: #1c1b22;
  --muted: #6b6878;
  --border: #e5e2da;
  --accent: #6d5efc;
  --accent-ink: #ffffff;
  --accent-soft: #ecebff;
  --high: #e5484d;
  --high-soft: #fdecec;
  --medium: #d98a00;
  --medium-soft: #fff3da;
  --low: #2f9e6b;
  --low-soft: #e2f4ea;
  --shadow: 0 1px 2px rgba(20, 18, 30, .05), 0 6px 20px rgba(20, 18, 30, .06);
  --radius: 14px;
  --sidebar-w: 224px;
  --tabbar-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111017; --surface: #1a1922; --surface-2: #24222e; --text: #ecebf3; --muted: #9b98ad;
    --border: #2d2b38; --accent: #8c80ff; --accent-ink: #121017; --accent-soft: #29254d;
    --high: #ff6b70; --high-soft: #3a1c22; --medium: #ffb224; --medium-soft: #392b10;
    --low: #4cc38a; --low-soft: #14301f; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111017; --surface: #1a1922; --surface-2: #24222e; --text: #ecebf3; --muted: #9b98ad;
  --border: #2d2b38; --accent: #8c80ff; --accent-ink: #121017; --accent-soft: #29254d;
  --high: #ff6b70; --high-soft: #3a1c22; --medium: #ffb224; --medium-soft: #392b10;
  --low: #4cc38a; --low-soft: #14301f; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
kbd, code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .82em; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 5px; padding: 0 .35em;
}

/* ---------- Layout ---------- */
.app { min-height: 100%; }
.main {
  max-width: 820px;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 16px calc(var(--tabbar-h) + 96px + env(safe-area-inset-bottom));
}

/* Sidebar = bottom tab bar on phones */
.sidebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.brand, .sidebar-hint { display: none; }
.nav { display: flex; height: var(--tabbar-h); }
.nav-item {
  flex: 1; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; background: none; color: var(--muted); font-size: 11px; font-weight: 600;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { color: var(--accent); }
.nav-item .badge {
  position: absolute; top: 7px; left: calc(50% + 8px);
  min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink); font-size: 10.5px; line-height: 17px; text-align: center;
}
.nav-item .badge:empty { display: none; }

.fab {
  position: fixed; z-index: 21; right: 18px;
  bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 18px; border: 0;
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 45%, transparent);
  display: grid; place-items: center;
}
.fab svg { width: 26px; height: 26px; stroke-width: 2.4; }

/* Tablet & laptop: real sidebar */
@media (min-width: 760px) {
  .sidebar {
    top: 0; right: auto; width: var(--sidebar-w);
    border-top: 0; border-right: 1px solid var(--border);
    background: var(--surface); backdrop-filter: none;
    padding: calc(22px + env(safe-area-inset-top)) 14px 20px;
    display: flex; flex-direction: column;
  }
  .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; letter-spacing: -.02em; padding: 0 10px 22px; }
  .nav { flex-direction: column; height: auto; gap: 2px; }
  .nav-item {
    flex: none; flex-direction: row; justify-content: flex-start; gap: 12px;
    padding: 10px 12px; border-radius: 10px; font-size: 14.5px; font-weight: 550; color: var(--text);
  }
  .nav-item svg { width: 20px; height: 20px; color: var(--muted); }
  .nav-item:hover { background: var(--surface-2); }
  .nav-item.active { background: var(--accent-soft); color: var(--accent); }
  .nav-item.active svg { color: var(--accent); }
  .nav-item .badge { position: static; margin-left: auto; background: transparent; color: var(--muted); font-size: 12.5px; }
  .nav-item.active .badge { color: var(--accent); }
  .sidebar-hint { display: block; margin-top: auto; padding: 0 12px; color: var(--muted); font-size: 12.5px; }
  .main { margin-left: calc(var(--sidebar-w) + max(0px, (100vw - var(--sidebar-w) - 820px) / 2)); padding: 34px 32px 60px; }
  .fab { display: none; }
}

/* ---------- Top bar ---------- */
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.heading h1 { margin: 0; font-size: 28px; line-height: 1.15; letter-spacing: -.025em; font-weight: 800; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.search {
  display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; color: var(--muted);
  width: 38px; overflow: hidden; transition: width .2s ease; cursor: text;
}
.search svg { width: 18px; height: 18px; }
.search input { border: 0; outline: 0; background: none; width: 100%; min-width: 0; color: var(--text); }
.search:focus-within, .search.has-value { width: 190px; border-color: var(--accent); }
@media (min-width: 760px) { .search { width: 210px; } .search:focus-within, .search.has-value { width: 240px; } }

.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 1px solid var(--border); background: var(--surface); border-radius: 10px; color: var(--muted);
}
.icon-btn:hover { color: var(--text); }
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: 44px; z-index: 30; min-width: 210px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  padding: 6px; display: flex; flex-direction: column;
}
.menu button, .menu a {
  text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 8px;
  color: var(--text); text-decoration: none; font-size: 14px;
}
.menu button:hover, .menu a:hover { background: var(--surface-2); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 2px; width: auto; }

/* ---------- Quick add ---------- */
.quick-add { margin-bottom: 22px; position: relative; }
.quick-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px 6px 6px 12px; box-shadow: var(--shadow);
}
.quick-row:focus-within { border-color: var(--accent); }
.quick-plus { color: var(--accent); stroke-width: 2.2; }
.quick-row input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; padding: 8px 0; font-size: 15.5px; }
/* The hint floats over the page so nothing jumps when it appears/disappears */
.quick-hint {
  position: absolute; z-index: 5; top: calc(100% + 6px); left: 0; right: 0; margin: 0;
  padding: 7px 11px; font-size: 12.5px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .15s, visibility .15s;
}
.quick-add:focus-within .quick-hint { opacity: 1; visibility: visible; }
@media (max-width: 480px) { #detailsBtn { display: none; } }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid transparent; border-radius: 10px; padding: 9px 16px; font-weight: 650; font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn.small { padding: 7px 12px; font-size: 13.5px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--high); }
.pill {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 5px 12px; font-size: 13px; font-weight: 600; color: var(--text);
}
.pill:hover { border-color: var(--accent); }
.pill.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- Sections & cards ---------- */
.section { margin-bottom: 26px; }
.section-title {
  display: flex; align-items: center; gap: 8px; margin: 0 4px 10px;
  font-size: 12.5px; text-transform: uppercase; letter-spacing: .07em; font-weight: 750; color: var(--muted);
}
.section-title .count { font-weight: 600; opacity: .8; }
.section-title.danger { color: var(--high); }

.progress-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 14px;
}
.progress-card .label { font-size: 14px; font-weight: 600; white-space: nowrap; }
.bar { flex: 1; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--low); border-radius: inherit; transition: width .4s ease; }

.focus-card {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #5b4bf0, #9a4fe0);
  color: #fff; border-radius: 18px; padding: 18px 18px 16px; margin-bottom: 26px;
  box-shadow: 0 12px 30px rgba(91, 75, 240, .28);
}
.focus-card .eyebrow { font-size: 12px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; opacity: .85; }
.focus-card .focus-title { font-size: 21px; font-weight: 750; letter-spacing: -.015em; margin: 6px 0 4px; line-height: 1.25; overflow-wrap: anywhere; }
.focus-card .why { font-size: 13.5px; opacity: .9; margin: 0 0 14px; }
.focus-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.focus-actions button {
  border: 0; border-radius: 10px; padding: 8px 14px; font-weight: 700; font-size: 13.5px;
  background: rgba(255,255,255,.95); color: #2a2366;
}
.focus-actions button.secondary { background: rgba(255,255,255,.18); color: #fff; }

/* ---------- Task list ---------- */
.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.task {
  --p: var(--medium); --p-soft: var(--medium-soft);
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 10px 12px 14px; transition: border-color .15s, transform .15s, opacity .2s;
}
.task:hover { border-color: color-mix(in srgb, var(--p) 45%, var(--border)); }
.task.p-high { --p: var(--high); --p-soft: var(--high-soft); }
.task.p-low { --p: var(--low); --p-soft: var(--low-soft); }
.task.leaving { opacity: 0; transform: translateX(14px); }

.check {
  width: 24px; height: 24px; margin-top: 1px; border-radius: 50%; padding: 0;
  border: 2px solid var(--p); background: var(--p-soft); color: transparent;
  display: grid; place-items: center; flex: none; transition: background .15s;
}
.check svg { width: 14px; height: 14px; stroke-width: 3; }
.check:hover { color: var(--p); }
.task.done .check { background: var(--p); color: #fff; }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }

.task-body {
  flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 0;
  display: flex; flex-direction: column; gap: 5px;
}
.task-title { display: block; font-size: 15px; font-weight: 550; overflow-wrap: anywhere; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.task-meta:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted);
}
.chip svg { width: 13px; height: 13px; stroke-width: 2.2; }
.chip.prio { background: var(--p-soft); color: var(--p); }
.chip.overdue { background: var(--high-soft); color: var(--high); }
.chip.today { background: var(--accent-soft); color: var(--accent); }
.chip.icon-only { padding: 2px 6px; }

.task .del {
  width: 32px; height: 32px; border: 0; background: none; border-radius: 8px; color: var(--muted);
  display: grid; place-items: center; flex: none; margin-top: -4px;
}
.task .del:hover { color: var(--high); background: var(--high-soft); }
@media (hover: hover) { .task .del { opacity: 0; } .task:hover .del, .task .del:focus-visible { opacity: 1; } }

.tag-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }

/* ---------- Matrix ---------- */
.matrix { display: grid; gap: 12px; }
@media (min-width: 640px) { .matrix { grid-template-columns: 1fr 1fr; } }
.quad { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; min-height: 140px; }
.quad h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.quad h3 .dot { width: 10px; height: 10px; border-radius: 50%; }
.quad p.desc { margin: 2px 0 12px; font-size: 12.5px; color: var(--muted); }
.quad .task { padding: 9px 8px 9px 10px; background: var(--bg); }
.quad .task-title { font-size: 14px; }
.quad .empty-mini { color: var(--muted); font-size: 13px; padding: 6px 2px; }
.matrix-help { color: var(--muted); font-size: 13px; margin: 0 4px 14px; }

/* ---------- Empty states ---------- */
.empty {
  text-align: center; padding: 44px 20px; color: var(--muted);
  border: 1.5px dashed var(--border); border-radius: 18px;
}
.empty .big { font-size: 40px; line-height: 1; margin-bottom: 10px; }
.empty h2 { margin: 0 0 6px; color: var(--text); font-size: 18px; }
.empty p { margin: 0 0 14px; font-size: 14px; }

/* ---------- Dialog ---------- */
dialog {
  border: 0; padding: 0; background: var(--surface); color: var(--text);
  width: min(520px, 100vw); max-width: 100vw; max-height: 92vh; border-radius: 20px; box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(10, 8, 20, .45); backdrop-filter: blur(2px); }
@media (max-width: 559px) {
  dialog { margin: auto 0 0; width: 100vw; border-radius: 22px 22px 0 0; max-height: 94vh; }
  dialog[open] { animation: sheet-up .22s ease-out; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
#taskForm { padding: 18px 20px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; }
.dlg-head h2 { margin: 0; font-size: 19px; letter-spacing: -.01em; }
.dlg-head .icon-btn { border: 0; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; flex: 1; }
.field > span, .field > legend { font-size: 13px; font-weight: 650; color: var(--muted); padding: 0; }
.field em { font-style: normal; font-weight: 500; opacity: .8; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--border); background: var(--bg); border-radius: 10px;
  padding: 10px 12px; outline: 0; min-height: 42px;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field input.invalid { border-color: var(--high); }
.row { display: flex; gap: 12px; }
.quick-dates { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -4px; }
.segmented { display: flex; gap: 8px; }
.segmented label { flex: 1; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.seg {
  display: block; text-align: center; padding: 9px 6px; border-radius: 10px; font-weight: 650; font-size: 14px;
  border: 1.5px solid var(--border); cursor: pointer; transition: all .15s;
}
.seg.p-high { --p: var(--high); --p-soft: var(--high-soft); }
.seg.p-medium { --p: var(--medium); --p-soft: var(--medium-soft); }
.seg.p-low { --p: var(--low); --p-soft: var(--low-soft); }
.segmented input:checked + .seg { border-color: var(--p); background: var(--p-soft); color: var(--p); }
.segmented input:focus-visible + .seg { outline: 2px solid var(--accent); outline-offset: 2px; }
.dlg-foot { display: flex; align-items: center; gap: 8px; padding-top: 4px; }
.spacer { flex: 1; }

/* ---------- "Desktop site" warning (font size is scaled up by app.js) ---------- */
.mode-tip {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  display: flex; flex-direction: column; gap: .4em;
  background: #ffe9a8; color: #3b2a00; padding: 1em 1.1em 1.1em;
  font-size: 15px; line-height: 1.4; box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.mode-tip strong { font-size: 1.1em; }
.mode-tip button {
  align-self: flex-start; margin-top: .3em; border: 0; border-radius: .6em;
  background: #3b2a00; color: #fff; font-weight: 700; font-size: 1em; padding: .5em 1.1em;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: calc(var(--tabbar-h) + 86px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 14px; width: max-content; max-width: min(560px, calc(100vw - 32px));
  background: #1f1d29; color: #fff; padding: 11px 12px 11px 16px; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25); font-size: 14px; animation: toast-in .2s ease-out;
}
@media (min-width: 760px) { .toast { bottom: 28px; left: calc(50% + var(--sidebar-w) / 2); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
.toast-btn { border: 0; background: none; color: #b8afff; font-weight: 750; padding: 2px 4px; }

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

/* ================= Plan my day ================= */
.plan-controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 14px; font-size: 14px; font-weight: 600;
}
.plan-controls label { display: inline-flex; align-items: center; gap: 8px; }
.plan-controls input, .plan-controls select {
  border: 1px solid var(--border); background: var(--bg); border-radius: 9px; padding: 6px 8px; min-height: 36px; outline: 0;
}
.plan-controls input:focus, .plan-controls select:focus { border-color: var(--accent); }

.plan-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 10px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
}
.stat .k { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat .v { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; }
.stat.good .v { color: var(--low); }
.stat.bad .v { color: var(--high); }
.learn-note { font-size: 13px; color: var(--muted); margin: 0 4px 18px; }
.learn-note strong { color: var(--text); }

.overload {
  background: var(--high-soft); border: 1px solid color-mix(in srgb, var(--high) 35%, transparent);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 18px;
}
.overload h3 { margin: 0 0 4px; font-size: 15px; color: var(--high); }
.overload p { margin: 0 0 10px; font-size: 13.5px; }
.overload ul { margin: 0 0 12px; padding-left: 18px; font-size: 14px; }
.overload .btn { background: var(--high); color: #fff; }

.timeline { list-style: none; margin: 0 0 26px; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 76px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.block { display: flex; gap: 14px; align-items: stretch; margin-bottom: 8px; position: relative; }
.block .when { width: 66px; flex: none; text-align: right; font-size: 12.5px; font-weight: 700; color: var(--muted); padding-top: 12px; line-height: 1.25; }
.block .when small { display: block; font-weight: 500; opacity: .8; }
.block .node { width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--p, var(--accent)); flex: none; margin-top: 15px; z-index: 1; }
.block .card {
  --p: var(--medium); flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--p); border-radius: 12px; padding: 10px 10px 10px 12px;
}
.block.p-high { --p: var(--high); } .block.p-medium { --p: var(--medium); } .block.p-low { --p: var(--low); }
.block.p-high .card { --p: var(--high); } .block.p-low .card { --p: var(--low); }
.block .card-body { flex: 1; min-width: 0; }
.block .card-title { font-weight: 650; font-size: 14.5px; overflow-wrap: anywhere; }
.block .card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.block.optional .card { border-style: dashed; border-left-style: solid; opacity: .85; }
.block.now .card { box-shadow: 0 0 0 2px var(--accent); }
.block.now .node { background: var(--accent); border-color: var(--accent); }
.block.past { opacity: .55; }
.now-tag { font-size: 11px; font-weight: 800; letter-spacing: .06em; color: var(--accent-ink); background: var(--accent); border-radius: 6px; padding: 1px 6px; }
.block.break .card { background: transparent; border: 1px dashed var(--border); border-left: 1px dashed var(--border); color: var(--muted); font-size: 13px; padding: 6px 12px; }
.block.break .node { width: 8px; height: 8px; margin-top: 10px; margin-left: 2px; margin-right: 2px; border-color: var(--border); }
.block.break .when { padding-top: 6px; }
.focus-btn {
  flex: none; display: inline-flex; align-items: center; gap: 5px; border: 0; border-radius: 9px;
  padding: 7px 11px; font-weight: 700; font-size: 13px; background: var(--accent-soft); color: var(--accent);
}
.focus-btn svg { width: 13px; height: 13px; fill: currentColor; stroke: none; }
.block.now .focus-btn, .focus-btn.main { background: var(--accent); color: var(--accent-ink); }

/* Insights */
.insights { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 20px; }
.insights h3 { margin: 0 0 12px; font-size: 16px; }
.bars { display: flex; align-items: flex-end; gap: 8px; height: 120px; margin-bottom: 6px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.bars .vbar { flex: none; width: 100%; max-width: 34px; border-radius: 6px 6px 3px 3px; background: var(--accent); min-height: 3px; }
.bars .col.today .vbar { background: linear-gradient(180deg, #8c80ff, #5b4bf0); }
.bars .val { font-size: 11px; color: var(--muted); font-weight: 600; }
.bar-labels { display: flex; gap: 8px; margin-bottom: 14px; }
.bar-labels span { flex: 1; text-align: center; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.ins-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .ins-grid { grid-template-columns: repeat(4, 1fr); } }
.ins-grid .stat { background: var(--bg); }
.ins-grid .stat .v { font-size: 18px; }
.ins-grid .stat .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.insights .learn-note { margin: 12px 2px 0; }

/* Play button on task rows */
.task .del.play:hover { color: var(--accent); background: var(--accent-soft); }
.task .del.play svg { fill: currentColor; stroke: none; width: 15px; height: 15px; }

/* ================= Focus timer ================= */
.focus-overlay {
  position: fixed; inset: 0; z-index: 70;
  background: radial-gradient(120% 90% at 50% 0%, #2a2366 0%, #110f1c 60%);
  color: #fff; display: grid; place-items: center; padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  animation: focus-in .25s ease-out;
}
@keyframes focus-in { from { opacity: 0; transform: scale(.98); } to { opacity: 1; transform: none; } }
.focus-inner { width: min(420px, 100%); display: flex; flex-direction: column; align-items: center; text-align: center; position: relative; }
.focus-min { position: absolute; top: -8px; right: -4px; width: 40px; height: 40px; border-radius: 12px; border: 0; background: rgba(255,255,255,.08); color: #fff; display: grid; place-items: center; }
.focus-eyebrow { margin: 0; font-size: 12.5px; letter-spacing: .1em; text-transform: uppercase; opacity: .65; font-weight: 700; }
.focus-inner h2 { margin: 6px 0 22px; font-size: 24px; line-height: 1.25; letter-spacing: -.01em; overflow-wrap: anywhere; padding: 0 30px; }
.ring { position: relative; width: min(260px, 70vw); aspect-ratio: 1; margin-bottom: 18px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); stroke-linecap: round; }
.ring-bg { stroke: rgba(255,255,255,.1); stroke-width: 8; fill: none; }
.ring-fg { stroke: #8c80ff; stroke-width: 8; fill: none; transition: stroke-dashoffset .5s linear; }
.focus-overlay.over .ring-fg { stroke: #ffb224; }
.focus-overlay.paused .ring-fg { stroke: rgba(255,255,255,.35); }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-text span { font-size: clamp(44px, 14vw, 60px); font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.ring-text small { font-size: 13px; opacity: .65; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.focus-overlay.over .ring-text span { color: #ffb224; }
.focus-sub { margin: 0 0 22px; font-size: 14px; opacity: .75; min-height: 1.4em; }
.focus-controls { display: flex; gap: 10px; margin-bottom: 12px; width: 100%; }
.fbtn {
  flex: 1; border: 0; border-radius: 14px; padding: 13px 10px; font-weight: 700; font-size: 15px;
  background: rgba(255,255,255,.1); color: #fff;
}
.fbtn:hover { background: rgba(255,255,255,.16); }
.fbtn.primary { width: 100%; background: #fff; color: #2a2366; flex: none; }
.focus-notify { margin-top: 14px; border: 0; background: none; color: #b8afff; font-weight: 650; font-size: 13.5px; }

.focus-pill {
  position: fixed; z-index: 22; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 8px; max-width: calc(100vw - 120px);
  border: 0; border-radius: 999px; padding: 10px 16px; background: #1f1d29; color: #fff;
  font-weight: 650; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.focus-pill span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pill-dot { width: 9px; height: 9px; border-radius: 50%; background: #8c80ff; flex: none; animation: orb-blink 1.4s ease-in-out infinite; }
@keyframes orb-blink { 50% { opacity: .3; } }
@media (min-width: 760px) { .focus-pill { bottom: 24px; left: calc(50% + var(--sidebar-w) / 2); } }

@media (max-width: 480px) {
  .plan-stats .stat .v { font-size: 18px; }
  .timeline::before { left: 62px; }
  .block .when { width: 52px; font-size: 11.5px; }
  .block { gap: 10px; }
}

/* ================= Game: rank chip, XP, profile ================= */
.rank-chip {
  position: relative; display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px 0 8px;
  border: 1px solid var(--border); background: var(--surface); border-radius: 10px; overflow: hidden;
}
.rank-chip:hover { border-color: var(--accent); }
.rank-icon { font-size: 19px; line-height: 1; }
.rank-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.05; }
.rank-text strong { font-size: 12.5px; white-space: nowrap; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.rank-text small { font-size: 11px; color: var(--muted); font-weight: 650; font-variant-numeric: tabular-nums; }
.rank-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--surface-2); }
.rank-bar span { display: block; height: 100%; background: linear-gradient(90deg, #6d5efc, #ff6fb1); transition: width .5s ease; }
@media (max-width: 430px) { .rank-text strong { display: none; } .rank-chip { padding: 0 10px 0 8px; gap: 6px; } }

.xp-float {
  position: fixed; z-index: 80; transform: translateX(-50%); pointer-events: none;
  font-weight: 800; font-size: 15px; padding: 3px 9px; border-radius: 999px; animation: xp-up 1.5s ease-out forwards;
}
.xp-float.plus { background: var(--low); color: #fff; }
.xp-float.minus { background: var(--high); color: #fff; }
@keyframes xp-up { 0% { opacity: 0; transform: translate(-50%, 6px) scale(.8); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, 40px); } }
.confetti { position: fixed; inset: 0; z-index: 90; pointer-events: none; }

#profileDialog { width: min(600px, 100vw); max-height: 92vh; overflow-y: auto; }
.profile-wrap { padding: 18px 20px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
#profileBody { display: flex; flex-direction: column; gap: 12px; }
.p-hero { display: flex; align-items: center; gap: 16px; padding: 16px; border-radius: 16px; color: #fff;
  background: linear-gradient(135deg, #5b4bf0, #9a4fe0); }
.p-icon { font-size: 46px; line-height: 1; }
.p-hero > div:last-child { flex: 1; min-width: 0; }
.p-rank { font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.p-xp { font-size: 13.5px; opacity: .9; margin: 2px 0 8px; }
.xp-bar { height: 8px; border-radius: 99px; background: rgba(255,255,255,.25); overflow: hidden; }
.xp-bar span { display: block; height: 100%; background: #fff; border-radius: inherit; }
.p-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.p-stats .stat { padding: 10px; }
.p-stats .stat .v { font-size: 18px; }
@media (max-width: 480px) { .p-stats { grid-template-columns: repeat(2, 1fr); } }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.badge { border: 1px solid var(--border); border-radius: 12px; padding: 10px; text-align: center; background: var(--bg); opacity: .55; }
.badge.got { opacity: 1; background: var(--surface); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.b-icon { font-size: 26px; }
.b-name { font-weight: 700; font-size: 13px; margin-top: 2px; }
.b-desc { font-size: 11.5px; color: var(--muted); }
.rules { margin: 0; padding-left: 18px; font-size: 14px; display: flex; flex-direction: column; gap: 3px; }
.rules .neg { color: var(--high); font-weight: 600; }
.ladder { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.ladder li { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 10px; background: var(--bg); font-size: 13px; opacity: .6; }
.ladder li.past { opacity: .85; }
.ladder li.current { opacity: 1; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.l-icon { font-size: 17px; }
.l-name { flex: 1; }
.l-xp { font-size: 11.5px; color: var(--muted); }
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; }
.history li { display: flex; gap: 10px; align-items: baseline; }
.h-delta { width: 44px; text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; flex: none; }
.h-delta.plus { color: var(--low); } .h-delta.minus { color: var(--high); }
.h-reason { flex: 1; min-width: 0; }
.h-when { color: var(--muted); font-size: 12px; }
.ask-row { margin-top: 6px; font-size: 13.5px; }
.set-h { margin: 8px 0 0; font-size: 12.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.set-note { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ================= AI ================= */
.chip.ai { font-weight: 650; }
.chip.ai-good { background: var(--low-soft); color: var(--low); }
.chip.ai-mid { background: var(--medium-soft); color: var(--medium); }
.chip.ai-bad { background: var(--high-soft); color: var(--high); }
.ai-hint { margin: -4px 0 0; font-size: 13px; line-height: 1.45; padding: 9px 11px; border-radius: 10px; background: var(--accent-soft); color: var(--text); }
.ai-hint:empty { display: none; }
.ai-hint.ai-good { background: var(--low-soft); }
.ai-hint.ai-mid { background: var(--medium-soft); }
.ai-hint.ai-bad { background: var(--high-soft); }
.ai-box .ai-line { margin: 0 0 8px; font-size: 14.5px; }
.ai-better { color: var(--low); font-weight: 700; }
.ai-patterns { margin: 4px 0 8px; padding-left: 18px; font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.ai-foot { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.ai-progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 4px 0 10px; }
.ai-progress span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }

/* "How long did it take?" */
dialog.small-dialog { width: min(440px, 100vw); }
.log-wrap { padding: 18px 20px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
.log-wrap h2 { margin: 0; font-size: 18px; overflow-wrap: anywhere; }
.log-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 4px; }
.log-choice { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--bg); }
.log-choice:hover { border-color: var(--accent); }
.log-choice strong { font-size: 16px; }
.log-choice span { font-size: 11.5px; color: var(--muted); }
.log-foot { display: flex; align-items: center; margin-top: 4px; }
