:root {
  color-scheme: light dark;
  --bg: light-dark(#fbfcf8, #141914);
  --text: light-dark(#20291f, #f5f7f0);
  --secondary: light-dark(#687164, #a4ae9e);
  --divider: light-dark(#e5e9df, #30392d);
  --field: light-dark(#eef2e8, #232c20);
  --track: light-dark(#e8ecdf, #303a2b);
  --ring: light-dark(#bdcba9, #59694b);
  --button: light-dark(#2e4328, #d0ec9c);
  --button-text: light-dark(#ffffff, #1d2a15);
  --phase-bg: light-dark(#eaf0e2, #303c26);
  --phase-text: light-dark(#486039, #d0e4b1);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; min-height: 100svh; display: grid; place-items: center; padding: 16px; background: light-dark(#edf0e8, #0b100c); }
button, select, input { font: inherit; color: inherit; }
button, select { -webkit-tap-highlight-color: transparent; touch-action: manipulation; cursor: pointer; }
button { border: 0; }
button:disabled, select:disabled { opacity: .48; cursor: default; }
button:active:not(:disabled) { opacity: .75; }
:focus-visible { outline: 3px solid light-dark(#759a53, #d0ec9c); outline-offset: 3px; }
svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 1.7; fill: none; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.app { width: min(100%, 400px); height: min(870px, calc(100svh - 32px)); min-height: 590px; background: var(--bg); padding: 24px 24px 18px; border: 1px solid var(--divider); border-radius: 34px; box-shadow: 0 12px 34px #00000019; display: flex; flex-direction: column; }
.title-row { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
h1 { margin: 0; font-size: 20px; line-height: 1.45; font-weight: 500; letter-spacing: -.045em; }
.field-row { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.field-label, .detail-label { color: var(--secondary); font-size: 12px; line-height: 1.4; }
.pattern-tools { display: flex; gap: 2px; margin-right: -6px; }
.icon-button { min-width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; background: transparent; border-radius: 12px; color: var(--secondary); padding: 0; }
.icon-button svg { width: 18px; height: 18px; }
.icon-button:active { background: var(--field); }
.pattern-select { width: 100%; height: 50px; padding: 0 12px; font-size: 16px; border: 1px solid transparent; border-radius: 13px; background: var(--field); text-overflow: ellipsis; }
.round-row { display: flex; align-items: baseline; justify-content: center; gap: 12px; margin: 20px 0 16px; flex-shrink: 0; }
.round-label { color: var(--secondary); font-size: 13px; letter-spacing: .04em; }
.round-number { font-size: 34px; line-height: 1; font-weight: 500; font-variant-numeric: tabular-nums; }
.timer-space { flex: 1; min-height: 160px; container-type: size; display: grid; place-items: center; }
.dial { --progress: 100%; width: min(100cqw, 100cqh, 306px); aspect-ratio: 1; border-radius: 50%; padding: 4px; background: conic-gradient(var(--ring) 0% var(--progress), var(--track) var(--progress) 100%); container-type: inline-size; }
.dial-inner { width: 100%; height: 100%; border-radius: 50%; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.phase { border-radius: 100px; padding: 6px 16px; margin-bottom: 9px; background: var(--phase-bg); color: var(--phase-text); font-size: 13px; font-weight: 500; line-height: 1.4; white-space: nowrap; }
.clock { font-size: clamp(44px, 32cqi, 98px); font-weight: 500; line-height: 1.05; letter-spacing: -.065em; padding-right: .065em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.clock-caption { color: var(--secondary); font-size: 12px; line-height: 1.4; letter-spacing: .08em; margin-top: 9px; }
.next { text-align: center; color: var(--secondary); font-size: 12px; line-height: 1.6; margin: 15px 0 20px; flex-shrink: 0; }
.details { border-top: 1px solid var(--divider); padding-top: 15px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; flex-shrink: 0; }
.detail { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.detail-value { font-size: 18px; font-weight: 500; min-height: 38px; display: flex; align-items: center; font-variant-numeric: tabular-nums; }
.sound-select { max-width: 100%; min-height: 38px; padding: 0 3px; border: 0; border-radius: 7px; font-size: 16px; background: var(--bg); }
.actions { display: grid; grid-template-columns: 52px minmax(0, 1fr) 52px; gap: 10px; align-items: center; margin-top: 20px; flex-shrink: 0; }
.main-button { height: 64px; border-radius: 100px; background: var(--button); color: var(--button-text); display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 17px; font-weight: 500; padding: 0 10px; white-space: nowrap; }
.main-button svg { width: 19px; height: 19px; stroke-width: 2; }
.reset-button { width: 52px; min-height: 64px; border-radius: 16px; background: transparent; color: var(--secondary); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 5px 0; }
.reset-button svg { width: 23px; height: 23px; }
.reset-button span { font-size: 11px; line-height: 1.4; white-space: nowrap; }
.system-status { color: var(--secondary); font-size: 10px; line-height: 1.5; text-align: center; min-height: 15px; margin: 10px 0 0; }
.notice { padding: 9px 11px; margin: 10px 0 0; border-radius: 10px; background: light-dark(#f2e9d8, #3c3425); color: light-dark(#76551f, #e8c98d); font-size: 12px; line-height: 1.6; flex-shrink: 0; }
.app[data-phase="prepare"] { --ring: light-dark(#b18b45, #dfbc77); --phase-bg: light-dark(#f2e9d8, #3c3425); --phase-text: light-dark(#856022, #e8c98d); }
.app[data-phase="work"] { --ring: light-dark(#6e9448, #c1df8a); }
.app[data-phase="rest"] { --ring: light-dark(#678c9d, #95becb); --phase-bg: light-dark(#e4eef2, #283840); --phase-text: light-dark(#3b6a7c, #b4d8e2); }
.app[data-status="paused"] .phase { background: var(--field); color: var(--text); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

dialog { color: var(--text); background: var(--bg); width: min(410px, calc(100% - 24px)); max-height: calc(100dvh - 32px); margin: auto; border: 1px solid var(--divider); border-radius: 24px; padding: 20px 22px 24px; box-shadow: 0 20px 80px #00000040; overscroll-behavior: contain; }
dialog::backdrop { background: #080e0ac4; backdrop-filter: blur(5px); }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
h2 { font-size: 19px; font-weight: 500; line-height: 1.5; margin: 0; }
.dialog-heading .icon-button { margin-right: -8px; }
.input-label, legend { font-size: 13px; color: var(--secondary); padding: 0; display: block; margin-bottom: 8px; }
input, dialog select { background: var(--field); border: 1px solid transparent; border-radius: 10px; padding: 0 12px; min-height: 46px; min-width: 0; width: 100%; font-size: 16px; }
fieldset { padding: 0; border: 0; min-width: 0; }
.duration-fields { margin: 20px 0; }
.duration-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.duration-row label { display: flex; align-items: center; gap: 8px; }
.duration-row input { text-align: center; font-variant-numeric: tabular-nums; }
.duration-row span { color: var(--secondary); font-size: 13px; }
.hint { color: var(--secondary); font-size: 12px; line-height: 1.6; margin: 8px 0 0; }
.sound-edit-row { display: flex; gap: 10px; }
.sound-edit-row select { flex: 1; }
.secondary-button { background: var(--field); color: var(--text); border-radius: 12px; padding: 0 16px; min-height: 46px; display: flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap; }
.secondary-button svg { width: 18px; height: 18px; }
.form-error { color: light-dark(#9a3529, #ffb3a3); font-size: 13px; line-height: 1.6; margin: 12px 0 0; }
.storage-hint { margin-top: 18px; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 24px; }
.save-button { min-height: 48px; border-radius: 12px; background: var(--button); color: var(--button-text); font-weight: 500; }
@media (max-width: 480px) {
  body { padding: 0; background: var(--bg); }
  .app { width: 100%; max-width: 430px; height: 100svh; max-height: none; border: 0; box-shadow: none; border-radius: 0; padding: max(22px, env(safe-area-inset-top)) 24px max(16px, env(safe-area-inset-bottom)); }
}
@media (max-height: 740px) {
  .app { padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .title-row { margin-bottom: 1px; }
  .round-row { margin: 12px 0; }
  .round-number { font-size: 29px; }
  .next { margin: 10px 0 12px; }
  .details { padding-top: 10px; }
  .actions { margin-top: 12px; }
  .main-button, .reset-button { min-height: 56px; height: 56px; }
  .phase { padding: 4px 12px; margin-bottom: 6px; font-size: 12px; }
  .clock-caption { margin-top: 5px; }
}
@media (max-width: 360px) {
  .app { padding-left: 18px; padding-right: 18px; }
  h1 { font-size: 18px; }
  .title-row { gap: 6px; }
  .actions { grid-template-columns: 48px minmax(0, 1fr) 48px; gap: 7px; }
  .reset-button { width: 48px; }
  .main-button { font-size: 16px; }
  dialog { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; } }

.time-adjust { display: flex; gap: 3px; }
.time-adjust button { min-width: 44px; min-height: 44px; padding: 0 3px; border-radius: 9px; font-size: 12px; background: var(--field); }
