:root {
  color-scheme: dark;
  --bg: #11100f;
  --bg-deep: #080a09;
  --surface: rgba(31, 27, 24, .58);
  --surface-strong: rgba(36, 30, 26, .86);
  --text: #f2eee7;
  --muted: #a49c93;
  --faint: #746d66;
  --line: rgba(235, 202, 161, .16);
  --line-strong: rgba(235, 202, 161, .3);
  --accent: #dfa05f;
  --accent-hot: #ffd79e;
  --button-text: #17110d;
  --focus: #f2bd76;
  --shadow: rgba(0, 0, 0, .36);
  --ambient-rgb: 211, 137, 70;
  --page-inline: clamp(20px, 4vw, 64px);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

:root[data-theme="moon"] {
  color-scheme: light;
  --bg: #e8e4da;
  --bg-deep: #d4cec2;
  --surface: rgba(255, 255, 255, .48);
  --surface-strong: rgba(250, 248, 242, .88);
  --text: #292b2c;
  --muted: #595b57;
  --faint: #74756f;
  --line: rgba(42, 49, 50, .18);
  --line-strong: rgba(42, 49, 50, .34);
  --accent: #727b7b;
  --accent-hot: #faf8f2;
  --button-text: #292b2c;
  --focus: #40565b;
  --shadow: rgba(61, 57, 49, .2);
  --ambient-rgb: 64, 76, 78;
}

* { box-sizing: border-box; }

html {
  min-width: 0;
  min-height: 100%;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 52% 42%, rgba(var(--ambient-rgb), .075) 0, transparent 43%),
    linear-gradient(150deg, var(--bg), var(--bg-deep));
  color: var(--text);
  transition: background-color .5s ease, color .5s ease;
}

button, input, select { font: inherit; }
button, summary, select, input { -webkit-tap-highlight-color: transparent; }
button, summary { touch-action: manipulation; }
a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 4px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  transform: translateY(-160%);
}
.skip-link:focus { transform: none; }

.ambient-haze {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .48;
  background-image: radial-gradient(circle at 50% 48%, transparent 0 24%, rgba(0,0,0,.1) 76%);
}
:root[data-theme="moon"] .ambient-haze { opacity: .24; }

.site-header {
  position: fixed;
  z-index: 20;
  inset: max(18px, env(safe-area-inset-top)) var(--page-inline) auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.site-header > * { pointer-events: auto; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .19em;
  text-decoration: none;
}
.brand-mark {
  width: 7px;
  height: 7px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 60%, transparent);
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 23px;
}
.icon-button:hover { border-color: var(--line); color: var(--text); }

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(300px, 1.45fr) minmax(220px, 1fr);
  align-items: center;
  gap: clamp(24px, 3vw, 64px);
  width: min(1440px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 84px var(--page-inline) 92px;
}

.intro { align-self: center; max-width: 310px; }
.eyebrow {
  margin: 0 0 18px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .26em;
}
h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(46px, 5vw, 76px);
  font-weight: 400;
  letter-spacing: -.045em;
  line-height: .95;
}
.tagline {
  margin: 15px 0 0;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(18px, 2vw, 24px);
  font-style: italic;
}
.subcopy {
  margin: 36px 0 0;
  color: var(--faint);
  font-size: 13px;
  letter-spacing: .08em;
}

.timer-surface {
  position: relative;
  display: grid;
  justify-items: center;
  min-width: 0;
}
.vessel-wrap {
  position: relative;
  width: min(100%, 510px);
  height: min(68vh, 670px);
  min-height: 420px;
  isolation: isolate;
}
#hourglass-canvas { display: block; width: 100%; height: 100%; }
.semantic-fallback {
  position: absolute;
  inset: 8% 12%;
  display: grid;
  place-content: center;
  justify-items: center;
  border: 1px solid var(--line);
  border-radius: 42% 46% 40% 48% / 33% 38% 41% 36%;
  color: var(--muted);
  text-align: center;
}
.semantic-fallback[hidden] { display: none; }
.semantic-fallback span { font-size: 48px; }
.semantic-fallback p { max-width: 18em; font-size: 12px; }
.flip-gesture {
  position: absolute;
  inset: 4%;
  border: 0;
  background: transparent;
  cursor: ns-resize;
}
.flip-gesture[hidden] { display: none; }

.time-readout {
  position: absolute;
  inset: auto auto 4%;
  display: grid;
  justify-items: center;
  gap: 5px;
  pointer-events: none;
}
#remaining {
  font-variant-numeric: tabular-nums;
  font-size: clamp(28px, 3vw, 43px);
  font-weight: 250;
  letter-spacing: .06em;
}
.state-label {
  color: var(--faint);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .18em;
  text-transform: uppercase;
}
body.numbers-hidden #remaining { visibility: hidden; }

.controls { max-width: 330px; }
.primary-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.button {
  min-width: 116px;
  min-height: 52px;
  padding: 13px 22px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: transform .16s ease, background-color .2s ease, border-color .2s ease;
}
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(1px); }
.button[hidden] { display: none; }
.button-primary {
  border-color: var(--accent);
  background: var(--accent-hot);
  color: var(--button-text);
  box-shadow: 0 10px 36px color-mix(in srgb, var(--accent) 16%, transparent);
  font-weight: 650;
}
.button-secondary, .button-danger-quiet { background: transparent; color: var(--muted); }
.button-danger-quiet { color: var(--text); border-color: var(--line-strong); font-size: 12px; }

.duration-panel { margin-top: 28px; }
.preset-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.preset {
  min-width: 44px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.preset:hover { border-color: var(--line); color: var(--text); }
.preset.is-selected {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--text);
}

.custom-duration { margin-top: 18px; }
.custom-duration > label {
  display: block;
  margin-bottom: 7px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.custom-field {
  display: grid;
  grid-template-columns: minmax(76px, 1fr) auto auto;
  align-items: center;
  border-bottom: 1px solid var(--line-strong);
}
.custom-field input {
  width: 100%;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--text);
  outline: 0;
}
.custom-field span { color: var(--faint); font-size: 12px; }
.custom-field button {
  min-width: 54px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--accent-hot);
  cursor: pointer;
}
.field-error { min-height: 1.4em; margin: 6px 0 0; color: #d9988e; font-size: 11px; }

.settings { margin-top: 26px; border-top: 1px solid var(--line); }
.settings summary {
  display: flex;
  justify-content: space-between;
  min-height: 48px;
  padding: 16px 0 10px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  list-style: none;
}
.settings summary::-webkit-details-marker { display: none; }
.settings[open] summary span { transform: rotate(45deg); }
.settings-grid { display: grid; gap: 2px; padding: 5px 0 0; }
.setting-row, .setting-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-size: 12px;
}
.setting-action { width: 100%; cursor: pointer; text-align: left; }
.setting-action::after { content: "↗"; color: var(--faint); }
.setting-muted { color: var(--muted); }
select {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 28px 0 10px;
}
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }
.notice { min-height: 1.5em; margin: 12px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

.site-footer {
  position: fixed;
  z-index: 20;
  inset: auto var(--page-inline) max(18px, env(safe-area-inset-bottom));
}
.site-footer nav { display: flex; flex-wrap: wrap; gap: 10px 24px; }
.site-footer a { color: var(--faint); font-size: 10px; letter-spacing: .05em; text-decoration: none; }
.site-footer a:hover { color: var(--text); }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

body[data-state="running"] .intro,
body[data-state="paused"] .intro,
body[data-state="completing"] .intro,
body[data-state="complete"] .intro { opacity: .32; }
:root[data-theme="moon"] body[data-state="running"] .intro,
:root[data-theme="moon"] body[data-state="paused"] .intro,
:root[data-theme="moon"] body[data-state="completing"] .intro,
:root[data-theme="moon"] body[data-state="complete"] .intro { opacity: .46; }
body[data-state="running"] .duration-panel,
body[data-state="paused"] .duration-panel,
body[data-state="completing"] .duration-panel,
body[data-state="flipping"] .duration-panel { display: none; }
body[data-state="running"] .settings:not([open]),
body[data-state="completing"] .settings:not([open]) { opacity: .4; }
body[data-state="flipping"] .vessel-wrap { animation: vessel-flip .72s cubic-bezier(.6,0,.3,1); }
body[data-state="completing"] .vessel-wrap { animation: vessel-breathe 1.1s ease-out; }
body.chrome-idle[data-state="running"] .chrome-control,
body.chrome-idle[data-state="running"] .site-footer,
body.chrome-idle[data-state="running"] .controls { opacity: 0; pointer-events: none; }
.chrome-control, .site-footer, .controls { transition: opacity .5s ease; }

@keyframes vessel-flip { to { transform: rotate(180deg); } }
@keyframes vessel-breathe { 50% { filter: brightness(1.12); transform: scale(1.012); } }

@media (max-width: 920px) and (orientation: portrait) {
  .site-header { position: absolute; }
  .app-shell {
    grid-template-columns: 1fr;
    gap: 10px;
    align-content: start;
    padding-top: 80px;
    padding-bottom: 112px;
  }
  .intro { align-self: auto; max-width: none; text-align: center; }
  .eyebrow { margin-bottom: 10px; }
  h1 { font-size: clamp(42px, 13vw, 64px); }
  .tagline { margin-top: 10px; }
  .subcopy { display: none; }
  .vessel-wrap { width: min(100%, 500px); height: min(55dvh, 580px); min-height: 330px; }
  .time-readout { bottom: 1%; }
  .controls { width: min(100%, 460px); max-width: none; margin: 0 auto; }
  .primary-actions { justify-content: center; }
  .duration-panel { margin-top: 18px; }
  .preset-row { grid-template-columns: repeat(8, 1fr); gap: 2px; }
  .preset { min-width: 36px; }
  .site-footer { position: relative; inset: auto; margin: -72px var(--page-inline) max(24px, env(safe-area-inset-bottom)); }
  .site-footer nav { justify-content: center; }
  body[data-state="running"] .intro,
  body[data-state="paused"] .intro,
  body[data-state="completing"] .intro,
  body[data-state="complete"] .intro { display: none; }
  body[data-state="running"] .app-shell,
  body[data-state="paused"] .app-shell,
  body[data-state="completing"] .app-shell,
  body[data-state="complete"] .app-shell { padding-top: 58px; }
  body[data-state="running"] .vessel-wrap,
  body[data-state="paused"] .vessel-wrap,
  body[data-state="completing"] .vessel-wrap,
  body[data-state="complete"] .vessel-wrap { height: min(67dvh, 660px); }
}

@media (max-width: 520px) {
  :root { --page-inline: 16px; }
  .app-shell { padding-top: 70px; }
  .vessel-wrap { height: min(52dvh, 520px); min-height: 290px; }
  .preset-row { grid-template-columns: repeat(4, 1fr); }
  .button { min-height: 50px; }
}

@media (orientation: landscape) and (max-height: 560px) {
  .site-header { top: max(10px, env(safe-area-inset-top)); }
  .app-shell {
    grid-template-columns: minmax(0, 1.78fr) minmax(150px, .48fr);
    gap: clamp(8px, 1.4vw, 18px);
    min-height: 100dvh;
    padding: 8px max(44px, env(safe-area-inset-right)) 8px max(28px, env(safe-area-inset-left));
  }
  .intro { display: none; }
  .timer-surface { grid-column: 1; width: 100%; justify-self: stretch; }
  .vessel-wrap { width: min(72vw, 610px); height: calc(100dvh - 16px); min-height: 0; }
  .time-readout { inset: auto 1% 13% auto; transform: none; align-items: start; justify-items: start; }
  .controls { grid-column: 2; width: 100%; max-width: 228px; }
  .primary-actions { flex-direction: column; align-items: stretch; }
  .button { width: 100%; min-height: 44px; padding: 8px 14px; }
  .duration-panel { margin-top: 8px; }
  .preset-row { grid-template-columns: repeat(4, 1fr); }
  .preset { min-height: 36px; }
  .custom-duration { margin-top: 7px; }
  .settings { margin-top: 8px; }
  .settings summary { min-height: 38px; padding: 10px 0 6px; }
  .settings-grid { position: absolute; z-index: 30; right: max(20px, env(safe-area-inset-right)); bottom: 12px; width: min(330px, 42vw); padding: 10px 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-strong); backdrop-filter: blur(18px); }
  .site-footer { position: fixed; left: max(18px, env(safe-area-inset-left)); right: auto; bottom: max(9px, env(safe-area-inset-bottom)); margin: 0; }
  .site-footer a:not(:first-child) { display: none; }
  body[data-state="running"] .controls,
  body[data-state="paused"] .controls,
  body[data-state="completing"] .controls,
  body[data-state="complete"] .controls { align-self: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (prefers-contrast: more) {
  :root { --muted: #d0cbc4; --faint: #b4aea7; --line: rgba(255,255,255,.34); --line-strong: rgba(255,255,255,.62); }
  :root[data-theme="moon"] { --muted: #434647; --faint: #54585a; --line: rgba(0,0,0,.34); --line-strong: rgba(0,0,0,.58); }
}

.content-page {
  background: linear-gradient(145deg, var(--bg), var(--bg-deep));
}
.content-header,
.content-footer {
  width: min(820px, calc(100% - var(--page-inline) * 2));
  margin: 0 auto;
  padding: max(26px, env(safe-area-inset-top)) 0 24px;
}
.content-header { position: relative; z-index: 2; }
.content-shell {
  position: relative;
  z-index: 1;
  width: min(820px, calc(100% - var(--page-inline) * 2));
  margin: 0 auto;
  padding: clamp(44px, 8vw, 110px) 0 80px;
}
.content-shell h1 {
  max-width: 700px;
  font-size: clamp(48px, 9vw, 96px);
  line-height: .98;
}
.content-lead {
  max-width: 650px;
  margin: 40px 0 clamp(70px, 10vw, 130px);
  color: var(--muted);
  font-size: clamp(17px, 2.2vw, 22px);
  line-height: 1.9;
}
.content-shell section {
  display: grid;
  grid-template-columns: minmax(130px, .55fr) minmax(0, 1.45fr);
  gap: 30px;
  padding: 34px 0;
  border-top: 1px solid var(--line);
}
.content-shell h2 { margin: 0; color: var(--accent); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }
.content-shell section > p { margin: 0; color: var(--muted); line-height: 1.9; }
.content-shell section > p + p { margin-top: 14px; grid-column: 2; }
.text-link { color: var(--text); text-underline-offset: 5px; }
.quiet-link { margin-top: 90px; padding: 42px; border: 1px solid var(--line); border-radius: 28px; background: var(--surface); }
.quiet-link p { margin: 0 0 10px; color: var(--faint); font-size: 12px; }
.quiet-link a { font-family: Georgia, "Times New Roman", serif; font-size: 28px; text-decoration: none; }
.content-button { min-height: 48px; padding: 10px 18px; border: 1px solid var(--line-strong); border-radius: 999px; background: transparent; color: var(--text); cursor: pointer; }
.content-footer { display: flex; gap: 24px; padding-top: 24px; padding-bottom: max(36px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.content-footer a { color: var(--faint); font-size: 12px; text-decoration: none; }
@media (max-width: 620px) {
  .content-shell section { grid-template-columns: 1fr; gap: 14px; }
  .content-shell section > p + p { grid-column: 1; }
  .quiet-link { margin-top: 60px; padding: 28px; }
}
