:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-2: #1f232c;
  --border: #2a2f3a;
  --text: #e6e8ee;
  --muted: #8b91a1;
  --accent: #7aa2ff;
  --accent-2: #5b8def;
  --running: #3ddc84;
  --stop: #ff6b6b;
  --shadow: 0 1px 0 rgba(255,255,255,0.04), 0 4px 14px rgba(0,0,0,0.3);

  --bar-h-collapsed: 8px;
  --bar-h-expanded:  56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
}
/* Off-screen drawers (.side-menu, .type-panel) use translateX(±100%) to slide
   out of view. In Chrome's mobile emulation those transformed boxes can be
   counted toward horizontal overflow, which expands the layout viewport and
   makes `position: fixed` and `sticky` track that wider viewport — visually
   they drift with scroll. Clipping horizontal overflow on the document keeps
   the layout viewport equal to the visible viewport. */
html, body { overflow-x: clip; }
@supports not (overflow: clip) {
  html, body { overflow-x: hidden; }
}

#app {
  max-width: 760px;
  margin: 0 auto;
  /* Left padding kept small so the page-edge → expand-triangle distance
     matches the triangle → coloured-tab distance. */
  padding: 24px 20px 60px 6px;
}

/* ---------- sticky top stack (timeline + running bar + adjust) ---------- */

.top-stack {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
}

/* ---------- timeline strip ---------- */

.timeline-strip {
  position: relative;
  background: var(--bg);
  border-bottom: 1px solid transparent;
  transition: border-color 150ms ease;
}
.timeline-strip:hover { border-bottom-color: var(--border); }

.timeline-axis {
  position: relative;
  height: 14px;
  font-size: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  opacity: 0.6;
  transition: opacity 150ms ease;
}
.timeline-strip:hover .timeline-axis { opacity: 1; }
.timeline-axis .tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  padding-top: 2px;
}

.timeline-bar {
  position: relative;
  width: 100%;
  height: var(--bar-h-collapsed);
  margin-top: 4px;
  background: #0a0c10;
  cursor: default;
  transition: height 160ms cubic-bezier(.4,.0,.2,1);
  overflow: visible;
}
.timeline-strip:hover .timeline-bar { height: var(--bar-h-expanded); }

.tl-block {
  position: absolute;
  top: 0; bottom: 0;
  background: var(--block-color, #555);
  cursor: default;
  overflow: visible;
}
.tl-block.is-running {
  /* subtle stripe to indicate live */
  background-image: repeating-linear-gradient(
    135deg,
    rgba(255,255,255,0.0) 0 6px,
    rgba(255,255,255,0.12) 6px 12px
  );
}
.tl-block.is-clamped-left::before,
.tl-block.is-clamped-right::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: rgba(255,255,255,0.5);
}
.tl-block.is-clamped-left::before  { left: 0; }
.tl-block.is-clamped-right::after  { right: 0; }

.tl-handle {
  position: absolute;
  top: 0; bottom: 0;
  width: 12px;
  cursor: ew-resize;
  background: rgba(255,255,255,0);
  opacity: 0;
  transition: opacity 160ms ease, background 160ms ease;
  z-index: 2;
}
/* Handles sit fully inside the block so adjacent blocks never share a hit area. */
.tl-handle.start { left: 0; }
.tl-handle.end   { right: 0; }

/* Visible gripper inside the handle. */
.tl-handle::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 22%;
  bottom: 22%;
  width: 2px;
  margin-left: -1px;
  background: rgba(255,255,255,0.9);
  border-radius: 1px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.35);
  transition: background 150ms ease;
}

/* Handles appear only when their own block is hovered. */
.tl-block:hover .tl-handle {
  opacity: 1;
  background: rgba(255,255,255,0.22);
}
.tl-handle:hover {
  background: rgba(255,255,255,0.45) !important;
}
.tl-handle:hover::before { background: white; }

.tl-block.is-locked-start .tl-handle.start,
.tl-block.is-locked-end   .tl-handle.end { display: none; }

.tl-gap {
  position: absolute;
  top: 0; bottom: 0;
  background: transparent;
  cursor: pointer;
}
.tl-gap.future { cursor: default; }
.tl-gap.future::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    135deg,
    rgba(255,255,255,0.0) 0 4px,
    rgba(255,255,255,0.04) 4px 8px
  );
}
.timeline-strip:hover .tl-gap:not(.future):hover {
  background: rgba(122,162,255,0.18);
}
.tl-gap-plus {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 300;
  color: var(--accent);
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}
.timeline-strip:hover .tl-gap:not(.future):hover .tl-gap-plus { opacity: 1; }

.now-marker {
  position: absolute;
  top: -4px; bottom: -4px;
  width: 1px;
  background: var(--running);
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}
.timeline-strip:hover .now-marker { opacity: 0.8; }

/* ---------- tooltip ---------- */

.tooltip {
  position: fixed;
  z-index: 200;
  background: rgba(20,23,30,0.96);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  max-width: 320px;
}
.tooltip-name { font-weight: 600; margin-bottom: 2px; }
.tooltip-line { color: var(--muted); }
.tooltip-line.warn { color: #ffb86b; }

/* ---------- insert menu ---------- */

.insert-menu {
  position: fixed;
  z-index: 220;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 0;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  min-width: 220px;
  max-height: 70vh;
  overflow: auto;
}
.insert-menu-header {
  padding: 4px 12px 6px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.insert-menu-items {
  list-style: none;
  padding: 0;
  margin: 0;
}
.insert-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
}
.insert-menu-item:hover { background: var(--panel-2); }
.insert-menu-item .swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex: none;
}
.insert-menu-item .name { flex: 1; }
.insert-menu-item .tags { color: var(--muted); font-size: 11px; }

.menu-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
.insert-menu-item.danger .name { color: var(--stop); }
.insert-menu-item.danger .swatch.danger {
  background: var(--stop);
  opacity: 0.85;
}
.insert-menu-item.danger:hover { background: rgba(255,107,107,0.12); }

/* ---------- general ---------- */

.hidden { display: none !important; }

/* ---------- thin running bar ---------- */

.running-bar {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 7px 16px;
  min-height: 38px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.running-bar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-color, transparent);
  opacity: 0.14;
  pointer-events: none;
}
.running-bar > * {
  position: relative;
  z-index: 1;
}
.running-bar.is-paused::before { opacity: 0.07; }

.rb-info {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.rb-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--accent-color, var(--text));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.rb-tags {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.running-bar.is-paused .rb-name::after {
  content: ' · paused';
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
}

.rb-time {
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
  text-align: center;
  white-space: nowrap;
}
.running-bar.is-paused .rb-time { color: var(--muted); }

.rb-time .rb-time-prev,
.rb-time .rb-time-sep {
  color: var(--muted);
  font-weight: 400;
}
.rb-time .rb-time-sep { margin: 0 4px; }

.rb-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
}
.rb-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(0,0,0,0.18);
  color: var(--text);
  padding: 5px 11px;
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
}
/* SVG-mask icon shown before each button's text label. The fill follows
   currentColor so it inherits the button's text colour. */
.rb-btn::before {
  content: '';
  display: block;
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  margin-right: 6px;
  background-color: currentColor;
  -webkit-mask: var(--btn-icon, none) no-repeat center / contain;
          mask: var(--btn-icon, none) no-repeat center / contain;
}
#pause-btn {
  --btn-icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><rect x='4' y='2.5' width='3' height='11' fill='black'/><rect x='9' y='2.5' width='3' height='11' fill='black'/></svg>");
}
#pause-btn.is-resume {
  --btn-icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><polygon points='4,2.5 4,13.5 13.5,8' fill='black'/></svg>");
}
.rb-btn-stop {
  --btn-icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><rect x='3.5' y='3.5' width='9' height='9' fill='black'/></svg>");
}
.rb-btn:hover { background: rgba(0,0,0,0.32); border-color: rgba(255,255,255,0.18); }
.rb-btn-stop {
  background: var(--stop);
  color: white;
  border-color: var(--stop);
  font-weight: 600;
}
.rb-btn-stop:hover { background: var(--stop); border-color: var(--stop); filter: brightness(1.08); }
.rb-btn.is-resume {
  background: rgba(61, 220, 132, 0.18);
  color: var(--running);
  border-color: rgba(61, 220, 132, 0.55);
  font-weight: 600;
}
.rb-btn.is-resume:hover { background: rgba(61, 220, 132, 0.28); border-color: var(--running); }
.rb-btn[aria-expanded="true"] {
  background: rgba(255,255,255,0.10);
  border-color: rgba(255,255,255,0.25);
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-stop {
  background: var(--stop);
  border-color: var(--stop);
  color: white;
  font-weight: 600;
  padding: 10px 18px;
}
.btn-stop:hover { filter: brightness(1.05); border-color: var(--stop); }
.btn-stop-secondary {
  background: transparent;
  border-color: var(--stop);
  color: var(--stop);
  font-weight: 600;
}
.btn-stop-secondary:hover { background: rgba(255,107,107,0.1); border-color: var(--stop); }
.btn-ghost {
  background: transparent;
  color: var(--muted);
}
.btn-ghost[aria-expanded="true"] { color: var(--text); border-color: var(--accent); }

#types {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}
#types-hidden {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}

/* ---------- project + task hierarchy ---------- */

.proj-block {
  list-style: none;
  display: block;
}

.proj-row-wrap {
  /* expand triangle | bordered project line */
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 6px;
  align-items: center;
}

.proj-line {
  display: grid;
  /* coloured-grip tab | main | total | + | edit */
  grid-template-columns: 28px 1fr auto 28px 28px;
  gap: 0 6px;
  align-items: center;
  background: var(--panel);
  /* The "border" is an inset shadow rather than a real border. Inset shadows
     render under children, so the grip cell's coloured background covers the
     ring where the tab is — no faint grey seam around the coloured tab. */
  box-shadow: inset 0 0 0 1px var(--border);
  border: none;
  border-radius: 10px;
  padding: 0 6px 0 0;        /* no vertical padding — grip fills full height */
  overflow: hidden;
  position: relative;
}
.proj-line:hover { box-shadow: inset 0 0 0 1px var(--accent); }

.proj-expand {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  width: 24px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 120ms ease, background 120ms ease, transform 160ms ease;
}
.proj-expand:hover { color: var(--text); background: var(--panel-2); }
.proj-expand::before {
  content: '▾';
  display: inline-block;
  /* Position-relative offset (not transform) so the icon shifts within the
     click area without rotating the offset together with the chevron. */
  position: relative;
  left: 1px;
  transition: transform 160ms ease;
}
.proj-block.is-collapsed .proj-expand::before { transform: rotate(-90deg); }
.proj-block.no-tasks .proj-expand { visibility: hidden; }

.task-list {
  list-style: none;
  margin: 0;
  display: grid;
  /* Spacing between tasks. Matches both #types gap and the padding-top below,
     so every gap on the tracking page is uniform. */
  gap: 6px;
  /* Right edge aligned with the project line's right edge (no right padding).
     Left edge: past the expand-cell column (24px + 6px gap = 30px) PLUS an
     extra indent so tasks are visibly offset from the project line. */
  margin-left: 30px;
  padding: 6px 0 0 27px;
}
.proj-block.is-collapsed .task-list { display: none; }
/* When the project is collapsed but contains a running task, the list still
   needs to render that task. The renderer puts only the running task into the
   list in this state. */
.proj-block.is-collapsed.has-running-task .task-list { display: grid; }
/* Drag-time auto-expand: while the cursor is hovering a collapsed project
   during a task drag, its task-list is shown as a drop target. */
.proj-block.is-drag-expanded .task-list { display: grid; }
/* Empty task-lists need visible space during a task drag so the drop hit-test
   has something to land on. */
body.dragging-task .task-list {
  min-height: 32px;
}

.task-row {
  display: grid;
  /* Match the project line's column tracks so columns line up vertically.
     Tasks have no "add-task" button, so its column is left empty and the
     edit button is forced into the last column. */
  grid-template-columns: 28px 1fr auto 28px 28px;
  gap: 0 6px;
  align-items: center;
  background: var(--panel-2);
  /* Same inset-shadow trick as .proj-line: lets the coloured grip tab merge
     into the row's edge without a visible 1 px seam. */
  box-shadow: inset 0 0 0 1px transparent;
  border: none;
  border-radius: 7px;
  padding: 0 6px 0 0;        /* no vertical padding — grip fills full height */
  list-style: none;
  position: relative;
  overflow: hidden;          /* clip the coloured grip tab to the rounded corners */
}
.task-row:hover { box-shadow: inset 0 0 0 1px var(--accent); }
.task-row .row-edit { grid-column: 5; }

.add-task-row {
  list-style: none;
  margin: 2px 0 0;
}
.add-task-row .row-add-task-inline {
  appearance: none;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--muted);
  border-radius: 6px;
  width: 100%;
  padding: 5px 8px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: color 120ms, border-color 120ms;
  text-align: left;
}
.add-task-row .row-add-task-inline:hover { color: var(--text); border-color: var(--accent); }

/* Drag placeholders + clone (used by both kinds) */
.proj-block.is-placeholder .proj-line,
.task-row.is-placeholder {
  background: rgba(122, 162, 255, 0.06);
  /* Dashed outline at the inside edge — survives the border→box-shadow swap. */
  outline: 1px dashed rgba(122, 162, 255, 0.5);
  outline-offset: -1px;
}
.proj-block.is-placeholder .proj-line > *,
.task-row.is-placeholder > * { visibility: hidden; }

.drag-clone {
  position: fixed;
  top: 0;
  left: 0;
  --tx: 0px;
  --ty: 0px;
  transform: translate(var(--tx), var(--ty)) scale(1.02) rotate(-0.8deg);
  pointer-events: none;
  z-index: 300;
  box-shadow: 0 18px 36px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.04);
  border-color: var(--accent);
  background: var(--panel);
  margin: 0;
  cursor: grabbing;
}


/* Drag handle and edit/expand buttons (shared by project & task rows) */
/* Coloured "tab" on the left of every row. The full grip cell is filled with
   the project/task colour; the drag-handle dots sit inside it. */
.row-grip {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  background: var(--type-color, transparent);
  color: rgba(0, 0, 0, 0.65);
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -1px;
  user-select: none;
  transition: color 120ms ease;
  touch-action: none;
  /* The ⋮⋮ glyph sits in the upper portion of its em-box on most fonts, so
     pure flex centering looks bottom-skewed. Nudge the visual up by adding
     bottom padding (which shrinks the centered area). */
  padding-bottom: 3px;
}
.proj-line:hover .row-grip,
.task-row:hover .row-grip { color: rgba(0, 0, 0, 0.95); }
.row-grip:active { cursor: grabbing; }

/* The standalone colour stripe is no longer needed — the grip tab carries the
   colour. Hide rather than remove so the existing HTML templates don't need
   any markup changes. */
.row-color { display: none; }

.row-edit, .row-add-task {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 120ms ease, background 120ms ease, color 120ms ease, transform 160ms ease;
}
.proj-line:hover .row-edit,
.proj-line:hover .row-add-task,
.task-row:hover .row-edit { opacity: 1; }
.row-edit:hover, .row-add-task:hover { background: var(--panel-2); color: var(--text); }
.row-add-task { font-size: 16px; font-weight: 300; }

.proj-block.is-hidden-row .proj-line,
.task-row.is-hidden-row {
  opacity: 0.55;
}
.proj-block.is-hidden-row .row-name::after,
.task-row.is-hidden-row .row-name::after {
  content: '  hidden';
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-left: 6px;
}

.hidden-toggle {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 8px 4px 4px;
  text-align: left;
}
.hidden-toggle:hover { color: var(--text); }

.types-hidden {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: grid;
  gap: 8px;
}

.grip-inline, .edit-inline {
  display: inline-block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  vertical-align: -1px;
}
.grip-inline { letter-spacing: -2px; }

.row-main {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  /* Same padding on both project and task rows so heights match. */
  padding: 10px 12px;
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}
.row-name { font-weight: 500; }
.task-row .row-name { font-weight: 400; }
.row-tags { color: var(--muted); font-size: 12px; }
.type-tag {
  cursor: default;
  transition: color 120ms ease, text-shadow 120ms ease;
}
.type-tag.is-glow {
  color: var(--accent);
  text-shadow: 0 0 8px rgba(122, 162, 255, 0.7);
}

.row-total {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 13px;
  min-width: 56px;
  text-align: right;
  padding-right: 4px;
}
.row-total.has-time { color: var(--text); }
.row-total.is-aggregate { color: var(--text); }

/* Currently-tracking row: no coloured outline — only an inset glow that
   fades from the edges inward. Saturation high so the row reads as active
   without a hard border. Hover layers the accent ring on top of the glow. */
.proj-block.active .proj-line {
  box-shadow: inset 0 0 26px 0 color-mix(in srgb, var(--type-color, var(--running)) 55%, transparent);
}
.proj-block.active .proj-line:hover {
  box-shadow:
    inset 0 0 0 1px var(--accent),
    inset 0 0 26px 0 color-mix(in srgb, var(--type-color, var(--running)) 55%, transparent);
}
.proj-block.active .proj-line .row-name { color: var(--type-color, var(--running)); }
.task-row.active {
  box-shadow: inset 0 0 22px 0 color-mix(in srgb, var(--type-color, var(--running)) 55%, transparent);
}
.task-row.active:hover {
  box-shadow:
    inset 0 0 0 1px var(--accent),
    inset 0 0 22px 0 color-mix(in srgb, var(--type-color, var(--running)) 55%, transparent);
}
.task-row.active .row-name { color: var(--type-color, var(--running)); }

.hint {
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
}
.hint code {
  background: var(--panel);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-size: 11px;
}

@media (max-width: 560px) {
  /* Compact running bar: info on the left taking remaining space, then the
     live timer, then the action buttons. No more centered time column. */
  .running-bar {
    padding: 6px 10px;
    gap: 8px;
    font-size: 12px;
    grid-template-columns: minmax(0, 1fr) auto auto;
  }
  .rb-name {
    font-size: 13px;
    /* Allow Project / Task names to wrap onto multiple lines. */
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: anywhere;
    max-width: 100%;
  }
  .rb-tags { display: none; }
  .rb-time {
    font-size: 16px;
    text-align: left;          /* not centered anymore */
  }
  /* Drop the prior-accumulated total + separator — only the live session counts. */
  .rb-time .rb-time-prev,
  .rb-time .rb-time-sep { display: none; }

  /* Action buttons become compact, same-size icon buttons. The icon comes
     from the global .rb-btn::before rule; text is hidden via font-size: 0. */
  .rb-btn {
    padding: 0;
    font-size: 0;              /* hides the original text label */
    width: 36px;
    min-width: 36px;
    height: 28px;
    justify-content: center;
    text-align: center;
  }
  /* Drop the label-spacing on the icon so it sits centred in the square. */
  .rb-btn::before { margin-right: 0; }
}

/* ---------- floating hamburger + side menu ---------- */

/* Hamburger pinned to the bottom-right corner. Stays put when the menu opens;
   the icon morphs ≡ → × so the same button dismisses the drawer. */
.menu-button {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  /* Above both drawers so it remains clickable when one is open. */
  z-index: 110;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
  transition:
    background 120ms ease,
    border-color 120ms ease,
    transform 200ms cubic-bezier(.4,.0,.2,1);
  display: flex;
  align-items: center;
  justify-content: center;
}
.menu-button:hover { background: var(--panel-2); border-color: var(--accent); }
.menu-button.is-open { transform: rotate(90deg); }

.menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 95;
  opacity: 1;
  transition: opacity 160ms ease;
}
.menu-backdrop.hidden {
  display: block !important;
  opacity: 0;
  pointer-events: none;
}

/* Bottom-right drawer that slides in from the right. Caps at 80% of viewport
   width on small screens, 360 px on wider ones; height is 75 vh, anchored to
   the bottom edge. */
.side-menu {
  position: fixed;
  right: 0;
  bottom: 0;
  width: min(80vw, 360px);
  height: 75vh;
  background: var(--panel);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  border-top-left-radius: 12px;
  box-shadow: -8px -4px 24px rgba(0,0,0,0.45);
  padding: 16px 12px 84px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transform: translateX(0);
  transition: transform 200ms cubic-bezier(.4,.0,.2,1);
}
.side-menu.hidden {
  display: flex !important;
  transform: translateX(100%);
  pointer-events: none;
}

.menu-item {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  padding: 10px 14px;
  text-align: left;
  font: inherit;
  font-size: 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.menu-item:hover { background: var(--panel-2); }
.menu-item.is-active {
  background: var(--panel-2);
  color: var(--accent);
  border-color: var(--border);
}

/* ---------- stats view ---------- */

.view.hidden { display: none !important; }

.stats-section { margin-bottom: 22px; }
.stats-section-head {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.stats-section-head-tight {
  justify-content: flex-start;
  gap: 12px;
}

/* ---------- collapsible filter cards on Stats ----------
   The filter card aligns flush with the list items below; the chevron sits
   to the LEFT of the card, in the gutter. Achieved by giving #view-stats
   a 34px left padding (28px chevron + 6px gap) and absolute-positioning the
   chevron at left: -34px relative to the filter. */

#view-stats { padding-left: 30px; }
/* Indent only the non-rounded content (summary line, distribution heading, pie
   + legend) so it sits inside the visible bounds of the filter cards' rounded
   corners. The work-type rows (themselves rounded blocks) keep full width and
   line up with the filter cards. */
#view-stats .stats-list-summary,
#view-stats .stats-section-head,
#view-stats .stats-pie-wrap {
  padding-left: 10px;
  padding-right: 10px;
}

.stats-filter {
  position: relative;
  margin-bottom: 10px;
}

.stats-filter-toggle {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  font-weight: 700;
  width: 24px;
  height: 48px;            /* match head height */
  border-radius: 6px;
  cursor: pointer;
  position: absolute;
  left: -30px;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 120ms ease, background 120ms ease;
}
.stats-filter-toggle:hover { color: var(--text); background: var(--panel-2); }
.stats-filter-toggle::before {
  content: '▾';
  display: inline-block;
  position: relative;
  left: 1px;
  transition: transform 160ms ease;
}
.stats-filter.is-collapsed .stats-filter-toggle::before { transform: rotate(-90deg); }

.stats-filter-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 120ms ease;
}
.stats-filter-card:hover { border-color: var(--accent); }

.stats-filter-head {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: none;
  padding: 14px 14px;
  min-height: 48px;
  font: inherit;
  cursor: pointer;
  transition: background 120ms ease;
}
.stats-filter-head:hover { background: var(--panel-2); }

/* Divider between head and body when the filter is expanded so the body
   reads as nested under the head. */
.stats-filter:not(.is-collapsed) .stats-filter-head {
  border-bottom: 1px solid var(--border);
}

.stats-filter-label {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  flex: 0 0 auto;
}
.stats-filter-summary {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
/* Label is always shown. Summary (current filter state) appears only while
   collapsed — when expanded the body shows the controls so the summary is
   redundant. */
.stats-filter:not(.is-collapsed) .stats-filter-summary { display: none; }

.stats-filter-body {
  padding: 12px 14px;
  display: grid;
  gap: 10px;
}
.stats-filter.is-collapsed .stats-filter-body { display: none; }

.stats-filter-actions {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 24px;             /* whitespace between Show all + Clear */
  min-height: 0;
  /* The pill-shaped tag chips above are visibly inset from the body's left
     edge by their corner radius; nudge non-pill content right so it lines
     up with the chip text instead of the chip's box edge. */
  padding-left: 6px;
}
.stats-filter-actions:empty { display: none; }
.stats-filter-actions .tags-clear { font-size: 12px; }

.stats-tags-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.stats-tags-toggle input { margin: 0; cursor: pointer; }
.stats-tags-toggle:hover { color: var(--text); }

.stats-tags-empty {
  font-size: 12px;
  color: var(--muted);
  padding: 4px 0 4px 6px;       /* same nudge as actions to align under chips */
  font-style: italic;
}

.stats-list-summary {
  display: flex;
  justify-content: flex-end;
  gap: 22px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}
.stats-list-summary:empty { display: none; }
.stats-list-summary-val {
  color: var(--text);
  font-weight: 600;
  margin-left: 4px;
}

.date-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.date-preset {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, color 120ms;
}
.date-preset:hover { border-color: var(--accent); }
.date-preset.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0c0e12;
  font-weight: 600;
}

.date-custom {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  align-items: center;
  /* Align with the "List all known…" checkbox below — same 6px nudge as
     .stats-filter-actions, so non-pill content lines up with pill text. */
  padding-left: 6px;
}
.date-custom label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
.date-custom input[type="date"] {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font: inherit;
  font-size: 13px;
  color-scheme: dark;
}

.date-summary {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.stats-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.stats-tag {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.stats-tag:hover { color: var(--text); border-color: var(--accent); }
.stats-tag.is-active {
  background: var(--accent);
  color: #0c0e12;
  border-color: var(--accent);
  font-weight: 600;
}
.tags-clear {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}
.tags-clear:hover { text-decoration: underline; }

.stats-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}
.stats-row {
  display: grid;
  grid-template-columns: 6px 1fr auto;
  gap: 10px;
  align-items: center;
  background: var(--panel);
  /* Inset shadow as the "border" so the colour stripe can sit flush against
     the rounded edge — matches the tracking page's project/task styling. */
  box-shadow: inset 0 0 0 1px var(--border);
  border: none;
  border-radius: 8px;
  padding: 0 12px 0 0;
  min-height: 36px;
  overflow: hidden;
  position: relative;
}
.stats-row-color { align-self: stretch; background: var(--type-color, transparent); }
.stats-row-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
  padding: 8px 0 8px 4px;
}
.stats-row-name { min-width: 0; }
.stats-row.active {
  box-shadow: inset 0 0 22px 0 color-mix(in srgb, var(--type-color, var(--running)) 55%, transparent);
}
.stats-row.active .wt-name,
.stats-row.active .stats-row-time { color: var(--type-color, var(--running)); }
.stats-row-time {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}
.stats-row-pct {
  color: var(--muted);
  font-size: 11px;
  margin-left: 6px;
}
.stats-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 8px 0;
}

.stats-pie-wrap {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  align-items: start;
}
.stats-pie {
  width: 220px;
  height: 220px;
  display: block;
}
.stats-pie-legend {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}
.stats-pie-legend li {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 8px;
  align-items: center;
}
.stats-pie-legend .swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}
.stats-pie-legend .pct {
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
@media (max-width: 560px) {
  .stats-pie-wrap { grid-template-columns: 1fr; }
  .stats-pie { margin: 0 auto; }
}

/* ---------- logs view ---------- */

.logs-section { margin-bottom: 22px; }

.logs-date-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.logs-date-nav {
  appearance: none;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  width: 32px;
  height: 30px;
  border-radius: 6px;
  font: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}
.logs-date-nav:hover { border-color: var(--accent); }
.logs-date-input {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font: inherit;
  font-size: 13px;
  color-scheme: dark;
}

.logs-summary {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.logs-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}
.logs-row {
  display: grid;
  grid-template-columns: 6px auto 1fr auto auto;
  gap: 0 10px;
  align-items: center;
  background: var(--panel);
  /* Same inset-shadow trick as the stats rows. */
  box-shadow: inset 0 0 0 1px var(--border);
  border: none;
  border-radius: 8px;
  padding: 0 10px 0 0;
  min-height: 38px;
  overflow: hidden;
  position: relative;
}
.logs-row:hover { box-shadow: inset 0 0 0 1px var(--accent); }
.logs-row-color {
  align-self: stretch;
  background: var(--type-color, transparent);
}
.logs-row-time {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--text);
  padding-left: 8px;
  white-space: nowrap;
}
.logs-row-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.logs-row-name {
  min-width: 0;
  /* Long names wrap onto multiple lines (matches Tracking/Stats), instead of
     being clipped with an ellipsis. */
  overflow-wrap: anywhere;
}
.logs-row-dur {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.logs-row-actions {
  display: flex;
  gap: 2px;
}
.logs-action {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: background 120ms, color 120ms;
}
.logs-action:hover { background: var(--panel-2); color: var(--text); }
.logs-action.danger:hover { background: rgba(255,107,107,0.12); color: var(--stop); }

.logs-row.is-running {
  box-shadow: inset 0 0 22px 0 color-mix(in srgb, var(--type-color, var(--running)) 55%, transparent);
}
.logs-row.is-running:hover {
  box-shadow:
    inset 0 0 0 1px var(--accent),
    inset 0 0 22px 0 color-mix(in srgb, var(--type-color, var(--running)) 55%, transparent);
}
.logs-row.is-running .wt-name,
.logs-row.is-running .logs-row-time { color: var(--type-color, var(--running)); }

.logs-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 12px 0;
  text-align: center;
}

@media (max-width: 560px) {
  .logs-row { grid-template-columns: 4px auto 1fr auto; }
  .logs-row-main .row-tags { display: none; }
  .logs-row-dur { display: none; }
}

/* ---------- log-panel form (inside .type-panel drawer) ---------- */

.lp-times { gap: 4px; }
.lp-time-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.lp-time-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 0 0 auto;
}
.lp-time-cell input { width: 110px; }
.lp-sub {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.lp-dash {
  color: var(--muted);
  padding-bottom: 8px;
}
.lp-duration {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  margin-left: auto;
  padding-bottom: 8px;
}

/* ---------- floating add button ---------- */

.fab {
  position: fixed;
  right: 20px;
  /* Stack above the hamburger (bottom: 20, height: 52) with a 12 px gap. */
  bottom: 84px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #0c0e12;
  /* Reserve border space so the hover state doesn't reflow. */
  border: 2px solid transparent;
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,0.45), 0 0 0 1px rgba(255,255,255,0.06);
  z-index: 80;
  transition: filter 150ms ease, border-color 150ms ease;
}
.fab:hover {
  filter: brightness(1.06);
  border-color: rgba(255, 255, 255, 0.55);
}

/* ---------- type panel (slide-in) ---------- */

.type-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  /* Above the hamburger (z 110) so + opens a fully-covering drawer; the
     menu drawer is below this and uses its own dimmer at z 95. */
  z-index: 125;
  opacity: 1;
  transition: opacity 160ms ease;
}
.type-panel-backdrop.hidden {
  display: block !important;
  opacity: 0;
  pointer-events: none;
}

.type-panel {
  position: fixed;
  right: 0;
  bottom: 0;
  width: min(80vw, 460px);
  height: 75vh;
  background: var(--panel);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  border-top-left-radius: 12px;
  box-shadow: -8px -4px 24px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  /* Above the hamburger (z 110) so the + drawer fully covers it. */
  z-index: 130;
  transform: translateX(0);
  transition: transform 200ms cubic-bezier(.4,.0,.2,1);
}
.type-panel.hidden {
  display: flex !important;
  transform: translateX(100%);
  pointer-events: none;
}

.type-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.type-panel-header h2 {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.type-panel-x {
  font-size: 22px;
  line-height: 1;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
}

.type-panel-body {
  flex: 1;
  overflow: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: stretch;
}
.tp-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 0 0 auto;
}
.tp-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.tp-input {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
}
.tp-input:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
.tp-hint { color: var(--muted); font-size: 11px; }
.tp-hint code {
  background: var(--panel-2);
  padding: 0 4px;
  border-radius: 3px;
  font-size: 11px;
}
.tp-new-project {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
.tp-new-project .tp-input { flex: 1; }
.tp-confirm {
  appearance: none;
  border: 1px solid var(--running);
  background: rgba(61, 220, 132, 0.18);
  color: var(--running);
  padding: 6px 10px;
  min-width: 36px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1;
}
.tp-confirm:hover { background: rgba(61, 220, 132, 0.28); }

/* Project > Work Type display in lists, menus, and the running bar */
.wt-project { font-weight: 400; color: var(--muted); }
.wt-sep { color: var(--muted); margin: 0 2px; }
.wt-name { font-weight: 600; }
/* In the running bar, the work type span inherits the accent colour from .rb-name. */
.rb-name .wt-project,
.rb-name .wt-sep { color: rgba(255,255,255,0.6); }

.tp-color-row { display: flex; align-items: center; gap: 10px; }
.tp-color {
  appearance: none;
  -webkit-appearance: none;
  width: 44px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}
.tp-color::-webkit-color-swatch-wrapper { padding: 2px; }
.tp-color::-webkit-color-swatch { border: none; border-radius: 4px; }
.tp-color-text { width: 100px; font-variant-numeric: tabular-nums; text-transform: lowercase; }
.tp-error {
  color: var(--stop);
  font-size: 12px;
  min-height: 16px;
}

.tp-delete-prompt {
  background: rgba(255, 107, 107, 0.10);
  border: 1px solid rgba(255, 107, 107, 0.5);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tp-delete-prompt-msg {
  margin: 0;
  font-size: 13px;
  color: var(--text);
}
.tp-delete-prompt-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tp-delete-prompt-actions .btn { font-size: 12px; padding: 6px 10px; }

.type-panel-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}
.tp-spacer { flex: 1; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0c0e12;
  font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.05); border-color: var(--accent); }
