:root {
  --bg: #05080d;
  --panel: rgba(9, 16, 25, .86);
  --ink: #f2f6f7;
  --soft: #c7d1d5;
  --muted: #8b9aa4;
  --dim: #6d7c86;
  --line: rgba(217, 238, 240, .12);
  --line-strong: rgba(217, 238, 240, .2);
  --accent: #5eead4;
  --accent-soft: #99f6e4;
  --accent-glow: rgba(94, 234, 212, .2);
  --sans: "Aptos", "Segoe UI Variable", "Segoe UI", sans-serif;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  color-scheme: dark;
}

html[data-mode="break"] {
  --accent: #f5b568;
  --accent-soft: #ffd49a;
  --accent-glow: rgba(245, 181, 104, .2);
}

* { box-sizing: border-box; }

html {
  min-width: 300px;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-width: 300px;
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 38%, var(--accent-glow), transparent 31rem),
    var(--bg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .4s ease;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

body::before {
  opacity: .2;
  background-image:
    linear-gradient(rgba(255, 255, 255, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .025) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: linear-gradient(to bottom, black, transparent 90%);
}

body::after {
  background:
    linear-gradient(90deg, transparent 49.92%, rgba(217, 238, 240, .035) 50%, transparent 50.08%),
    linear-gradient(transparent 49.92%, rgba(217, 238, 240, .035) 50%, transparent 50.08%);
}

button,
a { color: inherit; font: inherit; }

button { border: 0; }
a { text-decoration: none; }

::selection { color: var(--bg); background: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 4px;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 10px 14px;
  transform: translateY(-160%);
  color: var(--bg);
  background: var(--accent);
  border-radius: 6px;
  font: 600 .75rem var(--mono);
}

.skip-link:focus { transform: none; }

.focus-app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100svh;
  isolation: isolate;
}

.utility-header,
.utility-footer {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding-inline: max(24px, env(safe-area-inset-left));
  color: var(--dim);
  font: 500 .66rem var(--mono);
  letter-spacing: .09em;
  text-transform: uppercase;
}

.utility-header {
  min-height: 76px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 12px;
  color: var(--soft);
}

.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  color: var(--bg);
  background: var(--accent);
  border-radius: 50%;
  font-weight: 700;
  letter-spacing: -.03em;
  transition: background-color .35s ease;
}

.brand:hover .brand-label { color: var(--ink); }

.local-status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0;
}

.local-status span {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--accent-glow);
}

.timer-stage {
  display: grid;
  place-items: center;
  padding: clamp(34px, 6vh, 68px) 22px;
}

.timer-panel {
  display: grid;
  width: min(100%, 470px);
  justify-items: center;
}

.timer-heading {
  margin-bottom: 24px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font: 500 .67rem var(--mono);
  letter-spacing: .18em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--soft);
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  font-weight: 450;
  letter-spacing: -.02em;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(100%, 390px);
  margin-bottom: clamp(30px, 5vh, 46px);
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(9, 16, 25, .58);
  backdrop-filter: blur(16px);
}

.mode {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 10px;
  cursor: pointer;
  color: var(--dim);
  background: transparent;
  border-radius: 8px;
  font: 500 .68rem var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  transition: color .2s ease, background-color .2s ease, box-shadow .2s ease;
}

.mode small {
  color: inherit;
  font-size: .58rem;
  opacity: .65;
}

.mode:hover { color: var(--soft); }

.mode[aria-pressed="true"] {
  color: var(--ink);
  background: rgba(255, 255, 255, .04);
  box-shadow: inset 0 -2px var(--accent);
}

.timer-dial {
  position: relative;
  display: grid;
  width: clamp(248px, 64vw, 360px);
  aspect-ratio: 1;
  place-items: center;
}

.timer-dial::before,
.timer-dial::after {
  content: "";
  position: absolute;
  z-index: -1;
  background: var(--line);
}

.timer-dial::before { width: calc(100% + 46px); height: 1px; }
.timer-dial::after { width: 1px; height: calc(100% + 46px); }

.timer-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  transform: rotate(-90deg);
}

.ring-track,
.ring-progress {
  fill: none;
  vector-effect: non-scaling-stroke;
}

.ring-track {
  stroke: var(--line-strong);
  stroke-width: 1.25;
}

.ring-progress {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 0;
  filter: drop-shadow(0 0 5px var(--accent-glow));
  transition: stroke .35s ease;
}

.timer-readout {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
}

.mode-label {
  margin: 0;
  color: var(--accent);
  font: 500 .68rem var(--mono);
  letter-spacing: .2em;
  text-transform: uppercase;
}

.timer-value {
  color: var(--ink);
  font: 500 clamp(4rem, 15vw, 6.25rem)/.95 var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.08em;
  text-indent: -.08em;
}

.timer-status {
  min-height: 1.35em;
  margin: 0;
  color: var(--muted);
  font-size: .9rem;
}

.timer-controls {
  display: grid;
  grid-template-columns: minmax(138px, 1.4fr) 1fr 1fr;
  width: min(100%, 420px);
  gap: 10px;
  margin-top: clamp(34px, 6vh, 50px);
}

.primary-control,
.secondary-control {
  min-height: 48px;
  padding: 0 18px;
  cursor: pointer;
  border-radius: 10px;
  font: 500 .7rem var(--mono);
  letter-spacing: .11em;
  text-transform: uppercase;
  transition: transform .12s ease, color .2s ease, border-color .2s ease, background-color .3s ease;
}

.primary-control {
  color: var(--bg);
  background: var(--accent);
  box-shadow: 0 12px 34px var(--accent-glow);
}

.secondary-control {
  color: var(--muted);
  background: rgba(9, 16, 25, .58);
  border: 1px solid var(--line);
}

.primary-control:hover { background: var(--accent-soft); }
.secondary-control:hover { color: var(--ink); border-color: var(--line-strong); }
.primary-control:active, .secondary-control:active { transform: scale(.975); }

.sound-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.sound-light {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
}

.sound-control[aria-pressed="false"] .sound-light {
  background: var(--dim);
  box-shadow: none;
}

.rounds {
  display: flex;
  width: min(100%, 420px);
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.round-meter { display: flex; gap: 8px; }

.round-mark {
  width: 28px;
  height: 3px;
  background: var(--line-strong);
  border-radius: 99px;
  transition: background-color .25s ease, box-shadow .25s ease;
}

.round-mark.is-complete {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.rounds p {
  margin: 0;
  color: var(--dim);
  font: 500 .64rem var(--mono);
  letter-spacing: .12em;
}

.rounds p span { color: var(--soft); }

.utility-footer {
  min-height: 64px;
  padding-bottom: max(4px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}

.utility-footer p { margin: 0; }

.shortcut-hints {
  display: flex;
  align-items: center;
  gap: 8px;
}

kbd {
  color: var(--soft);
  font: inherit;
}

@keyframes completion-pulse {
  0%, 100% { transform: scale(1); }
  42% { transform: scale(1.025); }
}

.timer-dial.celebrate { animation: completion-pulse .62s ease; }

@media (max-width: 620px) {
  .utility-header,
  .utility-footer { padding-inline: 20px; }
  .utility-header { min-height: 64px; }
  .brand-label { font-size: .6rem; }
  .local-status { font-size: .58rem; }
  .timer-stage { padding-block: 34px 42px; }
  .timer-heading { margin-bottom: 20px; }
  .mode-switch { margin-bottom: 28px; }
  .timer-controls { grid-template-columns: 1fr 1fr; }
  .primary-control { grid-column: 1 / -1; }
  .utility-footer { justify-content: center; }
  .shortcut-hints { display: none; }
}

@media (max-width: 360px) {
  .brand-label { display: none; }
  .mode { gap: 4px; padding-inline: 6px; }
  .mode small { display: none; }
  .round-mark { width: 22px; }
}

@media (max-height: 740px) and (min-width: 621px) {
  .timer-stage { padding-block: 28px; }
  .timer-heading { margin-bottom: 14px; }
  .mode-switch { margin-bottom: 22px; }
  .timer-dial { width: 270px; }
  .timer-controls { margin-top: 24px; }
  .rounds { margin-top: 18px; padding-top: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }
}

@media (forced-colors: active) {
  body::before, body::after, .timer-dial::before, .timer-dial::after { display: none; }
  .mode-switch, .secondary-control { border: 1px solid CanvasText; }
  .brand-mark, .primary-control { color: Canvas; background: CanvasText; }
  .ring-track { stroke: GrayText; }
  .ring-progress, .round-mark.is-complete { stroke: Highlight; background: Highlight; }
}
