/* ---------- tokens ---------- */
:root {
  --font: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo',
    'Noto Sans KR', 'Malgun Gothic', 'Segoe UI', Roboto, sans-serif;
  --bg: #f7f5f0;
  --card: #fffefb;
  --sunken: #f1eee7;
  --line: #e6e2d9;
  --line-strong: #d6d1c6;
  --ink: #1f2321;
  --ink-2: #474b48;
  --muted: #6c706b;
  --faint: #a4a69f;
  --on-accent: #ffffff;
  --shadow: 0 1px 2px rgba(31, 35, 33, 0.04), 0 8px 24px -12px rgba(31, 35, 33, 0.1);
  --radius: 16px;
  --radius-s: 11px;
  --break: #23877d;
  --accent: #2f5bd3;
  --live: var(--accent); /* accent of the running phase */
  --accent-soft: color-mix(in srgb, var(--accent) 10%, transparent);
  --live-soft: color-mix(in srgb, var(--live) 12%, transparent);
  color-scheme: light;
}
[data-accent='terracotta'] { --accent: #b85c3c; }
[data-accent='blue'] { --accent: #2f5bd3; }
[data-accent='green'] { --accent: #3d7a4a; }
[data-accent='plum'] { --accent: #85487d; }

[data-theme='dark'] {
  --bg: #111312;
  --card: #181b19;
  --sunken: #1f2320;
  --line: #2a2e2b;
  --line-strong: #3a3f3b;
  --ink: #f3f3ef;
  --ink-2: #cfd0ca;
  --muted: #9a9d96;
  --faint: #636761;
  --on-accent: #0f1110;
  --shadow: none;
  --break: #5cc4b5;
  color-scheme: dark;
}
[data-theme='dark'][data-accent='terracotta'] { --accent: #e08a68; }
[data-theme='dark'][data-accent='blue'] { --accent: #8aa6f5; }
[data-theme='dark'][data-accent='green'] { --accent: #84c08f; }
[data-theme='dark'][data-accent='plum'] { --accent: #cf93c4; }

body[data-phase='break'] { --live: var(--break); }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
  overflow-wrap: anywhere;
  transition: background-color 0.25s, color 0.25s;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: 0.45; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
[hidden] { display: none !important; }
.sprite { position: absolute; }
.ico {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 50; padding: 10px 14px;
  background: var(--ink); color: var(--bg); border-radius: 10px; text-decoration: none;
}
.skip-link:focus { top: 12px; }
.muted { color: var(--muted); }
kbd {
  display: inline-block; min-width: 1.9em; padding: 1px 7px; text-align: center;
  font: 500 12px/1.6 var(--font); color: var(--ink-2);
  background: var(--sunken); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px;
}

/* ---------- shell ---------- */
.shell { max-width: 1240px; margin: 0 auto; padding: 0 40px; }
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 76px; border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; color: var(--ink); }
.brand-name { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.header-nav { display: flex; align-items: center; gap: 6px; }
.nav-link {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px;
  font-size: 15px; color: var(--muted); text-decoration: none; border-radius: 10px;
}
.nav-link:hover { color: var(--ink); background: var(--sunken); }
.pill-btn {
  display: inline-flex; align-items: center; gap: 7px; min-height: 40px; margin-left: 6px; padding: 0 15px;
  font-size: 14.5px; font-weight: 600; border: 1px solid var(--line-strong); border-radius: 999px;
}
.pill-btn:hover { background: var(--sunken); }
.pill-btn .ico { width: 17px; height: 17px; }

.title-row { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; padding: 36px 0 26px; }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.3; }
.subtitle { font-size: 15px; color: var(--muted); }

.app-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) 304px; gap: 32px; align-items: start;
}

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 48px; padding: 0 16px; font-size: 16px; font-weight: 500; color: var(--muted);
  border-radius: 10px 10px 0 0;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected='true'] { color: var(--ink); font-weight: 700; }
.tab[aria-selected='true']::after {
  content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px;
  background: var(--accent); border-radius: 2px;
}
.tab .ico { width: 18px; height: 18px; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: background-color 0.25s, border-color 0.25s;
}
.timer-card { padding: 22px 28px 18px; outline: none; }
.card-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mode-label { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--live); }
body[data-state='running'] .dot { animation: dot-breathe 2s ease-in-out infinite; }
@keyframes dot-breathe { 50% { opacity: 0.35; } }
.toolbar-actions { display: flex; align-items: center; gap: 4px; }
.ghost-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px;
  font-size: 14px; color: var(--ink-2); border-radius: 10px;
}
.ghost-btn:hover { background: var(--sunken); color: var(--ink); }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; color: var(--ink-2); border-radius: 10px;
}
.icon-btn:hover { background: var(--sunken); color: var(--ink); }
.icon-btn .ico { width: 20px; height: 20px; }
.icon-btn[aria-pressed='true'] { color: var(--accent); }
.icon-btn.small { width: 34px; height: 34px; }
.icon-btn.small .ico { width: 18px; height: 18px; }

/* ---------- big display ---------- */
.display-wrap { display: flex; flex-direction: column; align-items: center; padding: 22px 0 26px; }
.display-caption { font-size: 15px; color: var(--muted); letter-spacing: 0.01em; }
.display {
  --dsize: clamp(62px, 17vw, 120px);
  position: relative; display: inline-flex; align-items: flex-start; justify-content: center;
  margin: 6px 0 0; padding: 4px 14px; border-radius: 18px; cursor: pointer;
  font-variant-numeric: tabular-nums; font-feature-settings: 'tnum';
  transition: background-color 0.2s;
}
.display:hover:not([aria-disabled='true']) { background: var(--accent-soft); }
.display[aria-disabled='true'] { cursor: default; }
.dgroup { display: flex; flex-direction: column; align-items: center; }
.dnum {
  font-size: var(--dsize); font-weight: 300; line-height: 1.04; letter-spacing: -0.035em;
  color: var(--ink); transition: color 0.3s;
}
.dunit { margin-top: 4px; font-size: 14px; color: var(--muted); }
.dcolon {
  font-size: calc(var(--dsize) * 0.78); font-weight: 200; line-height: 1.3; color: var(--faint);
  padding: 0 0.06em; transform: translateY(-0.02em);
}
.dcs {
  position: absolute; right: 0; top: 0.8em; transform: translateX(80%);
  font-size: calc(var(--dsize) * 0.3); font-weight: 400; color: var(--muted); letter-spacing: -0.01em;
}
body[data-mode='stopwatch'] .display { --dsize: clamp(52px, 14vw, 112px); }
.display-hint { margin-top: 12px; font-size: 14px; color: var(--muted); min-height: 1.6em; }
body.finished .dnum { color: var(--live); }
body.finished .display { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { background-color: transparent; }
  50% { background-color: var(--live-soft); }
}

/* ---------- progress / meta ---------- */
.progress { height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress-bar {
  height: 100%; width: 100%; background: var(--live); transform-origin: left center; transform: scaleX(0);
}
.meta-row {
  display: flex; justify-content: space-between; gap: 12px; margin-top: 10px;
  font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.meta-row b { margin-left: 6px; font-weight: 600; color: var(--ink); }

/* ---------- controls ---------- */
.controls { display: flex; justify-content: center; align-items: stretch; gap: 12px; margin: 28px 0 22px; }
.main-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-width: 200px; min-height: 56px; padding: 0 28px;
  font-size: 18px; font-weight: 600; letter-spacing: -0.01em;
  color: var(--on-accent); background: var(--live); border-radius: 14px;
  transition: background-color 0.25s, transform 0.12s, filter 0.15s;
}
.main-btn:hover { filter: brightness(1.06); }
.main-btn:active { transform: scale(0.98); }
.main-btn .ico { width: 20px; height: 20px; }
body[data-state='running'] .main-btn { background: var(--ink); color: var(--bg); }
.sub-btn {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-width: 76px; min-height: 56px; padding: 6px 10px;
  font-size: 12.5px; color: var(--ink-2);
  background: var(--card); border: 1px solid var(--line-strong); border-radius: 14px;
}
.sub-btn:hover:not(:disabled) { background: var(--sunken); color: var(--ink); }
.sub-btn .ico { width: 19px; height: 19px; }

.set-dots { display: flex; justify-content: center; gap: 6px; margin: -6px 0 20px; padding: 0; list-style: none; }
.set-dots li { width: 30px; height: 4px; border-radius: 4px; background: var(--line); transition: background-color 0.3s; }
.set-dots li.done { background: var(--faint); }
.set-dots li.current { background: var(--live); }
.set-dots li.current.half { background: linear-gradient(90deg, var(--accent) 50%, var(--break) 50%); }

.card-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-top: 14px; border-top: 1px solid var(--line);
}
.kbd-hint { font-size: 13.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.foot-actions { display: flex; gap: 4px; }
.text-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 10px;
  font-size: 14px; color: var(--ink-2); border-radius: 10px;
}
.text-btn:hover { background: var(--sunken); color: var(--ink); }
.text-btn .ico { width: 17px; height: 17px; }
.text-btn.center { justify-content: center; }

/* ---------- stats ---------- */
.stats-line {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 4px 0; font-size: 14px; color: var(--muted);
}
.stats { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.stats .ico { width: 17px; height: 17px; margin-right: 2px; }
.stats b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.stats .sep { margin: 0 6px; color: var(--faint); }
.stats-note { font-size: 13px; color: var(--faint); }

/* ---------- laps ---------- */
.laps-card { margin-top: 20px; padding: 18px 24px 10px; }
.laps-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.laps-head h2 { font-size: 16px; font-weight: 700; }
.laps-empty { padding: 10px 0 14px; font-size: 14px; color: var(--muted); }
.laps-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 15px; }
.laps-table th {
  padding: 8px 6px; font-size: 13px; font-weight: 500; color: var(--muted); text-align: right;
  border-bottom: 1px solid var(--line);
}
.laps-table td { padding: 10px 6px; text-align: right; border-bottom: 1px solid var(--line); }
.laps-table tr:last-child td { border-bottom: 0; }
.laps-table th:first-child, .laps-table td:first-child { text-align: left; }
.laps-table td:first-child { color: var(--muted); }
.lap-tag { margin-left: 8px; font-size: 12px; font-weight: 500; }
tr.fast td:nth-child(2) { color: var(--accent); font-weight: 600; }
tr.slow td:nth-child(2) { color: var(--muted); }
tr.fast .lap-tag { color: var(--accent); }
tr.slow .lap-tag { color: var(--faint); }

/* ---------- sidebar ---------- */
.sidebar { display: flex; flex-direction: column; gap: 16px; padding-top: 66px; }
.panel { padding: 20px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 14px; }
.panel-title .count { font-weight: 500; color: var(--muted); font-size: 14px; }
.panel-note { font-size: 13.5px; line-height: 1.6; color: var(--muted); }
.panel-note.small { font-size: 13px; margin-top: 12px; }
.panel-text { font-size: 14.5px; line-height: 1.7; color: var(--ink-2); }
.panel-text + .panel-text { margin-top: 10px; }
.panel-text.muted { color: var(--muted); font-size: 14px; }
.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.preset {
  min-height: 52px; font-size: 19px; font-weight: 500; font-variant-numeric: tabular-nums;
  border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--card);
  transition: border-color 0.15s, background-color 0.15s;
}
.preset small { margin-left: 2px; font-size: 12.5px; color: var(--muted); font-weight: 400; }
.preset:hover { border-color: var(--line-strong); background: var(--sunken); }
.preset[aria-pressed='true'] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.preset[aria-pressed='true'] small { color: inherit; }
.wide-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 46px; margin-top: 10px; font-size: 14.5px; color: var(--ink-2);
  background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius-s);
}
.wide-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.wide-btn.accent { margin-top: 16px; font-weight: 600; color: var(--on-accent); background: var(--accent); border-color: transparent; }
.wide-btn.accent:hover { filter: brightness(1.06); }

.pomo-form { margin-top: 12px; }
.field-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 7px 0; font-size: 15px; color: var(--ink-2);
}
.num-field { display: inline-flex; align-items: center; gap: 8px; }
.num-field em { width: 1.2em; font-style: normal; font-size: 14px; color: var(--muted); }
.num-field input {
  width: 64px; height: 40px; padding: 0 10px; text-align: right; font-size: 16px;
  font-variant-numeric: tabular-nums; background: var(--card);
  border: 1px solid var(--line-strong); border-radius: 10px; -moz-appearance: textfield; appearance: textfield;
}
.num-field input::-webkit-inner-spin-button, .num-field input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.num-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.num-field input[aria-invalid='true'] { border-color: #c4473a; }
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 15px; color: var(--ink-2); cursor: pointer;
}
.switch-row.bordered { margin-top: 16px; }
.switch {
  position: relative; flex: none; width: 44px; height: 26px; margin: 0; appearance: none; -webkit-appearance: none;
  background: var(--line-strong); border-radius: 999px; cursor: pointer; transition: background-color 0.2s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); transition: transform 0.2s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.form-error { margin-top: 10px; font-size: 13.5px; color: #c4473a; }
[data-theme='dark'] .form-error { color: #f08b7e; }

.field-label { display: block; margin-bottom: 6px; font-size: 14px; color: var(--muted); }
.sound-row { display: flex; gap: 8px; }
.select {
  flex: 1; min-width: 0; height: 44px; padding: 0 36px 0 12px; font-size: 15px;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23888' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 13px center;
  border: 1px solid var(--line-strong); border-radius: 10px; appearance: none; -webkit-appearance: none;
}
.select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.square-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 12px; font-size: 14px;
  color: var(--ink-2); border: 1px solid var(--line-strong); border-radius: 10px; white-space: nowrap;
}
.square-btn:hover { background: var(--sunken); color: var(--ink); }
.square-btn .ico { width: 15px; height: 15px; }
.volume-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.volume-row output { width: 3.2em; text-align: right; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
input[type='range'] {
  --fill: 60%;
  flex: 1; height: 28px; margin: 0; background: transparent; appearance: none; -webkit-appearance: none; cursor: pointer;
}
input[type='range']::-webkit-slider-runnable-track {
  height: 4px; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent) var(--fill), var(--line-strong) var(--fill));
}
input[type='range']::-moz-range-track { height: 4px; border-radius: 4px; background: var(--line-strong); }
input[type='range']::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--accent); }
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%;
  background: var(--card); border: 2px solid var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
input[type='range']::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%; background: var(--card); border: 2px solid var(--accent);
}

.saved-list { margin: 0; padding: 0; list-style: none; }
.saved-list li { display: flex; align-items: center; border-top: 1px solid var(--line); }
.saved-list li:first-child { border-top: 0; }
.saved-load {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start;
  padding: 9px 8px 9px 0; text-align: left; border-radius: 8px;
}
.saved-load:hover .saved-name { color: var(--accent); }
.saved-name { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.saved-desc { font-size: 13px; color: var(--muted); }
.saved-del { width: 36px; height: 36px; color: var(--faint); }
.saved-del:hover { color: var(--ink); }
.saved-del .ico { width: 16px; height: 16px; }

/* ---------- content sections ---------- */
.content { margin-top: 64px; padding-top: 48px; border-top: 1px solid var(--line); }
.content h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.guide {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 28px 64px;
  grid-template-areas: 'intro steps' 'tips steps'; align-items: start;
}
.content-intro { grid-area: intro; }
.steps { grid-area: steps; }
.tips { grid-area: tips; }
.content-intro p { margin-top: 14px; font-size: 16px; line-height: 1.75; color: var(--ink-2); }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { position: relative; padding: 0 0 26px 52px; counter-increment: step; }
.steps li::before {
  content: counter(step, decimal-leading-zero); position: absolute; left: 0; top: 1px;
  font-size: 16px; font-weight: 500; color: var(--accent); font-variant-numeric: tabular-nums;
}
.steps h3 { font-size: 17px; font-weight: 700; }
.steps p { margin-top: 6px; font-size: 16px; line-height: 1.75; color: var(--ink-2); }
.tips { padding: 22px 24px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.tips h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.tips ul { margin: 0; padding-left: 1.1em; }
.tips li { padding: 3px 0; font-size: 15px; line-height: 1.7; color: var(--ink-2); }
.tips li::marker { color: var(--accent); }

.faq-list { margin-top: 18px; border-top: 1px solid var(--line); }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary {
  position: relative; display: block; padding: 18px 44px 18px 2px; font-size: 16px; font-weight: 600;
  cursor: pointer; list-style: none; border-radius: 6px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before, .faq summary::after {
  content: ''; position: absolute; right: 8px; top: 50%; width: 14px; height: 1.6px; background: var(--muted);
  transition: transform 0.2s;
}
.faq summary::after { transform: rotate(90deg); }
.faq details[open] summary::after { transform: rotate(0deg); }
.faq details p { padding: 0 44px 20px 2px; font-size: 15.5px; line-height: 1.8; color: var(--ink-2); }

.site-footer {
  display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  margin-top: 64px; padding: 26px 0 40px; border-top: 1px solid var(--line); font-size: 14px; color: var(--ink-2);
}
.site-footer .muted { font-size: 13.5px; }

/* ---------- dialogs ---------- */
.dialog {
  width: min(440px, calc(100vw - 32px)); padding: 26px 26px 24px; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.35);
}
.dialog::backdrop { background: rgba(20, 22, 21, 0.38); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.dialog[open] { animation: dialog-in 0.18s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin: -6px -8px 4px 0; }
.dialog h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.dialog-text { font-size: 14.5px; line-height: 1.65; color: var(--muted); margin-bottom: 18px; }
.dialog-text.small { margin: 16px 0 0; font-size: 13.5px; }
.dialog-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 50px; margin-top: 20px; font-size: 16px; font-weight: 600;
  color: var(--on-accent); background: var(--accent); border-radius: 12px;
}
.dialog-primary:hover { filter: brightness(1.06); }
.dialog-primary .ico { width: 17px; height: 17px; }
.dialog-secondary {
  width: 100%; min-height: 48px; margin-top: 8px; font-size: 15px; color: var(--ink-2);
  border: 1px solid var(--line-strong); border-radius: 12px;
}
.dialog-secondary:hover { background: var(--sunken); }
.dialog-actions.stack { display: flex; flex-direction: column; gap: 4px; }
.text-input {
  width: 100%; height: 48px; padding: 0 14px; font-size: 16px;
  background: var(--sunken); border: 1px solid var(--line); border-radius: 12px;
}
.text-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--card); }
.text-input.mono { font-size: 14.5px; color: var(--ink-2); }

.time-fields { display: flex; align-items: flex-start; justify-content: center; gap: 6px; }
.time-field { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; font-size: 14px; color: var(--muted); }
.time-field input {
  width: 100%; height: 76px; text-align: center; font-size: 38px; font-weight: 300; font-variant-numeric: tabular-nums;
  color: var(--ink); background: var(--sunken); border: 1px solid var(--line); border-radius: 14px;
}
.time-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--card); }
.time-colon { padding-top: 18px; font-size: 28px; font-weight: 200; color: var(--faint); }

.finish { text-align: center; padding-top: 30px; }
.finish-mark { display: grid; place-items: center; margin-bottom: 14px; }
.finish-mark svg { width: 52px; height: 52px; fill: none; stroke: var(--live); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.finish h2 { font-size: 23px; }
.finish .dialog-text { margin: 8px 0 0; }

.keys { margin: 8px 0 0; }
.keys div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.keys dt { font-size: 15px; color: var(--ink-2); }
.keys dd { margin: 0; display: flex; gap: 4px; }

/* ---------- toasts ---------- */
.toasts {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 40;
  display: flex; flex-direction: column; align-items: center; gap: 8px; transform: translateX(-50%);
  pointer-events: none; width: max-content; max-width: calc(100vw - 32px);
}
.toast {
  padding: 11px 18px; font-size: 15px; font-weight: 500; color: var(--bg); background: var(--ink);
  border-radius: 999px; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.2s ease-out;
}
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity 0.25s, transform 0.25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.stage .toasts { position: absolute; bottom: auto; top: calc(84px + env(safe-area-inset-top)); }

/* ---------- fullscreen stage ---------- */
.stage {
  position: fixed; inset: 0; z-index: 30;
  display: grid; grid-template-rows: auto 1fr auto; justify-items: center;
  padding: calc(18px + env(safe-area-inset-top)) 20px calc(22px + env(safe-area-inset-bottom));
  background: var(--bg); color: var(--ink); overflow: hidden; user-select: none; -webkit-user-select: none;
  --ring-size: min(84vmin, calc(100dvh - 210px), 860px);
}
.stage:fullscreen { background: var(--bg); }
.stage:focus { outline: none; }
.stage::backdrop { background: var(--bg); }
body.stage-open { overflow: hidden; }
.stage-top { justify-self: end; display: flex; align-items: center; gap: 4px; }
.stage-bottom { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.stage .controls { margin: 0; }
.stage-ui { transition: opacity 0.35s ease; }
.stage.idle-ui .stage-ui { opacity: 0; pointer-events: none; }
.stage.idle-ui { cursor: none; }
.dial {
  position: relative; align-self: center; width: var(--ring-size); height: var(--ring-size);
  display: grid; place-items: center; cursor: pointer;
}
.ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring circle { fill: none; stroke-width: 3.4; }
.ring-track { stroke: var(--line); }
.ring-fill {
  stroke: var(--live); stroke-linecap: round; stroke-dasharray: 100 100;
  transition: stroke 0.4s;
}
.stage.flash .ring-fill { animation: ring-flash 1.4s ease-in-out infinite; }
@keyframes ring-flash { 50% { opacity: 0.25; } }
.dial-text { position: relative; display: flex; flex-direction: column; align-items: center; }
.stage-digits {
  font-size: calc(var(--ring-size) * 0.27); font-weight: 300; line-height: 1; letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; color: var(--ink); transition: color 0.3s;
}
.stage-digits.long { font-size: calc(var(--ring-size) * 0.2); }
.stage-digits .c { color: var(--faint); font-weight: 200; padding: 0 0.02em; position: relative; top: -0.06em; }
.stage-sub { margin-top: calc(var(--ring-size) * 0.035); font-size: clamp(15px, calc(var(--ring-size) * 0.04), 30px); color: var(--muted); }
.stage.urgent .stage-digits, .stage.flash .stage-digits { color: var(--live); }
.swatches { display: flex; gap: 10px; }
.swatch {
  position: relative; width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--line-strong);
}
.swatch::before { content: ''; position: absolute; inset: -8px; } /* larger touch target */
.swatch[data-accent='terracotta'] { background: #b85c3c; }
.swatch[data-accent='blue'] { background: #2f5bd3; }
.swatch[data-accent='green'] { background: #3d7a4a; }
.swatch[data-accent='plum'] { background: #85487d; }
.swatch[aria-checked='true'] { box-shadow: 0 0 0 2px var(--ink); }

/* ---------- responsive ---------- */
@media (max-width: 1023px) {
  .shell { padding: 0 24px; }
  .app-grid { grid-template-columns: 1fr; gap: 24px; }
  .sidebar { padding-top: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
  .guide { grid-template-columns: 1fr; grid-template-areas: 'intro' 'steps' 'tips'; }
}
@media (max-width: 680px) {
  body { font-size: 16.5px; }
  .shell { padding: 0 16px; }
  .site-header { height: 64px; }
  .brand-name { font-size: 18px; }
  .brand-mark { width: 27px; height: 27px; }
  .header-nav { gap: 0; }
  .nav-link { padding: 0 9px; font-size: 14.5px; }
  .pill-btn { padding: 0 12px; margin-left: 2px; }
  .title-row { padding: 24px 0 16px; gap: 10px; }
  h1 { font-size: 23px; }
  .subtitle { font-size: 14px; }
  .tabs { margin-bottom: 14px; gap: 0; }
  .tab { flex: 1; padding: 0 4px; font-size: 15.5px; gap: 6px; }
  .tab .ico { width: 17px; height: 17px; }
  .timer-card { padding: 16px 18px 12px; }
  .toolbar-actions .ghost-btn { padding: 0 9px; font-size: 13.5px; }
  .toolbar-actions .theme-toggle .theme-label { display: none; }
  .toolbar-actions .theme-toggle { width: 40px; padding: 0; justify-content: center; }
  .toolbar-actions .ghost-btn .ico { width: 19px; height: 19px; }
  .display-wrap { padding: 16px 0 20px; }
  .display { padding: 2px 6px; }
  .dcolon { padding: 0; }
  .dunit { font-size: 13.5px; }
  .controls { gap: 8px; margin: 22px 0 18px; }
  .main-btn { flex: 1; min-width: 0; padding: 0 16px; }
  .sub-btn { min-width: 70px; }
  .card-foot { flex-wrap: wrap; }
  .kbd-hint { display: none; }
  .foot-actions { justify-content: flex-end; margin: 0 -10px; width: calc(100% + 20px); }
  .foot-actions [data-action='save'] { margin-right: auto; }
  .sidebar { grid-template-columns: 1fr; }
  .laps-card { padding: 16px 16px 6px; }
  .content { margin-top: 48px; padding-top: 36px; }
  .steps li { padding-left: 40px; }
  .tips { padding: 18px 18px; }
  .faq details p { padding-right: 8px; }
  .stage { --ring-size: min(88vmin, calc(100dvh - 260px)); }
  .stage-bottom { gap: 18px; }
  .stage .main-btn { min-width: 170px; }
  .dialog { padding: 22px 20px 20px; }
}
@media (max-width: 359px) {
  .nav-link[href='#guide'] { display: none; }
}
@media (pointer: coarse) {
  .kbd-hint { display: none; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .stage { --ring-size: min(70vh, 70vw); grid-template-rows: auto 1fr auto; padding-top: 8px; padding-bottom: 8px; }
  .stage-bottom { flex-direction: row; gap: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
