/* Gruvbox Material dark (medium), same values as foot/waybar */
:root {
  --bg-dim: #1d2021; --bg0: #282828; --bg1: #32302f; --bg2: #3a3735; --bg3: #45403d;
  --grey0: #7c6f64; --grey1: #928374; --fg: #d4be98; --fg-hi: #ddc7a1;
  --red: #ea6962; --orange: #e78a4e; --yellow: #d8a657; --green: #a9b665;
  --aqua: #89b482; --blue: #7daea3; --purple: #d3869b;
  /* quest colours: gruvbox hues, a bit stronger so they stay apart in charts
     (validated: dark surface, adjacent pairs, CVD). Slot n is assigned by the server (colors.py). */
  --q1: #bc598c; --q2: #d37e01; --q3: #2677b2; --q4: #48a260;
  --q5: #8a6fd1; --q6: #a89400; --q7: #1f9a99; --q8: #d4523f;
  --radius: 8px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg-dim); color: var(--fg);
  font: 13px/1.5 "JetBrains Mono", monospace;
  display: grid; grid-template-columns: 64px 1fr; grid-template-rows: auto 1fr;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input { font: inherit; color: var(--fg); }
.muted { color: var(--grey0); }

/* ---------- sidebar ---------- */
nav {
  grid-row: 1 / 3; background: var(--bg-dim); border-right: 1px solid var(--bg1);
  display: flex; flex-direction: column; align-items: center; padding: 14px 0; gap: 6px;
}
nav .logo { color: var(--yellow); font-size: 20px; margin-bottom: 14px; }
nav button {
  width: 48px; padding: 8px 0; border-radius: var(--radius); color: var(--grey0);
  display: flex; flex-direction: column; align-items: center; font-size: 10px; gap: 2px;
}
nav button span { font-size: 17px; }
nav button:hover { background: var(--bg1); color: var(--fg); }
nav button.on { background: var(--bg1); color: var(--yellow); }
nav .spacer { flex: 1; }

/* ---------- timer bar ---------- */
.timer {
  background: var(--bg-dim); border-bottom: 1px solid var(--bg1);
  display: flex; align-items: center; gap: 16px; padding: 12px 24px;
}
.timer .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--yellow); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.timer .quest { font-size: 15px; cursor: pointer; }
.timer .sep { color: var(--grey0); }
.assign {
  position: relative; background: var(--bg1); border: 1px solid var(--bg3); border-radius: var(--radius);
  padding: 4px 10px; color: var(--yellow); white-space: nowrap;
}
.assign:hover { border-color: var(--yellow); }
.assign-menu {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 260px; z-index: 10;
  background: var(--bg1); border: 1px solid var(--bg3); border-radius: var(--radius); padding: 6px;
  display: none; text-align: left;
}
.assign-menu.open { display: block; }
.assign-menu div { padding: 6px 10px; border-radius: 6px; color: var(--fg); }
.assign-menu div:hover { background: var(--bg3); }
.assign-menu .hint { color: var(--grey0); font-size: 11px; padding: 4px 10px; }
.timer .clock { margin-left: auto; font-size: 26px; color: var(--yellow); letter-spacing: 1px; cursor: pointer; }
.stop {
  width: 38px; height: 38px; border-radius: 50%; background: var(--yellow); color: var(--bg0);
  font-size: 14px; display: flex; align-items: center; justify-content: center;
}
.stop:hover { background: var(--orange); }
.timer.idle .dot { background: var(--grey0); animation: none; }
.timer.idle .clock, .timer.idle .assign, .timer.idle .stop { display: none; }

/* ---------- layout: columns ("lanes") ---------- */
main.start {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px; padding: 22px 28px; overflow: auto; align-items: start;
}
@media (max-width: 1150px) {
  main.start { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  main.start > .col:nth-child(2) { grid-column: 2; grid-row: 1 / 3; }
  main.start > .col:nth-child(3) { grid-column: 1; grid-row: 2; }
}
@media (max-width: 700px) {
  main.start { grid-template-columns: minmax(0, 1fr); }
  main.start > .col:nth-child(n) { grid-column: 1; grid-row: auto; }
}
.lane { --c: var(--grey1); margin-bottom: 26px; }
.c-aqua { --c: var(--aqua); } .c-blue { --c: var(--blue); } .c-green { --c: var(--green); }
.c-orange { --c: var(--orange); } .c-purple { --c: var(--purple); } .c-grey { --c: var(--grey1); }

/* lane header like "Thu 15": bold title, number in colour, thick coloured underline */
.lane-head {
  display: flex; align-items: baseline; gap: 10px; padding: 0 2px 9px; margin-bottom: 12px;
  border-bottom: 2px solid var(--c);
}
.lane-head h2 { margin: 0; font-size: 16px; font-weight: 700; color: var(--fg-hi); }
.lane-head .num { color: var(--c); font-size: 15px; }
.lane-head .right { margin-left: auto; color: var(--grey0); font-size: 11px; }

/* ---------- add box (dashed, like "Add a task…") ---------- */
.addbox {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px; padding: 8px 8px 8px 12px;
  border: 1.5px dashed color-mix(in srgb, var(--c) 45%, var(--bg3)); border-radius: 10px;
  background: color-mix(in srgb, var(--c) 6%, transparent);
}
.addbox:focus-within { border-color: var(--c); border-style: solid; }
.addbox .plus { color: var(--c); font-weight: 700; font-size: 16px; }
.addbox input { flex: 1; min-width: 0; background: none; border: 0; outline: none; padding: 2px 0; }
.addbox input::placeholder { color: color-mix(in srgb, var(--c) 65%, var(--grey0)); }
.addbox .kbd { font-size: 10px; color: var(--grey0); border: 1px solid var(--bg3); border-radius: 5px; padding: 2px 6px; }

/* ---------- cards ---------- */
.card {
  --s: var(--c);                         /* stripe colour, default = lane colour */
  position: relative; background: var(--bg0); border: 1px solid var(--bg2); border-radius: 12px;
  padding: 12px 14px 12px 22px; margin-bottom: 10px; cursor: default;
}
.card::before {                          /* coloured stripe on the left edge */
  content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--s);
}
.card:hover { border-color: var(--bg3); }
.card.click { cursor: pointer; }
.card .title { color: var(--fg-hi); font-size: 14px; line-height: 1.35; }
.card .sub-title { color: var(--grey0); font-size: 12px; margin-top: 2px; }
.card .meta { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.card .handle { position: absolute; right: 12px; bottom: 10px; color: var(--bg3); font-size: 14px; }
.card.running { border-color: var(--yellow); background: color-mix(in srgb, var(--yellow) 5%, var(--bg0)); }
.card.done { opacity: .55; }
.card.done .title { text-decoration: line-through; color: var(--grey1); }
.card.done::before { background: var(--grey0); }

/* round buttons inside cards */
.rnd {
  width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--bg3); color: var(--grey0);
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; flex: none;
}
.rnd.check:hover { border-color: var(--green); color: var(--green); }
.card.done .rnd.check { background: var(--green); border-color: var(--green); color: var(--bg0); }
.rnd.play:hover, .card.running .rnd.play { border-color: var(--yellow); color: var(--yellow); }
.push { margin-left: auto; }

/* pills */
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--bg3); background: var(--bg1); font-size: 11px; color: var(--grey1); white-space: nowrap;
}
.pill .d { width: 7px; height: 7px; border-radius: 50%; }
.pill.warn { color: var(--orange); border-color: color-mix(in srgb, var(--orange) 45%, transparent); }

/* live timer row inside the running card */
.live-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.live-row .d { width: 8px; height: 8px; border-radius: 50%; background: var(--yellow); animation: pulse 2s infinite; }
.live-row .live { color: var(--yellow); font-size: 16px; font-weight: 700; }
.live-row .pause { color: var(--grey1); letter-spacing: -2px; }

/* ---------- start: habits as compact chips for today ---------- */
.c-red { --c: var(--red); }
.lane-head .link { margin-left: auto; color: var(--c); font-size: 12px; }
.lane-head .link:hover { text-decoration: underline; }
.hchips { display: flex; flex-wrap: wrap; gap: 8px; }
.hchip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 7px; border-radius: 999px;
  background: var(--bg0); border: 1px solid var(--bg2); color: var(--fg-hi);
}
.hchip:hover { border-color: var(--bg3); }
.hchip .box {
  width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--grey0); font-size: 11px;
  display: inline-flex; align-items: center; justify-content: center; color: transparent;
}
.hchip.done { --h: var(--green); background: color-mix(in srgb, var(--h) 14%, var(--bg0)); border-color: color-mix(in srgb, var(--h) 50%, transparent); }
.hchip.bad.done { --h: var(--red); }
.hchip.done .box { background: var(--h); border-color: var(--h); color: var(--bg0); }

/* ---------- habit page ---------- */
main.habitpage { padding: 22px 28px; overflow: auto; }
.hp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.hcard { margin: 0; padding: 14px 16px 12px 22px; }
.hc-top { display: flex; align-items: center; gap: 10px; }
.hc-top .title { font-size: 16px; font-weight: 700; }
.today-btn { margin-left: auto; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--bg3); color: var(--grey1); }
.today-btn:hover { border-color: var(--s); color: var(--s); }
.today-btn.done { background: var(--s); border-color: var(--s); color: var(--bg0); font-weight: 700; }
.hc-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 14px 0 3px; }
.hc-week button { height: 26px; border-radius: 7px; background: var(--bg2); }
.hc-week button.done { background: var(--s); }
.hc-week button:hover { outline: 1px solid var(--grey0); }
.hc-week button.today { outline: 1px solid var(--s); outline-offset: 1px; }
.hc-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; font-size: 10px; color: var(--grey0); text-align: center; }
.heat-label { font-size: 10px; color: var(--grey0); margin: 12px 0 4px; }
.heat { display: grid; grid-template-rows: repeat(7, 9px); grid-auto-flow: column; grid-auto-columns: 9px; gap: 3px; margin-bottom: 12px; }
.heat span { border-radius: 2px; background: var(--bg2); }
.heat span.on { background: var(--s); }
.hc-stats { display: flex; gap: 14px; align-items: baseline; font-size: 12px; color: var(--grey1); flex-wrap: wrap; }
.hc-stats b { color: var(--fg-hi); font-size: 15px; }
.trend { margin-left: auto; padding: 2px 9px; border-radius: 999px; font-size: 11px; border: 1px solid currentColor; }
.trend.green { color: var(--green); } .trend.red { color: var(--red); }
.trend.orange { color: var(--orange); } .trend.grey { color: var(--grey0); }
.hc-foot { display: flex; justify-content: flex-end; margin-top: 6px; height: 16px; }
.hc-foot button { font-size: 11px; color: var(--grey0); opacity: 0; }
.hcard:hover .hc-foot button { opacity: 1; }
.hc-foot button:hover { color: var(--red); }
.trait-seg { display: inline-flex; border: 1px solid var(--bg3); border-radius: 999px; padding: 2px; flex: none; }
.trait-seg button { padding: 2px 10px; border-radius: 999px; font-size: 11px; color: var(--grey1); }
.trait-seg button.on[data-trait="good"] { background: var(--green); color: var(--bg0); }
.trait-seg button.on[data-trait="bad"] { background: var(--red); color: var(--bg0); }

/* ---------- done today ---------- */
.done-item { display: flex; gap: 10px; padding: 3px 0; color: var(--grey1); }
.done-item .ok { color: var(--green); }
.done-item .time { margin-left: auto; color: var(--grey0); }

/* ---------- sidequest "again?" chips ---------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chips button { padding: 3px 10px; border-radius: 999px; border: 1px solid var(--bg3); color: var(--grey1); font-size: 11px; }
.chips button:hover { border-color: var(--yellow); color: var(--yellow); }
.chips button.last { border-color: color-mix(in srgb, var(--yellow) 50%, transparent); color: var(--yellow); }
details summary { cursor: pointer; color: var(--grey0); padding: 4px 2px; list-style: none; }
details summary::before { content: "▸ "; }
details[open] summary::before { content: "▾ "; }
details .card { opacity: .7; }

/* ---------- quest detail ---------- */
main.detail { padding: 22px 28px; overflow: auto; }
.backlink { color: var(--grey0); margin-bottom: 14px; }
.backlink:hover { color: var(--fg); }
.dgrid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 28px; align-items: start; max-width: 1200px; }
@media (max-width: 900px) { .dgrid { grid-template-columns: minmax(0, 1fr); } }
.why { color: var(--grey1); margin: 0 0 14px; font-style: italic; }
.stats { display: flex; gap: 26px; margin-bottom: 16px; }
.stats div b { display: block; font-size: 18px; font-weight: 700; color: var(--fg-hi); }
.stats div { color: var(--grey0); font-size: 11px; }
.general {
  display: flex; align-items: center; gap: 10px; width: 100%; margin-bottom: 12px; padding: 10px 14px;
  border: 1.5px dashed var(--bg3); border-radius: 12px; color: var(--grey1);
}
.general:hover { border-color: var(--yellow); color: var(--yellow); }
.general.running { border: 1px solid var(--yellow); color: var(--yellow); background: color-mix(in srgb, var(--yellow) 6%, transparent); }
.subs { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--bg2); }
.sub { display: flex; gap: 8px; align-items: center; padding: 2px 0; color: var(--grey1); font-size: 12px; cursor: pointer; }
.sub .box { width: 12px; height: 12px; border: 1px solid var(--grey0); border-radius: 3px; flex: none; }
.sub.done .box { background: var(--grey0); }
.sub.done span:last-child { text-decoration: line-through; color: var(--grey0); }
.sub.add-sub { color: var(--s); }
.entry { display: flex; gap: 10px; padding: 4px 0; color: var(--grey1); }
.entry .when { width: 92px; color: var(--grey0); flex: none; }
.entry .dur { margin-left: auto; }
.action { display: flex; gap: 10px; padding: 6px 0; color: var(--fg); cursor: pointer; }
.action:hover { color: var(--yellow); }

/* ---------- calendar ---------- */
main.calendar { padding: 18px 24px; overflow: auto; min-width: 0; }
.cal-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.cal-bar h1 { margin: 0; font-size: 18px; color: var(--fg-hi); }
.cal-bar .range { color: var(--grey0); }
.cal-bar .arrow { color: var(--grey1); width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--bg3); }
.cal-bar .arrow:hover { color: var(--yellow); border-color: var(--yellow); }
.seg { margin-left: auto; display: inline-flex; background: var(--bg0); border: 1px solid var(--bg2); border-radius: 999px; padding: 3px; }
.seg button { padding: 5px 16px; border-radius: 999px; color: var(--grey1); }
.seg button.on { background: var(--yellow); color: var(--bg0); font-weight: 700; }
.cal-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; align-items: start; }
.cal-body.planning { grid-template-columns: 290px minmax(0, 1fr); }
.days { display: grid; grid-template-columns: repeat(7, minmax(150px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.planning .days { grid-template-columns: repeat(7, minmax(128px, 1fr)); gap: 10px; }
.day { --c: var(--bg3); min-height: 380px; border-radius: 12px; padding: 0 3px 10px; margin: 0; }
.day .lane-head .num { color: var(--grey1); }
.day.today { --c: var(--yellow); }
.day.today .lane-head .num { color: var(--yellow); }
.day.past .lane-head h2 { color: var(--grey1); }
.day.drop { background: color-mix(in srgb, var(--yellow) 7%, transparent); outline: 1.5px dashed var(--yellow); outline-offset: 2px; }
.day .card { padding: 10px 10px 10px 18px; }
.day .card .title { font-size: 13px; }
.day .empty { color: var(--bg3); text-align: center; padding: 20px 0; font-size: 11px; }
.card.mini { background: transparent; border-style: dashed; padding-top: 7px; padding-bottom: 7px; }
.card.mini .title { font-size: 12px; color: var(--grey1); }
.card.mini .meta { margin-top: 6px; }
.card.missed { background: transparent; }
.card.missed .title { color: var(--grey1); }
.status { font-size: 11px; color: var(--grey1); margin-top: 8px; }
.status.ok { color: var(--green); }
.status.no { color: var(--grey0); }
.to-today { font-size: 11px; color: var(--blue); margin-left: 4px; }
.to-today:hover { text-decoration: underline; }
.card .x { position: absolute; top: 6px; right: 9px; color: var(--grey0); display: none; font-size: 14px; }
.card .x:hover { color: var(--red); }
.planning .card .x { display: block; }
[draggable="true"] { cursor: grab; }
.dragging { opacity: .4; }
.qdot { width: 9px; height: 9px; border-radius: 3px; flex: none; }

/* plan mode: source panel */
.source { position: sticky; top: 0; }
.source .hint { color: var(--grey0); font-size: 11px; margin: -4px 0 12px; }
/* collapsed: one slim row per quest; click opens it big with its tasks (only one open at a time) */
.src-quest {
  --q: var(--grey0); position: relative; background: var(--bg0); border: 1px solid var(--bg2);
  border-radius: 12px; margin-bottom: 8px; overflow: hidden; transition: border-color .15s;
}
.src-quest::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--q); }
.src-quest .head { display: flex; align-items: center; gap: 8px; padding: 9px 12px 9px 18px; color: var(--fg-hi); }
.src-quest .head:hover { background: var(--bg1); }
.src-quest .caret { color: var(--grey0); width: 14px; text-align: center; }
.src-quest.open { border-color: var(--q); background: color-mix(in srgb, var(--q) 7%, var(--bg0)); }
.src-quest.open::before { top: 14px; bottom: auto; height: 26px; }
.src-quest.open .head { font-size: 16px; font-weight: 700; padding: 12px 12px 4px 18px; }
.src-quest.open .head:hover { background: none; }
.src-quest .why { margin: 0 12px 10px 18px; font-size: 12px; }
.src-quest .drag-whole {
  margin: 0 12px 10px 18px; padding: 6px 10px; border: 1.5px dashed var(--q); border-radius: 8px;
  color: var(--q); font-size: 12px; display: flex; align-items: center; gap: 8px;
}
.src-tasks { padding: 0 12px 12px 18px; display: flex; flex-direction: column; gap: 6px; }
.src-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px;
  background: var(--bg1); border: 1px solid var(--bg2); border-left: 3px solid var(--q);
}
.src-item:hover { border-color: var(--bg3); border-left-color: var(--q); background: var(--bg2); }
.src-item .t { color: var(--grey0); font-size: 11px; margin-left: auto; }
.src-item .grip { margin-left: 8px; }
.grip { color: var(--grey0); margin-left: auto; letter-spacing: -2px; }
.src-side { padding: 9px 12px 9px 20px; margin-bottom: 8px; display: flex; align-items: center; }

/* ---------- stats ---------- */
main.statspage { padding: 22px 28px; overflow: auto; }
.st-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.st-bar h1 { margin: 0; font-size: 18px; color: var(--fg-hi); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 26px; }
.tile { background: var(--bg0); border: 1px solid var(--bg2); border-radius: 12px; padding: 14px 16px; }
.tile .lbl { color: var(--grey1); font-size: 12px; }
.tile .val { color: var(--fg-hi); font-size: 26px; font-weight: 700; margin: 2px 0; }
.tile .delta { color: var(--grey0); font-size: 11px; }
.st-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 28px; align-items: start; }
@media (max-width: 1000px) { .st-grid { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--bg0); border: 1px solid var(--bg2); border-radius: 12px; padding: 16px 18px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--fg); margin-bottom: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend em { font-style: normal; color: var(--grey1); }
.view-toggle { margin-left: auto; font-size: 11px; color: var(--grey1); border: 1px solid var(--bg3); border-radius: 999px; padding: 2px 10px; }
.view-toggle:hover { color: var(--yellow); border-color: var(--yellow); }
/* stacked bar chart: one y axis, recessive grid, 2px gaps between segments, 4px rounded tops */
.chart { position: relative; height: 230px; display: grid; grid-template-columns: 38px 1fr; }
.y-axis { position: relative; font-size: 10px; color: var(--grey0); }
.y-axis span { position: absolute; right: 8px; transform: translateY(50%); }
.plot { position: relative; display: flex; align-items: flex-end; gap: 10px; border-bottom: 1px solid var(--bg3); }
.plot .grid { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--bg2); pointer-events: none; }
.bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; cursor: default; position: relative; }
.bar-col:hover { background: color-mix(in srgb, var(--fg) 4%, transparent); border-radius: 6px 6px 0 0; }
.stack { width: min(34px, 70%); display: flex; flex-direction: column-reverse; gap: 2px; }
.stack div { border-radius: 1px; }
.stack div:last-child { border-radius: 4px 4px 1px 1px; }
.x-labels { display: grid; grid-template-columns: 38px 1fr; font-size: 10px; color: var(--grey0); margin-top: 6px; }
.x-labels > div { display: flex; gap: 10px; }
.x-labels span { flex: 1; text-align: center; }
.x-labels span.now { color: var(--yellow); }
.tip {
  position: absolute; z-index: 5; pointer-events: none; background: var(--bg1); border: 1px solid var(--bg3);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; min-width: 170px; display: none;
}
.tip b { color: var(--fg-hi); display: block; margin-bottom: 4px; }
.tip div { display: flex; align-items: center; gap: 6px; color: var(--fg); }
.tip div i { width: 8px; height: 8px; border-radius: 2px; }
.tip div em { margin-left: auto; font-style: normal; color: var(--grey1); padding-left: 12px; }
.tip .tot { border-top: 1px solid var(--bg3); margin-top: 4px; padding-top: 4px; }
.st-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.st-table th, .st-table td { text-align: right; padding: 5px 6px; border-bottom: 1px solid var(--bg2); }
.st-table th:first-child, .st-table td:first-child { text-align: left; }
.st-table th { color: var(--grey1); font-weight: 400; }
/* quest share: ranked horizontal bars */
.share { display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px 10px; align-items: center; font-size: 12px; }
.share .name { display: flex; align-items: center; gap: 6px; color: var(--fg-hi); }
.share .track { height: 8px; background: var(--bg2); border-radius: 4px; overflow: hidden; }
.share .fill { height: 100%; border-radius: 0 4px 4px 0; }
.share .num { color: var(--fg); text-align: right; }
.share .pct { color: var(--grey0); text-align: right; width: 34px; }
/* small bars: sidequests per period, habit weeks */
.mini { display: flex; align-items: flex-end; gap: 3px; height: 36px; }
.mini div { flex: 1; border-radius: 2px 2px 0 0; background: var(--s); min-height: 2px; }
.mini div.zero { background: var(--bg2); }
.hrow { display: grid; grid-template-columns: 110px 1fr 68px auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--bg2); }
.hrow:last-child { border-bottom: 0; }
.hrow .nm { display: flex; align-items: center; gap: 7px; color: var(--fg-hi); }
.hrow .nm i { width: 7px; height: 7px; border-radius: 50%; }
.hrow .avg { color: var(--grey1); font-size: 12px; text-align: right; }
.hrow .trend { margin-left: 0; }

/* ---------- focus mode ---------- */
.focus {
  position: fixed; inset: 0; z-index: 50; background: var(--bg0);
  display: none; flex-direction: column; align-items: center; justify-content: safe center;
  padding: 64px 24px 24px; overflow-y: auto;
}
.focus.open { display: flex; animation: fade .25s ease-out; }
@keyframes fade { from { opacity: 0; transform: scale(.985); } }
.focus .back { position: absolute; top: 20px; left: 24px; color: var(--grey0); }
.focus .back:hover { color: var(--fg); }
.f-quest { letter-spacing: 3px; text-transform: uppercase; font-size: 12px; }
.f-task { font-size: 30px; color: var(--fg-hi); margin: 6px 0 18px; text-align: center; }
.f-clock { font-size: clamp(56px, 11vw, 104px); color: var(--yellow); letter-spacing: 2px; line-height: 1; }
.f-actions { display: flex; gap: 12px; margin-top: 28px; position: relative; }
.f-stop { background: var(--yellow); color: var(--bg0); padding: 9px 26px; border-radius: 999px; }
.f-stop:hover { background: var(--orange); }
.f-switch { border: 1px solid var(--bg3); color: var(--grey1); padding: 9px 18px; border-radius: 999px; position: relative; }
.f-switch:hover { border-color: var(--yellow); color: var(--yellow); }
.f-switch .assign-menu { top: calc(100% + 8px); }
.f-subs { margin-top: 44px; width: min(360px, 100%); }
.f-subs .sub { font-size: 14px; padding: 6px 0; }
.f-subs .sub .box { width: 14px; height: 14px; }
.f-meta { margin-top: 40px; color: var(--grey0); font-size: 12px; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--bg1); border: 1px solid var(--bg3); border-radius: var(--radius); padding: 10px 16px;
  color: var(--fg); display: none;
}
.toast.show { display: block; animation: fade .2s ease-out; }
.toast b { color: var(--green); font-weight: 700; }

/* ---------- real app additions ---------- */
main { min-width: 0; }
.empty-hint { color: var(--grey0); font-size: 12px; padding: 6px 2px 12px; }
.card .title[contenteditable] { outline: none; border-radius: 4px; }
.card .title[contenteditable]:focus { background: var(--bg1); }
.rnd.del:hover { border-color: var(--red); color: var(--red); }
.card .tools { margin-left: auto; display: flex; gap: 6px; opacity: 0; }
.card:hover .tools, .card:focus-within .tools { opacity: 1; }
.sub .x-sub { margin-left: auto; color: var(--grey0); opacity: 0; }
.sub:hover .x-sub { opacity: 1; }
.sub .x-sub:hover { color: var(--red); }
.sub-add { display: flex; gap: 8px; align-items: center; padding: 2px 0; font-size: 12px; }
.sub-add input { flex: 1; background: none; border: 0; outline: none; color: var(--fg); padding: 2px 0; }
.sub-add input::placeholder { color: color-mix(in srgb, var(--s) 70%, var(--grey0)); }
.why-edit { width: 100%; background: none; border: 0; outline: none; color: var(--grey1); font-style: italic; padding: 0; margin: 0 0 14px; resize: none; }
.why-edit:focus { color: var(--fg); }
.entry .x-entry { color: var(--grey0); opacity: 0; }
.entry:hover .x-entry { opacity: 1; }
.entry .x-entry:hover { color: var(--red); }
.entry .what { cursor: pointer; }
.entry .what:hover { color: var(--yellow); }
.entry .live { color: var(--yellow); }
.offline { position: fixed; top: 0; left: 0; right: 0; z-index: 70; background: var(--red); color: var(--bg0);
  text-align: center; padding: 4px; font-size: 12px; display: none; }
.offline.show { display: block; }
.toast.err b { color: var(--red); }
.add.small { padding: 3px 10px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--c) 50%, transparent);
  color: var(--c); font-size: 11px; }
.add.small:hover { background: color-mix(in srgb, var(--c) 12%, transparent); }
.chips button.on { background: var(--yellow); border-color: var(--yellow); color: var(--bg0); font-weight: 700; }
.chips .lbl { font-size: 11px; color: var(--grey0); align-self: center; margin-right: 2px; }
.date-pick { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.card .note { color: var(--grey1); font-size: 12px; margin-top: 2px; }
.undo { font-size: 11px; color: var(--grey0); margin-left: auto; }
.undo:hover { color: var(--fg); text-decoration: underline; }
.heat span.fut { visibility: hidden; }
.hc-foot { gap: 12px; }
/* done page */
main.donepage { padding: 22px 28px; overflow: auto; }
.done-days { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 22px; align-items: start; }
.done-days .lane { margin: 0; }
.day-today { --c: var(--yellow); }
.block { display: flex; gap: 10px; padding: 3px 0; color: var(--grey1); align-items: center; }
.block .t { color: var(--grey0); width: 96px; flex: none; font-size: 12px; }
.block .q { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.block .time { margin-left: auto; color: var(--grey0); }
.done-sec { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--grey0); margin: 8px 0 2px; }
.done-sec:first-child { margin-top: 0; }
a.link { color: var(--c, var(--aqua)); text-decoration: none; }
.block .time, .done-item .time { white-space: nowrap; flex: none; }
.block .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-menu { z-index: 80; min-width: 200px; }
.card[data-pid]:hover .x { display: block; }
.status .to-today { background: none; border: 0; padding: 0; cursor: pointer; }
.cal-bar a.arrow { display: grid; place-items: center; text-decoration: none; }
.cal-title-hint { color: var(--grey0); font-size: 12px; }
/* login */
.login { position: fixed; inset: 0; z-index: 90; background: var(--bg-dim); display: grid; place-items: center; padding: 16px; }
.login form { width: min(320px, 100%); display: flex; flex-direction: column; gap: 12px; align-items: stretch; text-align: center; }
.login .logo { color: var(--yellow); font-size: 34px; }
.login h1 { margin: 0 0 10px; font-size: 20px; color: var(--fg-hi); letter-spacing: 2px; }
.login input { background: var(--bg0); border: 1px solid var(--bg3); border-radius: 10px; padding: 10px 12px; outline: none; }
.login input:focus { border-color: var(--yellow); }
.login button { background: var(--yellow); color: var(--bg0); border-radius: 10px; padding: 10px; font-weight: 700; }
.login button:hover { background: var(--orange); }
.login-err { color: var(--red); min-height: 1.5em; font-size: 12px; }

/* ---------- touch screens: no hover, so show the hover-only tools ---------- */
@media (hover: none) {
  .card .tools, .sub .x-sub, .entry .x-entry, .hc-foot button { opacity: 1; }
  .card[data-pid] .x { display: block; }
}

/* ---------- phone: bottom tab bar, one column everywhere ---------- */
@media (max-width: 700px) {
  body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; height: 100dvh; }
  .wide-only { display: none; }

  nav {
    grid-row: 3; flex-direction: row; gap: 0; padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--bg1);
  }
  nav .logo, nav .spacer { display: none; }
  nav button { width: auto; flex: 1; padding: 6px 0; }
  nav #logout { flex: 0 0 44px; }

  .timer { padding: calc(8px + env(safe-area-inset-top)) 12px 8px; gap: 10px; min-height: 52px; }
  .timer .quest { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
  .timer .sep { display: none; }
  #assign-label { display: inline-block; max-width: 30vw; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
  .timer .assign-menu { position: fixed; top: calc(56px + env(safe-area-inset-top)); left: 12px; right: 12px; min-width: 0; }
  .timer .clock { font-size: 20px; letter-spacing: 0; }
  .stop { width: 34px; height: 34px; flex: none; }

  main.start, main.detail, main.calendar, main.habitpage, main.statspage, main.donepage { padding: 14px 12px 28px; }
  main.start { gap: 0; }
  .lane { margin-bottom: 22px; }

  /* calendar: days stacked vertically instead of 7 columns */
  .cal-bar { gap: 8px; }
  .cal-bar .range { flex-basis: 100%; order: 5; }
  .cal-bar .seg { order: 6; margin-left: 0; }
  .days, .planning .days { grid-template-columns: minmax(0, 1fr); overflow: visible; gap: 4px; }
  .day { min-height: 0; }
  .day .empty { padding: 4px 0 10px; text-align: left; }
  .cal-body.planning { grid-template-columns: minmax(0, 1fr); }
  .source { position: static; }

  .st-bar { flex-wrap: wrap; gap: 8px; }
  .st-bar .seg { margin-left: 0; flex-basis: 100%; }
  .st-bar .seg button { flex: 1; padding: 5px 6px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 20px; }
  .tile { padding: 10px 12px; }
  .tile .val { font-size: 20px; }
  .hrow { grid-template-columns: 90px 1fr 56px auto; gap: 8px; }

  .hp-grid, .done-days { grid-template-columns: minmax(0, 1fr); }
  .assign-menu { max-width: calc(100vw - 24px); }

  .focus { padding: calc(56px + env(safe-area-inset-top)) 16px 24px; }
  .focus .back { top: calc(16px + env(safe-area-inset-top)); left: 16px; }
  .focus .back .muted { display: none; }
  .f-task { font-size: 22px; }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); max-width: calc(100vw - 24px); }
}
@media (hover: none) {
  /* a tap leaves :hover stuck on the last tapped tab */
  nav button:hover:not(.on) { background: none; color: var(--grey0); }
}
