:root {
  --bg: #14131a;
  --bg-2: #1c1b25;
  --card: #201f2b;
  --line: #322f3f;
  --text: #ece9f5;
  --muted: #9a94ac;
  --accent: #a78bfa;
  --accent-strong: #8b5cf6;
  --focus: #a78bfa;
  --short: #34d399;
  --long: #38bdf8;
  --gaming: #fb923c;
  --radius: 18px;
  --shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  background: radial-gradient(1200px 800px at 70% -10%, #2a2740 0%, var(--bg) 55%);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}

body[data-mode="focus"]  { --accent: var(--focus);  --accent-strong: #8b5cf6; }
body[data-mode="short"]  { --accent: var(--short);  --accent-strong: #10b981; }
body[data-mode="long"]   { --accent: var(--long);   --accent-strong: #0ea5e9; }
body[data-mode="gaming"] { --accent: var(--gaming); --accent-strong: #f97316; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  gap: 16px;
}
.brand { font-weight: 700; letter-spacing: 0.02em; font-size: 17px; }
.brand span { opacity: 0.9; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.icon-btn {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: #26243180; border-color: var(--accent); }
.icon-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

/* ---------- stage ---------- */
.stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 64px;
}
#timer-home { width: 100%; max-width: 460px; }

.card {
  background: linear-gradient(180deg, var(--card), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ---------- tabs ---------- */
.tabs {
  display: flex;
  gap: 6px;
  background: #17161f;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 5px;
  flex-wrap: wrap;
}
.tab {
  flex: 1 1 auto;
  min-width: 64px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 6px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s, color 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--accent-strong); color: #fff; }
.tab.running:not(.active) {
  color: var(--text);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent);
}
.badge {
  font-size: 11px;
  background: #0003;
  border-radius: 999px;
  padding: 1px 7px;
  min-width: 18px;
}
.tab.active .badge { background: #ffffff2e; }

/* ---------- dial ---------- */
.dial { position: relative; width: 100%; aspect-ratio: 1; max-width: 320px; margin: 0 auto; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: #ffffff12; stroke-width: 12; }
.ring-fg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 12;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.3s linear, stroke 0.3s;
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--accent) 60%, transparent));
}
.dial-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.time {
  font-size: clamp(44px, 14vw, 68px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.blurb { color: var(--muted); font-size: 13px; }

/* ---------- controls ---------- */
/* 3-column grid so Start/Pause stays dead-centre whether or not Stop is showing */
.controls {
  display: grid;
  grid-template-columns: 46px auto 46px;
  gap: 12px;
  align-items: center;
  justify-items: center;
}
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  background: var(--accent-strong);
  color: #fff;
  border: 0;
  border-radius: 12px;
  padding: 0 36px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.1s, filter 0.15s;
}
.btn-primary.sm {
  min-height: 0;
  padding: 9px 16px;
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: none;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary .ico { flex: none; width: 15px; height: 15px; fill: currentColor; }

/* square neutral buttons flanking Start/Pause (stop, popout) */
.btn-round {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.btn-round svg { flex: none; width: 16px; height: 16px; fill: currentColor; }
.btn-round:hover { border-color: var(--accent); color: var(--accent); }
.btn-round:active { transform: translateY(1px); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 18px;
  font-size: 13px;
  cursor: pointer;
}
.btn-ghost.sm { padding: 8px 12px; }
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }

/* The tally is redundant on the desktop card (each tab already shows its count),
   so it only appears in the mini player. */
.tally {
  display: none;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  font-size: 12px;
  color: var(--muted);
}
.pip-body .tally { display: flex; }

.tally-item b { color: var(--text); font-weight: 700; }
.tally-item::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
  background: var(--muted);
}
/* Only the mode you're currently viewing shows its colour; the rest stay neutral. */
#timer-card[data-mode="focus"]  .tally-item[data-mode="focus"]::before,
.pip-body[data-mode="focus"]    .tally-item[data-mode="focus"]::before  { background: var(--focus); }
#timer-card[data-mode="short"]  .tally-item[data-mode="short"]::before,
.pip-body[data-mode="short"]    .tally-item[data-mode="short"]::before  { background: var(--short); }
#timer-card[data-mode="long"]   .tally-item[data-mode="long"]::before,
.pip-body[data-mode="long"]     .tally-item[data-mode="long"]::before   { background: var(--long); }
#timer-card[data-mode="gaming"] .tally-item[data-mode="gaming"]::before,
.pip-body[data-mode="gaming"]   .tally-item[data-mode="gaming"]::before { background: var(--gaming); }

.current-task {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.current-task .ct-title { color: var(--text); font-weight: 600; }

.home-slot {
  width: 100%;
  margin-top: 16px;
  background: var(--bg-2);
  border: 1px dashed var(--line);
  color: var(--muted);
  padding: 22px;
  border-radius: var(--radius);
  cursor: pointer;
}
.home-slot:hover { color: var(--text); border-color: var(--accent); }

/* ---------- panels ---------- */
.panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(360px, 92vw);
  background: var(--bg-2);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 20px;
  overflow-y: auto;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; }
.panel-head h2 { margin: 0; font-size: 16px; }

.setting-group { display: flex; flex-direction: column; gap: 10px; }
.setting-group h3 {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.setting-group label { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.setting-group label.row { justify-content: flex-start; }
.setting-group input[type="number"] { width: 72px; }
input[type="number"], input[type="text"] {
  background: #16151d;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 9px;
  font: inherit;
}
input[type="range"] { flex: 1; accent-color: var(--accent); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------- tasks ---------- */
.task-form { display: flex; gap: 8px; }
.task-form input { flex: 1; }
.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #16151d;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
}
.task-item.active { border-color: var(--accent); }
.task-item .t-title {
  flex: 1;
  cursor: pointer;
  font-size: 13.5px;
  word-break: break-word;
}
.task-item.done .t-title { text-decoration: line-through; color: var(--muted); }
.task-item .t-del {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  padding: 2px 6px;
}
.task-item .t-del:hover { color: #f87171; }
.panel-foot { display: flex; align-items: center; justify-content: space-between; }
.muted { color: var(--muted); }
.tiny { font-size: 11.5px; }

/* ---------- scrim ---------- */
.scrim { position: fixed; inset: 0; background: #0007; z-index: 15; }

/* ---------- mini player (document PiP window + fallback) ---------- */
.pip-body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, sans-serif;
  padding: 12px;
}
.pip-body .card {
  box-shadow: none;
  border: 0;
  background: transparent;
  padding: 0;
  gap: 14px;
  max-width: 300px;
  margin: 0 auto;
}
.pip-body .tabs { flex-wrap: wrap; }
.pip-body .tab { min-width: 0; flex: 1 1 40%; padding: 7px 4px; font-size: 11px; }
.pip-body .badge { display: none; }
.pip-body .dial { max-width: 190px; }
.pip-body .time { font-size: 40px; }
.pip-body .controls { gap: 9px; grid-template-columns: 42px auto 42px; }
.pip-body .btn-primary { min-height: 42px; padding: 0 20px; font-size: 14px; }
.pip-body .btn-round { width: 42px; height: 42px; }
.pip-body .current-task { display: none; }
.pip-body .home-slot { display: none; }
.pip-body .tally { font-size: 11px; gap: 2px 10px; padding-top: 10px; }
.pip-body .tally-item::before { width: 6px; height: 6px; margin-right: 4px; }

@media (max-width: 420px) {
  .btn-primary { padding: 0 24px; }
  .controls { gap: 10px; grid-template-columns: 44px auto 44px; }
}
