:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --border: #e3e6ee;
  --text: #1b1e27;
  --muted: #6b7280;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #d97706;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1117; --surface: #171a23; --surface-2: #1f2330; --border: #2a2f3d;
    --text: #e6e8ee; --muted: #9098a9; --accent: #818cf8; --accent-soft: #23264a;
    --danger: #f87171; --success: #4ade80; --warn: #fbbf24;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1117; --surface: #171a23; --surface-2: #1f2330; --border: #2a2f3d;
  --text: #e6e8ee; --muted: #9098a9; --accent: #818cf8; --accent-soft: #23264a;
  --danger: #f87171; --success: #4ade80; --warn: #fbbf24;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
a { color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  border: 0; background: transparent; cursor: pointer; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 120px; }
label.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
input[type=color] { width: 32px; height: 32px; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: none; cursor: pointer; }

/* ---------- layout */
.app { display: grid; grid-template-columns: 248px 1fr auto; height: 100vh; overflow: hidden; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto;
  padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; overflow-x: hidden;
}
.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.view { flex: 1; overflow-y: auto; padding: 8px 32px 64px; }
.view > * { max-width: 920px; }
.view > .wide { max-width: 1100px; }
/* Pages sit centred at a comfortable reading width (padding, so no child margin can undo it);
   the admin page gets a little more room and the Today dashboard uses the full width. */
@media (min-width: 801px) {
  .view:not(.is-dash) { padding-left: max(32px, calc((100% - 920px) / 2)); padding-right: max(32px, calc((100% - 920px) / 2)); }
  .view.is-wide { padding-left: max(32px, calc((100% - 1100px) / 2)); padding-right: max(32px, calc((100% - 1100px) / 2)); }
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 4px 8px 16px; }
.brand img { width: 28px; height: 28px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; cursor: pointer;
  color: var(--text); border: 0; background: none; width: 100%; text-align: left; white-space: nowrap;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item.drop-hover { outline: 2px dashed var(--accent); }
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--muted); }
.nav-item svg { color: var(--muted); }
.nav-item.active svg { color: var(--accent); }
.nav-section {
  display: flex; align-items: center; justify-content: space-between; margin: 16px 0 4px; padding: 0 10px;
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.nav-section .icon-btn { width: 24px; height: 24px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.sidebar .spacer { flex: 1; min-height: 16px; }

.topbar {
  display: flex; align-items: center; gap: 16px; padding: 18px 32px 12px; min-height: 72px;
}
.view-head { flex: 1; min-width: 0; }
.view-head h1 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.view-head .sub { color: var(--muted); font-size: 13px; }
.menu-btn { display: inline-grid; margin-left: -8px; }

/* ---------- tracker */
.tracker { display: flex; align-items: center; gap: 10px; }
.tracker .pill {
  display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); max-width: 420px;
}
.tracker .pill.on { border-color: var(--accent); }
.tracker .pill.break { border-color: var(--success); }
.tracker .ttl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; max-width: 200px; }
.tracker .clock { font-variant-numeric: tabular-nums; font-weight: 600; }
.tracker .pomo { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tracker .idle { color: var(--muted); font-size: 13px; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.round-btn {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; border: 0;
  background: var(--accent); color: #fff; cursor: pointer;
}
.round-btn.stop { background: var(--danger); }

/* ---------- add form */
.add { display: flex; gap: 8px; margin: 8px 0 16px; }
.add input { padding: 11px 14px; font-size: 15px; box-shadow: var(--shadow); }
.hint { color: var(--muted); font-size: 12px; margin: -10px 0 14px 4px; }
.hint code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

/* ---------- tasks */
.tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.task-wrap.dragging { opacity: .4; }
.task-wrap.drag-over > .task { box-shadow: 0 -3px 0 var(--accent); }
.task {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.task:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.task-wrap.is-sel > .task { border-color: var(--accent); }
.task-wrap.is-active > .task { border-color: var(--accent); background: linear-gradient(90deg, var(--accent-soft), var(--surface) 60%); }
.chk {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); background: none;
  display: grid; place-items: center; cursor: pointer; color: transparent; flex: none; padding: 0;
}
.chk svg { width: 14px; height: 14px; }
.chk:hover { border-color: var(--success); color: var(--success); }
.is-done > .task .chk { background: var(--success); border-color: var(--success); color: #fff; }
.is-done > .task .t-title { text-decoration: line-through; color: var(--muted); }
.t-body { flex: 1; min-width: 0; cursor: pointer; }
.t-title { overflow-wrap: anywhere; }
.t-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 3px; }
.t-meta:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; padding: 1px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.chip.tag { border: 1px solid currentColor; background: none; }
.chip.overdue { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.chip.due-today { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.t-time { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.t-time .over { color: var(--danger); }
.play {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; color: var(--accent); flex: none; padding: 0;
}
.play:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.is-active > .task .play { background: var(--accent); color: #fff; border-color: var(--accent); }
.subtasks { list-style: none; margin: 4px 0 0 30px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.subtasks .task { padding: 6px 10px; box-shadow: none; }
.subtasks .chk { width: 18px; height: 18px; }
.subtasks .play { width: 26px; height: 26px; }
.subtasks .play svg { width: 14px; height: 14px; }
.progress { height: 3px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.progress > div { height: 100%; background: var(--accent); }

.done-toggle { margin: 20px 0 8px; background: none; border: 0; color: var(--muted); cursor: pointer; font-weight: 600; padding: 4px 0; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; border: 1px dashed var(--border); border-radius: var(--radius); }
.empty strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.group-title { margin: 22px 0 8px; font-size: 13px; font-weight: 700; color: var(--muted); }

/* ---------- detail panel */
.panel {
  width: 0; overflow: hidden; background: var(--surface); border-left: 1px solid var(--border);
  transition: width .18s ease;
}
.panel.open { width: 400px; overflow-y: auto; overflow-x: hidden; }
.panel-inner { padding: 18px 20px 40px; display: flex; flex-direction: column; gap: 16px; width: 100%; min-width: 0; }
.panel-head { display: flex; align-items: center; gap: 8px; }
.panel-head .crumb { flex: 1; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel .title-input { font-size: 18px; font-weight: 600; border-color: transparent; padding: 6px 8px; margin-left: -8px; }
.panel .title-input:hover { border-color: var(--border); }
.field > label, .field > .lbl { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 140px; }
.time-box { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--surface-2); border-radius: var(--radius); }
.time-box .big { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.time-box .of { color: var(--muted); font-size: 12px; }
.tag-toggle { cursor: pointer; border: 1px solid var(--border); background: none; padding: 3px 10px; font-size: 12.5px; border-radius: 999px; color: var(--muted); }
.tag-toggle.on { color: #fff; border-color: transparent; }
.sub-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.sub-list li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; background: var(--surface-2); }
.sub-list li .s-title { flex: 1; cursor: pointer; overflow-wrap: anywhere; }
.sub-list li.done .s-title { text-decoration: line-through; color: var(--muted); }
.sub-list .chk { width: 18px; height: 18px; }
.sub-list .chk svg { width: 12px; height: 12px; }
.sub-list li.done .chk { background: var(--success); border-color: var(--success); color: #fff; }

/* ---------- worklog / settings */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; }
.card h2 { margin: 0 0 12px; font-size: 15px; }
.card p.desc { margin: -6px 0 12px; color: var(--muted); font-size: 13px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 7px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar-row { display: grid; grid-template-columns: 160px 1fr 80px; gap: 10px; align-items: center; margin: 6px 0; font-size: 13px; }
.bar-row .bar { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.bar-row .bar > div { height: 100%; border-radius: 5px; }
.bar-row .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.day { margin-bottom: 14px; }
.day-head { display: flex; justify-content: space-between; font-weight: 700; padding: 8px 0; border-bottom: 1px solid var(--border); }
.wl-row { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--border); }
.wl-row .what { flex: 1; min-width: 0; }
.wl-row .what .parent { color: var(--muted); }
.wl-row .ents { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.wl-row .ent { font-size: 11.5px; color: var(--muted); background: var(--surface-2); border-radius: 6px; padding: 1px 4px 1px 7px; display: inline-flex; align-items: center; gap: 2px; }
.wl-row .ent button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 3px; font-size: 13px; line-height: 1; }
.wl-row .ent button:hover { color: var(--danger); }
.wl-row .dur { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.list-edit { display: flex; flex-direction: column; gap: 8px; }
.list-edit .row input[type=text] { flex: 1; width: auto; }
.kbd { font: 12px ui-monospace, monospace; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; }
.err { color: var(--danger); min-height: 1em; margin: 0; font-size: 13px; }

/* ---------- login & toast */
.login { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); padding: 16px; }
.login-card {
  width: 100%; max-width: 340px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); padding: 28px; display: flex; flex-direction: column; gap: 12px; align-items: stretch; text-align: center;
}
.login-card img { align-self: center; }
.login-card h1 { margin: 0 0 8px; font-size: 20px; }
.login-card .btn { justify-content: center; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; transition: .2s; z-index: 50; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.error { background: var(--danger); color: #fff; }
.scrim { display: none; }

/* ---------- responsive */
@media (max-width: 1100px) {
  .panel.open { position: fixed; right: 0; top: 0; bottom: 0; z-index: 30; box-shadow: var(--shadow); }
}
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 35; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; gap: 10px; }
  .tracker { width: 100%; }
  .tracker .pill { max-width: 100%; flex: 1; }
  .view { padding: 8px 16px 64px; }
  .panel.open, .panel-inner { width: 100%; }
  .bar-row { grid-template-columns: 100px 1fr 64px; }
  .t-time { display: none; }
}

/* ---------- accounts & admin */
.as-banner {
  display: flex; align-items: center; gap: 12px; padding: 8px 32px; font-size: 13px;
  background: color-mix(in srgb, var(--warn) 18%, var(--surface)); border-bottom: 1px solid color-mix(in srgb, var(--warn) 40%, var(--border));
}
.as-banner strong { color: var(--text); }
.as-banner .btn { margin-left: auto; }
.me { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin-top: 6px; border-top: 1px solid var(--border); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 12px; text-transform: uppercase;
}
.me .who { min-width: 0; line-height: 1.2; }
.me .who div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .who .u { color: var(--muted); font-size: 12px; }
.badge { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.admin { background: var(--accent-soft); color: var(--accent); }
.badge.off { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.badge.live { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.utable { width: 100%; border-collapse: collapse; font-size: 13px; }
.utable th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.utable td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.utable tr.is-off td { opacity: .6; }
.utable .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.utable .num { font-variant-numeric: tabular-nums; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; align-items: end; }
.dlg {
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow); padding: 0; width: min(420px, calc(100% - 32px));
}
.dlg::backdrop { background: rgba(0, 0, 0, .45); }
.dlg form { padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.dlg h2 { margin: 0; font-size: 17px; }
.dlg p { margin: 0; color: var(--muted); font-size: 13px; }
.dlg .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.secret { font: 15px ui-monospace, monospace; background: var(--surface-2); border: 1px dashed var(--border); border-radius: 8px; padding: 10px 12px; user-select: all; overflow-wrap: anywhere; }
@media (max-width: 800px) {
  .as-banner { padding: 8px 16px; flex-wrap: wrap; }
  .utable thead { display: none; }
  .utable tr { display: grid; grid-template-columns: 1fr auto; padding: 8px 0; border-bottom: 1px solid var(--border); }
  .utable td { border: 0; padding: 3px 0; }
  .utable td.hide-sm { display: none; }
  .utable .acts { grid-column: 1 / -1; justify-content: flex-start; }
}

/* ---------- collapsible sidebar: icon rail with hover flyout (desktop/tablet) */
.nav-item .nav-label { overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 801px) {
  .app.nav-collapsed { grid-template-columns: 64px 1fr auto; }
  .app.nav-collapsed .sidebar {
    width: 64px; padding: 16px 10px; position: relative; z-index: 35;
    transition: width .16s ease, box-shadow .16s ease; transition-delay: 0s;
  }
  /* Fly out over the page on hover (short delay avoids accidental pops) or keyboard focus. */
  .app.nav-collapsed .sidebar:hover,
  .app.nav-collapsed .sidebar:focus-within {
    width: 248px; padding: 16px 12px; box-shadow: 8px 0 24px rgba(0, 0, 0, .18); transition-delay: .12s;
  }
  .app.nav-collapsed .sidebar:not(:hover):not(:focus-within) :is(.nav-label, .count, .brand-name, .me .who, .me .icon-btn, .nav-empty) { display: none; }
  .app.nav-collapsed .sidebar:not(:hover):not(:focus-within) .nav-item { justify-content: center; padding: 8px 0; }
  .app.nav-collapsed .sidebar:not(:hover):not(:focus-within) .brand { justify-content: center; padding: 4px 0 16px; }
  .app.nav-collapsed .sidebar:not(:hover):not(:focus-within) .me { justify-content: center; padding: 8px 0; }
  .app.nav-collapsed .sidebar:not(:hover):not(:focus-within) .nav-section {
    font-size: 0; height: 1px; padding: 0; margin: 12px 8px; background: var(--border);
  }
  .app.nav-collapsed .sidebar:not(:hover):not(:focus-within) .nav-section .icon-btn { display: none; }
}

/* ---------- Today dashboard */
.view > .dash { max-width: 2200px; }
.dash-tools { display: flex; justify-content: flex-end; gap: 8px; margin: -6px 0 10px; }
.dash-custom { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-bottom: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; min-width: 0; }
.kpi .k { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; margin-top: 2px; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; min-height: 1.2em; }
.kpi .meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 8px; }
.kpi .meter > div { height: 100%; border-radius: 3px; background: var(--accent); }
.kpi.alert .v { color: var(--danger); }
.dash-cols { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.dash-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.widget { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; min-width: 0; }
.widget > h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 14px; }
.widget > h2 .aside { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--muted); }
.widget > h2 .aside a { text-decoration: none; }
.widget .muted { color: var(--muted); font-size: 13px; }
.widget.plan .tasks .task { box-shadow: none; }
.widget.plan .empty { padding: 28px 12px; }
.mini-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.mini-list li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.mini-list li:last-child { border-bottom: 0; }
.mini-list .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.mini-list .when { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 12px; }
.now-card { display: flex; align-items: center; gap: 14px; }
.now-card .ttl { font-weight: 600; overflow-wrap: anywhere; cursor: pointer; }
.now-card .clock-big { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.now-card .round-btn { width: 44px; height: 44px; flex: none; }
.now-card .round-btn svg { width: 22px; height: 22px; }

/* weekly hours: single series, thin bars rounded at the data end, recessive baseline */
.wk { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; align-items: end; height: 150px; padding-top: 18px; border-bottom: 1px solid var(--border); position: relative; }
.wk .col { position: relative; height: 100%; display: flex; align-items: flex-end; justify-content: center; cursor: default; }
.wk .bar { width: min(28px, 60%); background: var(--accent); border-radius: 4px 4px 0 0; min-height: 0; }
.wk .col.future .bar { background: transparent; }
.wk .col:hover .bar { filter: brightness(1.12); }
.wk .val { position: absolute; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 600; color: var(--text); white-space: nowrap; }
.wk .tip {
  position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); display: none; z-index: 5;
  background: var(--text); color: var(--bg); font-size: 12px; padding: 5px 8px; border-radius: 6px; white-space: nowrap; pointer-events: none;
}
.wk .col:hover .tip { display: block; }
.wk-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-top: 6px; font-size: 11px; color: var(--muted); text-align: center; }
.wk-days .today { color: var(--text); font-weight: 700; }
.wk-scale { position: absolute; top: 0; left: 0; font-size: 11px; color: var(--muted); }
.pbar { display: grid; grid-template-columns: minmax(0, 1fr) 64px; gap: 4px 10px; align-items: center; margin: 8px 0; font-size: 13px; position: relative; }
.pbar .name { display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pbar .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.pbar .track { grid-column: 1 / -1; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.pbar .track > div { height: 100%; border-radius: 4px; }
@media (max-width: 1000px) {
  .dash-cols { grid-template-columns: minmax(0, 1fr); }
}
/* Wide screens: give the plan more room and flow the side widgets into two columns instead of leaving empty space. */
@media (min-width: 1500px) {
  .dash-cols { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1.5fr); }
  .dash-col.side { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}

/* ---------- search button + command palette */
.search-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 8px 0 10px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 13px;
}
.search-btn:hover { color: var(--text); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.search-btn kbd, .pal-foot kbd, .focus-help kbd {
  font: 11px ui-monospace, monospace; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; color: var(--muted);
}
.palette { position: fixed; inset: 0; z-index: 60; background: rgba(8, 10, 16, .45); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.pal-box { width: min(640px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 24px 64px rgba(0, 0, 0, .35); overflow: hidden; display: flex; flex-direction: column; max-height: 70vh; }
.pal-search { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--muted); }
.pal-search input { border: 0; box-shadow: none !important; padding: 6px 0; font-size: 16px; background: transparent; }
.pal-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.pal-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.pal-item.on { background: var(--accent-soft); }
.pal-item.on .pal-label { color: var(--accent); }
.pal-item.is-done .pal-label { text-decoration: line-through; color: var(--muted); }
.pal-ic { width: 22px; display: grid; place-items: center; color: var(--muted); flex: none; }
.pal-ic .dot { width: 10px; height: 10px; }
.pal-glyph { font-weight: 700; font-size: 14px; color: var(--muted); }
.pal-glyph.ok { color: var(--success); }
.pal-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pal-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-hint { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.pal-empty { padding: 18px; text-align: center; color: var(--muted); }
.pal-foot { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 8px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }

/* ---------- focus mode */
.focus { position: fixed; inset: 0; z-index: 55; background: var(--bg); overflow-y: auto; animation: focus-in .22s ease; }
@keyframes focus-in { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: none; } }
body.focus-on { overflow: hidden; }
.focus-inner { max-width: 640px; margin: 0 auto; padding: 28px 24px 48px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 18px; }
.focus-top { width: 100%; display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; }
.focus-proj { display: inline-flex; align-items: center; gap: 6px; }
.focus-title { margin: 6px 0 0; font-size: clamp(24px, 4vw, 36px); line-height: 1.2; letter-spacing: -.02em; overflow-wrap: anywhere; }
.focus-meta { margin: 0; color: var(--muted); }
.focus-ring { position: relative; width: 240px; height: 240px; }
.focus-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--surface-2); stroke-width: 10; }
.ring-fill { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.ring-fill.over { stroke: var(--danger); }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-clock { font-size: 44px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.ring-sub { font-size: 13px; color: var(--muted); }
.ring-total { font-size: 12px; color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }
.focus-pomo { font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; }
.focus-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.btn.big { padding: 11px 22px; font-size: 15px; border-radius: 10px; }
.btn.big svg { width: 18px; height: 18px; }
.focus-section { width: 100%; text-align: left; }
.focus-section h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 8px 0 8px; display: flex; gap: 8px; }
.focus-section h2 span { font-weight: 600; }
.focus-subs { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.focus-subs li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.focus-subs li span { flex: 1; overflow-wrap: anywhere; }
.focus-subs li.done span { text-decoration: line-through; color: var(--muted); }
.focus-subs li.done .chk { background: var(--success); border-color: var(--success); color: #fff; }
.focus-subs li.live { border-color: var(--accent); }
.focus-notes { white-space: pre-wrap; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; color: var(--text); font-size: 14px; }
.focus-help { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.focus-done { justify-content: center; min-height: 80vh; }
.focus-burst {
  width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; font-size: 48px; color: #fff; background: var(--success);
  animation: burst .5s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes burst { from { transform: scale(.3); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .focus, .focus-burst, .ring-fill { animation: none; transition: none; } }
@media (max-width: 800px) {
  .search-btn span, .search-btn kbd { display: none; }
  .search-btn { padding: 0 8px; }
  .palette { padding-top: 8vh; }
  .focus-ring { width: 200px; height: 200px; }
  .ring-clock { font-size: 36px; }
}

/* ---------- two-step sign-in */
.login-hint { margin: 0; font-size: 13px; color: var(--muted); }
.login-hint:empty { display: none; }
.secret.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 18px; text-align: center; }
.totp-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
