:root {
  --bg: #0f172a; --panel: #1e293b; --panel-2: #273449; --text: #e2e8f0; --muted: #94a3b8;
  --cool: #1f2937; --hot: #ea580c; --accent: #38bdf8; --run: #22c55e; --danger: #f87171;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
[hidden] { display: none !important; }
button, select, input { font: inherit; color: inherit; }
button { background: var(--panel-2); border: 1px solid #334155; border-radius: 10px; padding: 10px 14px; min-height: 44px; cursor: pointer; }
button.primary { background: var(--accent); color: #082f49; border-color: var(--accent); font-weight: 600; }
button:disabled { opacity: .45; cursor: not-allowed; }
input, select { background: var(--panel); border: 1px solid #334155; border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%; }
.error { color: var(--danger); min-height: 1.35em; margin: 8px 0 0; }

/* login */
#login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
#login form { width: min(360px, 100%); display: grid; gap: 14px; background: var(--panel); padding: 24px; border-radius: var(--radius); }
#login h1 { margin: 0 0 4px; }
#login .hint { margin: -6px 0 0; color: var(--muted); font-size: .88rem; }
#login .note { margin: 0; min-height: 1.35em; font-size: .9rem; }
#login .auth-links { display: flex; justify-content: space-between; gap: 12px; margin: 0; font-size: .9rem; }
#login .auth-links a { color: var(--accent); text-decoration: none; }
#login .auth-links a:last-child { margin-left: auto; }
#login .google-box { display: grid; gap: 10px; justify-items: center; }
#login .google-btn { min-height: 44px; }
#login .or { margin: 0; color: var(--muted); font-size: .82rem; text-align: center; }
label { display: grid; gap: 6px; color: var(--muted); font-size: .9rem; }

/* header and tabs */
/* top band: the name with Tasks, Entries and Sign out on the first line; the view switch and the menu on the second; one line on a wide screen */
header { display: flex; flex-direction: column; gap: 6px; padding: 8px 12px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.hrow { display: flex; align-items: center; gap: 6px; min-width: 0; }
.hrow:first-child { justify-content: space-between; }
.hbtns { display: flex; gap: 6px; flex: 0 0 auto; }
header h1 { font-size: .88rem; line-height: 1.1; margin: 0; white-space: nowrap; }
header button, header select { min-height: 40px; padding: 6px 8px; font-size: .85rem; }
#btn-logout, #btn-entries { white-space: nowrap; min-height: 34px; padding: 4px 10px; }
header select { flex: 1 1 0; min-width: 0; }
#tz-badge { flex: 0 0 auto; margin-right: auto; padding: 3px 8px; border: 1px solid #334155; border-radius: 999px; font-size: .74rem; color: var(--muted); white-space: nowrap; cursor: help; }
@media (min-width: 700px) {
  header { flex-direction: row; align-items: center; }
  .hrow, .hbtns { display: contents; }
  header h1 { order: 0; }
  #view-toggle { order: 1; }
  header select { order: 2; max-width: 240px; }
  #tz-badge { order: 3; margin-right: 0; }
  #btn-entries { order: 4; margin-left: auto; }
  #btn-logout { order: 5; }
}
#banner { margin: 0 12px 8px; padding: 10px 12px; border-radius: 10px; background: #78350f; color: #fde68a; cursor: pointer; }
#tabbar { display: flex; gap: 6px; padding: 0 12px 8px; align-items: stretch; }
#tabs { position: relative; display: flex; gap: 6px; flex: 0 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tab { display: flex; align-items: center; gap: 8px; white-space: nowrap; padding: 6px 6px 6px 12px; background: var(--panel); border: 1px solid #334155; border-radius: 10px; }
.tab.active { border-color: var(--accent); background: #0c4a6e; }
.tab .tab-name { cursor: pointer; display: grid; line-height: 1.15; min-height: 36px; align-content: center; }
.tab .tab-name small { color: var(--muted); font-variant-numeric: tabular-nums; }
.tab .tab-name small.on { color: var(--run); }
.tab .close { min-height: 36px; min-width: 36px; padding: 0; border-radius: 8px; }
/* Multitask and New task share the tab band: they take whatever width the tabs leave, so each new tab makes them smaller */
#actions { display: flex; gap: 6px; flex: 1 1 0; min-width: 124px; container-type: inline-size; }
.tile-button { flex: 1 1 0; min-width: 0; padding: 4px 6px; border-style: dashed; color: var(--accent); white-space: nowrap; overflow: hidden; font-size: .85rem; }
.tile-button .short { display: none; }
@container (max-width: 200px) { .tile-button .full { display: none; } .tile-button .short { display: inline; } }

/* tiles: a treemap. Position and size of every tile are set by app.js from the time logged; colour = heat. */
#tiles-row { display: flex; gap: 8px; align-items: flex-start; margin: 0 12px 24px; }
#tiles-row[hidden] { display: none; }
#tiles { position: relative; flex: 1 1 auto; min-width: 0; }
/* the list on the right: every task, most time since inception first; scrolls inside, tap = start/stop */
#picker { flex: 0 0 clamp(116px, 26vw, 260px); display: flex; flex-direction: column; min-height: 0;
  background: var(--panel); border: 1px solid #334155; border-radius: 10px; overflow: hidden; }
#picker .pk-head { flex: 0 0 auto; display: flex; align-items: center; gap: 4px; padding: 4px 4px 4px 10px; font-size: .78rem; font-weight: 600; border-bottom: 1px solid #334155; }
#picker .pk-title { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#picker .pk-title span { color: var(--muted); font-weight: 400; }
#pk-find { flex: 0 0 auto; width: 30px; height: 28px; padding: 0; border-radius: 6px; font-size: .85rem; line-height: 1; background: transparent; color: var(--muted); border: 1px solid transparent; }
#pk-find:hover, #pk-find.on { color: var(--text); border-color: #334155; background: rgba(148, 163, 184, .08); }
#pk-searchbar { flex: 0 0 auto; padding: 6px; border-bottom: 1px solid #334155; }
#pk-searchbar[hidden] { display: none; }
#pk-search { width: 100%; box-sizing: border-box; padding: 6px 8px; font-size: .8rem; min-height: 0; }
#pk-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: block; }
.pk-row { display: grid; grid-template-columns: 8px 1fr auto; gap: 2px 7px; align-items: center; width: 100%; min-height: 44px;
  padding: 6px 8px; border: 0; border-bottom: 1px solid #26344a; border-radius: 0; background: transparent; color: var(--text); text-align: left; font-size: .8rem; }
.pk-row:hover { background: rgba(148, 163, 184, .08); }
.pk-row i { width: 8px; height: 8px; border-radius: 2px; display: block; }
.pk-row .nm { min-width: 0; overflow-wrap: anywhere; line-height: 1.25; color: #cbd5e1; }
.pk-row .nm b { color: var(--text); font-weight: 600; }
.pk-row .nm small { color: var(--muted); }
.pk-row .tm { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .74rem; white-space: nowrap; }
.pk-row.idle .nm, .pk-row.idle .nm b { color: #94a3b8; }
.pk-row.grp .nm, .pk-row.grp .nm b { color: #94a3b8; font-weight: 500; }   /* bio.*: a group (the sum of its tasks), at the bottom */
.pk-row.running { background: rgba(34, 197, 94, .14); box-shadow: inset 3px 0 0 var(--run); }
.pk-row.running .tm { color: #86efac; }
.pk-row.elsewhere { background: rgba(34, 197, 94, .08); box-shadow: inset 3px 0 0 var(--run); }
.pk-row.elsewhere .tm { color: #86efac; }
.pk-empty { color: var(--muted); padding: 10px; font-size: .8rem; }
@media (max-width: 480px) {
  #tiles-row { gap: 6px; }
  .pk-row { grid-template-columns: 1fr; padding: 6px 7px; font-size: .74rem; }
  .pk-row i { display: none; }
  .pk-row { box-shadow: inset 3px 0 0 var(--sw, transparent); }
}
.tile { position: absolute; background: var(--panel); border-radius: 10px; overflow: hidden; }
.tile .tile { background: #172033; }
.tile .body { position: absolute; }
/* a top-level box's share of the whole: one big faint number over the box; the tiles show through, taps go through */
.share-mark { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none; z-index: 2; font-weight: 800; line-height: 1; letter-spacing: -.04em; white-space: nowrap; overflow: hidden;
  color: rgba(255, 255, 255, .13); font-variant-numeric: tabular-nums; }
.head { display: flex; flex-wrap: wrap; align-content: center; align-items: baseline; gap: 0 8px; width: 100%; height: 100%;
  padding: 4px 8px; text-align: left; overflow: hidden; border: 2px solid transparent; border-radius: 10px; min-height: 0;
  background: var(--hbg, var(--cool)); color: var(--hfg, var(--text)); }
.tile:not(.leaf) > .head { height: var(--hh, 30px); border-radius: 10px 10px 4px 4px; padding: 0 34px 0 8px; align-content: center; flex-wrap: nowrap; }
.head .name { font-weight: 600; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head .total { flex: 0 0 auto; opacity: .85; font-variant-numeric: tabular-nums; font-size: .9em; }
.head .share { display: none; opacity: .75; font-size: .75rem; }
.head .run { flex: 1 0 100%; font-variant-numeric: tabular-nums; font-weight: 700; color: #86efac; text-shadow: 0 0 2px rgba(0,0,0,.6); display: none; }
.head .elsewhere { flex: 1 0 100%; color: var(--muted); font-size: .8rem; display: none; }
.head.narrow .total { display: none; }
.tile.running > .head { border-color: var(--run); animation: pulse 1.6s ease-in-out infinite; }
.tile.running > .head .run { display: block; }
.tile.running > .head.compact .run { flex: 0 0 auto; }
.tile.running > .head.compact .total { display: none; }
.tile.elsewhere > .head { border-color: var(--run); box-shadow: inset 0 0 0 1px var(--run); }   /* multitasking: running in another tab is green too (no pulse) */
.tile.elsewhere > .head:disabled, .pk-row.elsewhere:disabled { opacity: 1; cursor: default; }
.tile.elsewhere > .head .run { display: block; }
.tile.elsewhere > .head.compact .run { flex: 0 0 auto; }
.tile.elsewhere > .head.compact .total { display: none; }
.tile.elsewhere > .head .elsewhere { font-size: .72rem; }
.tile.elsewhere > .head .elsewhere { display: block; }
.tile.elsewhere > .head.compact .elsewhere { display: none; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(34, 197, 94, .25); } }
.empty { color: var(--muted); padding: 24px 12px; text-align: center; }

/* dialogs */
dialog { background: var(--panel); color: var(--text); border: 1px solid #334155; border-radius: var(--radius); padding: 18px; width: min(520px, calc(100% - 24px)); }
dialog::backdrop { background: rgba(2, 6, 23, .7); }
dialog h2 { margin: 0 0 12px; }
dialog form { display: grid; gap: 12px; }
menu { display: flex; gap: 8px; justify-content: flex-end; padding: 0; margin: 12px 0 0; }
#entries-list { display: grid; gap: 8px; max-height: 60vh; overflow: auto; }
.entry { background: var(--panel-2); border-radius: 10px; padding: 10px; display: grid; gap: 6px; font-size: .92rem; }
.entry .k { font-weight: 600; }
.entry .when { color: var(--muted); font-variant-numeric: tabular-nums; }
.entry .row { display: flex; gap: 8px; flex-wrap: wrap; }
.entry input { min-height: 38px; }
#toast { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #020617; border: 1px solid #334155;
  padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 24px); z-index: 20; }
#toast.show { opacity: 1; pointer-events: auto; }
#toast button { margin-left: 12px; min-height: 32px; padding: 2px 14px; }

/* toolbar: view switch (before the period) and the period */
header select { text-overflow: ellipsis; }
#view-toggle { display: flex; border: 1px solid #334155; border-radius: 10px; overflow: hidden; flex: 0 0 auto; }
#view-toggle button { border: 0; border-radius: 0; background: var(--panel); min-height: 40px; padding: 6px 9px; }
#view-toggle button.on { background: #0c4a6e; color: #e0f2fe; font-weight: 600; }
.muted { color: var(--muted); margin: 0; }

/* tabs show the full path of the running tile */
.tab .tab-name small.path { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- treemap polish: zero-time tiles look inactive, big tiles get a large label, zoom button on parents ---- */
.head.zero { --hbg: #172033; --hfg: #8a99b0; border-color: rgba(148, 163, 184, .12); }
.head.zero .total { display: none; }
.head.big { display: flex; flex-direction: column; flex-wrap: nowrap; justify-content: center; align-items: flex-start; gap: 2px; padding: 8px 10px; }
.head.big .name { flex: 0 0 auto; white-space: normal; max-height: 2.4em; overflow: hidden; font-size: var(--fs, 16px); line-height: 1.2; }
.head.big .total { flex: 0 0 auto; font-size: calc(var(--fs, 16px) * .95); font-weight: 700; opacity: .95; }
.head.big .share { display: block; flex: 0 0 auto; }
.head.big .run, .head.big .elsewhere { flex: 0 0 auto; }
/* groups (tiles with sub-tasks): a framed box with a section header, so its sub-tiles read as belonging to it.
   The header keeps the heat colour as a left accent bar instead of a full fill, which leaves fills to the leaves. */
.tile.group { box-shadow: inset 0 0 0 1px var(--gb); }
.tile.group.g0 { --gb: #64748b; background: #1b2638; }
.tile.group.g1 { --gb: #475569; background: #141d2d; }
.tile.group.g2 { --gb: #3b4a61; background: #111827; }
.tile.group > .head { background: rgba(148, 163, 184, .07); color: #e2e8f0; border-radius: 10px 10px 0 0;
  box-shadow: inset 4px 0 0 var(--hbg, #334155), inset 0 -1px 0 var(--gb); padding-left: 12px; }
.tile.group > .head.zero { color: #8a99b0; }
.tile.group > .head .total { color: #94a3b8; opacity: 1; }
.tile.group.g0 > .head .name { letter-spacing: .02em; font-size: .82rem; font-weight: 700; }   /* the task as typed: no capitals */
.tile.group.g1 > .head .name, .tile.group.g2 > .head .name { font-size: .8rem; font-weight: 600; }
.tile.group > .head .total { font-size: .76rem; }
.tile.leaf > .head:not(.big) { font-size: var(--fs, 14px); padding: 3px 6px; }
.zoom { position: absolute; top: 2px; right: 3px; width: 28px; height: 24px; min-height: 0; padding: 0; border-radius: 6px; z-index: 1;
  background: rgba(2, 6, 23, .28); border: 1px solid rgba(255, 255, 255, .22); color: inherit; font-size: .85rem; line-height: 1; }
.tile:not(.leaf) > .zoom { top: calc((var(--hh, 30px) - 24px) / 2); }

/* legend row under the tab band */
#legend { padding: 0 12px 8px; display: grid; gap: 6px; }
#legend-cap { color: var(--muted); font-size: .74rem; }
#legend-row { display: flex; gap: 10px; align-items: center; }
#legend-scale { flex: 1; display: flex; align-items: center; gap: 6px; font-size: .7rem; color: var(--muted); min-width: 0; }
#lg-bar { flex: 1; height: 10px; border-radius: 5px; border: 1px solid rgba(148, 163, 184, .25); }
#lg-lo, #lg-hi { white-space: nowrap; }

/* zoom breadcrumb */
#crumbs { display: flex; gap: 4px; align-items: center; padding: 0 12px 8px; overflow-x: auto; scrollbar-width: none; white-space: nowrap; font-size: .85rem; }
#crumbs button { min-height: 32px; padding: 3px 10px; }
#crumbs .sep { color: var(--muted); }
#crumbs .here { font-weight: 600; padding: 0 4px; }

/* sankey: a light card so the bands read like a finance Sankey */
#sankey { padding: 0 12px 24px; }
#sk-scroll { overflow-x: auto; border: 1px solid #cbd5e1; border-radius: var(--radius); background: #f8fafc; }
#sk-svg { display: block; user-select: none; -webkit-user-select: none; }
#sk-svg text { fill: #0f172a; font-size: 12.5px; paint-order: stroke; stroke: rgba(248, 250, 252, .85); stroke-width: 3px; stroke-linejoin: round; pointer-events: none; }
#sk-svg .nm { font-weight: 500; fill: #334155; }
#sk-svg .val { font-weight: 700; }
#sk-svg .node { cursor: pointer; }
#sk-svg .node:hover rect.bar { filter: brightness(1.08); }
#sk-svg .node.sel rect.bar { stroke: #0f172a; stroke-width: 2.5px; }
#sk-svg .node.running rect.bar { stroke: #16a34a; stroke-width: 2.5px; }
#sk-svg .link { fill: none; pointer-events: none; }
#sk-note { margin: 8px 2px 0; font-size: .78rem; }
#sk-detail { margin-top: 10px; padding: 12px; background: var(--panel); border: 1px solid #334155; border-radius: var(--radius); display: grid; gap: 6px; }
#sk-detail h3 { margin: 0; font-size: 1rem; }
#sk-detail .kv { color: var(--muted); font-size: .88rem; }
#sk-detail .kv b { color: var(--text); font-weight: 600; }
#sk-detail .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

/* the task box in the entry pop-up: type to search; the list filters as you type; a task that is not there is created */
.combo { position: relative; }
.sugg { list-style: none; margin: 4px 0 0; padding: 4px; max-height: 240px; overflow-y: auto; background: var(--panel-2);
  border: 1px solid #334155; border-radius: 10px; }
.sugg li { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 7px; cursor: pointer; min-height: 40px; }
.sugg li i { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 3px; }
.sugg li span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sugg li small { flex: 0 0 auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.sugg li.on, .sugg li:hover { background: #0c4a6e; }
.sugg li.new { color: var(--accent); }
.sugg li.none { color: var(--muted); cursor: default; }

/* today bar (Tiles and Sankey, period Today) */
#strip-top { padding: 0 12px 10px; }
.ds-title { font-size: .8rem; color: var(--muted); margin: 0 0 5px; }
.ds-title b { color: var(--accent); letter-spacing: .06em; }
.ds-bar { position: relative; display: grid; gap: 2px; padding: 2px; background: #172033; border: 1px solid #334155; border-radius: 8px; overflow: hidden;
  background-image: linear-gradient(to right, rgba(148, 163, 184, .16) 1px, transparent 1px); background-size: 12.5% 100%; }
.ds-track { position: relative; height: 24px; }
.ds-track i { position: absolute; top: 0; bottom: 0; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18); overflow: hidden; cursor: pointer; }
.ds-track i span { display: block; padding: 0 4px; font-size: .68rem; line-height: 24px; color: #fff; white-space: nowrap; font-style: normal; text-shadow: 0 1px 1px rgba(0, 0, 0, .5); }
.ds-track i.run { box-shadow: inset 0 0 0 1px var(--run), 0 0 4px var(--run); }
.ds-now { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #f43f5e; z-index: 2; pointer-events: none; }
.ds-axis { position: relative; height: 15px; font-size: .66rem; color: var(--muted); margin: 2px 2px 0; }
.ds-axis span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.ds-axis span:first-child { transform: none; }
.ds-axis span:last-child { transform: translateX(-100%); }
.ds-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .74rem; color: var(--muted); margin-top: 5px; }
.ds-legend .chip { display: inline-flex; align-items: center; gap: 5px; }
.ds-legend .chip i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* calendar: a group per day, newest first; time runs left to right */
#calendar { padding: 0 12px 24px; }
#cal-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
#cal-bar button { min-height: 38px; padding: 6px 12px; }
#cal-note { font-size: .76rem; margin-left: auto; text-align: right; }
#cal-bar { flex-wrap: wrap; }
#cal-smooth { display: flex; border: 1px solid #334155; border-radius: 10px; overflow: hidden; }
#cal-smooth button { border: 0; border-radius: 0; background: var(--panel); }
#cal-smooth button.on { background: #0c4a6e; color: #e0f2fe; font-weight: 600; }
/* a smoothed block: the parts that fill a gap are striped, so you can see what was added */
.cb .fill { position: absolute; top: 0; bottom: 0; pointer-events: none;
  background: repeating-linear-gradient(135deg, rgba(255, 255, 255, .34) 0 3px, transparent 3px 7px); }
#sm-list { max-height: 40vh; overflow: auto; margin: 0 0 4px; padding-left: 18px; font-size: .82rem; color: #cbd5e1; display: grid; gap: 3px; }
#sm-summary { margin: 4px 0 6px; font-weight: 600; }
#cal-scroll { overflow-x: auto; border: 1px solid #334155; border-radius: var(--radius); background: var(--panel); padding: 4px 6px 8px; }
#cal-body { min-width: 100%; }
.cd { padding: 8px 0 4px; border-bottom: 1px solid rgba(148, 163, 184, .16); }
.cd:last-child { border-bottom: 0; }
.cd-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: .82rem; }
.cd-head b { position: sticky; left: 4px; }                /* the date and the totals stay in view while the widened grid is scrolled sideways */
.cd-head span { position: sticky; right: 4px; }
.cd-head span { color: var(--muted); font-size: .72rem; }
.cd.today .cd-head b { color: var(--accent); }
.cd-axis { position: relative; height: 13px; font-size: .62rem; color: var(--muted); }
.cd-axis span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.cd-axis span:first-child { transform: none; }
.cd-axis span:last-child { transform: translateX(-100%); }
.cd-tracks { position: relative; display: grid; gap: 3px; }
.cd-track { position: relative; height: 28px; background: #172033; border-radius: 6px; cursor: cell;
  background-image: linear-gradient(to right, rgba(148, 163, 184, .16) 1px, transparent 1px); background-size: 12.5% 100%; }
.cb { position: absolute; top: 0; bottom: 0; min-height: 0; padding: 0 5px; border: 1px solid rgba(255, 255, 255, .2); border-radius: 5px; color: #fff;
  font-size: .7rem; text-align: left; overflow: hidden; white-space: nowrap; }
.cb .bn { display: block; overflow: hidden; text-overflow: ellipsis; font-weight: 600; text-shadow: 0 1px 1px rgba(0, 0, 0, .45); pointer-events: none; }
.cb.running { border-color: var(--run); box-shadow: 0 0 0 2px rgba(34, 197, 94, .35); }
.cb.dragging { z-index: 3; box-shadow: 0 0 0 2px #fff; overflow: visible; }
.cb .grip { position: absolute; top: 0; bottom: 0; width: min(12px, 30%); cursor: ew-resize; touch-action: none; z-index: 1; }
.cb .grip.l { left: 0; }
.cb .grip.r { right: 0; }
.cb .grip::after { content: ""; position: absolute; top: 50%; left: 50%; height: 14px; margin: -7px 0 0 -1px; width: 2px; border-radius: 2px; background: rgba(255, 255, 255, .6); pointer-events: none; }
.cd-now { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #f43f5e; z-index: 2; pointer-events: none; }
#cal-more { display: block; margin: 10px auto 0; }

/* Entries: the raw table */
dialog.wide { width: min(980px, calc(100% - 16px)); }
#raw-scroll { max-height: 62vh; overflow: auto; border: 1px solid #334155; border-radius: 8px; }
#raw-table { border-collapse: collapse; width: 100%; font: .74rem/1.3 ui-monospace, SFMono-Regular, Consolas, monospace; }
#raw-table th { position: sticky; top: 0; background: #172033; text-align: left; padding: 5px 8px; border-bottom: 1px solid #334155; white-space: nowrap; }
#raw-table td { padding: 4px 8px; border-bottom: 1px solid rgba(148, 163, 184, .12); white-space: nowrap; }
#raw-table td.null { color: var(--muted); font-style: italic; }
#raw-table th.sortable { cursor: pointer; user-select: none; }
#raw-table th.sorted { color: #4ade80; }
#raw-table td.ed { cursor: text; text-decoration: underline dotted #475569; text-underline-offset: 3px; }
#raw-table td.ed:hover { background: rgba(74, 222, 128, .1); }
#raw-table td.editing { padding: 1px 2px; }
#raw-table td.editing input { min-height: 0; height: 26px; width: auto; min-width: 180px; padding: 2px 6px; font: inherit; }
#raw-table tr.saved td { background: rgba(74, 222, 128, .22); transition: background .6s; }
#raw-table td.del { padding: 0 4px; }
#raw-table td.del button { min-height: 0; height: 24px; width: 24px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: .8rem; }
#raw-table td.del button:hover { color: #f87171; }
#raw-note { font-size: .76rem; margin-bottom: 6px; }

#ver { text-align: center; color: var(--muted); font-size: .68rem; padding: 4px 0 18px; }

/* width handle along the top of the Daily trend grid: a two-way arrow on hover, drag to narrow or widen the time scale */
.cd-resizer { position: relative; height: 24px; margin: 0 0 2px; cursor: ew-resize; touch-action: none; border-radius: 6px; user-select: none; -webkit-user-select: none;
  border-bottom: 1px dashed rgba(148, 163, 184, .28); }
.cd-resizer:hover, .cd-resizer[data-drag] { background: rgba(56, 189, 248, .10); border-bottom-color: var(--accent); }
.rz-pill { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); padding: 1px 10px; border-radius: 999px; font-size: .72rem; line-height: 1.4;
  background: var(--accent); color: #082f49; font-weight: 700; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .12s; box-shadow: 0 1px 4px rgba(0, 0, 0, .4); }
.cd-resizer:hover .rz-pill, .cd-resizer[data-drag] .rz-pill { opacity: 1; }
@media (hover: none) {           /* a finger cannot hover: show the handle all the time, in the middle of the screen */
  .rz-pill { position: sticky; left: 50%; opacity: .75; }
  .cd-resizer { display: flex; justify-content: flex-start; align-items: center; }
}

/* ---------- Reports ---------- */
#reports { padding: 0 12px 28px; }
#rp-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 6px; }
#rp-range { display: flex; border: 1px solid #334155; border-radius: 10px; overflow: hidden; flex-wrap: wrap; }
#rp-range button { border: 0; border-radius: 0; background: var(--panel); min-height: 36px; padding: 4px 10px; font-size: .82rem; }
#rp-range button.on { background: #0c4a6e; color: #e0f2fe; font-weight: 600; }
#rp-actions { display: flex; gap: 6px; flex-wrap: wrap; }
#rp-actions button { min-height: 36px; padding: 4px 10px; font-size: .8rem; }
#rp-note { font-size: .76rem; margin: 0 0 10px; }
#rp-body { display: grid; gap: 12px; transition: opacity .15s; }
#rp-body.loading { opacity: .55; }
.rp-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.rp-hero, .rp-tile { background: var(--panel); border: 1px solid #334155; border-radius: var(--radius); padding: 10px 12px; display: grid; gap: 2px; align-content: start; min-width: 0; }
.rp-hero { grid-column: 1 / -1; }
.rp-hero .val { font-size: 3rem; font-weight: 650; line-height: 1.05; }
.rp-tile .val { font-size: 1.35rem; font-weight: 600; line-height: 1.2; }
.rp-hero .lbl, .rp-tile .lbl { color: var(--muted); font-size: .76rem; }
.rp-hero .sub, .rp-tile .sub { color: var(--muted); font-size: .72rem; overflow: hidden; text-overflow: ellipsis; }
.rp-card { background: var(--panel); border: 1px solid #334155; border-radius: var(--radius); padding: 12px; min-width: 0; }
.rp-card h3 { margin: 0; font-size: .98rem; }
.rp-sub { margin: 2px 0 8px; color: var(--muted); font-size: .76rem; }
.rp-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .76rem; color: #cbd5e1; margin: 0 0 6px; }
.rp-legend .it { display: inline-flex; align-items: center; gap: 6px; }
.rp-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.rp-chart svg { display: block; overflow: visible; }
.rp-every-bar { display: flex; gap: 8px; align-items: center; margin: 0 0 8px; }
.rp-cat { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--muted); }
.rp-cat select { min-height: 36px; padding: 4px 8px; font-size: .85rem; max-width: 70vw; }
.rp-days { display: flex; min-width: 0; }
.rp-days-axis { flex: 0 0 40px; }
.rp-days-scroll { flex: 1 1 auto; min-width: 0; overflow-x: auto; overflow-y: hidden; }
.rp-days svg { display: block; }
.rp-card .tick.mon { fill: #cbd5e1; font-weight: 600; }
.rp-card .grid { stroke: #2c3a4f; stroke-width: 1; }
.rp-card .base { stroke: #475569; stroke-width: 1; }
.rp-card .tick { fill: #94a3b8; font-size: 10.5px; font-variant-numeric: tabular-nums; }
.rp-card .num { fill: #e2e8f0; font-size: 9.5px; font-weight: 600; font-variant-numeric: tabular-nums; pointer-events: none; }
.rp-card .col:hover path, .rp-card .col:focus-within path { filter: brightness(1.18); }
.rp-card .cell:hover, .rp-card .cell:focus { stroke: #e2e8f0; stroke-width: 1.5; outline: none; }
.rp-card rect[tabindex]:focus { outline: none; }
.rp-meters { display: grid; gap: 10px; }
.rp-meter { display: grid; grid-template-columns: minmax(90px, 1.1fr) 2fr auto; grid-template-areas: "nm bar fig" "meta meta meta"; gap: 2px 10px; align-items: center; }
.rp-meter .nm { grid-area: nm; display: flex; align-items: center; gap: 6px; font-size: .86rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-meter .nm i, .rp-tasks .nm i { width: 10px; height: 10px; border-radius: 2px; flex: 0 0 auto; display: inline-block; }
.rp-meter .bar { grid-area: bar; height: 8px; background: #26344a; border-radius: 4px; overflow: hidden; }
.rp-meter .bar span { display: block; height: 100%; background: #3987e5; border-radius: 4px; }
.rp-meter .fig { grid-area: fig; display: flex; gap: 8px; align-items: baseline; font-variant-numeric: tabular-nums; font-size: .86rem; }
.rp-meter .fig span { color: var(--muted); font-size: .76rem; min-width: 2.6em; text-align: right; }
.rp-meter .meta { grid-area: meta; color: var(--muted); font-size: .72rem; }
@media (max-width: 480px) {
  .rp-meter { grid-template-columns: 1fr auto; grid-template-areas: "nm fig" "bar bar" "meta meta"; }
}
.rp-twrap { overflow-x: auto; }
.rp-card table { border-collapse: collapse; width: 100%; font-size: .8rem; }
.rp-card th { text-align: left; color: var(--muted); font-weight: 500; font-size: .72rem; padding: 4px 8px; border-bottom: 1px solid #334155; white-space: nowrap; }
.rp-card td { padding: 5px 8px; border-bottom: 1px solid #26344a; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rp-tasks td.nm { display: flex; align-items: center; gap: 6px; white-space: normal; min-width: 160px; }
.rp-more { margin-top: 8px; min-height: 34px; padding: 4px 12px; font-size: .8rem; }
.rp-table { margin-top: 8px; }
.rp-table summary { cursor: pointer; color: var(--muted); font-size: .76rem; }
.rp-table table { margin-top: 6px; font-size: .74rem; }
.rp-src { color: var(--muted); font-size: .74rem; margin: 0; }
#rp-tip { position: fixed; z-index: 30; pointer-events: none; background: #0b1220; border: 1px solid #334155; border-radius: 8px; padding: 7px 10px; font-size: .78rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .45); max-width: 260px; }
#rp-tip b { display: block; margin-bottom: 4px; font-weight: 600; }
#rp-tip .tr { display: grid; grid-template-columns: 12px auto 1fr; gap: 6px; align-items: center; }
#rp-tip .tr i { width: 10px; height: 2px; border-radius: 1px; display: block; }   /* line keys, not boxes */
#rp-tip .tr strong { font-variant-numeric: tabular-nums; }
#rp-tip .tr span { color: var(--muted); }
#rp-tip .tr:not(:has(i))::before { content: ""; }

/* ---------- fit to the window: no sideways page scroll anywhere; in Tiles the page itself does not scroll ---------- */
html, body { overflow-x: clip; }
#tiles-row { margin-bottom: 8px; }
.head.tiny > * { display: none; }                      /* too small for text: the tooltip and the task list name it */
.ds-key { display: none; }
#legend-cap { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 600px) {
  /* a thinner day bar; its colour key folds behind "key" */
  #strip-top { padding-bottom: 6px; }
  .ds-title { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; font-size: .74rem; }
  .ds-key { display: inline-block; margin-left: auto; min-height: 26px; padding: 2px 10px; font-size: .72rem; border-radius: 8px; }
  .ds-track { height: 15px; }
  .ds-track i span { line-height: 15px; font-size: .6rem; }
  .ds-axis { height: 13px; font-size: .6rem; }
  #strip-top:not(.keyopen) .ds-legend { display: none; }
  #legend { padding-bottom: 4px; gap: 3px; }
}
@media (max-width: 360px) {
  /* the smallest phones: the header buttons must fit beside the name */
  header h1 { white-space: normal; font-size: .76rem; }
  .hbtns { gap: 4px; }
  .hbtns button { padding: 4px 6px; font-size: .76rem; }
}
@media (max-width: 360px) {
  #view-toggle button { padding: 4px 6px; font-size: .76rem; }
  header select { min-width: 84px; font-size: .76rem; }
}
