:root {
  --bg: #f1f4ef;
  --bg-deep: #e2e8df;
  --surface: rgba(252, 254, 250, 0.88);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --surface-soft: rgba(245, 249, 243, 0.92);
  --text: #17232d;
  --muted: #536471;
  --primary: #216869;
  --primary-strong: #184d4e;
  --secondary: #d97706;
  --secondary-strong: #b45309;
  --accent: #edf7f4;
  --border: rgba(23, 35, 45, 0.1);
  --border-strong: rgba(23, 35, 45, 0.16);
  --shadow: 0 28px 70px rgba(43, 62, 52, 0.16);
  --shadow-soft: 0 18px 44px rgba(43, 62, 52, 0.1);
  --danger: #b4234f;
  --success: #0f7b53;
  --disabled: #c9d3d8;
  --ring-track: rgba(23, 35, 45, 0.08);
  --font-display: "Bahnschrift", "Aptos", "Segoe UI", sans-serif;
  --font-body: "Aptos", "Segoe UI", sans-serif;
}

:root[data-theme="contrast"] {
  --bg: #eff4f8;
  --bg-deep: #d5e0eb;
  --surface: rgba(255, 255, 255, 0.97);
  --surface-strong: rgba(255, 255, 255, 1);
  --surface-soft: rgba(245, 250, 255, 0.96);
  --text: #06131f;
  --muted: #294255;
  --primary: #005f73;
  --primary-strong: #003f4d;
  --secondary: #ca6702;
  --secondary-strong: #9b4d00;
  --accent: #edf8ff;
  --border: rgba(6, 19, 31, 0.14);
  --border-strong: rgba(6, 19, 31, 0.22);
  --shadow: 0 28px 70px rgba(6, 19, 31, 0.14);
  --shadow-soft: 0 18px 44px rgba(6, 19, 31, 0.08);
  --danger: #b00020;
  --success: #00723f;
  --ring-track: rgba(6, 19, 31, 0.12);
}

:root[data-theme="dusk"] {
  --bg: #16232c;
  --bg-deep: #0f171d;
  --surface: rgba(23, 35, 45, 0.88);
  --surface-strong: rgba(27, 42, 53, 0.96);
  --surface-soft: rgba(24, 38, 48, 0.92);
  --text: #f4f8fb;
  --muted: #c5d2dd;
  --primary: #6cc2c6;
  --primary-strong: #8ad3d6;
  --secondary: #f4b860;
  --secondary-strong: #ffd08c;
  --accent: #203240;
  --border: rgba(244, 248, 251, 0.12);
  --border-strong: rgba(244, 248, 251, 0.2);
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.36);
  --shadow-soft: 0 18px 44px rgba(0, 0, 0, 0.24);
  --danger: #ff7b9b;
  --success: #74d3a5;
  --disabled: #536471;
  --ring-track: rgba(244, 248, 251, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

:root[data-theme="dusk"] {
  color-scheme: dark;
}

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background: linear-gradient(180deg, #f7faf6 0%, var(--bg) 55%, var(--bg-deep) 100%);
  overflow-x: hidden;
}

:root[data-theme="dusk"] body {
  background: linear-gradient(180deg, #20313a 0%, var(--bg) 45%, var(--bg-deep) 100%);
}

button,
input,
textarea,
select {
  font: inherit;
}

.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;
}

.background-orb {
  position: fixed;
  z-index: 0;
  border-radius: 50%;
  filter: blur(12px);
  pointer-events: none;
  opacity: 0.75;
}

.orb-one {
  top: -7rem;
  right: -3rem;
  width: 20rem;
  height: 20rem;
  background: radial-gradient(circle, rgba(33, 104, 105, 0.2), rgba(33, 104, 105, 0));
}

.orb-two {
  bottom: -6rem;
  left: -4rem;
  width: 24rem;
  height: 24rem;
  background: radial-gradient(circle, rgba(217, 119, 6, 0.14), rgba(217, 119, 6, 0));
}

:root[data-theme="dusk"] .orb-one {
  background: radial-gradient(circle, rgba(108, 194, 198, 0.22), rgba(108, 194, 198, 0));
}

:root[data-theme="dusk"] .orb-two {
  background: radial-gradient(circle, rgba(244, 184, 96, 0.14), rgba(244, 184, 96, 0));
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1320px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2.25rem 0 3.5rem;
}

body.is-fullscreen .app-shell {
  width: min(100vw - 1.25rem, 1600px);
  padding-top: 1rem;
  padding-bottom: 1.25rem;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.5rem;
  align-items: end;
  margin-bottom: 2rem;
}

body.is-fullscreen .hero {
  margin-bottom: 1.25rem;
}

.hero-side {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  align-items: stretch;
}

.eyebrow {
  margin: 0 0 0.7rem;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--primary);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
}

h1 {
  margin-bottom: 0.75rem;
  font-size: clamp(3rem, 7vw, 5.5rem);
  line-height: 0.9;
  letter-spacing: 0.01em;
}

.subtitle {
  margin-bottom: 0;
  max-width: 44rem;
  font-size: clamp(1.12rem, 2vw, 1.45rem);
  line-height: 1.5;
  color: var(--muted);
}

.hero-note {
  max-width: 22rem;
  padding: 1.1rem 1.2rem;
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
  border-radius: 24px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, transparent), color-mix(in srgb, var(--surface-strong) 85%, transparent));
  box-shadow: var(--shadow-soft);
}

.hero-note-label {
  display: inline-block;
  margin-bottom: 0.45rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-note p {
  margin: 0;
  line-height: 1.5;
  color: var(--muted);
}

.hero-button {
  min-width: 11rem;
}

.timer-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(360px, 0.94fr);
  gap: 1.75rem;
  align-items: stretch;
}

body.is-fullscreen .timer-layout {
  gap: 1rem;
}

.panel {
  position: relative;
  overflow: hidden;
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: 34px;
  background: var(--surface);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0));
}

.timer-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.panel-header,
.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 1.25rem;
  align-items: flex-start;
}

.section-heading {
  flex-direction: column;
  margin-bottom: 0;
}

.panel-header h2,
.section-heading h2 {
  margin-bottom: 0.35rem;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.panel-header p,
.section-heading p,
.completion-note,
.preference-card p {
  color: var(--muted);
}

.status {
  min-width: 7.2rem;
  margin: 0;
  padding: 0.7rem 0.95rem;
  border-radius: 999px;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 800;
  background: color-mix(in srgb, var(--primary) 11%, transparent);
  color: var(--primary);
}

.status.running {
  background: color-mix(in srgb, var(--success) 16%, transparent);
  color: var(--success);
}

.status.paused {
  background: color-mix(in srgb, var(--secondary) 16%, transparent);
  color: var(--secondary-strong);
}

.status.complete {
  background: color-mix(in srgb, var(--danger) 16%, transparent);
  color: var(--danger);
}

.display-card {
  padding: 1.35rem 1.35rem 1.5rem;
  border: 1px solid color-mix(in srgb, var(--text) 8%, transparent);
  border-radius: 30px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-strong) 96%, transparent), color-mix(in srgb, var(--surface-soft) 96%, transparent));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.display-label {
  margin: 0 0 0.9rem;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.time-display {
  padding: 1.45rem 1rem;
  border-radius: 24px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 80%, white), color-mix(in srgb, var(--surface-strong) 98%, transparent));
  border: 1px solid color-mix(in srgb, var(--primary) 10%, transparent);
  text-align: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(3.3rem, 9vw, 6.8rem);
  letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 -12px 26px color-mix(in srgb, var(--primary) 8%, transparent);
}

.preset-section,
.keypad-section,
.recent-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.preset-grid,
.recent-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.control-group {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
}

.button,
.keypad-button,
.preset-button,
.chip-button,
.recent-button {
  border: 1px solid transparent;
  border-radius: 24px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition:
    transform 160ms ease,
    background-color 160ms ease,
    box-shadow 160ms ease,
    opacity 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.button {
  min-height: 4.25rem;
  padding: 1rem 1.1rem;
  font-size: 1.05rem;
  font-weight: 800;
  box-shadow: 0 16px 30px rgba(23, 35, 45, 0.12);
}

.button-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 72%, white));
  border-color: color-mix(in srgb, var(--primary-strong) 28%, transparent);
}

.button-primary:hover:not(:disabled),
.button-primary:focus-visible:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-strong), var(--primary));
}

.button-secondary,
.preset-button,
.chip-button,
.recent-button {
  color: var(--text);
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-strong) 98%, transparent), color-mix(in srgb, var(--surface-soft) 98%, transparent));
  border-color: color-mix(in srgb, var(--text) 10%, transparent);
}

.button-secondary:hover:not(:disabled),
.button-secondary:focus-visible:not(:disabled),
.preset-button:hover:not(:disabled),
.preset-button:focus-visible:not(:disabled),
.chip-button:hover:not(:disabled),
.chip-button:focus-visible:not(:disabled),
.recent-button:hover:not(:disabled),
.recent-button:focus-visible:not(:disabled) {
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-strong) 98%, transparent), color-mix(in srgb, var(--accent) 84%, transparent));
}

.preset-button,
.recent-button,
.chip-button {
  min-height: 3.35rem;
  padding: 0.9rem 1rem;
  font-weight: 800;
  box-shadow: 0 12px 24px rgba(23, 35, 45, 0.08);
}

.preset-button {
  min-width: 6.5rem;
}

.recent-button {
  min-width: 7.5rem;
}

.chip-button {
  border-radius: 999px;
}

.chip-button.is-active,
.preset-button.is-active,
.recent-button.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  border-color: color-mix(in srgb, var(--primary-strong) 40%, transparent);
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.keypad-button {
  position: relative;
  min-height: 5.75rem;
  padding: 1.1rem;
  font-size: clamp(1.65rem, 3vw, 2.1rem);
  font-weight: 800;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-strong) 98%, transparent), color-mix(in srgb, var(--surface-soft) 98%, transparent));
  color: var(--text);
  border-color: color-mix(in srgb, var(--text) 8%, transparent);
  box-shadow: 0 18px 30px rgba(23, 35, 45, 0.1);
}

.digit-button:hover,
.digit-button:focus-visible {
  background: linear-gradient(180deg, color-mix(in srgb, white 98%, transparent), color-mix(in srgb, var(--accent) 86%, transparent));
}

.keypad-action {
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-soft) 95%, transparent), color-mix(in srgb, var(--accent) 76%, transparent));
  font-size: 1.1rem;
}

.keypad-action:hover,
.keypad-action:focus-visible {
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-strong) 98%, transparent), color-mix(in srgb, var(--accent) 88%, transparent));
}

.button:hover:not(:disabled),
.button:focus-visible:not(:disabled),
.keypad-button:hover:not(:disabled),
.keypad-button:focus-visible:not(:disabled),
.preset-button:hover:not(:disabled),
.preset-button:focus-visible:not(:disabled),
.chip-button:hover:not(:disabled),
.chip-button:focus-visible:not(:disabled),
.recent-button:hover:not(:disabled),
.recent-button:focus-visible:not(:disabled) {
  transform: translateY(-2px) scale(1.01);
}

.button:focus-visible,
.keypad-button:focus-visible,
.preset-button:focus-visible,
.chip-button:focus-visible,
.recent-button:focus-visible,
.toggle input:focus-visible + .toggle-ui {
  outline: 4px solid color-mix(in srgb, var(--primary) 24%, transparent);
  outline-offset: 4px;
}

.button:disabled,
.keypad-button:disabled,
.preset-button:disabled,
.chip-button:disabled,
.recent-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
  transform: none;
}

.recent-empty {
  width: 100%;
  padding: 1rem 1.1rem;
  border: 1px dashed color-mix(in srgb, var(--text) 14%, transparent);
  border-radius: 22px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface-soft) 90%, transparent);
}

.visual-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.5rem;
  background:
    radial-gradient(circle at top, color-mix(in srgb, var(--primary) 8%, transparent), transparent 48%),
    linear-gradient(180deg, color-mix(in srgb, var(--surface-strong) 92%, transparent), color-mix(in srgb, var(--surface-soft) 92%, transparent));
}

.progress-wrap {
  position: relative;
  width: min(100%, 520px);
  margin: 0 auto;
  aspect-ratio: 1 / 1;
}

.progress-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg) scaleX(-1);
  transform-origin: center;
}

.progress-track,
.progress-value {
  fill: none;
  stroke-width: 18;
}

.progress-track {
  stroke: var(--ring-track);
}

.progress-value {
  stroke: var(--primary);
  stroke-linecap: round;
  transition: stroke-dashoffset 180ms linear, stroke 180ms ease;
  filter: drop-shadow(0 10px 18px color-mix(in srgb, var(--primary) 18%, transparent));
}

.progress-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.progress-percent {
  font-family: var(--font-display);
  font-size: clamp(2.9rem, 8vw, 5rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.03em;
}

.progress-label {
  margin-top: 0.7rem;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.completion-note {
  margin: 0;
  padding: 0.2rem 1.1rem 0;
  text-align: center;
  line-height: 1.6;
}

.preferences {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: auto;
}

.preference-grid {
  display: grid;
  gap: 1rem;
}

.preference-card {
  display: grid;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
  border-radius: 24px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-strong) 96%, transparent), color-mix(in srgb, var(--surface-soft) 94%, transparent));
}

.preference-card h3 {
  margin-bottom: 0.25rem;
  font-size: 1.1rem;
}

.preference-card p {
  margin-bottom: 0;
  line-height: 1.5;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  cursor: pointer;
}

.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-ui {
  position: relative;
  width: 3.4rem;
  height: 2rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 16%, transparent);
  transition: background-color 160ms ease;
}

.toggle-ui::after {
  content: "";
  position: absolute;
  top: 0.2rem;
  left: 0.22rem;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
  transition: transform 160ms ease;
}

.toggle input:checked + .toggle-ui {
  background: var(--primary);
}

.toggle input:checked + .toggle-ui::after {
  transform: translateX(1.38rem);
}

.toggle-text {
  font-weight: 700;
}

.app-shell.completion-flash .display-card,
.app-shell.completion-flash .visual-panel {
  animation: completionPulse 850ms ease-in-out 4;
}

@keyframes completionPulse {
  0%,
  100% {
    box-shadow: var(--shadow);
  }

  50% {
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--secondary) 20%, transparent), var(--shadow);
  }
}

@media (max-width: 1080px) {
  .timer-layout {
    grid-template-columns: 1fr;
  }

  .progress-wrap {
    width: min(100%, 460px);
  }
}

@media (max-width: 920px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .hero-side {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: stretch;
  }

  .hero-note {
    max-width: none;
    flex: 1 1 18rem;
  }

  .hero-button {
    flex: 0 0 auto;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 1rem, 100%);
    padding-top: 1rem;
  }

  .panel {
    padding: 1.2rem;
    border-radius: 26px;
  }

  .panel-header {
    flex-direction: column;
  }

  .control-group {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem;
  }

  .preset-grid,
  .recent-list,
  .chip-group {
    gap: 0.65rem;
  }

  .keypad {
    gap: 0.8rem;
  }

  .keypad-button {
    min-height: 5rem;
    border-radius: 20px;
    font-size: clamp(1.45rem, 7vw, 1.95rem);
  }

  .button {
    min-height: 4rem;
  }

  .display-card {
    padding: 1rem 1rem 1.2rem;
  }

  .time-display {
    padding: 1.25rem 0.7rem;
    font-size: clamp(2.8rem, 12vw, 4.25rem);
    letter-spacing: 0.08em;
  }

  .progress-wrap {
    width: min(100%, 380px);
  }

  .hero-button,
  .preset-button,
  .recent-button,
  .chip-button {
    width: 100%;
  }

  .hero-side {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
