*,
*::before,
*::after {
  box-sizing: border-box;
}

@font-face {
  font-family: "Visuelt Pro";
  src: url("fonts/VisueltPro-Light.ttf") format("truetype");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Visuelt Pro";
  src: url("fonts/VisueltPro-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Visuelt Pro";
  src: url("fonts/VisueltPro-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Visuelt Pro";
  src: url("fonts/VisueltPro-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --c-white: #ffffff;
  --c-grey: #f3f4f6;
  --c-navy: #0f293a;
  --c-red: #ff002b;
  --font-sans: "Visuelt Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-timer: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, monospace;
  --radius-pill: 9999px;
  --radius-panel: 16px;
  --touch-min: 44px;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: var(--c-white);
  --surface: var(--c-grey);
  --text: var(--c-navy);
  --muted: rgba(15, 41, 58, 0.62);
  --border: rgba(15, 41, 58, 0.14);
  --focus-ring: var(--c-red);
  --input-bg: var(--c-white);
  --preset-fill: rgba(15, 41, 58, 0.08);
  --preset-fill-hover: rgba(15, 41, 58, 0.14);
  --ghost-hover-bg: rgba(15, 41, 58, 0.06);
  --overlay-bg: var(--c-navy);
  --overlay-text: var(--c-white);
  --overlay-muted: rgba(255, 255, 255, 0.78);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: var(--c-navy);
  --surface: rgba(255, 255, 255, 0.07);
  --text: var(--c-white);
  --muted: rgba(255, 255, 255, 0.68);
  --border: rgba(255, 255, 255, 0.2);
  --focus-ring: var(--c-white);
  --input-bg: rgba(255, 255, 255, 0.06);
  --preset-fill: rgba(255, 255, 255, 0.12);
  --preset-fill-hover: rgba(255, 255, 255, 0.18);
  --ghost-hover-bg: rgba(255, 255, 255, 0.08);
  --overlay-bg: var(--c-navy);
  --overlay-text: var(--c-white);
  --overlay-muted: rgba(255, 255, 255, 0.78);
}

html {
  font-family: var(--font-sans);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.font-timer {
  font-family: var(--font-timer);
  font-variant-numeric: tabular-nums;
}

.skip-link {
  position: absolute;
  left: -9999px;
  z-index: 100;
  padding: 0.5rem 1rem;
  min-height: var(--touch-min);
  background: var(--c-red);
  color: var(--c-white);
  border-radius: var(--radius-pill);
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

.skip-link:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.header {
  padding: 1rem 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.header-inner {
  max-width: 36rem;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

@media (min-width: calc(36rem + 2rem)) {
  .header-inner {
    padding-inline: 1rem;
  }
}

.header-copy {
  flex: 1 1 12rem;
  text-align: left;
  padding-right: 3rem;
}

@media (min-width: 480px) {
  .header-copy {
    padding-right: 0;
  }
}

.title {
  margin: 0;
  font-size: clamp(1.35rem, 4vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.btn-theme-icon {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: var(--touch-min);
  height: var(--touch-min);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  line-height: 1;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

@media (min-width: 480px) {
  .btn-theme-icon {
    position: relative;
    top: auto;
    right: auto;
    flex-shrink: 0;
  }
}

.btn-theme-icon:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

.theme-icon {
  display: none;
}

html[data-theme="light"] .theme-icon--moon {
  display: inline;
}

html[data-theme="dark"] .theme-icon--sun {
  display: inline;
}

.main {
  flex: 1;
  width: 100%;
  max-width: 36rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
  display: flex;
  flex-direction: column;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  padding: 1.25rem;
}

.timer-panel {
  text-align: center;
}

.timer-panel.flash-accent-once {
  animation: flash-accent 0.65s ease-out 1;
}

@keyframes flash-accent {
  0% {
    background-color: transparent;
    box-shadow: inset 0 0 0 0 transparent;
  }
  35% {
    background-color: rgba(255, 0, 43, 0.22);
    box-shadow: inset 0 0 0 3px rgba(255, 0, 43, 0.35);
  }
  100% {
    background-color: transparent;
    box-shadow: inset 0 0 0 0 transparent;
  }
}

.timer-display.timer-display--idle {
  display: none;
}

.timer-display {
  padding: 0.5rem 0 0.25rem;
}

.wall-clock-row {
  margin-top: 0.35rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 0.35rem 0.5rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.wall-clock-label {
  font-weight: 500;
}

.wall-clock {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
}

.slot-window-hint {
  margin-top: 0.25rem;
}

.slot-window-hint:not([hidden]) {
  color: var(--c-red);
}

.timer-value {
  font-size: clamp(3.5rem, 14vw, 6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--text);
  display: inline-block;
  transition: font-size 0.25s ease;
}

.timer-value--compact {
  font-size: clamp(1.75rem, 8vw, 2.75rem);
  opacity: 0.85;
}

.timer-panel.done .timer-value:not(.timer-value--compact) {
  color: var(--c-red);
}

@media (prefers-reduced-motion: no-preference) {
  .timer-panel.timer-urgent .timer-value {
    animation: urgent-pulse 0.85s ease-in-out infinite;
  }
}

@keyframes urgent-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.88;
    transform: scale(1.02);
  }
}

.timer-status {
  margin: 0.65rem 0 0;
  min-height: 1.35rem;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 400;
}

.timer-status:empty {
  margin-top: 0.35rem;
}

.timer-panel.done .timer-status {
  color: var(--muted);
  font-weight: 400;
}

.duration-block {
  margin-top: 1.25rem;
  text-align: left;
}

.tablist {
  display: flex;
  width: 100%;
  margin-bottom: 1rem;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--input-bg);
}

.tab {
  flex: 1;
  min-height: var(--touch-min);
  margin: 0;
  padding: 0.5rem 0.75rem;
  border: none;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.tab:last-child {
  border-right: none;
}

.tab:hover:not(:disabled):not([aria-selected="true"]) {
  background: var(--preset-fill-hover);
}

.tab[aria-selected="true"] {
  background: var(--c-red);
  color: var(--c-white);
}

.tab:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.tab:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: -3px;
  position: relative;
  z-index: 1;
}

.tab-panel[hidden] {
  display: none !important;
}

.panel-title--tab {
  margin-bottom: 0.85rem;
  margin-top: 0;
}

.field-hint {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 400;
}

.custom-duration-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: stretch;
  margin-top: 0.75rem;
}

.custom-minutes-input {
  width: 100%;
  min-height: var(--touch-min);
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
}

.custom-minutes-input:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.btn-interval-start-wide {
  width: 100%;
  min-height: var(--touch-min);
  margin-top: 0.85rem;
  border-radius: 12px;
}

.timer-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: var(--overlay-bg);
}

.timer-overlay[hidden] {
  display: none;
}

body.overlay-open {
  overflow: hidden;
}

.overlay-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 2;
  min-height: var(--touch-min);
  padding-inline: 1rem;
}

.overlay-close:focus-visible {
  outline: 3px solid var(--c-white);
  outline-offset: 3px;
}

.overlay-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 42rem;
  text-align: center;
}

.overlay-timer-value {
  font-size: clamp(4rem, 18vw, 10rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  display: inline-block;
  color: var(--overlay-text);
}

.overlay-timer-value--compact {
  font-size: clamp(2rem, 10vw, 3.25rem);
  opacity: 0.88;
}

.overlay-inner.done .overlay-timer-value:not(.overlay-timer-value--compact) {
  color: var(--c-red);
}

@media (prefers-reduced-motion: no-preference) {
  .overlay-inner.overlay-urgent .overlay-timer-value {
    animation: urgent-pulse 0.85s ease-in-out infinite;
  }
}

.overlay-timer-label {
  margin: 1rem 0 0;
  font-size: clamp(1rem, 3vw, 1.35rem);
  font-weight: 400;
  color: var(--overlay-muted);
}

.overlay-inner.done .overlay-timer-label {
  color: var(--overlay-muted);
  font-weight: 400;
}

.panel-title {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.preset-row .btn-preset-solid {
  flex: 1 1 calc((100% - 2rem) / 5);
  min-width: calc(var(--touch-min) * 2);
  border-radius: var(--radius-pill);
}

.clock-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.time-label-block {
  margin-bottom: -0.15rem;
}

.time-input-large {
  width: 100%;
  min-height: var(--touch-min);
  padding: 0.65rem 1rem;
  font-size: 1.35rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}

.time-input-large:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.btn-slot-wide,
.btn-reset-wide {
  width: 100%;
  min-height: var(--touch-min);
  border-radius: 12px;
}

.action-controls {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.action-controls[hidden] {
  display: none !important;
}

.duration-setup[hidden] {
  display: none !important;
}

.action-row {
  width: 100%;
}

.action-row .btn {
  flex: 1 1 0;
  min-width: 0;
}

.btn-min-touch {
  min-height: var(--touch-min);
}

.btn {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  padding: 0.65rem 1.25rem;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 500;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.btn:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--c-red);
  border-color: var(--c-red);
  color: var(--c-white);
  min-height: var(--touch-min);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

html[data-theme="light"] .btn-secondary {
  border-color: rgba(15, 41, 58, 0.35);
}

html[data-theme="dark"] .btn-secondary {
  border-color: rgba(255, 255, 255, 0.55);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--preset-fill-hover);
}

.btn-preset-solid {
  background: var(--preset-fill);
  border-color: transparent;
  color: var(--text);
  font-weight: 600;
  min-height: var(--touch-min);
}

.btn-preset-solid:hover:not(:disabled) {
  background: var(--preset-fill-hover);
}

.btn-preset-solid.active-minutes {
  background: var(--c-red);
  border-color: var(--c-red);
  color: var(--c-white);
}

.btn-preset-solid.active-minutes:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.btn-ghost:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--ghost-hover-bg);
}

.overlay-close.btn-secondary,
.overlay-close {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.45);
  color: var(--c-white);
}

.overlay-close:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
}

@media (prefers-reduced-motion: reduce) {
  .timer-panel.timer-urgent .timer-value,
  .overlay-inner.overlay-urgent .overlay-timer-value {
    animation: none;
  }

  .timer-panel.flash-accent-once {
    animation: none;
  }
}
