/* Still Water — UI styles (docs/ux/spec.md §1–§5) */

@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("fonts/source-serif-4-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Source Sans 3';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("fonts/source-sans-3-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Typography (rem-based relative to 16px root; minimum 14px / weight 400) */
  --font-serif: 'Source Serif 4', 'Iowan Old Style', Georgia, serif;
  --font-sans: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;

  --text-splash-title: 2.375rem; /* 38px phone */
  --text-splash-sub: 1.0625rem;  /* 17px phone */
  --text-heading: 1.375rem;      /* 22px phone */
  --text-tab: 1rem;              /* 16px phone */
  --text-section: 1.0625rem;     /* 17px phone */
  --text-control: 1rem;          /* 16px phone */
  --text-segment: 0.9375rem;     /* 15px phone */
  --text-body: 1rem;             /* 16px phone */
  --text-helper: 0.875rem;       /* 14px phone */

  /* Surfaces & Ink (WCAG 2.1 verified) */
  --surface-bg: #161D1C;
  --surface-sheet: #1A2120;
  --surface-well: #131918;
  --surface-key: #252F2D;
  --surface-key-press: #2E3A37;
  --surface-trigger: rgba(24, 31, 30, 0.90);
  --surface-active: #E6DFD1;
  --surface-active-press: #D7CEBD;

  --ink-primary: #F0EDE6;
  --ink-secondary: #C4BFB4;
  --ink-muted: #A39E93;
  --ink-on-light: #161C1B;

  --accent-moss: #6D9B80;
  --accent-amber: #DFB160;
  --accent-holiday: #C95B51;

  --border-hairline: #303B38;
  --border-control: #667370;
  --border-active: #F0EDE6;

  /* Pond tint swatches */
  --swatch-slate: #46627B;
  --swatch-teal: #357274;
  --swatch-sand: #9F8A64;
  --swatch-moss: #456648;

  /* Safe-area insets */
  --safe-top: max(14px, env(safe-area-inset-top));
  --safe-bottom: max(16px, env(safe-area-inset-bottom));
  --safe-left: max(16px, env(safe-area-inset-left));
  --safe-right: max(16px, env(safe-area-inset-right));

  --trigger-size: 4.125rem; /* 66px phone: comfortable rim clearance for "Options" label */
}

@media (min-width: 744px) and (min-height: 600px) {
  :root {
    --text-splash-title: 3rem;     /* 48px iPad */
    --text-splash-sub: 1.1875rem;  /* 19px iPad */
    --text-heading: 1.625rem;      /* 26px iPad */
    --text-tab: 1.0625rem;         /* 17px iPad */
    --text-section: 1.1875rem;     /* 19px iPad */
    --text-control: 1.0625rem;     /* 17px iPad */
    --text-segment: 1rem;          /* 16px iPad */
    --text-body: 1.0625rem;        /* 17px iPad */
    --text-helper: 0.9375rem;      /* 15px iPad */

    --safe-top: max(24px, env(safe-area-inset-top));
    --safe-bottom: max(24px, env(safe-area-inset-bottom));
    --safe-left: max(24px, env(safe-area-inset-left));
    --safe-right: max(24px, env(safe-area-inset-right));

    --trigger-size: 4.375rem;      /* 70px iPad */
  }
}

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

html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-size: 100%;
  background-color: var(--surface-bg);
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background-color: var(--surface-bg);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent-amber);
  outline-offset: 2px;
}

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

/* Full-bleed live pond canvas (touch-action: none strictly on canvas only) */
#pond {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  width: 100dvw;
  height: 100dvh;
  display: block;
  background-color: var(--surface-bg);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* ==========================================================================
   UI Root Layer & Pond-Edge Stone Triggers (spec §2, §3.2, §5.1)
   ========================================================================== */

.ui-layer {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.pond-triggers {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: 1;
  visibility: visible;
  transition: opacity 180ms ease-out, visibility 0ms linear 0ms;
}

.pond-triggers.is-suppressed {
  opacity: 0;
  visibility: hidden;
  transition: opacity 180ms ease-out, visibility 0ms linear 180ms;
}

.pond-triggers.is-suppressed .pond-trigger {
  pointer-events: none;
}

.pond-trigger {
  position: fixed;
  bottom: var(--safe-bottom);
  min-width: var(--trigger-size);
  min-height: var(--trigger-size);
  width: var(--trigger-size);
  height: var(--trigger-size);
  padding: 0.125rem 0.25rem 0.4375rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  border-radius: 50%;
  border: 1px solid rgba(240, 237, 230, 0.22);
  background-color: var(--surface-trigger);
  color: var(--ink-primary);
  box-shadow: 0 2px 8px rgba(8, 12, 11, 0.40);
  font-family: var(--font-sans);
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  opacity: 0.96;
  transition:
    opacity 180ms ease-out,
    background-color 140ms ease-out,
    border-color 140ms ease-out,
    transform 140ms ease-out;
}

.pond-trigger--holiday {
  top: var(--safe-top);
  bottom: auto;
  left: var(--safe-left);
}

.pond-trigger-indicator {
  position: absolute;
  top: 5px;
  left: 50%;
  width: 5px;
  height: 5px;
  margin-left: -2.5px;
  border-radius: 50%;
  background-color: var(--accent-amber);
  opacity: 0;
  transform: scale(0.6);
  pointer-events: none;
  transition: opacity 160ms ease-out, transform 160ms ease-out;
}

.pond-trigger--holiday.is-active {
  border-width: 2px;
  border-color: var(--accent-amber);
}

.pond-trigger--holiday.is-active .pond-trigger-icon {
  color: var(--accent-amber);
}

.pond-trigger--holiday.is-active .holiday-bow-dot,
.switch-row.is-holiday-active .holiday-bow-dot {
  fill: var(--accent-holiday);
}

.switch-row.is-holiday-active .switch-row-icon {
  color: var(--accent-amber);
}

.pond-trigger--holiday.is-active .pond-trigger-indicator {
  opacity: 1;
  transform: scale(1);
}

.pond-trigger--help {
  left: var(--safe-left);
}

.pond-trigger--feed {
  left: 0;
  right: 0;
  margin-inline: auto;
}

.pond-trigger--feed.is-fed {
  border-color: var(--accent-amber);
}

.pond-trigger--options {
  right: var(--safe-right);
}

.pond-trigger.is-idle {
  opacity: 0.40;
  transition:
    opacity 700ms ease-out,
    background-color 140ms ease-out,
    border-color 140ms ease-out,
    transform 140ms ease-out;
}

.pond-trigger:focus-visible {
  opacity: 1;
  border-color: var(--border-active);
}

@media (hover: hover) {
  .pond-trigger:hover {
    background-color: rgba(34, 43, 41, 0.94);
    border-color: rgba(240, 237, 230, 0.36);
  }
}

.pond-trigger:active {
  background-color: rgba(46, 58, 55, 0.96);
  transform: scale(0.96);
}

.pond-trigger-icon {
  width: 1.375rem;  /* 22px at 16px root */
  height: 1.375rem;
  flex-shrink: 0;
  display: block;
}

.pond-trigger-label {
  font-size: var(--text-helper);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
  color: var(--ink-primary);
  white-space: nowrap;
}

/* ==========================================================================
   Settings Sheet & Dismiss Backdrop (spec §3.4, §5.1)
   ========================================================================== */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  pointer-events: auto;
  cursor: default;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.sheet-backdrop:focus {
  outline: none;
}

.settings-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 21;
  display: flex;
  flex-direction: column;
  height: min(560px, 66vh);
  height: min(560px, 66dvh);
  background-color: var(--surface-sheet);
  border-top: 1px solid var(--border-hairline);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 20px rgba(8, 12, 11, 0.45);
  color: var(--ink-primary);
  pointer-events: auto;
  transform: translateY(100%);
  transition: transform 240ms cubic-bezier(0.4, 0, 1, 1);
  will-change: transform;
}

.settings-sheet.is-open {
  transform: translateY(0);
  transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.settings-sheet:focus,
.settings-sheet:focus-visible {
  outline: none;
}

/* Quiet matte bottom scroll-fade cue when .sheet-body overflows below */
.settings-sheet::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: min(calc(2.25rem + var(--safe-bottom)), 26%);
  border-bottom-left-radius: inherit;
  border-bottom-right-radius: inherit;
  background: linear-gradient(
    to bottom,
    rgba(26, 33, 32, 0) 0%,
    rgba(26, 33, 32, 0.72) 58%,
    rgba(26, 33, 32, 0.96) 100%
  );
  pointer-events: none;
  opacity: 0;
  transition: opacity 180ms ease-out;
  z-index: 2;
}

.settings-sheet.has-scroll-more::after {
  opacity: 1;
}

/* Sticky Sheet Header */
.sheet-header {
  position: relative;
  z-index: 3;
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.125rem 0.5rem;
  min-height: 52px;
  padding: 0 0.25rem 0 0.5rem;
  border-bottom: 1px solid var(--border-hairline);
  background-color: var(--surface-sheet);
  border-radius: 16px 16px 0 0;
}

.sheet-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  min-width: 0;
}

.sheet-tab {
  position: relative;
  flex-shrink: 0;
  min-width: 68px;
  min-height: 50px;
  padding: 0.25rem 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--ink-secondary);
  font-family: var(--font-sans);
  font-size: var(--text-tab);
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 140ms ease-out;
}

.sheet-tab[aria-selected="true"] {
  color: var(--ink-primary);
  font-weight: 600;
}

.sheet-tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 0.625rem;
  right: 0.625rem;
  bottom: 0;
  height: 3px;
  background-color: var(--accent-amber);
  border-radius: 2px 2px 0 0;
}

@media (hover: hover) {
  .sheet-tab:hover {
    color: var(--ink-primary);
  }
}

.sheet-tab:focus-visible {
  outline-offset: -4px;
  border-radius: 6px;
}

.sheet-done {
  flex-shrink: 0;
  align-self: center;
  margin-left: auto;
  min-width: 64px;
  min-height: 48px;
  padding: 0.375rem 0.875rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--accent-amber);
  font-family: var(--font-sans);
  font-size: var(--text-tab);
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 140ms ease-out;
}

@media (hover: hover) {
  .sheet-done:hover {
    background-color: var(--surface-key);
  }
}

.sheet-done:active {
  background-color: var(--surface-key-press);
}

.sheet-done:focus-visible {
  outline-offset: -2px;
}

/* Scrollable Sheet Body */
.sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border-control) transparent;
  padding:
    0.75rem
    max(1.25rem, var(--safe-right))
    calc(1.25rem + var(--safe-bottom))
    max(1.25rem, var(--safe-left));
}

.sheet-panel {
  min-width: 0;
}

/* ==========================================================================
   Options Tab Controls (spec §1.1, §3.4, §4.1, §4.2)
   ========================================================================== */

.options-section {
  container-type: inline-size;
  margin-top: 0.75rem;
  padding-top: 0.625rem;
  border-top: 1px solid var(--border-hairline);
}

.options-section--first {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

/* Feeding primary CTA & motion permission control (P6, M1, spec §3.4) */
.action-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: var(--text-control);
  line-height: 1.3;
  text-align: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 140ms ease-out, border-color 140ms ease-out, transform 140ms ease-out;
}

.action-btn--primary {
  min-height: 3.25rem; /* 52px */
  padding: 0.75rem 1.25rem;
  border: 1px solid transparent;
  background-color: var(--surface-active);
  color: var(--ink-on-light);
  font-weight: 600;
}

@media (hover: hover) {
  .action-btn--primary:hover {
    background-color: #EDE7DA;
  }
}

.action-btn--primary:active {
  background-color: var(--surface-active-press);
  transform: scale(0.985);
}

.action-btn--secondary {
  min-height: 3rem; /* 48px */
  padding: 0.625rem 1rem;
  border: 1px solid var(--border-control);
  background-color: var(--surface-key);
  box-shadow: inset 0 1px 0 rgba(240, 237, 230, 0.07);
  color: var(--ink-primary);
  font-weight: 500;
}

@media (hover: hover) {
  .action-btn--secondary:hover {
    background-color: #2B3634;
    border-color: rgba(240, 237, 230, 0.45);
  }
}

.action-btn--secondary:active {
  background-color: var(--surface-key-press);
  transform: scale(0.985);
}

.action-btn:disabled {
  opacity: 0.72;
  cursor: default;
}

.action-btn-icon {
  width: 1.25rem; /* 20px */
  height: 1.25rem;
  flex-shrink: 0;
  display: block;
}

.motion-control {
  margin-top: 0.625rem; /* 10px below Feed the koi */
}

.motion-helper {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-helper);
  font-weight: 400;
  line-height: 1.4;
  color: var(--ink-secondary);
}

.motion-control:not([hidden]) .motion-helper {
  min-height: 1.4em;
  min-height: 1lh;
}

.motion-helper:focus {
  outline: none;
}

.action-btn:not([hidden]) + .motion-helper {
  margin-top: 0.375rem;
}

.section-heading {
  margin: 0 0 0.375rem;
  font-family: var(--font-serif);
  font-size: var(--text-section);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0.01em;
  color: var(--ink-primary);
}

.control-group {
  margin-top: 0.5rem;
}

.control-group:first-of-type {
  margin-top: 0;
}

.control-label {
  display: block;
  margin: 0 0 0.25rem;
  font-family: var(--font-sans);
  font-size: var(--text-segment);
  font-weight: 500;
  line-height: 1.2;
  color: var(--ink-secondary);
}

/* Water tint selector (4 unboxed pigment discs directly on #1A2120) */
.tint-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.375rem;
}

.tint-option {
  position: relative;
  min-height: 3.125rem; /* 50px hit target */
  padding: 0.25rem 0.25rem 0.1875rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  color: var(--ink-secondary);
  font-family: var(--font-sans);
  font-size: var(--text-helper);
  font-weight: 500;
  line-height: 1.15;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 140ms ease-out;
}

@media (hover: hover) {
  .tint-option:hover {
    color: var(--ink-primary);
  }

  .tint-option[aria-checked="false"]:hover .tint-swatch {
    box-shadow: 0 0 0 2px var(--surface-sheet), 0 0 0 3px rgba(240, 237, 230, 0.36);
  }
}

.tint-option:active .tint-swatch {
  transform: scale(0.94);
}

.tint-option[aria-checked="true"] {
  color: var(--ink-primary);
  font-weight: 600;
}

.tint-swatch {
  width: 1.75rem; /* 28px pigment disc */
  height: 1.75rem;
  border-radius: 50%;
  border: 1px solid rgba(240, 237, 230, 0.24);
  flex-shrink: 0;
  transition: box-shadow 140ms ease-out, border-color 140ms ease-out, transform 140ms ease-out;
}

.tint-option[aria-checked="true"] .tint-swatch {
  border-color: rgba(240, 237, 230, 0.35);
  box-shadow: 0 0 0 3px var(--surface-sheet), 0 0 0 5px var(--border-active);
}

.tint-swatch--slate { background-color: var(--swatch-slate); }
.tint-swatch--teal  { background-color: var(--swatch-teal); }
.tint-swatch--sand  { background-color: var(--swatch-sand); }
.tint-swatch--moss  { background-color: var(--swatch-moss); }

.tint-name {
  display: block;
  text-align: center;
}

/* Segmented bars (Floor 2-way, Koi 4-way, Lily pads 4-way) */
.segmented-bar {
  display: grid;
  gap: 0.1875rem;
  padding: 0.1875rem;
  background-color: var(--surface-well);
  border: 1px solid var(--border-hairline);
  border-radius: 10px;
}

.segmented-bar--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.segmented-bar--4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.segment-btn {
  min-height: 3rem; /* 48px */
  padding: 0.375rem 0.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 0;
  border-radius: 7px;
  background-color: transparent;
  box-shadow: none;
  color: var(--ink-secondary);
  font-family: var(--font-sans);
  font-size: var(--text-segment);
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 140ms ease-out, color 140ms ease-out;
}

.segment-btn--floor {
  min-height: 3rem; /* 48px */
  padding: 0.375rem 0.75rem;
}

@media (hover: hover) {
  .segment-btn[aria-checked="false"]:hover {
    background-color: rgba(240, 237, 230, 0.06);
    color: var(--ink-primary);
  }
}

.segment-btn[aria-checked="false"]:active {
  background-color: rgba(240, 237, 230, 0.10);
  color: var(--ink-primary);
}

.segment-btn[aria-checked="true"] {
  background-color: var(--surface-active);
  color: var(--ink-on-light);
  font-weight: 600;
}

.segment-btn[aria-checked="true"]:active {
  background-color: var(--surface-active-press);
}

.segment-icon {
  width: 1.25rem; /* 20px */
  height: 1.25rem;
  flex-shrink: 0;
  display: block;
}

/* Hairline Switch List & Native <input type="checkbox" switch> (X1, spec §4.1) */
.switch-list {
  margin-top: 0.625rem; /* 10px */
  border-top: 1px solid var(--border-hairline);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 3.125rem; /* 50px */
  padding: 0.4375rem 0;
  border-bottom: 1px solid var(--border-hairline);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.switch-list .switch-row:last-child {
  border-bottom: 0;
}

.switch-row-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1;
}

.switch-row-icon {
  width: 1.5rem; /* 24px */
  height: 1.5rem;
  flex-shrink: 0;
  color: var(--ink-secondary);
}

.switch-row-text {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
}

.switch-row-label {
  font-family: var(--font-sans);
  font-size: var(--text-control);
  font-weight: 500;
  line-height: 1.3;
  color: var(--ink-primary);
}

.switch-row-helper {
  font-family: var(--font-sans);
  font-size: var(--text-helper);
  font-weight: 400;
  line-height: 1.4;
  color: var(--ink-secondary);
}

/* Native WebKit iOS 18+ switch haptics: NEVER set appearance: none here! */
input[type="checkbox"][switch] {
  color-scheme: dark;
  accent-color: var(--accent-moss);
  width: 51px;
  height: 31px;
  margin: 0;
  flex-shrink: 0;
  cursor: pointer;
}

/* Progressive fallback ONLY on browsers lacking native switch support */
.no-native-switch input[type="checkbox"][switch] {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  width: 52px;
  height: 32px;
  border-radius: 16px;
  border: 1.5px solid var(--border-control);
  background-color: var(--surface-key);
  transition: background-color 180ms ease-out, border-color 180ms ease-out;
}

.no-native-switch input[type="checkbox"][switch]::before {
  content: "";
  position: absolute;
  top: 2.5px;
  left: 2.5px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: var(--ink-primary);
  transition: transform 180ms ease-out;
}

.no-native-switch input[type="checkbox"][switch]:checked {
  background-color: var(--accent-moss);
  border-color: var(--accent-moss);
}

.no-native-switch input[type="checkbox"][switch]:checked::before {
  transform: translateX(20px);
}

input[type="checkbox"][switch]:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ==========================================================================
   Sounds, Sleep Timer & Daily Reminder Controls (Phases 4 & 6: P9, P16–P18, X4)
   ========================================================================== */

.options-section--pond,
.options-section--timer,
.options-section--reminder {
  margin-top: 1rem;
  padding-top: 0.875rem;
}

.options-section--timer {
  scroll-margin-bottom: 1.5rem;
}

.section-heading--inline {
  margin: 0;
}

.slider-group {
  margin-top: 0.25rem;
}

.slider-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.slider-header--section {
  align-items: center;
  margin-bottom: 0.25rem;
}

.slider-label {
  font-family: var(--font-sans);
  font-size: var(--text-control);
  font-weight: 500;
  line-height: 1.3;
  color: var(--ink-primary);
}

.slider-readout {
  font-family: var(--font-sans);
  font-size: var(--text-segment);
  font-weight: 500;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  color: var(--accent-amber);
  white-space: nowrap;
}

.slider-readout--timer {
  color: var(--ink-secondary);
}

.slider-readout--timer.is-active {
  color: var(--accent-amber);
  font-weight: 600;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3rem; /* 48px */
}

.slider-row--timer {
  gap: 0;
}

.slider-row--timer .stone-slider {
  scroll-margin-bottom: 5rem;
}

.slider-icon {
  width: 1.5rem; /* 24px (spec §1.5) */
  height: 1.5rem;
  flex-shrink: 0;
  display: block;
  color: var(--ink-secondary);
}

/* Accessible matte stone range slider (spec §4.3: 8px recessed track, 32px limestone thumb) */
.stone-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  min-width: 0;
  width: 100%;
  height: 3rem; /* 48px full vertical touch target */
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
}

.stone-slider:focus-visible {
  outline: 2px solid var(--accent-amber);
  outline-offset: 2px;
  border-radius: 6px;
}

.stone-slider::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 4px;
  border: 1px solid var(--border-control);
  background: linear-gradient(
    to right,
    var(--accent-amber) 0%,
    var(--accent-amber) var(--pct, 0%),
    var(--surface-well) var(--pct, 0%),
    var(--surface-well) 100%
  );
}

.stone-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 32px;
  height: 32px;
  margin-top: -13px; /* vertically centers 32px thumb over 6px inner track */
  border-radius: 50%;
  border: 2px solid var(--surface-sheet);
  background: radial-gradient(
    circle,
    var(--border-control) 0 3px,
    var(--ink-primary) 3.5px 100%
  );
  box-shadow: 0 1px 4px rgba(8, 12, 11, 0.45);
  cursor: pointer;
}

.stone-slider:active::-webkit-slider-thumb {
  background: radial-gradient(
    circle,
    var(--border-control) 0 3px,
    var(--surface-active) 3.5px 100%
  );
}

.stone-slider::-moz-range-track {
  height: 8px;
  border-radius: 4px;
  border: 1px solid var(--border-control);
  background: linear-gradient(
    to right,
    var(--accent-amber) 0%,
    var(--accent-amber) var(--pct, 0%),
    var(--surface-well) var(--pct, 0%),
    var(--surface-well) 100%
  );
}

.stone-slider::-moz-range-thumb {
  width: 32px;
  height: 32px;
  box-sizing: border-box;
  border-radius: 50%;
  border: 2px solid var(--surface-sheet);
  background: radial-gradient(
    circle,
    var(--border-control) 0 3px,
    var(--ink-primary) 3.5px 100%
  );
  box-shadow: 0 1px 4px rgba(8, 12, 11, 0.45);
  cursor: pointer;
}

.switch-list--sounds {
  margin-top: 0.5rem;
}

/* 2-column sound switch grid on Landscape & iPad, auto-collapsing cleanly at 200% zoom */
@container (min-width: 24.5rem) {
  .switch-list--sounds {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 1.375rem;
  }

  .switch-list--sounds .switch-row {
    gap: 0.5rem;
    border-bottom: 1px solid var(--border-hairline);
  }

  .switch-list--sounds .switch-row-main {
    gap: 0.625rem;
  }

  .switch-list--sounds .switch-row:nth-last-child(-n+2) {
    border-bottom: 0;
  }
}

/* Sleep timer discrete 8-stop tick dots & endpoint labels (spec §3.4) */
.timer-ticks {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px; /* aligns 4px dots under 32px thumb stop centers */
  margin-top: -2px;
}

.timer-tick {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: var(--border-control);
  flex-shrink: 0;
  transition: background-color 140ms ease-out;
}

.timer-tick.is-current {
  background-color: var(--accent-amber);
}

.timer-endpoints {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.375rem;
  font-family: var(--font-sans);
  font-size: var(--text-helper);
  font-weight: 400;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  color: var(--ink-secondary);
}

.timer-helper {
  margin: 0.5rem 0 0;
  font-family: var(--font-sans);
  font-size: var(--text-helper);
  font-weight: 400;
  line-height: 1.4;
  color: var(--ink-secondary);
}

/* Daily reminder section (X4, spec §3.4 item 5) */
.options-section--reminder {
  scroll-margin-bottom: 1.5rem;
}

.reminder-controls.is-pending .switch-row--reminder {
  cursor: default;
}

.switch-row--reminder {
  min-height: 3.25rem; /* 52px */
  border-bottom: 0;
}

.reminder-time-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  min-height: 3.25rem; /* 52px */
  padding: 0.5rem 0 0.25rem;
  border-top: 1px solid var(--border-hairline);
  scroll-margin-bottom: calc(2.25rem + var(--safe-bottom));
}

.reminder-time-label {
  font-family: var(--font-sans);
  font-size: var(--text-control);
  font-weight: 500;
  line-height: 1.3;
  color: var(--ink-primary);
}

.select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: min(8.75rem, 100%); /* 140px */
  max-width: 100%;
}

.stone-select {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-width: min(8.75rem, 100%);
  min-height: 3rem; /* 48px */
  padding: 0.5rem 2.375rem 0.5rem 0.875rem;
  border: 1px solid var(--border-control);
  border-radius: 8px;
  background-color: var(--surface-key);
  box-shadow: inset 0 1px 0 rgba(240, 237, 230, 0.07);
  color: var(--ink-primary);
  color-scheme: dark;
  font-family: var(--font-sans);
  font-size: var(--text-control);
  font-weight: 500;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 140ms ease-out, border-color 140ms ease-out;
}

@media (hover: hover) {
  .stone-select:hover:not(:disabled) {
    background-color: #2B3634;
    border-color: rgba(240, 237, 230, 0.45);
  }
}

.stone-select:active:not(:disabled) {
  background-color: var(--surface-key-press);
}

.stone-select:disabled {
  opacity: 0.6;
  cursor: default;
}

.stone-select option {
  background-color: var(--surface-sheet);
  color: var(--ink-primary);
}

.select-chevron {
  position: absolute;
  right: 0.75rem;
  width: 1.125rem; /* 18px */
  height: 1.125rem;
  color: var(--ink-secondary);
  pointer-events: none;
}

.reminder-status {
  margin: 0.5rem 0 0;
  font-family: var(--font-sans);
  font-size: var(--text-helper);
  font-weight: 400;
  line-height: 1.45;
  color: var(--accent-amber);
  scroll-margin-bottom: calc(2.25rem + var(--safe-bottom));
}

.reminder-status.is-pending {
  color: var(--ink-secondary);
}

.reminder-note {
  margin: 0.25rem 0 0;
  max-width: 58ch;
  font-family: var(--font-sans);
  font-size: var(--text-segment);
  font-weight: 400;
  line-height: 1.5;
  color: var(--ink-secondary);
}

/* ==========================================================================
   Tap-to-Resume Audio Hint (M8, X2, spec §3.6)
   ========================================================================== */

.audio-resume-hint {
  position: fixed;
  top: calc(var(--safe-top) + 12px);
  left: 0;
  right: 0;
  margin-inline: auto;
  width: fit-content;
  z-index: 15;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  min-height: 3rem; /* 48px */
  max-width: calc(100vw - 2rem);
  padding: 0.625rem 1.25rem;
  border: 1px solid var(--accent-amber);
  border-radius: 8px;
  background-color: var(--surface-sheet);
  color: var(--ink-primary);
  box-shadow: 0 2px 12px rgba(8, 12, 11, 0.45);
  font-family: var(--font-sans);
  font-size: var(--text-segment);
  font-weight: 500;
  line-height: 1.3;
  text-align: center;
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
  transition: opacity 220ms ease-out, background-color 140ms ease-out;
}

.audio-resume-hint.is-visible {
  opacity: 1;
}

.audio-resume-hint.is-hiding {
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease-out, background-color 140ms ease-out;
}

@media (hover: hover) {
  .audio-resume-hint:hover {
    background-color: var(--surface-key);
  }
}

.audio-resume-hint:active {
  background-color: var(--surface-key-press);
}

.audio-resume-icon {
  width: 1.25rem; /* 20px */
  height: 1.25rem;
  flex-shrink: 0;
  display: block;
  color: var(--accent-amber);
}

.audio-resume-label {
  display: block;
}

/* ==========================================================================
   Sleep-Timer Expiry Resting State (P17, P28, M5, spec §3.7)
   ========================================================================== */

.sleep-veil {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding:
    var(--safe-top)
    calc(var(--safe-right) + 1rem)
    calc(var(--safe-bottom) + 2.5rem)
    calc(var(--safe-left) + 1rem);
  background: transparent;
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.sleep-veil.is-waking {
  pointer-events: none;
}

.sleep-veil:focus,
.sleep-veil:focus-visible {
  outline: none;
}

.sleep-caption {
  max-width: 30ch;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 500ms ease-out;
}

.sleep-veil.is-caption-visible .sleep-caption {
  opacity: 1;
}

.sleep-veil.is-waking .sleep-caption {
  opacity: 0;
  transition: opacity 180ms ease-out;
}

.sleep-veil:focus-visible .sleep-caption {
  outline: 1.5px solid rgba(223, 177, 96, 0.65);
  outline-offset: 2px;
}

.sleep-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.125rem; /* 18px */
  font-weight: 500;
  line-height: 1.3;
  color: var(--ink-muted);
  text-shadow: 0 1px 4px rgba(8, 12, 11, 0.90), 0 2px 12px rgba(8, 12, 11, 0.72);
}

.sleep-subtitle {
  margin: 0.25rem 0 0;
  font-family: var(--font-sans);
  font-size: var(--text-segment); /* 15px */
  font-weight: 400;
  line-height: 1.4;
  color: var(--ink-muted);
  text-shadow: 0 1px 4px rgba(8, 12, 11, 0.90), 0 2px 12px rgba(8, 12, 11, 0.72);
}

/* ==========================================================================
   News & About Tabs (spec §3.4, §8.7, §8.8)
   ========================================================================== */

.news-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 58ch;
}

.news-item {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-hairline);
}

.news-item:first-child {
  padding-top: 0.25rem;
}

.news-item:last-child {
  border-bottom: 0;
  padding-bottom: 0.25rem;
}

.news-date {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-helper);
  font-weight: 500;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  color: var(--accent-amber);
}

.news-title {
  margin: 0.25rem 0 0;
  font-family: var(--font-serif);
  font-size: var(--text-section);
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink-primary);
}

.news-body {
  margin: 0.375rem 0 0;
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: 400;
  line-height: 1.55;
  color: var(--ink-secondary);
}

.about-content {
  max-width: 58ch;
  padding-top: 0.25rem;
}

.about-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: var(--text-heading);
  font-weight: 500;
  line-height: 1.25;
  color: var(--ink-primary);
}

.about-version {
  margin: 0.25rem 0 0;
  font-family: var(--font-sans);
  font-size: var(--text-helper);
  font-weight: 400;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
}

.about-dedication {
  margin: 1rem 0 0;
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: 400;
  line-height: 1.55;
  color: var(--ink-primary);
}

.about-divider {
  margin: 1.25rem 0;
  border: 0;
  border-top: 1px solid var(--border-hairline);
}

.about-credits-heading {
  margin: 0;
  font-family: var(--font-serif);
  font-size: var(--text-section);
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink-primary);
}

.about-credits-body,
.about-privacy {
  margin: 0.5rem 0 0;
  font-family: var(--font-sans);
  font-size: var(--text-segment);
  font-weight: 400;
  line-height: 1.55;
  color: var(--ink-secondary);
}

.about-privacy {
  margin-top: 0.75rem;
}

.about-fonts {
  margin: 0.75rem 0 0;
  font-family: var(--font-sans);
  font-size: var(--text-helper);
  font-weight: 400;
  line-height: 1.5;
  color: var(--ink-muted);
}

.about-link {
  color: var(--accent-amber);
  text-decoration: underline;
  text-underline-offset: 3px;
  display: inline-block;
  padding: 0.25rem 0;
}

@media (hover: hover) {
  .about-link:hover {
    color: var(--ink-primary);
  }
}

/* ==========================================================================
   Launch Splash Veil (P1, spec §3.1, §5.1, §6)
   ========================================================================== */

.launch-splash {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding:
    calc(var(--safe-top) + 1rem)
    calc(var(--safe-right) + 1.5rem)
    calc(var(--safe-bottom) + 0.75rem)
    calc(var(--safe-left) + 1.5rem);
  background-color: rgba(22, 29, 28, 0.94);
  color: var(--ink-primary);
  text-align: center;
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  opacity: 1;
  transition: opacity 750ms ease-out;
  overflow-y: auto;
}

.launch-splash.is-repeat {
  transition-duration: 500ms;
}

.launch-splash.is-fast-fade {
  transition-duration: 350ms;
}

.launch-splash.is-fading {
  opacity: 0;
  pointer-events: none;
}

.splash-center {
  margin: auto 0;
  padding-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.625rem;
}

.splash-emblem {
  width: 3.5rem; /* 56px phone */
  height: 3.5rem;
  flex-shrink: 0;
  display: block;
  color: var(--surface-active);
  opacity: 0.85;
}

.splash-title {
  margin: 0.25rem 0 0;
  font-family: var(--font-serif);
  font-size: var(--text-splash-title);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: 0.01em;
  color: var(--ink-primary);
}

.splash-subtitle {
  margin: 0;
  max-width: 28ch;
  font-family: var(--font-sans);
  font-size: var(--text-splash-sub);
  font-weight: 400;
  line-height: 1.45;
  color: var(--ink-secondary);
}

.splash-footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1875rem;
  padding-top: 0.75rem;
}

.splash-credit {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-helper);
  font-weight: 400;
  line-height: 1.4;
  color: var(--ink-secondary);
}

.splash-version {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-helper);
  font-weight: 400;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
}

/* ==========================================================================
   Help Screen — Original Wordless Illustrations & 3D Flip (P7, spec §3.3, §5.1)
   ========================================================================== */

.help-screen {
  position: fixed;
  inset: 0;
  z-index: 24;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  perspective: 1200px;
}

.help-screen:focus,
.help-screen:focus-visible {
  outline: none;
}

.help-card {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: var(--surface-sheet);
  color: var(--ink-primary);
  transform-origin: center center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: rotateY(-90deg);
  opacity: 0;
  transition:
    transform 340ms cubic-bezier(0.4, 0, 1, 1),
    opacity 180ms ease-out;
  will-change: transform, opacity;
}

.help-screen.is-open .help-card {
  transform: rotateY(0deg);
  opacity: 1;
  transition:
    transform 420ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 160ms ease-out;
}

.help-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding:
    calc(var(--safe-top) + 1rem)
    calc(var(--safe-right) + 1rem)
    calc(var(--safe-bottom) + var(--trigger-size) + 1.5rem)
    calc(var(--safe-left) + 1rem);
}

.help-panels {
  width: 100%;
  max-width: 24rem;
  margin: auto 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
}

.help-panel {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.help-illustration {
  width: 100%;
  max-width: 22.5rem;
  height: auto;
  max-height: 16.5rem;
  display: block;
}

.help-divider {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--border-hairline);
  margin: 0.25rem 0;
}

.help-close {
  position: fixed;
  left: var(--safe-left);
  bottom: var(--safe-bottom);
  z-index: 2;
  width: var(--trigger-size);
  height: var(--trigger-size);
  min-width: var(--trigger-size);
  min-height: var(--trigger-size);
  padding: 0.125rem 0.25rem 0.4375rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  border-radius: 50%;
  border: 1.5px solid var(--border-control);
  background-color: var(--surface-key);
  box-shadow: inset 0 1px 0 rgba(240, 237, 230, 0.07), 0 2px 8px rgba(8, 12, 11, 0.40);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 140ms ease-out, border-color 140ms ease-out, transform 140ms ease-out;
}

@media (hover: hover) {
  .help-close:hover {
    background-color: #2B3634;
    border-color: rgba(240, 237, 230, 0.45);
  }
}

.help-close:active {
  background-color: var(--surface-key-press);
  transform: scale(0.96);
}

/* ==========================================================================
   Add-to-Home-Screen Gentle One-Time Hint (M4, spec §3.5)
   ========================================================================== */

.a2hs-hint {
  position: fixed;
  left: var(--safe-left);
  right: var(--safe-right);
  bottom: calc(var(--safe-bottom) + var(--trigger-size) + 12px);
  z-index: 16;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.625rem 0.875rem;
  max-width: 32rem;
  margin-inline: auto;
  padding: 0.75rem 0.875rem 0.75rem 1rem;
  border: 1px solid var(--border-control);
  border-radius: 8px;
  background-color: var(--surface-sheet);
  color: var(--ink-primary);
  box-shadow: 0 4px 16px rgba(8, 12, 11, 0.45);
  pointer-events: auto;
  opacity: 0;
  transition: opacity 220ms ease-out;
}

.a2hs-hint.is-visible {
  opacity: 1;
}

.a2hs-hint.is-hiding {
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease-out;
}

.a2hs-text {
  margin: 0;
  flex: 1 1 11rem;
  min-width: 0;
  font-family: var(--font-sans);
  font-size: var(--text-segment);
  font-weight: 400;
  line-height: 1.45;
  text-wrap: pretty;
  color: var(--ink-primary);
}

.a2hs-share-icon,
.a2hs-menu-icon {
  width: 1.125rem; /* 18px inline */
  height: 1.125rem;
  display: inline-block;
  vertical-align: -0.2em;
  margin: 0 0.125rem;
  color: var(--accent-amber);
}

.a2hs-dismiss {
  flex-shrink: 0;
  min-width: 4.25rem; /* 68px */
  min-height: 3rem;   /* 48px */
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--border-control);
  border-radius: 8px;
  background-color: var(--surface-key);
  box-shadow: inset 0 1px 0 rgba(240, 237, 230, 0.07);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  font-size: var(--text-segment);
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 140ms ease-out, border-color 140ms ease-out;
}

@media (hover: hover) {
  .a2hs-dismiss:hover {
    background-color: #2B3634;
    border-color: rgba(240, 237, 230, 0.45);
  }
}

.a2hs-dismiss:active {
  background-color: var(--surface-key-press);
}

/* ==========================================================================
   WebGL2 Fallback Screen (spec §3.8)
   ========================================================================== */

.fallback {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  width: 100dvw;
  height: 100dvh;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding:
    calc(var(--safe-top) + 16px)
    calc(var(--safe-right) + 8px)
    calc(var(--safe-bottom) + 28px)
    calc(var(--safe-left) + 8px);
  background-color: var(--surface-bg);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.fallback-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  z-index: 0;
}

.fallback-scrim {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: linear-gradient(
    to top,
    rgba(16, 22, 21, 0.35) 0%,
    rgba(16, 22, 21, 0.35) 42%,
    rgba(16, 22, 21, 0) 72%
  );
}

.fallback-panel {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  width: 100%;
  max-width: 360px;
  margin-top: auto;
  padding: 24px 22px;
  background-color: var(--surface-sheet);
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(8, 12, 11, 0.45);
  text-align: left;
}

.fallback-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: var(--text-heading);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: 0;
  color: var(--ink-primary);
}

.fallback-title:focus {
  outline: none;
}

.fallback-body {
  margin: 8px 0 0;
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: 400;
  line-height: 1.55;
  color: var(--ink-secondary);
}

.fallback-retry {
  margin-top: 18px;
  width: 100%;
  min-height: 52px;
  padding: 12px 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background-color: var(--surface-active);
  color: var(--ink-on-light);
  font-family: var(--font-sans);
  font-size: var(--text-control);
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 140ms ease-out, transform 140ms ease-out;
}

@media (hover: hover) {
  .fallback-retry:hover {
    background-color: #EDE7DA;
  }
}

.fallback-retry:active {
  background-color: var(--surface-active-press);
  transform: scale(0.985);
}

/* ==========================================================================
   Responsive Reflow for 200% Zoom & Narrow Containers
   ========================================================================== */

@container (max-width: 20rem) {
  .tint-grid,
  .segmented-bar--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@container (max-width: 14rem) {
  .segmented-bar--2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 340px) {
  .sheet-header {
    padding: 0 0.25rem;
  }

  .sheet-tab {
    min-width: 0;
    padding: 0 0.625rem;
  }

  .sheet-tab[aria-selected="true"]::after {
    left: 0.5rem;
    right: 0.5rem;
  }

  .sheet-done {
    min-width: 3rem;
    padding: 0 0.625rem;
  }
}

/* 200% zoom on 390px phone (~195px CSS viewport): prevent bottom trigger collision */
@media (max-width: 260px) {
  :root {
    --safe-left: max(6px, env(safe-area-inset-left));
    --safe-right: max(6px, env(safe-area-inset-right));
    --safe-top: max(8px, env(safe-area-inset-top));
    --safe-bottom: max(8px, env(safe-area-inset-bottom));
    --trigger-size: 3.5rem; /* 56px: 3 triggers fit 195px viewport with clear gaps */
  }

  .pond-trigger,
  .help-close {
    padding: 0.0625rem 0.125rem 0.25rem;
  }

  .pond-trigger-icon {
    width: 1.125rem;
    height: 1.125rem;
  }
}

/* ==========================================================================
   Phone Landscape: Right-Docked Drawer & Side-by-Side Help (spec §3.1, §3.3, §3.4)
   ========================================================================== */

@media (max-height: 500px) and (orientation: landscape) {
  .launch-splash {
    padding-top: max(0.75rem, var(--safe-top));
    padding-bottom: max(0.625rem, var(--safe-bottom));
  }

  .splash-center {
    padding-bottom: 0.25rem;
    gap: 0.4375rem;
  }

  .splash-emblem {
    width: 2.75rem; /* 44px landscape */
    height: 2.75rem;
  }

  .splash-title {
    font-size: 2rem; /* 32px landscape */
  }

  .splash-footer {
    padding-top: 0.375rem;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem 1rem;
  }

  .settings-sheet {
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: min(520px, 58vw);
    height: 100vh;
    height: 100dvh;
    border-top: 0;
    border-left: 1px solid var(--border-hairline);
    border-radius: 16px 0 0 16px;
    box-shadow: -4px 0 20px rgba(8, 12, 11, 0.45);
    transform: translateX(100%);
  }

  .settings-sheet.is-open {
    transform: translateX(0);
  }

  .settings-sheet::after {
    height: min(1.75rem, 18%);
  }

  .sheet-header {
    padding-top: env(safe-area-inset-top);
    padding-right: max(0.5rem, env(safe-area-inset-right));
    border-radius: 16px 0 0 0;
  }

  .sheet-body {
    padding:
      1rem
      max(1.25rem, var(--safe-right))
      calc(1.25rem + var(--safe-bottom))
      1.25rem;
  }

  .a2hs-hint {
    bottom: calc(var(--safe-bottom) + var(--trigger-size) + 8px);
    max-width: 32.5rem;
  }

  .fallback {
    padding-bottom: calc(var(--safe-bottom) + 16px);
  }

  .fallback-scrim {
    background: rgba(16, 22, 21, 0.35);
  }

  .fallback-panel {
    margin: auto 0;
    max-width: 400px;
    padding: 20px 22px;
  }

  .audio-resume-hint {
    top: calc(var(--safe-top) + 8px);
  }

  .sleep-veil {
    padding-bottom: calc(var(--safe-bottom) + 1.25rem);
  }
}

/* Side-by-side Help layout on standard landscape phones (collapses cleanly to single column at 200% zoom) */
@media (max-height: 500px) and (orientation: landscape) and (min-width: 560px) {
  .help-scroll {
    padding:
      max(0.75rem, var(--safe-top))
      calc(var(--safe-right) + 1rem)
      max(0.75rem, var(--safe-bottom))
      calc(var(--safe-left) + var(--trigger-size) + 1rem);
  }

  .help-panels {
    max-width: 46rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 1px minmax(0, 1fr);
    align-items: center;
    gap: 1.25rem;
  }

  .help-divider {
    width: 1px;
    height: 76%;
    min-height: 8rem;
    align-self: center;
    border-top: 0;
    border-left: 1px solid var(--border-hairline);
    margin: 0;
  }

  .help-illustration {
    max-height: min(14rem, 62dvh);
  }
}

/* 200% zoom on 844x390 landscape (~422x195 CSS viewport): keep header tabs single-row with exposed pond */
@media (max-height: 500px) and (orientation: landscape) and (max-width: 480px) {
  .settings-sheet {
    width: min(520px, 72vw);
  }
}

/* ==========================================================================
   iPad Portrait & Landscape: Centered Bottom Tray, Help & Top-Right Hint (spec §3.1, §3.3, §3.4, §3.5)
   ========================================================================== */

@media (min-width: 744px) and (min-height: 600px) {
  .splash-center {
    gap: 0.875rem;
  }

  .splash-emblem {
    width: 4.5rem; /* 72px iPad */
    height: 4.5rem;
  }

  .help-panels {
    max-width: 35rem;
    gap: 1.75rem;
  }

  .help-illustration {
    max-width: 32rem;
    max-height: 21.25rem;
  }

  .a2hs-hint {
    top: calc(var(--safe-top) + 12px);
    bottom: auto;
    left: auto;
    right: var(--safe-right);
    max-width: 24.5rem;
    margin-inline: 0;
  }

  .settings-sheet {
    left: 0;
    right: 0;
    margin-inline: auto;
    width: min(600px, 90vw);
    height: min(676px, 58vh);
    height: min(676px, 58dvh);
    border: 1px solid var(--border-hairline);
    border-bottom: 0;
    border-radius: 16px 16px 0 0;
  }

  .sheet-header {
    padding: 0 0.75rem;
  }

  .sheet-tab {
    padding: 0 1.25rem; /* 20px */
  }

  .sheet-body {
    padding: 1rem 1.75rem calc(1.5rem + var(--safe-bottom));
  }

  .control-group {
    margin-top: 0.75rem;
  }

  .control-label {
    margin-bottom: 0.3125rem;
  }

  .tint-grid {
    gap: 0.75rem; /* 12px */
  }

  .tint-swatch {
    width: 2rem; /* 32px pigment disc on iPad */
    height: 2rem;
  }

  .switch-list {
    margin-top: 0.75rem;
  }

  .switch-row {
    min-height: 3.25rem;
    padding: 0.5rem 0;
  }

  .fallback-panel {
    max-width: 440px;
    padding: 28px 26px;
  }

  .audio-resume-hint {
    top: calc(var(--safe-top) + 16px);
  }

  .sleep-title {
    font-size: 1.25rem;
  }
}

/* ==========================================================================
   Reduced Motion (spec §5.1, §5.3)
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .pond-triggers {
    transition: opacity 120ms linear, visibility 0ms linear 0ms;
  }

  .pond-triggers.is-suppressed {
    transition: opacity 120ms linear, visibility 0ms linear 120ms;
  }

  .pond-trigger {
    transition: opacity 150ms linear, background-color 120ms linear, border-color 120ms linear;
  }

  .pond-trigger.is-idle {
    opacity: 0.42;
    transition: opacity 150ms linear, background-color 120ms linear, border-color 120ms linear;
  }

  .pond-trigger:active,
  .help-close:active,
  .tint-option:active .tint-swatch {
    transform: none;
  }

  .pond-trigger-indicator {
    transition: opacity 120ms linear;
  }

  .launch-splash {
    transition: opacity 400ms linear;
  }

  .launch-splash.is-repeat {
    transition-duration: 300ms;
  }

  .launch-splash.is-fast-fade {
    transition-duration: 150ms;
  }

  .help-card,
  .help-screen.is-open .help-card {
    transform: none;
    transition: opacity 220ms ease-out;
  }

  .a2hs-hint,
  .a2hs-hint.is-hiding {
    transition: opacity 120ms linear;
  }

  .tint-swatch {
    transition: none;
  }

  .settings-sheet,
  .settings-sheet.is-open {
    transform: none;
    opacity: 0;
    transition: opacity 200ms ease-out;
  }

  .settings-sheet.is-open {
    opacity: 1;
  }

  .settings-sheet::after {
    transition: opacity 120ms linear;
  }

  .no-native-switch input[type="checkbox"][switch],
  .no-native-switch input[type="checkbox"][switch]::before,
  .action-btn,
  .stone-select,
  .fallback-retry {
    transition: none;
  }

  .action-btn:active,
  .fallback-retry:active {
    transform: none;
  }

  .audio-resume-hint,
  .audio-resume-hint.is-hiding {
    transition: opacity 120ms linear;
  }

  .sleep-caption,
  .sleep-veil.is-waking .sleep-caption {
    transition: opacity 160ms linear;
  }

  .timer-tick {
    transition: none;
  }
}
