:root {
  color-scheme: dark;
  --ink: #f5f1e8;
  --muted: #9a9890;
  --surface: #191816;
  --line: #34312c;
  --accent: #f04d2f;
  --accent-bright: #ff6447;
  --rest: #5ca6a8;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% 0%, rgba(240, 77, 47, .10), transparent 34rem),
    #11100e;
  color: var(--ink);
}

button, select { font: inherit; }
button, select { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.app { width: min(100% - 32px, 720px); margin: 0 auto; padding: max(20px, env(safe-area-inset-top)) 0 max(40px, env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-size: 15px; font-weight: 750; letter-spacing: .02em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; color: var(--accent-bright); font-size: 10px; letter-spacing: -.03em; }
.icon-button { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); cursor: pointer; }
.icon-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sound-off { display: none; }
.icon-button[aria-pressed="true"] .sound-on { display: none; }
.icon-button[aria-pressed="true"] .sound-off { display: block; }

.timer-card { position: relative; overflow: hidden; padding: 24px; border: 1px solid var(--line); border-radius: 28px; background: rgba(25, 24, 22, .86); box-shadow: 0 28px 70px rgba(0,0,0,.28); }
.timer-card::before { content: ""; position: absolute; width: 260px; height: 260px; top: -160px; right: -90px; border-radius: 50%; background: var(--accent); opacity: .06; filter: blur(10px); transition: background .3s; }
.timer-card.resting::before { background: var(--rest); opacity: .12; }
.round-row { display: flex; align-items: center; justify-content: space-between; }
.phase-pill { padding: 7px 11px; border-radius: 999px; color: #ff8a72; background: rgba(240,77,47,.12); font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.resting .phase-pill { color: #9bd4d5; background: rgba(92,166,168,.13); }
.round-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.round-count strong { color: var(--ink); }

.timer-wrap { position: relative; width: min(100%, 410px); margin: 18px auto 20px; aspect-ratio: 1; border-radius: 50%; cursor: grab; touch-action: none; user-select: none; }
.timer-wrap.dragging { cursor: grabbing; }
.progress-ring { width: 100%; height: 100%; }
.progress-ring circle { fill: none; stroke-width: 7; }
.ring-track, .ring-value { transform: rotate(-90deg); transform-origin: 160px 160px; }
.ring-track { stroke: #2b2925; }
.ring-value { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 911.06; stroke-dashoffset: 0; transition: stroke-dashoffset .2s linear, stroke .3s; }
.ring-knob { fill: var(--ink); stroke: var(--accent); stroke-width: 4; transform-box: view-box; transform-origin: 160px 160px; transition: stroke .3s; filter: drop-shadow(0 2px 4px rgba(0,0,0,.45)); }
.resting .ring-value { stroke: var(--rest); }
.resting .ring-knob { stroke: var(--rest); }
.clock { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.clock-label, .next-label { color: var(--muted); font-size: 13px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }
#timeDisplay { margin: 2px 0 7px; font-size: clamp(68px, 17vw, 112px); line-height: .95; font-weight: 800; letter-spacing: -.065em; font-variant-numeric: tabular-nums; }
.next-label { font-size: 11px; letter-spacing: .05em; text-transform: none; }

.controls { display: grid; grid-template-columns: 1fr minmax(170px, 2fr) 1fr; gap: 10px; align-items: center; }
.controls button { min-height: 54px; border-radius: 16px; border: 0; cursor: pointer; font-weight: 750; }
.secondary-control { color: var(--muted); background: #24221f; }
.primary-control { display: flex; align-items: center; justify-content: center; gap: 10px; color: white; background: var(--accent); box-shadow: 0 10px 28px rgba(240,77,47,.2); }
.primary-control:hover { background: var(--accent-bright); }
.play-icon { width: 0; height: 0; border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-left: 9px solid currentColor; }
.primary-control.running .play-icon { width: 10px; height: 12px; border: 0; border-left: 3px solid currentColor; border-right: 3px solid currentColor; }

.settings { padding: 34px 8px 0; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; }
.eyebrow { margin: 0 0 4px; color: var(--accent-bright); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 31px; font-weight: 500; letter-spacing: -.025em; }
.duration { color: var(--muted); font-size: 13px; }
.setting-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.setting-field { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 68px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 15px; background: rgba(25,24,22,.7); color: #c4c1b9; font-size: 13px; font-weight: 650; }
select { min-width: 76px; padding: 9px 26px 9px 10px; border: 0; border-radius: 9px; outline: none; color: var(--ink); background: #2a2824; font-weight: 750; text-align: right; }
.stepper { display: flex; align-items: center; overflow: hidden; border-radius: 9px; background: #2a2824; }
.stepper button { width: 34px; height: 36px; border: 0; background: transparent; cursor: pointer; color: var(--muted); font-size: 20px; }
.stepper output { min-width: 26px; text-align: center; color: var(--ink); font-weight: 800; }
.hint { margin: 16px 0 0; text-align: center; color: #706e68; font-size: 12px; }
kbd { padding: 2px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); font: inherit; }
button:focus-visible, select:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 3px; }
button:active { transform: translateY(1px); }

@media (max-width: 540px) {
  .app { width: min(100% - 20px, 720px); padding-top: 14px; }
  .topbar { margin: 0 6px 14px; }
  .timer-card { padding: 18px 14px 16px; border-radius: 23px; }
  .timer-wrap { margin: 12px auto; }
  .controls { grid-template-columns: 70px 1fr 70px; }
  .controls button { min-height: 50px; font-size: 12px; }
  .setting-grid { grid-template-columns: 1fr; }
  .settings { padding-top: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
