:root {
  color-scheme: dark;
  --background: #101311;
  --surface: #181d19;
  --surface-raised: #202721;
  --text: #f5f3ed;
  --muted: #a5ada6;
  --accent: #ee6458;
  --accent-hover: #f4756a;
  --focus: #ffd166;
  --border: #343d35;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  min-width: 280px;
  min-height: 100dvh;
  margin: 0;
  background: radial-gradient(circle at 50% 15%, #202821 0, var(--background) 45%);
  color: var(--text);
}

button, input { font: inherit; }
button { touch-action: manipulation; }

button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.app-shell {
  width: min(100%, 36rem);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(1.25rem, env(safe-area-inset-top)) 1.25rem max(1rem, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.app-header { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; gap: .55rem; align-items: center; color: var(--text); font-weight: 800; letter-spacing: .18em; text-decoration: none; }
.brand-mark { color: var(--accent); font-size: 1.35rem; }

.icon-button {
  width: 3rem; height: 3rem; display: grid; place-items: center;
  border: 1px solid transparent; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-button:hover { color: var(--text); background: var(--surface-raised); }
.icon-button svg { width: 1.45rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.timer-card { align-self: center; text-align: center; padding: 2rem 0; }
.mode-label { margin: 0; color: var(--accent); font-size: clamp(1rem, 4vw, 1.25rem); font-weight: 800; letter-spacing: .18em; }
.timer { margin: .25rem 0 0; font-size: clamp(5rem, 23vw, 8.5rem); font-variant-numeric: tabular-nums; font-weight: 700; letter-spacing: -.07em; line-height: 1; }
.status { min-height: 1.5em; margin: .75rem 0 2rem; color: var(--muted); }

.primary-button {
  min-width: min(100%, 17rem); min-height: 3.75rem; padding: .8rem 2rem;
  border: 0; border-radius: 1rem; background: var(--accent); color: #1a0d0b; font-weight: 800; font-size: 1.1rem; cursor: pointer;
  box-shadow: 0 .4rem 1.4rem rgba(238, 100, 88, .18);
}
.primary-button:hover { background: var(--accent-hover); }
.primary-button:active { transform: translateY(1px); }
.primary-button.compact { min-width: 0; min-height: 3.25rem; width: 100%; }

.secondary-controls { display: flex; justify-content: center; gap: 2rem; margin: 1rem 0 2.5rem; }
.text-button { min-width: 5rem; min-height: 3rem; border: 0; background: transparent; color: var(--muted); font-weight: 650; cursor: pointer; }
.text-button:hover { color: var(--text); }

.cycle { color: var(--muted); font-size: .9rem; }
.cycle p { margin: .7rem 0 0; }
.cycle-dots { display: flex; justify-content: center; flex-wrap: wrap; gap: .65rem; }
.cycle-dot { width: .7rem; height: .7rem; border: 2px solid #667068; border-radius: 50%; }
.cycle-dot.complete { border-color: var(--accent); background: var(--accent); }
.privacy-note { margin: 0; color: #7e877f; font-size: .8rem; text-align: center; }

.settings-dialog {
  width: min(calc(100% - 2rem), 30rem); max-height: calc(100dvh - 2rem); padding: 0;
  border: 1px solid var(--border); border-radius: 1.25rem; background: var(--surface); color: var(--text); box-shadow: 0 1.5rem 5rem #000a;
}
.settings-dialog::backdrop { background: #060806c7; backdrop-filter: blur(3px); }
.settings-dialog form { padding: 1.25rem; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.dialog-header h2 { margin: 0; font-size: 1.35rem; }
fieldset { margin: 0 0 1.25rem; padding: 0; border: 0; }
legend { width: 100%; margin-bottom: .35rem; color: var(--muted); font-size: .8rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
fieldset > label { min-height: 3.25rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--border); }
label span { display: flex; align-items: center; gap: .4rem; }
input[type="number"] { width: 4.25rem; padding: .5rem; border: 1px solid var(--border); border-radius: .5rem; background: #111512; color: var(--text); text-align: right; }
.toggle-row > span { display: flex; align-items: flex-start; flex-direction: column; gap: .15rem; }
.toggle-row small { color: var(--muted); }
input[type="checkbox"] { width: 2.7rem; height: 1.5rem; accent-color: var(--accent); cursor: pointer; }
.dialog-actions { padding-top: .25rem; }

@media (max-height: 600px) and (orientation: landscape) {
  .timer-card { padding: .75rem 0; }
  .timer { font-size: clamp(4rem, 20vh, 6rem); }
  .status { margin: .35rem 0 .8rem; }
  .secondary-controls { margin: .25rem 0 .8rem; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; } }
