.countdown-page {
  --chronme-ink: #5b6475;
  --timer-accent: var(--chronme-pink);
  --timer-muted: #676b78;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  font-size: 16px;
}

.countdown-page [hidden] { display: none !important; }

.countdown-card { text-align: center; padding: 26px 24px 28px; scroll-margin-block-start: max(12px, env(safe-area-inset-top)); }
.countdown-card-header { display: grid; grid-template-columns: 42px minmax(0, 1fr) 42px; align-items: center; }
.countdown-card-header h1 { grid-column: 2; }
.countdown-mute { display: grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 1px solid var(--chronme-line); border-radius: 10px; background: #f8f8fa; color: var(--chronme-ink); }
.countdown-mute:hover, .countdown-mute[aria-pressed="true"] { background: var(--chronme-soft); color: var(--timer-accent); }
.countdown-sound-off, .countdown-mute[aria-pressed="true"] .countdown-sound-on { display: none; }
.countdown-mute[aria-pressed="true"] .countdown-sound-off { display: inline; }
.countdown-card h1, .countdown-history h2, .countdown-dialog h2 { margin: 0; font-weight: 680; letter-spacing: -.025em; line-height: 1.25; }
.countdown-card h1 { font-size: 1.375rem; }
.countdown-setup { max-width: 360px; margin: 20px auto 0; }
.countdown-duration { display: flex; justify-content: center; align-items: start; gap: 8px; padding: 0; margin: 0; border: 0; }
.countdown-duration label { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.countdown-duration label span { font-size: .875rem; color: var(--timer-muted); }
.countdown-duration input, .countdown-colon, .countdown-display { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; font-variant-numeric: tabular-nums; font-weight: 650; }
.countdown-duration input { width: 2.7ch; min-width: 96px; max-width: 100%; padding: 0 3px; text-align: center; color: #5b6475; background: #f8f8fa; border: 1px solid #e7e7ee; border-radius: 12px; font-size: clamp(2.3rem, 10vw, 3.25rem); }
#timer-minutes { width: 3.4ch; }
.countdown-colon { margin-top: 5px; font-size: 2.3rem; color: #777e8c; }
.countdown-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.countdown-increments { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; max-width: 326px; margin: 12px auto 0; }
#timer-clear-time { margin: 0 0 8px; padding-inline: 12px; }
.countdown-increments button, .countdown-secondary, .countdown-primary { min-height: 42px; border: 1px solid transparent; border-radius: 10px; padding: 8px 16px; font-size: .875rem; font-weight: 650; }
.countdown-increments button { padding-inline: 4px; white-space: nowrap; }
.countdown-increments button, .countdown-secondary, #timer-active[data-overtime="true"] #timer-pause { border-color: #e4e4ed; background: #f8f8fa; color: var(--chronme-ink); }
.countdown-increments button:hover, .countdown-secondary:hover, #timer-active[data-overtime="true"] #timer-pause:hover { border-color: #ead0dd; color: var(--timer-accent); background: var(--chronme-soft); }
.countdown-primary, #timer-active[data-overtime="true"] #timer-finish { color: #fff; background: var(--timer-accent); min-width: 117px; }
.countdown-primary:hover, #timer-active[data-overtime="true"] #timer-finish:hover { background: #b62e5c; }
.countdown-options { text-align: left; }
.countdown-task-label { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 5px; font-size: .875rem; font-weight: 650; }
.countdown-task-label span { color: var(--timer-muted); font-size: .8125rem; font-weight: 400; }
#timer-task { width: 100%; padding: 9px 11px; min-height: 42px; background: #fff; color: var(--chronme-ink); border: 1px solid #d9d9e3; border-radius: 9px; font-size: 1rem; }
#timer-task::placeholder { color: #686b78; }
.countdown-track { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; padding: 11px 12px; border: 1px solid #eeeef3; border-radius: 10px; background: #f8f8fa; cursor: pointer; }
.countdown-track input { flex: 0 0 auto; width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--timer-accent); }
.countdown-track strong { display: block; font-size: .875rem; }
#timer-track-help { display: block; color: var(--timer-muted); font-size: .8125rem; line-height: 1.4; }
#timer-start { width: 100%; margin-top: 14px; }

.countdown-task-name { margin: 12px 0 0; color: var(--timer-muted); font-weight: 600; overflow-wrap: anywhere; }
.countdown-display { margin: 12px 0 16px; line-height: 1.1; color: #5b6475; font-size: clamp(2.4rem, 11vw, 4.5rem); letter-spacing: -.055em; }
#timer-active[data-overtime="true"] .countdown-display, .countdown-stats [data-difference="over"] { color: var(--timer-accent); }
.countdown-stats [data-difference="under"] { color: #18705a; }
.countdown-status { margin: 10px 0 0; color: var(--timer-muted); font-size: .875rem; }
.countdown-status:empty { display: none; }
.countdown-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0; }
.countdown-stats dt { color: var(--timer-muted); font-size: .8125rem; }
.countdown-stats dd { margin: 2px 0 0; font: 650 .9375rem/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; font-variant-numeric: tabular-nums; }
#timer-comparison { max-width: 360px; margin: 0 auto 18px; padding: 11px 8px; border-radius: 10px; background: #f8f8fa; }

.countdown-history { --history-icon-size: 42px; --history-action-gap: 6px; --history-columns: minmax(0, 1fr) minmax(0, 280px) calc(2 * var(--history-icon-size) + var(--history-action-gap)); margin-top: 14px; padding: 19px 24px; }
.countdown-history-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.countdown-history-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px 14px; margin-inline-start: auto; }
.countdown-download { position: relative; }
.countdown-download summary { display: flex; align-items: center; gap: 6px; list-style: none; cursor: pointer; }
.countdown-download summary::-webkit-details-marker { display: none; }
.countdown-download .modern-export { top: calc(100% + 5px); }
.countdown-history h2, .countdown-dialog h2 { font-size: 1.125rem; }
.countdown-history p { color: var(--timer-muted); font-size: .875rem; margin: 3px 0 0; }
#timer-history-empty { margin-top: 10px; }
.countdown-history-totals, .countdown-history-row { display: grid; grid-template-columns: var(--history-columns); gap: 14px; align-items: center; }
.countdown-history-totals { margin-top: 14px; padding: 10px 0; border-radius: 10px; background: #f8f8fa; }
.countdown-history-totals h3 { margin: 0; padding-left: 12px; font-size: .9375rem; }
.countdown-history-totals .countdown-total-note { padding-inline: 12px; font-size: .8125rem; }
.countdown-history-list { padding: 0; margin: 12px 0 0; list-style: none; }
.countdown-history-row { padding: 12px 0; }
.countdown-history-row + .countdown-history-row { border-top: 1px solid #eeeef2; }
.countdown-history-task { min-width: 0; overflow-wrap: anywhere; }
.countdown-history-name { position: relative; display: block; max-width: 410px; }
.countdown-history-name input { display: block; width: 100%; min-width: 0; min-height: 32px; padding: 3px 26px 3px 3px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--chronme-ink); font-size: 1rem; font-weight: 650; }
.countdown-history-name input::placeholder { color: var(--timer-muted); opacity: 1; }
.countdown-history-name input:hover { border-color: var(--chronme-line); }
.countdown-history-name input:focus { border-color: var(--timer-accent); outline: none; background: #fffafe; }
.countdown-history-name svg { position: absolute; top: 50%; inset-inline-end: 6px; transform: translateY(-50%); color: var(--timer-muted); pointer-events: none; }
.countdown-history-name:focus-within svg { color: var(--timer-accent); }
.countdown-history-task time { display: block; margin-inline-start: 4px; color: var(--timer-muted); font-size: .8125rem; }
.countdown-history-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--history-action-gap); }
.countdown-history-actions button { display: grid; place-items: center; width: var(--history-icon-size); padding: 0; }
.countdown-reuse:disabled { opacity: .65; cursor: default; }
.countdown-text-button { min-height: 34px; padding: 0; border: 0; background: transparent; color: var(--timer-muted); font-size: .8125rem; text-decoration: underline; text-underline-offset: 2px; }
.countdown-text-button:hover { color: var(--timer-accent); }
#timer-clear { display: block; margin-inline-start: auto; }
.countdown-dialog { width: min(390px, calc(100% - 32px)); padding: 22px; border: 1px solid var(--chronme-line); border-radius: 17px; color: var(--chronme-ink); }
.countdown-dialog::backdrop { background: #5b647566; }
.countdown-dialog .countdown-actions { justify-content: flex-end; }
.countdown-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 660px) {
  .countdown-history-totals { grid-template-columns: minmax(0, 1fr); gap: 5px; padding-inline: 12px; }
  .countdown-history-totals h3 { padding-left: 0; }
  .countdown-history-totals .countdown-total-note { padding-inline: 0; }
  .countdown-history-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "task actions" "stats stats"; gap: 7px; }
  .countdown-history-task { grid-area: task; }
  .countdown-history-name input { min-height: var(--history-icon-size); }
  .countdown-history-row .countdown-stats { grid-area: stats; padding-inline: 12px; }
  .countdown-history-actions { grid-area: actions; align-self: start; }
}

@media (max-width: 520px) {
  .countdown-card, .countdown-history { padding-inline: 16px; }
  .countdown-increments button, .countdown-primary, .countdown-secondary, .countdown-text-button { min-height: 44px; }
  .countdown-history { --history-icon-size: 44px; }
  .countdown-card-header { grid-template-columns: 44px minmax(0, 1fr) 44px; }
  .countdown-mute { width: 44px; height: 44px; }
}
