:root { --accent: var(--yellow); --accent-tint: var(--yellow-tint); --phase: var(--yellow); --phase-tint: var(--yellow-tint); }
html { height: 100%; overscroll-behavior: none; }
body { height: 100%; font-size: 16px; line-height: 1.45; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin: 0; }
button, input { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.timer-app { width: 100%; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; max-width: 680px; margin: auto; }
.topbar { display: flex; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 10px max(20px, env(safe-area-inset-left)); min-height: 68px; border-bottom: 1px solid var(--border); }
.topbar h1 { margin-right: auto; font-size: 18px; font-weight: 600; }
.app-name::before { background: var(--yellow); }
.btn { min-height: 44px; height: auto; font-size: 14px; }
.ico { width: 18px; height: 18px; }
main { min-height: 0; display: grid; padding: 24px 20px 16px; }
.setup { min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 16px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; }
.section-head h2 { font-size: 15px; font-weight: 500; color: var(--muted); }
.section-head .num { font-size: 18px; }
.duration-fields { display: grid; grid-template-rows: repeat(3, minmax(76px, 1fr)); gap: 12px; min-height: 0; }
.interval { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-width: 0; padding: 16px 18px; border: 1px solid var(--phase); border-radius: var(--card); background: var(--phase-tint); box-shadow: var(--shadow-card); }
.interval[data-kind="work"] { --phase: var(--green); --phase-tint: var(--green-tint); }
.interval[data-kind="rest"] { --phase: var(--red); --phase-tint: var(--red-tint); }
.interval label { color: var(--phase); font-weight: 600; font-size: 18px; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper .btn { min-width: 44px; padding: 0; font-size: 22px; font-weight: 400; }
.value-input { appearance: none; width: 5.4ch; max-width: 100%; min-width: 0; padding: 4px 0; font: 500 clamp(24px, 5vw, 36px)/1.3 var(--mono); color: var(--text); background: transparent; border: 1px solid transparent; border-radius: var(--r); text-align: center; }
.value-input:hover { border-color: var(--border-strong); }
.value-input[aria-invalid="true"] { border-color: var(--error); }
.count-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.count-card { display: grid; justify-items: center; align-content: center; gap: 8px; padding: 14px 8px; border-radius: var(--card); background: var(--surface); border: 1px solid var(--border); }
.count-card label { font-size: 14px; color: var(--muted); font-weight: 500; }
.count-card .value-input { width: 2.5ch; font-size: 32px; }
.count-card .stepper { gap: 0; }
.transport { display: grid; gap: 10px; padding: 0 max(20px, env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
.start { width: 100%; min-height: 60px; font-size: 20px; }
.session-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.notice { color: var(--error); font-size: 14px; }
.session { display: flex; flex-direction: column; justify-content: center; min-height: 0; border-radius: var(--card); }
.session[data-kind="work"] { --phase: var(--green); --phase-tint: var(--green-tint); }
.session[data-kind="rest"] { --phase: var(--red); --phase-tint: var(--red-tint); }
.session[data-kind="complete"] { --phase: var(--green); --phase-tint: var(--green-tint); }
.session-head { display: flex; justify-content: center; align-items: center; gap: 10px; }
.session-head h2 { font-size: clamp(24px, 5vw, 36px); font-weight: 600; color: var(--phase); }
.clock { color: var(--phase); text-align: center; font-size: clamp(68px, 18vw, 128px); letter-spacing: -0.065em; line-height: 1.3; font-weight: 500; margin: 12px -8px 0; }
.next { text-align: center; color: var(--muted); min-height: 24px; font-size: 16px; }
.session-counts { display: grid; grid-template-columns: 1fr 1fr; padding: 32px 0 24px; margin-top: 16px; }
.session-counts > div { display: grid; gap: 8px; justify-items: center; }
.session-counts > div + div { border-left: 1px solid var(--border); }
.session-counts span { font-size: 14px; color: var(--muted); }
.session-counts strong { font-size: 24px; font-weight: 500; }
progress { appearance: none; width: 100%; height: 8px; border: 0; border-radius: 4px; overflow: hidden; background: var(--sunk); color: var(--phase); }
progress::-webkit-progress-bar { background: var(--sunk); }
progress::-webkit-progress-value { background: var(--phase); border-radius: 4px; }
progress::-moz-progress-bar { background: var(--phase); }
.remaining { display: flex; justify-content: space-between; color: var(--muted); padding-top: 12px; font-size: 14px; }
dialog.dialog { width: 480px; max-width: calc(100vw - 24px); max-height: calc(100dvh - 32px); margin: auto; border: 1px solid var(--border); border-radius: 12px; }
dialog.dialog[open] { display: flex; flex-direction: column; }
.dialog-head { flex: none; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { font-size: 18px; font-weight: 600; }
.dialog-scroll { min-height: 0; overflow: auto; padding: 8px 20px calc(20px + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
.volume-row { display: grid; grid-template-columns: 1fr auto; padding: 16px 0; gap: 12px; }
.volume-row .num { color: var(--muted); font-size: 14px; }
input[type="range"] { grid-column: 1 / -1; appearance: none; width: 100%; height: 44px; margin: 0; cursor: pointer; background: transparent; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; background: var(--border-strong); border-radius: 3px; }
input[type="range"]::-moz-range-track { height: 6px; background: var(--border-strong); border-radius: 3px; }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); margin-top: -10px; box-shadow: var(--shadow-card); }
input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.settings-row { display: flex; min-height: 60px; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); }
.settings-row > span { font-size: 16px; }
.settings-row:last-child { border-bottom: 0; }
.switch { width: 48px; height: 28px; border-radius: 16px; min-width: 48px; }
.switch::before { content: ""; position: absolute; inset: -8px 0; }
.switch-thumb { width: 20px; height: 20px; top: 3px; left: 3px; }
.switch[aria-checked="true"] .switch-thumb { transform: translateX(20px); }
.switch:disabled { opacity: 0.4; cursor: not-allowed; }
.dialog-scroll h3 { padding: 24px 0 8px; color: var(--muted); font-size: 14px; font-weight: 500; }
.tone-options { display: grid; gap: 8px; padding-top: 16px; }
.tone-choice { justify-content: space-between; min-height: 52px; }
.tone-choice[aria-checked="true"] { background: var(--accent-tint); border-color: var(--accent); color: var(--accent); }
.tone-choice span:last-child { visibility: hidden; }
.tone-choice[aria-checked="true"] span:last-child { visibility: visible; }
.preview-voice { margin-top: 20px; width: 100%; }
#voice-notice { margin-top: 12px; }
@media (max-height: 690px) {
  main { padding-top: 14px; padding-bottom: 12px; }
  .setup { gap: 10px; }
  .duration-fields { gap: 8px; grid-template-rows: repeat(3, minmax(64px, 1fr)); }
  .interval { padding: 8px 12px; }
  .count-card { padding: 8px; gap: 2px; }
  .session-counts { margin-top: 0; padding: 20px 0; }
  .transport { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}
@media (max-width: 370px) {
  main { padding-left: 12px; padding-right: 12px; }
  .topbar, .transport { padding-left: 12px; padding-right: 12px; }
  .interval { padding-inline: 10px; gap: 4px; }
  .interval label { font-size: 16px; }
  .stepper { gap: 2px; }
  .count-card .stepper .btn { min-width: 40px; }
}
@media (max-height: 540px) {
  main { overflow-y: auto; }
  .setup { min-height: 390px; }
  .session { min-height: 340px; }
  .clock { font-size: 72px; }
}
@media (forced-colors: active) {
  .interval, .count-card, .btn, .switch { border: 1px solid ButtonText; }
  .switch-thumb { background: ButtonText; }
  .switch[aria-checked="true"] { outline: 2px solid Highlight; }
}
