/* Layout: a single centred instrument column for the timer (max 30rem); the board breaks out
   to a wide, horizontally snapping row of columns. Mono type for everything that counts;
   one electric phase colour (cobalt for focus, green for breaks) and nothing else loud. */
:root {
  --bg: #eef0f4;
  --surface: #ffffff;
  --surface-2: #e3e6ee;
  --line: rgba(15, 18, 34, 0.1);
  --line-strong: rgba(15, 18, 34, 0.2);
  --ink: #0f1222;
  --muted: #586075;
  --faint: #9097a8;
  --focus: #2d3af5;
  --on-focus: #ffffff;
  --rest: #0b936a;
  --on-rest: #ffffff;
  --warn: #d2402c;
  --l-red: #e5484d;
  --l-amber: #d99010;
  --l-green: #2f9e6a;
  --l-blue: #3e63dd;
  --l-violet: #8e4ec6;
  --l-grey: #8b90a0;
  --shadow: 0 18px 44px -22px rgba(15, 18, 34, 0.35);
  --lift: 0 24px 50px -16px rgba(15, 18, 34, 0.45);
  --scrim: rgba(15, 18, 34, 0.36);

  --font-mono: "Martian Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --font-body: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --t-xs: 0.7rem;
  --t-sm: 0.86rem;
  --t-md: 1rem;
  --ease: cubic-bezier(0.2, 0.75, 0.25, 1);
  --tab-h: 62px;
  --phase: var(--focus);
  --on-phase: var(--on-focus);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0c16;
    --surface: #12152a;
    --surface-2: #1b1f38;
    --line: rgba(232, 234, 246, 0.09);
    --line-strong: rgba(232, 234, 246, 0.18);
    --ink: #e8eaf6;
    --muted: #9aa0ba;
    --faint: #5d637e;
    --focus: #7783ff;
    --on-focus: #0a0c16;
    --rest: #3dd68c;
    --on-rest: #06140d;
    --warn: #ff7a62;
    --l-red: #ff6369;
    --l-amber: #f1b43a;
    --l-green: #4cc38a;
    --l-blue: #7093ff;
    --l-violet: #b07ceb;
    --l-grey: #8b90a8;
    --shadow: 0 18px 44px -22px rgba(0, 0, 0, 0.7);
    --lift: 0 24px 50px -16px rgba(0, 0, 0, 0.8);
    --scrim: rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0c16;
  --surface: #12152a;
  --surface-2: #1b1f38;
  --line: rgba(232, 234, 246, 0.09);
  --line-strong: rgba(232, 234, 246, 0.18);
  --ink: #e8eaf6;
  --muted: #9aa0ba;
  --faint: #5d637e;
  --focus: #7783ff;
  --on-focus: #0a0c16;
  --rest: #3dd68c;
  --on-rest: #06140d;
  --warn: #ff7a62;
  --l-red: #ff6369;
  --l-amber: #f1b43a;
  --l-green: #4cc38a;
  --l-blue: #7093ff;
  --l-violet: #b07ceb;
  --l-grey: #8b90a8;
  --shadow: 0 18px 44px -22px rgba(0, 0, 0, 0.7);
  --lift: 0 24px 50px -16px rgba(0, 0, 0, 0.8);
  --scrim: rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}
body[data-phase="break"] {
  --phase: var(--rest);
  --on-phase: var(--on-rest);
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
:root {
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
html,
body {
  min-height: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--t-md) / 1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
[hidden] {
  display: none !important;
}
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
svg {
  display: block;
}
a {
  color: inherit;
}
h1,
h2,
h3,
p,
ol,
ul,
dl,
dd {
  margin: 0;
  padding: 0;
}
ol,
ul {
  list-style: none;
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 8px;
}

.app {
  max-width: 30rem;
  margin-inline: auto;
  padding-left: max(18px, env(safe-area-inset-left, 0px));
  padding-right: max(18px, env(safe-area-inset-right, 0px));
  padding-block: 4px calc(var(--tab-h) + 32px + env(safe-area-inset-bottom, 0px));
}
body.on-board .app {
  max-width: 76rem;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.muted {
  color: var(--muted);
}
.small {
  font-size: var(--t-sm);
}
.lede {
  color: var(--muted);
  max-width: 36ch;
  margin-top: 8px;
}
.link {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
}
.link:hover {
  color: var(--ink);
}

.view {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.view.enter {
  animation: rise 0.4s var(--ease) both;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}
.block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.page-head {
  padding-top: 18px;
}
.page-title {
  font-family: var(--font-mono);
  font-weight: 300;
  font-size: 2.1rem;
  letter-spacing: -0.04em;
  line-height: 1.05;
}

/* ---------- Controls ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
}
.topbar-actions {
  display: flex;
  gap: 8px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}
.brand-mark {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    var(--phase) 0 22%,
    transparent 23% 42%,
    var(--phase) 43% 52%,
    transparent 53% 72%,
    var(--phase) 73% 80%,
    transparent 81%
  );
}
.icon-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  transition:
    background-color 0.2s,
    color 0.2s;
}
.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-btn[aria-pressed="true"] {
  background: var(--phase);
  color: var(--on-phase);
  border-color: transparent;
}
.icon-btn:active {
  transform: scale(0.95);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 20px;
  border-radius: 14px;
  border: 0;
  font-weight: 600;
  transition:
    transform 0.2s var(--ease),
    background-color 0.2s;
}
.btn:active {
  transform: scale(0.97);
}
.btn-wide {
  width: 100%;
}
.btn-ink {
  background: var(--ink);
  color: var(--bg);
}
.btn-phase {
  background: var(--phase);
  color: var(--on-phase);
}
.btn-line {
  background: transparent;
  border: 1px solid var(--line-strong);
}
.btn-warn {
  background: transparent;
  color: var(--warn);
  border: 1px solid color-mix(in oklab, var(--warn) 45%, transparent);
}
.btn-sm {
  min-height: 40px;
  padding: 0 14px;
  font-size: var(--t-sm);
  border-radius: 10px;
}

.seg {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: 13px;
  background: var(--surface-2);
}
.seg button {
  flex: 1;
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: var(--t-sm);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.field {
  display: grid;
  gap: 8px;
}

/* ---------- Focus ---------- */
.stage {
  position: relative;
  width: min(84vw, 340px, 44vh);
  aspect-ratio: 1;
  max-width: 100%;
  margin: 4px auto 0;
}
.tunnel {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.readout {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  pointer-events: none;
}
.phase-label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--phase);
  font-weight: 500;
}
.time {
  font-family: var(--font-mono);
  font-weight: 300;
  font-size: clamp(2.6rem, 13vw, 3.6rem);
  letter-spacing: -0.06em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  padding: 6px 10px;
  border-radius: 10px;
  background: color-mix(in oklab, var(--bg) 70%, transparent);
}
.cycle {
  display: flex;
  gap: 6px;
}
.cycle i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1.5px solid var(--phase);
}
.cycle i.on {
  background: var(--phase);
}
body.running .time {
  color: var(--ink);
}
body.paused .time {
  animation: blink 1.8s ease-in-out infinite;
}
@keyframes blink {
  50% {
    opacity: 0.35;
  }
}

.task-pill {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: center;
  text-align: left;
  width: 100%;
  padding: 12px 14px 12px 16px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.task-pill .eyebrow {
  grid-column: 1;
  color: var(--phase);
}
.task-pill-title {
  grid-column: 1;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-pill-title.empty {
  color: var(--muted);
  font-weight: 500;
}
.task-pill svg {
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.8;
  stroke-linecap: round;
}

.controls {
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  gap: 12px;
  align-items: center;
}
.ctl {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  border: 1px solid var(--line-strong);
  background: transparent;
  display: grid;
  place-items: center;
  color: var(--ink);
}
.ctl svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ctl:active,
.go:active {
  transform: scale(0.96);
}
.go {
  min-height: 60px;
  border-radius: 18px;
  border: 0;
  background: var(--phase);
  color: var(--on-phase);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  box-shadow: 0 16px 34px -16px var(--phase);
  transition:
    background-color 0.4s,
    transform 0.2s var(--ease);
}
body.running .go {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}
.capture {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  align-self: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px dashed var(--line-strong);
  background: transparent;
  color: var(--muted);
  font-size: var(--t-sm);
}
.capture svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}
.capture:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.next {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}
.next li {
  border-bottom: 1px solid var(--line);
}
.next button {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 12px 0;
  background: none;
  border: 0;
  text-align: left;
}
.radio {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  display: grid;
  place-items: center;
}
.radio::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--phase);
  transform: scale(0);
  transition: transform 0.2s var(--ease);
}
[aria-pressed="true"] > .radio {
  border-color: var(--phase);
}
[aria-pressed="true"] > .radio::after {
  transform: scale(1);
}
.next-title {
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.next-col {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.next-empty {
  padding: 14px 0;
  color: var(--muted);
  font-size: var(--t-sm);
}

/* Tunnel mode: everything but the work falls away. */
body.tunnel .topbar,
body.tunnel .modes,
body.tunnel .block,
body.tunnel .tabbar,
body.tunnel .task-pill svg {
  display: none;
}
body.tunnel .app {
  padding-top: 6vh;
}
body.tunnel .stage {
  width: min(90vw, 440px, 56vh);
}
body.tunnel .task-pill {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  text-align: center;
  grid-template-columns: 1fr;
  justify-items: center;
  pointer-events: none;
}
.exit-tunnel {
  position: fixed;
  z-index: 30;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: max(14px, env(safe-area-inset-right, 0px));
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  display: grid;
  place-items: center;
}
.exit-tunnel svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Board ---------- */
.board-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding-top: 14px;
  flex-wrap: wrap;
}
.board-switch {
  display: grid;
  grid-template-columns: auto auto;
  column-gap: 6px;
  align-items: center;
  background: none;
  border: 0;
  text-align: left;
  padding: 0;
  min-width: 0;
}
.board-switch .eyebrow {
  grid-column: 1 / -1;
}
.board-name {
  font-family: var(--font-mono);
  font-weight: 300;
  font-size: 1.9rem;
  letter-spacing: -0.04em;
  line-height: 1.1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 78vw;
}
.board-switch svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.8;
  stroke-linecap: round;
}
.board-meta {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.board {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  margin-inline: calc(-1 * max(18px, env(safe-area-inset-left, 0px)));
  padding: 4px max(18px, env(safe-area-inset-left, 0px)) 24px;
  scroll-padding-inline: max(18px, env(safe-area-inset-left, 0px));
}
.board::-webkit-scrollbar {
  display: none;
}
body.dragging .board {
  scroll-snap-type: none;
}
.col {
  flex: 0 0 min(84vw, 320px);
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: var(--surface-2);
  max-height: calc(100vh - 210px);
  max-height: calc(100dvh - 210px);
}
.col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 8px 6px 14px;
}
.col-name {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: none;
  border: 0;
  padding: 4px 0;
  text-align: left;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.col-count {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding: 2px 8px;
  border-radius: 999px;
}
.col.over .col-count {
  background: var(--warn);
  color: #fff;
}
.col-head .icon-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
}
.col-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 8px 8px;
  overflow-y: auto;
  min-height: 56px;
  overscroll-behavior: contain;
}
.col-list > * {
  flex-shrink: 0;
}
.col-add {
  display: flex;
  gap: 6px;
  padding: 0 8px 10px;
}
.col-add input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 11px;
  border: 1px dashed var(--line-strong);
  background: transparent;
}
.col-add input:focus {
  outline: none;
  border-style: solid;
  border-color: var(--focus);
  background: var(--surface);
}
.col-new {
  flex: 0 0 min(70vw, 240px);
  min-height: 110px;
  border-radius: 18px;
  border: 1px dashed var(--line-strong);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.wip-note {
  margin: 0 8px 8px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 0.78rem;
  background: color-mix(in oklab, var(--warn) 14%, transparent);
  color: var(--warn);
}

.card {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 12px 12px 10px 14px;
  border-radius: 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: left;
  width: 100%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: grab;
}
.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--lc, transparent);
}
.card-title {
  font-weight: 500;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.col.is-done .card-title {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: var(--line-strong);
}
.card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--muted);
  flex-wrap: wrap;
}
.poms {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}
.poms i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.3px solid var(--muted);
}
.poms i.on {
  background: var(--focus);
  border-color: var(--focus);
}
.poms i.over {
  background: var(--warn);
  border-color: var(--warn);
}
.card.current {
  border-color: var(--focus);
  box-shadow: 0 0 0 1px var(--focus);
}
.card.current .now {
  color: var(--focus);
  font-weight: 600;
}
.card.placeholder {
  opacity: 0.35;
  border-style: dashed;
  box-shadow: none;
}
.card.ghost {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  margin: 0;
  cursor: grabbing;
  box-shadow: var(--lift);
  transform: rotate(-2deg) scale(1.03);
  transition: transform 0.15s var(--ease);
}
.card.pressing {
  transform: scale(0.98);
  transition: transform 0.2s;
}
[data-l="red"] {
  --lc: var(--l-red);
}
[data-l="amber"] {
  --lc: var(--l-amber);
}
[data-l="green"] {
  --lc: var(--l-green);
}
[data-l="blue"] {
  --lc: var(--l-blue);
}
[data-l="violet"] {
  --lc: var(--l-violet);
}
[data-l="grey"] {
  --lc: var(--l-grey);
}

/* ---------- Stats ---------- */
.figures {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-block: 1px solid var(--line-strong);
}
.figures div {
  padding: 14px 0 12px;
  display: flex;
  flex-direction: column-reverse;
  gap: 4px;
  min-width: 0;
}
.figures div + div {
  padding-left: 14px;
  border-left: 1px solid var(--line);
}
.figures dd {
  font-family: var(--font-mono);
  font-weight: 300;
  font-size: 2rem;
  letter-spacing: -0.05em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.figures dd small {
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0;
  margin-left: 2px;
}
.figures dt {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.chart svg {
  width: 100%;
  height: auto;
  overflow: visible;
}
.chart text {
  fill: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
}
.chart .grid {
  stroke: var(--line);
}
.chart .bar {
  fill: color-mix(in oklab, var(--focus) 55%, var(--surface-2));
}
.chart .bar.today {
  fill: var(--focus);
}
.hours {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 2px;
}
.hours i {
  aspect-ratio: 1 / 2.2;
  border-radius: 3px;
  background: var(--surface-2);
}
.hours i[data-l="1"] {
  background: color-mix(in oklab, var(--focus) 25%, var(--surface-2));
}
.hours i[data-l="2"] {
  background: color-mix(in oklab, var(--focus) 50%, var(--surface-2));
}
.hours i[data-l="3"] {
  background: color-mix(in oklab, var(--focus) 75%, var(--surface-2));
}
.hours i[data-l="4"] {
  background: var(--focus);
}
.hours-axis {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--muted);
}
.rank li,
.log li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  align-items: center;
}
.rank,
.log {
  border-top: 1px solid var(--line-strong);
}
.rank b,
.log b {
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rank span,
.log span {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.rank .val,
.log .val {
  grid-row: 1 / span 2;
  grid-column: 2;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  color: var(--ink);
  text-align: right;
}
.log .partial {
  color: var(--muted);
}
.empty {
  display: grid;
  gap: 12px;
  justify-items: start;
  padding: 20px;
  border-radius: 16px;
  border: 1px dashed var(--line-strong);
}
.empty p {
  color: var(--muted);
  max-width: 34ch;
}

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  max-width: 30rem;
  margin-inline: auto;
  padding: 6px max(12px, env(safe-area-inset-left, 0px))
    calc(8px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-right, 0px));
  background: color-mix(in oklab, var(--bg) 84%, transparent);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
@media (min-width: 30rem) {
  .tabbar {
    bottom: 14px;
    left: 14px;
    right: 14px;
    border: 1px solid var(--line);
    border-radius: 20px;
    padding-bottom: 8px;
    box-shadow: var(--shadow);
  }
}
.tabbar a {
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 7px 0 3px;
  min-height: 52px;
  text-decoration: none;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.tabbar svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tabbar a[aria-current="page"] {
  color: var(--ink);
}
.tabbar a[aria-current="page"] svg {
  stroke: var(--phase);
}

/* ---------- Sheet ---------- */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--scrim);
  animation: fade 0.3s both;
}
.scrim.leaving {
  animation: fade 0.22s reverse both;
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 61;
  max-width: 30rem;
  margin-inline: auto;
  max-height: 90vh;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  box-shadow: 0 -18px 50px -20px rgba(0, 0, 0, 0.4);
  animation: sheet-in 0.4s var(--ease) both;
}
.sheet.leaving {
  animation: sheet-out 0.24s var(--ease) both;
}
@keyframes sheet-in {
  from {
    transform: translateY(100%);
  }
}
@keyframes sheet-out {
  to {
    transform: translateY(100%);
  }
}
.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 4px;
  background: var(--line-strong);
  margin: 10px auto 0;
  flex: none;
}
.sheet-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 12px max(20px, env(safe-area-inset-right, 0px))
    calc(22px + env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
}
.sheet-body > * {
  flex-shrink: 0;
}
.sheet-title {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  line-height: 1.2;
}
.input,
.textarea {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--ink);
}
.textarea {
  padding: 12px 14px;
  min-height: 96px;
  resize: vertical;
  line-height: 1.45;
}
.input:focus,
.textarea:focus {
  outline: none;
  border-color: var(--focus);
}
.title-input {
  font-size: 1.15rem;
  font-weight: 600;
}
.labels {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.label-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--lc, transparent);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  display: grid;
  place-items: center;
}
.label-dot[aria-pressed="true"] {
  border-color: var(--ink);
}
.label-dot[data-l="none"] {
  background: transparent;
}
.label-dot[data-l="none"]::after {
  content: "";
  width: 60%;
  height: 1.5px;
  background: var(--muted);
  transform: rotate(-45deg);
}
.stepper {
  display: flex;
  align-items: center;
  gap: 12px;
}
.stepper button {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: transparent;
  font-size: 1.2rem;
}
.stepper output {
  font-family: var(--font-mono);
  min-width: 7ch;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.row-actions .btn {
  flex: 1;
}
.moves {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.chip {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: transparent;
  font-size: var(--t-sm);
}
.chip[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.rows {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  min-height: 56px;
}
.row-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.row-text small {
  color: var(--muted);
  font-size: var(--t-sm);
}
.list-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 0;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.list-btn span:last-child {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
}
.list-btn[aria-current="true"] {
  font-weight: 600;
}
.switch {
  position: relative;
  width: 48px;
  height: 28px;
  flex: none;
}
.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}
.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  transition: background-color 0.2s;
}
.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ink);
  transition: transform 0.25s var(--ease);
}
.switch input:checked + span {
  background: var(--focus);
  border-color: transparent;
}
.switch input:checked + span::after {
  transform: translateX(20px);
  background: #fff;
}
.switch input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.confirm {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  bottom: calc(var(--tab-h) + 26px + env(safe-area-inset-bottom, 0px));
  max-width: calc(100% - 32px);
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: var(--t-sm);
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: rise 0.3s var(--ease) both;
}

/* ---------- Stats layout, key hints and desktop-only rail parts ---------- */
.stats {
  display: flex;
  flex-direction: column;
  gap: 26px;
}
.key-hints,
.rail-only {
  display: none;
}

/* ---------- Desktop ----------
   From 64rem the bottom tab bar becomes a left rail, Focus splits into the timer and
   an Up next panel, the board's columns share the full width, Stats becomes a grid
   and sheets open as centred dialogs. */
@media (min-width: 64rem) {
  :root {
    --rail-w: 92px;
    --gutter: clamp(32px, 4vw, 56px);
  }
  .app {
    max-width: none;
    margin: 0;
    padding: 14px var(--gutter) 56px calc(var(--rail-w) + var(--gutter));
  }
  body.on-board .app {
    max-width: none;
  }
  body.tunnel .app {
    padding-left: var(--gutter);
  }
  .app > .view {
    width: 100%;
    max-width: 72rem;
    margin-inline: auto;
  }
  .app > .view-board {
    max-width: none;
  }
  .app > [data-view="stats"] {
    max-width: 64rem;
  }

  /* Rail */
  .tabbar {
    top: 0;
    bottom: 0;
    left: 0;
    right: auto;
    width: var(--rail-w);
    max-width: none;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: calc(18px + env(safe-area-inset-top, 0px)) 12px
      calc(18px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
    border: 0;
    border-right: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none;
    background: var(--bg);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .rail-only {
    display: grid;
  }
  .rail-brand {
    place-items: center;
    height: 44px;
    margin-bottom: 14px;
  }
  .rail-brand .brand-mark {
    width: 26px;
    height: 26px;
  }
  .tabbar a,
  .rail-settings {
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 5px;
    min-height: 66px;
    padding: 8px 0;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: var(--faint);
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    transition:
      background-color 0.2s,
      color 0.2s;
  }
  .rail-settings {
    margin-top: auto;
  }
  .rail-settings svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
  }
  .tabbar a:hover,
  .rail-settings:hover {
    background: var(--surface-2);
    color: var(--ink);
  }
  .tabbar a[aria-current="page"] {
    background: var(--surface);
    box-shadow: 0 0 0 1px var(--line);
  }

  /* Focus: the timer on the left, what to work on beside it. */
  .view[data-view="focus"] {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(19rem, 24rem);
    grid-template-rows: repeat(6, auto) 1fr;
    grid-template-areas:
      "top top"
      "modes side"
      "stage side"
      "task side"
      "controls side"
      "capture side"
      "keys side";
    column-gap: clamp(32px, 5vw, 80px);
    row-gap: 18px;
    align-items: start;
  }
  .view[data-view="focus"] > .topbar {
    grid-area: top;
  }
  .view[data-view="focus"] > .modes,
  .view[data-view="focus"] > .task-pill,
  .view[data-view="focus"] > .controls {
    width: min(100%, 30rem);
    justify-self: center;
  }
  .view[data-view="focus"] > .modes {
    grid-area: modes;
  }
  .view[data-view="focus"] > .task-pill {
    grid-area: task;
  }
  .view[data-view="focus"] > .controls {
    grid-area: controls;
  }
  .view[data-view="focus"] > .capture {
    grid-area: capture;
    justify-self: center;
  }
  .topbar .brand-mark {
    display: none;
  }
  .view[data-view="focus"] > .stage {
    grid-area: stage;
    justify-self: center;
    width: min(100%, 480px, calc(100vh - 430px));
    min-width: 280px;
    margin: 0;
  }
  .view[data-view="focus"] > .block {
    grid-area: side;
    position: sticky;
    top: 20px;
    padding: 18px 20px 10px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
  }
  .time {
    font-size: clamp(3.6rem, 6.2vh, 4.6rem);
  }
  .key-hints {
    display: flex;
    grid-area: keys;
    justify-self: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 18px;
    margin: 0;
    color: var(--faint);
    font-size: 0.78rem;
  }
  .key-hints span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
  .key-hints kbd {
    min-width: 22px;
    padding: 2px 6px;
    border: 1px solid var(--line-strong);
    border-bottom-width: 2px;
    border-radius: 6px;
    background: var(--surface);
    color: var(--muted);
    font: 500 0.66rem / 1.4 var(--font-mono);
    text-align: center;
  }
  @media (hover: none) {
    .key-hints {
      display: none;
    }
  }

  /* Tunnel mode on a big screen: one centred column and a larger tunnel. */
  body.tunnel .view[data-view="focus"] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas: "stage" "task" "controls" "capture";
    padding-top: 2vh;
  }
  body.tunnel .view[data-view="focus"] > .stage {
    width: min(100%, 620px, 62vh);
  }
  body.tunnel .key-hints {
    display: none;
  }

  /* Board: columns share the width; a thin scrollbar when they overflow. */
  .board {
    margin-inline: calc(-1 * var(--gutter));
    padding: 4px var(--gutter) 24px;
    scroll-padding-inline: var(--gutter);
    scroll-snap-type: none;
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
  }
  .board::-webkit-scrollbar {
    display: block;
    height: 8px;
  }
  .board::-webkit-scrollbar-thumb {
    border-radius: 8px;
    background: var(--line-strong);
  }
  .col {
    flex: 1 0 280px;
    max-width: 380px;
    max-height: calc(100dvh - 170px);
  }
  .col-new {
    flex: 0 0 200px;
  }
  .board-name {
    max-width: 60vw;
    font-size: 2.2rem;
  }

  /* Stats: headline figures across the top, then two columns. */
  .page-title {
    font-size: 2.6rem;
  }
  .stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 36px 56px;
    align-items: start;
  }
  .stats > .figures {
    grid-column: 1 / -1;
  }
  .empty {
    max-width: 36rem;
  }

  /* Sheets open as centred dialogs. */
  .sheet {
    top: 0;
    bottom: 0;
    height: fit-content;
    max-width: 32rem;
    max-height: min(86vh, 780px);
    max-height: min(86dvh, 780px);
    margin: auto;
    border-bottom: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--lift);
    animation-name: sheet-pop;
    animation-duration: 0.28s;
  }
  .sheet.leaving {
    animation-name: sheet-drop;
    animation-duration: 0.2s;
  }
  .sheet-handle {
    display: none;
  }
  .sheet-body {
    padding: 22px 26px 26px;
  }
  .toast {
    left: calc(50% + var(--rail-w) / 2);
    bottom: 28px;
  }
  body.tunnel .toast {
    left: 50%;
  }
  .exit-tunnel {
    top: 20px;
    right: 24px;
  }

  /* The shared account sheet also opens centred, like Tunnel's own dialogs.
     html:root outranks the token map at the end of this file. */
  html:root {
    --acct-sheet-margin: auto;
    --acct-sheet-radius: 22px;
    --acct-sheet-gutter: 48px;
    --acct-handle: none;
    --acct-enter: acct-fade;
    --acct-shadow: var(--lift);
  }
}
@keyframes sheet-pop {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
}
@keyframes sheet-drop {
  to {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Account sheet: maps Tunnel's tokens onto the shared account sheet (css/account.css). */
:root {
  --acct-bg: var(--surface);
  --acct-field: var(--bg);
  --acct-raised: var(--surface-2);
  --acct-raised-on: var(--surface);
  --acct-ink: var(--ink);
  --acct-muted: var(--muted);
  --acct-faint: var(--faint);
  --acct-line: var(--line);
  --acct-line-strong: var(--line-strong);
  --acct-accent: var(--focus);
  --acct-danger: var(--warn);
  --acct-primary: var(--focus);
  --acct-on-primary: var(--on-focus);
  --acct-scrim: var(--scrim);
  --acct-shadow: 0 -18px 50px -20px rgba(0, 0, 0, 0.4);
  --acct-font-body: var(--font-body);
  --acct-font-display: var(--font-mono);
  --acct-font-label: var(--font-mono);
  --acct-display-size: 1.9rem;
  --acct-display-weight: 400;
  --acct-display-tracking: -0.045em;
  --acct-label-size: 0.64rem;
  --acct-label-weight: 500;
  --acct-sheet-radius: 22px 22px 0 0;
  --acct-radius: 12px;
  --acct-btn-radius: 14px;
  --acct-seg-radius: 13px;
  --acct-btn-h: 50px;
}
