:root {
  --bg: #fbfbfa;
  --ink: #1a1a1a;
  --tick: #9d9b94;
  --tick-lit: #c2c0b8;
  --tick-mid: #74726b;
  --tick-mid-lit: #a3a099;
  --tick-strong: #2e2d28;
  --tick-strong-lit: #5b5951;
  --rim: #cdcabf;
  --track: #e6e4dc;
  --line: #e3e3e0;
  --panel: #ffffff;
  --shadow: 0 8px 30px rgba(0,0,0,.10), 0 1px 3px rgba(0,0,0,.06);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
}

#stage {
  height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(12px, env(safe-area-inset-top)) 12px 12px;
}

#dial {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: manipulation;
}

/* ---- dial ---- */
/* The face is a real disc with a top-left highlight, so the dial reads as a
   round object sitting on the paper rather than as a ring of loose marks. */
.face  { fill: url(#g-face); filter: url(#f-face); }
.rim   { fill: none; stroke: var(--rim); stroke-width: 2.4; }
/* the colour stops on this ring, so it doubles as the edge of the wedges */
.track { fill: none; stroke: #c9c6bc; stroke-width: .9; }

/* Three weights of graduation, each a tapered blade with flat ends rather than
   a round-capped stroke. They differ only in width and inner radius -- the
   outer ends are flush, which is what keeps the crown circular. */
.tick          { fill: var(--tick); stroke: none; }
.tick.five     { fill: var(--tick-mid); stroke: none; }
.tick.quarter  { fill: var(--tick-strong); stroke: none; }
/* the lit facet of a chamfered mark -- the half turned toward the light */
.tick.lit         { fill: var(--tick-lit); }
.tick.five.lit    { fill: var(--tick-mid-lit); }
.tick.quarter.lit { fill: var(--tick-strong-lit); }
.index.lit        { fill: var(--tick-strong-lit); }
.index         { fill: var(--tick-strong); stroke: none; }

.wedge     { stroke: none; }
.sheen     { fill: url(#g-sheen); stroke: none; pointer-events: none; }
.halfmark  { stroke: rgba(255,255,255,.9); stroke-width: 1.6; stroke-linecap: round; }
/* A passed wedge is pale, so the notch has to flip to ink to stay visible */
.halfmark.passed { stroke: rgba(26,26,26,.28); }

/* Colour ties a label to its wedge, but the glyphs are a dark tint of that
   colour so they read as text. The halo is paper, not ink -- invisible where a
   label sits on the background, and only there to save it if one drifts over a
   wedge. paint-order keeps the halo behind the letterforms. */
.label {
  font-family: inherit;
  font-weight: 600;
  letter-spacing: .01em;
  stroke: var(--bg);
  stroke-linejoin: round;
  paint-order: stroke fill;
}

#hands       { filter: url(#f-hands); }
.hand        { fill: var(--ink); }
.hand.hour   { fill: #3a3833; }
.hub         { fill: var(--ink); }
.pin         { fill: var(--bg); }

/* ---- floating button ---- */
.fab {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: #8a8a8a;
  cursor: pointer;
  opacity: .55;
  transition: opacity .18s, color .18s, transform .18s;
  z-index: 10;
}
.fab:hover, .fab:focus-visible { opacity: 1; color: var(--ink); }
.fab[hidden] { display: none; }

.icon {
  width: 18px; height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

/* ---- panel ---- */
.panel {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  width: min(330px, calc(100vw - 24px));
  max-height: min(78dvh, 640px);
  overflow-y: auto;
  padding: 14px 14px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 20;
}
.panel[hidden] { display: none; }
.panel .close { position: absolute; top: 8px; right: 8px; }

.start-row {
  display: flex; align-items: center; gap: 8px;
  padding-right: 34px;
  padding-bottom: 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.rows { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; }

.row { display: flex; align-items: center; gap: 6px; }

.swatch {
  flex: 0 0 auto;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--line);
}

input {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 7px 8px;
  min-width: 0;
}
input:focus-visible { outline: none; border-color: #b9b9b4; }

.row .name { flex: 1 1 auto; width: 100%; }
.row .mins { flex: 0 0 58px; width: 58px; text-align: center; }
.row .mins::-webkit-outer-spin-button,
.row .mins::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.row .mins { -moz-appearance: textfield; }

.time { flex: 1 1 auto; }
.time:disabled { opacity: .38; }

.ghost {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #9a9a9a;
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}
.ghost:hover, .ghost:focus-visible { color: var(--ink); background: #f3f3f0; }
.ghost[aria-pressed="true"] { color: var(--ink); border-color: var(--line); background: #f3f3f0; }
.ghost.ok { color: #3f8f5f; }

.scale-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 2px;
  border-top: 1px solid var(--line);
}
.icon.dim { color: #b0b0b0; flex: 0 0 auto; }

.range {
  flex: 1 1 auto;
  -webkit-appearance: none; appearance: none;
  height: 3px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: var(--line);
  cursor: pointer;
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 15px; height: 15px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  cursor: pointer;
}
.range::-moz-range-thumb {
  width: 15px; height: 15px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  cursor: pointer;
}
.range:focus-visible { outline: none; }
.range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px rgba(0,0,0,.15); }

.foot {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
