:root {
  --bg: #f3f5f8; --card: #fff; --ink: #1b2430; --muted: #627083; --line: #dbe2ea;
  --pri: #1f5fae; --warn: #a05a00; --err: #b42318; --ok: #18794e;
  --run: #eaf6ee; --run-line: #9fd4b3; --pause: #fff6e3; --pause-line: #f0cf8a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151b; --card: #1a2029; --ink: #e5eaf0; --muted: #94a1b2; --line: #2b3542;
    --pri: #4b8ddf; --warn: #f0b052; --err: #ff7a6b; --ok: #4cc38a;
    --run: #15281e; --run-line: #2f6a47; --pause: #2b2312; --pause-line: #6e5520;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--ink); }
code, pre { font-family: Consolas, ui-monospace, monospace; font-size: 12px; }
pre { background: var(--bg); border: 1px solid var(--line); padding: 8px; border-radius: 6px; overflow: auto; }

header.top { display: flex; align-items: center; gap: 14px; padding: 8px 12px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.brand img { width: 22px; height: 22px; border-radius: 5px; }
nav { display: flex; gap: 2px; flex-wrap: wrap; }
nav button { background: none; border: 0; padding: 6px 10px; border-radius: 6px; color: var(--muted); }
nav button:hover { color: var(--ink); }
nav button.on { background: var(--pri); color: #fff; }

main { padding: 12px; max-width: 1400px; margin: 0 auto; }
.view { display: none; }
.view.on { display: block; }
.vhead { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.vhead h2 { margin: 0; font-size: 18px; }
.help { width: 24px; height: 24px; padding: 0; border-radius: 50%; background: #f5c518; border: 0; color: #1b1b1b; font-weight: 800; line-height: 24px; }
.help:hover { background: #ffd43b; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.card h3 { margin: 0 0 8px; font-size: 15px; }
button { font: inherit; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--pri); border-color: var(--pri); color: #fff; }
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: none; border-color: transparent; color: var(--muted); }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--ink); min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--pri); outline-offset: -1px; }
label { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; font-size: 13px; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty { color: var(--muted); text-align: center; padding: 18px; }
.spacer { flex: 1; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.start { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.picker { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; align-items: center; }
.picker select { max-width: 100%; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.chip { border-radius: 999px; font-size: 12px; padding: 3px 10px; }

.timers { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.timer.running { background: var(--run); border-color: var(--run-line); }
.timer.paused { background: var(--pause); border-color: var(--pause-line); }
.tpath { font-weight: 600; word-break: break-word; }
.tpath span { color: var(--muted); font-weight: 400; }
.clock { font-size: 36px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 2px 0; letter-spacing: .5px; }
.tmeta { font-size: 12px; color: var(--muted); }
.warn { color: var(--warn); font-size: 12px; font-weight: 600; }
.timer textarea { width: 100%; resize: vertical; margin: 8px 0; }
.btns { display: flex; gap: 6px; flex-wrap: wrap; }

.tablewrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--card); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 600; border-bottom: 0; }
td.act { white-space: nowrap; text-align: right; }
td.act button { padding: 2px 8px; font-size: 12px; }
td.flags span { margin-right: 4px; }
.over { color: var(--err); }
.under { color: var(--ok); }
.barcol { width: 30%; }
.bar { height: 10px; border-radius: 5px; background: var(--pri); opacity: .75; min-width: 2px; }
.sumhead { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }

.tree, .tree ul { list-style: none; margin: 0; padding-left: 18px; }
.tree { padding-left: 0; }
.tree ul { border-left: 1px dashed var(--line); margin-left: 8px; }
.node { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; flex-wrap: wrap; }
.node:hover { background: var(--bg); }
.node.inactive .nname { color: var(--muted); text-decoration: line-through; }
.nname { font-weight: 600; }
.pill { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.pill.off { color: var(--warn); }
.desc { font-size: 12px; color: var(--muted); }
.nact { margin-left: auto; display: flex; gap: 4px; opacity: .35; }
.node:hover .nact, .node:focus-within .nact { opacity: 1; }
.nact button { padding: 1px 8px; font-size: 12px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.grid .wide { grid-column: 1 / -1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.frow { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; }
.frow > div { flex: 1; }
.btnrow { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.card > button { margin-top: 6px; }
.colrow { display: grid; grid-template-columns: auto minmax(140px, 220px) 1fr auto; gap: 8px; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--line); }
.colrow .mv button { padding: 1px 8px; }
.preview { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.preview code { word-break: break-word; }

#banners .banner { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 14px; background: #e8f0fb; color: #12345a; border-bottom: 1px solid #c6d8f1; }
#banners .banner.warn { background: #fff4dc; color: #5a3b00; border-color: #f0d79c; }
#banners .banner.err { background: #fde8e6; color: #6d1a10; border-color: #f5c2bc; }

dialog { border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: var(--card); color: var(--ink); width: min(560px, 94vw); }
dialog::backdrop { background: rgba(10, 15, 25, .45); }
dialog h3 { margin: 0 0 10px; }
.dlgBtns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.helpbody { max-height: 65vh; overflow: auto; }
.helpbody p, .helpbody li { margin: 6px 0; }

#toasts { position: fixed; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 50; max-width: min(420px, 90vw); }
.toast { background: #1b2430; color: #fff; padding: 8px 12px; border-radius: 8px; box-shadow: 0 4px 14px rgba(0, 0, 0, .2); font-size: 13px; }
.toast.ok { background: #18794e; }
.toast.err { background: #b42318; }
.toast.warn { background: #a05a00; }

/* Narrow windows: you can make the PWA window small and park it beside your work */
@media (max-width: 560px) {
  main { padding: 6px; }
  header.top { padding: 6px 8px; gap: 6px; }
  nav button { padding: 4px 7px; font-size: 13px; }
  .timers { grid-template-columns: 1fr; gap: 6px; }
  .clock { font-size: 26px; }
  .card { padding: 8px; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .colrow { grid-template-columns: auto 1fr auto; }
  .colrow > .muted { display: none; }
  .barcol { display: none; }
}
