/* ─── Tokens ─────────────────────────────────────────── */
:root {
  /* Surfaces */
  --bg:      oklch(97.5% 0.005 80);
  --surface: oklch(99.5% 0.002 75);

  /* Text */
  --text:             oklch(16% 0.012 65);
  --text-mid:         oklch(40% 0.010 65);
  --text-muted:       oklch(50% 0.008 65);
  --text-placeholder: oklch(58% 0.007 65);

  /* Accent — warm amber/terracotta */
  --accent:      oklch(48% 0.16 52);
  --accent-dark: oklch(36% 0.14 52);
  --accent-dim:  oklch(95% 0.04 52);

  /* Structural */
  --border:     oklch(89% 0.006 65);
  --border-mid: oklch(80% 0.008 65);

  /* Success */
  --success:    oklch(55% 0.155 148);
  --success-bg: oklch(93% 0.055 148);

  /* Error — muted terracotta-red, kept close to the warm palette */
  --error: oklch(55% 0.12 33);

  /* Typography */
  --font-serif: 'Gloock', Georgia, serif;
  --font-ui:    'Hanken Grotesk', system-ui, sans-serif;

  /* Ring geometry */
  --ring-r: 84;
  --ring-circumference: 527.79; /* 2π × 84 */
}

/* ─── Reset ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  letter-spacing: 0.03em;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input  { font-family: inherit; }

/* ─── Screen system ──────────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  overflow-y: auto;
}
.screen.active { display: flex; }

.screen-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  z-index: 100;
}
.screen-overlay.hidden { display: none; }

/* ─── Container ──────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 56px 32px 40px;
}
.container.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 40px 32px;
}

/* ─── Screen 1: Declaration ──────────────────────────── */
#screen-declare .container {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.date-label {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 24px;
}

.heading {
  font-family: var(--font-serif);
  font-size: clamp(22px, 5vw, 28px);
  font-weight: 400;
  line-height: 1.3;
  color: var(--text);
  text-wrap: balance;
  margin-bottom: 8px;
}

.subheading {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 400;
  line-height: 1.5;
  margin-bottom: 32px;
}

.task-input {
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1.5px solid var(--border-mid);
  padding: 10px 0;
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--text);
  outline: none;
  margin-bottom: 32px;
  transition: border-color 0.2s;
}
.task-input::placeholder { color: var(--text-placeholder); }
.task-input:focus       { border-bottom-color: var(--accent); }
.task-input.error {
  border-bottom-color: var(--error);
  animation: input-shake 0.3s ease;
}
.task-input.error::placeholder { color: var(--error); }

@keyframes input-shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  60%      { transform: translateX(3px); }
}

/* Duration row */
.duration-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 28px;
}

/* ─── Primary button ─────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: oklch(99% 0.002 75);
  padding: 12px 24px;
  border-radius: 3px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  transition: background 0.15s;
  align-self: flex-start;
}
.btn-primary:hover    { background: var(--accent-dark); }
.btn-primary:disabled { opacity: 0.35; cursor: default; }

.btn-spacer {
  flex: 1;
  min-height: 24px;
}

.btn-start-full {
  width: 100%;
  padding: 15px 24px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.06em;
  border-radius: 3px;
  align-self: stretch;
}

/* ─── Duration stepper ───────────────────────────────── */
.duration-stepper {
  display: flex;
  gap: 6px;
}
.stepper-btn {
  width: 30px;
  padding: 6px 0;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.15s, border-color 0.15s;
}
.stepper-btn:hover { border-color: var(--border-mid); color: var(--text-mid); }

.duration-input {
  width: 72px;
  padding: 6px 10px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: transparent;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  outline: none;
  text-align: center;
  font-family: var(--font-ui);
  transition: border-color 0.15s;
}
.duration-input:focus { border-color: var(--accent); }
.duration-input::-webkit-inner-spin-button,
.duration-input::-webkit-outer-spin-button { display: none; }
.duration-input[type=number] { appearance: textfield; }
.duration-input.error { border-color: var(--error); }

/* ─── Sound row ──────────────────────────────────────── */
.sound-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sound-label {
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
}
.sound-tabs {
  display: flex;
  gap: 6px;
}
.sound-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 13px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: transparent;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.sound-tab:hover { border-color: var(--border-mid); color: var(--text-mid); }
.sound-tab.active {
  background: var(--accent-dim);
  border-color: transparent;
  color: var(--accent-dark);
}

.ambient-picker {
  display: flex;
  gap: 6px;
}
.ambient-opt {
  padding: 5px 11px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: transparent;
  font-size: 12px;
  color: var(--text-muted);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.ambient-opt:hover { border-color: var(--border-mid); color: var(--text-mid); }
.ambient-opt.active {
  background: var(--accent-dim);
  border-color: transparent;
  color: var(--accent-dark);
  font-weight: 500;
}

/* Settings gear */
.btn-settings {
  position: fixed;
  top: 20px;
  right: 20px;
  color: var(--text-muted);
  padding: 6px;
  border-radius: 3px;
  transition: color 0.15s;
}
.btn-settings:hover { color: var(--text-mid); }

/* ─── Screen 2: Active Session ───────────────────────── */
.focus-label {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 10px;
}
.focus-task {
  font-family: var(--font-serif);
  font-size: 19px;
  color: var(--text);
  margin-bottom: 36px;
  text-align: center;
  max-width: 300px;
  line-height: 1.45;
}

/* Ring */
.ring-wrap {
  position: relative;
  width: 200px;
  height: 200px;
  margin-bottom: 20px;
}
.ring-wrap.small {
  width: 120px;
  height: 120px;
  margin-bottom: 16px;
}
.ring-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track {
  fill: none;
  stroke: var(--border);
  stroke-width: 5.5;
}
.ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 5.5;
  stroke-linecap: round;
  stroke-dasharray: var(--ring-circumference);
  stroke-dashoffset: var(--ring-circumference);
  transition: stroke-dashoffset 1s linear;
}
.ring-complete {
  fill: none;
  stroke: var(--success);
  stroke-width: 5.5;
  stroke-linecap: round;
  stroke-dasharray: var(--ring-circumference);
  stroke-dashoffset: 0;
}
.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.ring-time {
  font-family: var(--font-serif);
  font-size: 38px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1;
}
.ring-unit {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-top: 5px;
  font-family: var(--font-ui);
}
.check-icon {
  display: block;
  color: var(--success);
}

.elapsed {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  margin-bottom: 16px;
}

.btn-cancel {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: underline;
  text-decoration-color: var(--border-mid);
  text-underline-offset: 3px;
  white-space: nowrap;
  transition: color 0.15s;
}
.btn-cancel:hover { color: var(--text-mid); }

/* Sound footer dropdown */
.sound-footer { position: relative; }
.sound-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: transparent;
  font-size: 12px;
  color: var(--text-mid);
  font-weight: 500;
  transition: border-color 0.15s, color 0.15s;
}
.sound-trigger:hover { border-color: var(--border-mid); color: var(--text); }
#sound-trigger-icon  { display: inline-flex; align-items: center; }
.sound-trigger .chevron { font-size: 10px; color: var(--text-muted); margin-left: 2px; }

.sound-dropdown {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 -4px 24px oklch(0% 0 0 / 0.07);
  min-width: 160px;
  overflow: hidden;
  z-index: 10;
}
.sound-dropdown.hidden { display: none; }
.dropdown-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text-mid);
  text-align: left;
  transition: background 0.1s, color 0.1s;
  border-bottom: 1px solid var(--border);
  font-weight: 400;
}
.dropdown-opt:last-child  { border-bottom: none; }
.dropdown-opt:hover       { background: var(--bg); color: var(--text); }
.dropdown-opt.active {
  color: var(--accent-dark);
  font-weight: 500;
  background: var(--accent-dim);
}
.spotify-icon  { flex-shrink: 0; }
.spotify-green { color: #1DB954; }

/* ─── Screen 3: Session End ──────────────────────────── */
.end-footer {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.btn-extend {
  background: transparent;
  color: var(--text-mid);
  padding: 7px 13px;
  border-radius: 3px;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  transition: border-color 0.15s, color 0.15s;
}
.btn-extend:hover { border-color: var(--border-mid); color: var(--text); }
.btn-extend-muted { opacity: 0.6; }
.btn-extend-muted:hover { opacity: 1; }
.btn-wrap-action {
  border-color: var(--accent);
  color: var(--accent-dark);
}
.btn-wrap-action:hover { border-color: var(--accent-dark); }

/* ─── Settings panel ─────────────────────────────────── */
.settings-panel {
  position: fixed;
  inset: 0;
  background: oklch(97.5% 0.005 80 / 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.settings-panel.hidden { display: none; }
.settings-inner {
  background: var(--surface);
  border-radius: 5px;
  padding: 28px 28px 32px;
  width: 90%;
  max-width: 380px;
  border: 1px solid var(--border);
  box-shadow: 0 8px 40px oklch(0% 0 0 / 0.08);
}
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.settings-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.03em;
}
.btn-settings-close {
  font-size: 13px;
  color: var(--text-muted);
  transition: color 0.15s;
}
.btn-settings-close:hover { color: var(--text); }
.settings-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 8px;
}
.settings-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.15s;
  margin-bottom: 10px;
  font-family: var(--font-ui);
}
.settings-input::placeholder { color: var(--text-placeholder); }
.settings-input:focus { border-color: var(--accent); }
.settings-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.55;
  font-weight: 400;
}

/* ─── Settings: divider + toggles ────────────────────── */
.settings-divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}
.settings-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.settings-toggle-row:last-child { margin-bottom: 0; }
.settings-toggle-label {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.settings-toggle-label .settings-label { margin-bottom: 0; }
.settings-toggle-label .settings-hint  { font-size: 12px; }

/* Toggle switch */
.toggle {
  position: relative;
  flex-shrink: 0;
  width: 36px;
  height: 20px;
  cursor: pointer;
  pointer-events: auto;
}
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 20px;
  transition: background 0.2s;
}
.toggle-track::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: oklch(99.5% 0.001 75);
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px oklch(0% 0 0 / 0.2);
}
.toggle input:checked + .toggle-track              { background: var(--accent); }
.toggle input:checked + .toggle-track::after { transform: translateX(16px); }

/* ─── Utilities ──────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Reduced motion ─────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .ring-progress { transition: none; }
  .toggle-track, .toggle-track::after { transition: none; }
}

/* ─── Mobile ─────────────────────────────────────────── */
@media (max-width: 400px) {
  .container { padding: 44px 20px 32px; }
  .end-buttons { flex-direction: column; align-items: stretch; }
  .btn-extend, .btn-wrap { text-align: center; }
}

/* ─── Compact window (PWA small float) ──────────────── */
@media (max-height: 550px) {
  .container         { padding: 32px 24px 24px; }
  .container.center  { padding: 24px; }
  .heading           { font-size: 20px; }
  .subheading        { margin-bottom: 16px; }
  .task-input        { margin-bottom: 20px; }
  .duration-row      { margin-bottom: 16px; gap: 8px; }
  .sound-row         { gap: 8px; }
  .ring-wrap         { width: 150px; height: 150px; margin-bottom: 12px; }
  .check-icon        { width: 33px; height: 33px; }
  .ring-time         { font-size: 30px; }
  .focus-task        { margin-bottom: 18px; font-size: 16px; }
  .elapsed           { margin-bottom: 10px; }
  .post-message      { font-size: 18px; }
}
