:root {
  --bg0: #070605;
  --bg1: #0f0d0a;
  --ink: #f7f3ec;
  --muted: rgba(247, 243, 236, 0.55);
  --faint: rgba(247, 243, 236, 0.12);
  --gold: #c9a962;
  --gold2: #e8d9b4;
  --line: rgba(255, 255, 255, 0.08);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  --menu-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  --topbar-bg: rgba(7, 6, 5, 0.65);
  --surface: rgba(255, 255, 255, 0.03);
  --surface-strong: rgba(255, 255, 255, 0.06);
  --control-bg: rgba(0, 0, 0, 0.35);
  --menu-bg: rgba(12, 11, 9, 0.96);
  --menu-bg-strong: rgba(12, 11, 9, 0.98);
  --quote-ink: rgba(250, 247, 239, 0.78);
  --quote-muted: rgba(250, 247, 239, 0.5);
  --ring-track: rgba(255, 255, 255, 0.06);
  --danger-ink: #f0d0d0;
  --danger-bg: rgba(80, 20, 20, 0.35);
  --danger-line: rgba(255, 120, 120, 0.25);
  --radius: 18px;
  --font-serif: "Cormorant Garamond", Georgia, serif;
  --font-sans: "DM Sans", system-ui, sans-serif;
}

body[data-theme="light"] {
  --bg0: #f2f0ea;
  --bg1: #fcfbf7;
  --ink: #211d18;
  --muted: rgba(33, 29, 24, 0.58);
  --faint: rgba(33, 29, 24, 0.1);
  --gold: #a98237;
  --gold2: #5f4721;
  --line: rgba(43, 35, 24, 0.13);
  --shadow: 0 24px 72px rgba(71, 58, 39, 0.15);
  --menu-shadow: 0 24px 68px rgba(71, 58, 39, 0.18);
  --topbar-bg: rgba(248, 247, 242, 0.78);
  --surface: rgba(255, 255, 255, 0.58);
  --surface-strong: rgba(255, 255, 255, 0.84);
  --control-bg: rgba(255, 255, 255, 0.72);
  --menu-bg: rgba(252, 251, 247, 0.96);
  --menu-bg-strong: rgba(252, 251, 247, 0.98);
  --quote-ink: rgba(33, 29, 24, 0.76);
  --quote-muted: rgba(33, 29, 24, 0.48);
  --ring-track: rgba(43, 35, 24, 0.08);
  --danger-ink: #7b2d2d;
  --danger-bg: rgba(130, 42, 42, 0.08);
  --danger-line: rgba(130, 42, 42, 0.22);
}

@media (prefers-color-scheme: light) {
  body[data-theme="system"] {
    --bg0: #f2f0ea;
    --bg1: #fcfbf7;
    --ink: #211d18;
    --muted: rgba(33, 29, 24, 0.58);
    --faint: rgba(33, 29, 24, 0.1);
    --gold: #a98237;
    --gold2: #5f4721;
    --line: rgba(43, 35, 24, 0.13);
    --shadow: 0 24px 72px rgba(71, 58, 39, 0.15);
    --menu-shadow: 0 24px 68px rgba(71, 58, 39, 0.18);
    --topbar-bg: rgba(248, 247, 242, 0.78);
    --surface: rgba(255, 255, 255, 0.58);
    --surface-strong: rgba(255, 255, 255, 0.84);
    --control-bg: rgba(255, 255, 255, 0.72);
    --menu-bg: rgba(252, 251, 247, 0.96);
    --menu-bg-strong: rgba(252, 251, 247, 0.98);
    --quote-ink: rgba(33, 29, 24, 0.76);
    --quote-muted: rgba(33, 29, 24, 0.48);
    --ring-track: rgba(43, 35, 24, 0.08);
    --danger-ink: #7b2d2d;
    --danger-bg: rgba(130, 42, 42, 0.08);
    --danger-line: rgba(130, 42, 42, 0.22);
  }
}

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

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-sans);
  font-weight: 400;
  letter-spacing: 0.01em;
  background: radial-gradient(1200px 800px at 10% -10%, #1a1510 0%, transparent 55%),
    radial-gradient(900px 700px at 90% 10%, #14110d 0%, transparent 50%), var(--bg0);
  display: flex;
  flex-direction: column;
}

body[data-theme="light"],
body[data-theme="system"] {
  color-scheme: light dark;
}

body[data-theme="light"] {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(230, 225, 215, 0.72)),
    var(--bg0);
}

@media (prefers-color-scheme: light) {
  body[data-theme="system"] {
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(230, 225, 215, 0.72)),
      var(--bg0);
  }
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
  z-index: 0;
}

body[data-theme="light"] .ambient {
  opacity: 0.35;
  mix-blend-mode: multiply;
}

@media (prefers-color-scheme: light) {
  body[data-theme="system"] .ambient {
    opacity: 0.35;
    mix-blend-mode: multiply;
  }
}

.topbar {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  background: var(--topbar-bg);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  display: inline-flex;
  width: 1.35rem;
  height: 1.35rem;
  color: var(--gold);
}

.chakra-mark {
  width: 100%;
  height: 100%;
}

.chakra-outer,
.chakra-inner,
.chakra-spokes {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.chakra-spokes {
  stroke-linecap: round;
}

.brand-text {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.brand-dot {
  opacity: 0.35;
  margin: 0 0.15em;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nav-level {
  display: inline-flex;
  align-items: center;
  position: relative;
  transform-origin: right center;
  view-transition-name: level-picker;
  animation: level-emerge 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.nav-link,
.nav-level-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1;
  color: var(--muted);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  min-width: 5.9rem;
  min-height: 2.2rem;
  padding: 0 0.95rem;
  cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.nav-link:hover,
.nav-level-button:hover,
.nav-link:focus,
.nav-level-button:focus {
  color: var(--ink);
  border-color: rgba(232, 217, 180, 0.18);
  background: rgba(255, 255, 255, 0.055);
  outline: none;
}

.nav-link.is-active,
.nav-level-button[aria-expanded="true"] {
  color: #1a1208;
  border-color: rgba(255, 255, 255, 0.2);
  background: linear-gradient(135deg, var(--gold2), var(--gold));
  box-shadow: 0 10px 32px rgba(201, 169, 98, 0.16);
}

.nav-level-menu {
  position: absolute;
  top: calc(100% + 2.5rem);
  right: -3.8rem;
  z-index: 40;
  width: min(330px, calc(100vw - 2rem));
  padding: 0.5rem;
  border: 1px solid rgba(232, 217, 180, 0.16);
  border-radius: calc(var(--radius) + 4px);
  background: var(--menu-bg);
  box-shadow: var(--menu-shadow);
  backdrop-filter: blur(18px);
  max-height: calc(100vh - 10rem);
  overflow: auto;
  transform-origin: top right;
  transform: translateY(0) scale(1);
  opacity: 1;
  visibility: visible;
  transition:
    opacity 0.22s ease,
    transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1),
    visibility 0.22s ease;
}

.page-home .nav-level-menu {
  right: -16.6rem;
}

.nav-level-menu.hidden {
  display: block !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-0.45rem) scale(0.985);
}

.level-option {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(6.5rem, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 0.65rem 0.75rem;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.level-option:hover,
.level-option:focus {
  border-color: rgba(201, 169, 98, 0.24);
  background: rgba(255, 255, 255, 0.045);
  outline: none;
}

.level-option.is-active {
  color: #1a1208;
  background: linear-gradient(135deg, var(--gold2), var(--gold));
}

.level-name {
  display: block;
  font-family: var(--font-serif);
  font-size: 1.08rem;
  font-weight: 500;
  line-height: 1.05;
}

.level-sub {
  display: block;
  margin-top: 0.18rem;
  color: var(--muted);
  font-size: 0.68rem;
}

.level-option.is-active .level-sub,
.level-option.is-active .level-meta {
  color: rgba(26, 18, 8, 0.66);
}

.level-meta {
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  line-height: 1.2;
  text-align: right;
  white-space: nowrap;
}

.page-home .topnav .nav-link.is-active {
  margin-right: 0;
}

.main {
  position: relative;
  z-index: 1;
  flex: 1;
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.foot {
  position: relative;
  z-index: 2;
  padding: 1rem 1.5rem 1.5rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.foot-version {
  margin-left: 0.75rem;
  opacity: 0.6;
}

/* Notices that float over the page: "a new version is ready"
   (static/js/update-check.js) and "time's up" (static/js/timer-core.js).
   One calm card: a short title, a quiet line, small buttons. */
.update-bar,
.timer-alarm {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: min(30rem, calc(100vw - 2rem));
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.95rem 1rem 0.95rem 1.25rem;
  border: 1px solid color-mix(in srgb, var(--gold) 35%, var(--line));
  border-radius: calc(var(--radius) + 2px);
  background: var(--menu-bg-strong);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--menu-shadow);
  color: var(--ink);
  animation: notice-in 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.update-bar {
  bottom: 1.25rem;
  z-index: 60;
}

.update-bar-copy {
  flex: 1 1 auto;
  min-width: 0;
}

.update-bar-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.25;
}

.update-bar-sub {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.update-bar-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.35rem;
}

.update-bar .btn,
.timer-alarm .btn {
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
  white-space: nowrap;
  text-decoration: none;
  box-shadow: none;
}

/* While "Update now" runs: the buttons step aside and a thin line shows
   how far along it is (static/js/update-check.js). It slides when the
   amount isn't known (starting, installing, restarting). */
.is-updating [hidden] {
  display: none !important;
}

.update-progress {
  position: relative;
  height: 3px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--gold) 16%, transparent);
  overflow: hidden;
}

.update-bar .update-progress {
  position: absolute;
  left: 1.25rem;
  right: 1.25rem;
  bottom: 0.6rem;
}

.update-bar.is-updating {
  padding-bottom: 1.35rem;
}

.update-required-card .update-progress {
  margin: 0.25rem 0 0.5rem;
}

.update-progress-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--gold);
  transition: width 0.35s ease;
}

.update-progress.is-indeterminate .update-progress-fill {
  width: 38%;
  transition: none;
  animation: update-slide 1.25s ease-in-out infinite;
}

@keyframes update-slide {
  from {
    transform: translateX(-105%);
  }
  to {
    transform: translateX(270%);
  }
}

/* The quiet line ticks with the percentage: keep digits even-width. */
.update-bar.is-updating .update-bar-sub {
  font-variant-numeric: tabular-nums;
}

@keyframes notice-in {
  from {
    opacity: 0;
    transform: translate(-50%, 0.5rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .update-bar,
  .timer-alarm {
    animation: none;
  }

  .update-progress.is-indeterminate .update-progress-fill {
    animation-duration: 3s;
  }
}

/* Narrow windows and phones: one slim row, so it never covers the clock's
   buttons; "Later" becomes a small cross. */
@media (max-width: 520px) {
  .update-bar,
  .timer-alarm {
    gap: 0.6rem;
    padding: 0.7rem 0.55rem 0.7rem 1rem;
  }

  .update-bar-title {
    font-size: 1.02rem;
  }

  .update-bar-sub {
    margin-top: 0.1rem;
    font-size: 0.74rem;
  }

  .update-bar-actions {
    gap: 0.15rem;
  }

  .update-bar .update-bar-later {
    order: 2;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    font-size: 0;
    border-radius: 50%;
  }

  .update-bar .update-bar-later::before {
    content: "\00d7";
    font-size: 1.35rem;
    line-height: 1;
  }
}


.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 3.5rem;
}

.timer-layout {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: min(1180px, 100%);
}

@media (max-width: 1180px) {
  .nav-level-menu {
    position: fixed;
    top: 6.35rem;
    right: 1rem;
  }

  .page-home .nav-level-menu {
    right: 1rem;
  }
}

.session-live {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  width: min(650px, 100%);
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(8px);
}

.live-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  min-width: 5.5rem;
}

.live-val {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--gold2);
  font-variant-numeric: tabular-nums;
}

.live-key {
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}

.shortcuts-hint {
  margin: 1rem 0 0;
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  font-weight: 300;
}

.shortcuts-hint kbd {
  font-family: var(--font-sans);
  font-size: 0.68rem;
  padding: 0.12rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--gold2);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
}

body[data-theme="light"] .modal-backdrop {
  background: rgba(33, 29, 24, 0.36);
}

@media (prefers-color-scheme: light) {
  body[data-theme="system"] .modal-backdrop {
    background: rgba(33, 29, 24, 0.36);
  }
}

.modal-sheet {
  position: relative;
  width: min(400px, 100%);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg1);
  padding: 1.5rem 1.35rem 1.25rem;
  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  top: 0.65rem;
  right: 0.85rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 500;
  margin: 0 0 1rem;
}

.modal-kicker {
  margin: 0 0 0.45rem;
  font-size: 0.68rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold);
}

.modal-copy {
  margin: -0.35rem 0 1.35rem;
  color: var(--muted);
  line-height: 1.55;
}

.confirm-sheet {
  width: min(430px, 100%);
  background:
    linear-gradient(135deg, rgba(216, 189, 121, 0.08), transparent 46%),
    var(--bg1);
}

/* "What's new" (static/js/whats-new.js): the title and the button stay put
   and only the notes scroll, so a long list never runs off the window. */
.whats-new-sheet {
  display: flex;
  flex-direction: column;
  width: min(460px, 100%);
  max-height: min(560px, calc(100vh - 3rem));
  /* dvh: the height actually visible, without a phone browser's bars */
  max-height: min(560px, calc(100dvh - 3rem));
  padding-bottom: 1rem;
}

.whats-new-sheet .modal-title {
  margin-bottom: 0.75rem;
}

.whats-new-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0 -1.35rem;
  padding: 0.25rem 1.35rem 0.5rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid transparent;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

/* More below: a soft fade and a line above the button say "keep scrolling". */
.whats-new-body.more {
  border-bottom-color: var(--line);
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 3rem), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 3rem), transparent);
}

.whats-new-sheet .modal-actions {
  flex: 0 0 auto;
  padding-top: 1rem;
}

.whats-new-list {
  margin: 0.75rem 0 0.5rem;
  padding-left: 1.1rem;
  line-height: 1.55;
}

.whats-new-list li + li {
  margin-top: 0.45rem;
}

.whats-new-switch {
  margin: 0.75rem 0 0.5rem;
}

.modal-actions a.btn {
  text-decoration: none;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.shortcut-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.shortcut-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--line);
  font-size: 0.88rem;
}

.shortcut-row:first-child {
  border-top: 0;
}

.shortcut-keys {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--gold2);
  white-space: nowrap;
}

.shortcut-action {
  color: var(--muted);
  text-align: right;
  font-weight: 300;
}

body.modal-open {
  overflow: hidden;
}

.choice-actions /* Keyboard focus: the app's own soft gold ring, not the browser's default. */
.btn:focus-visible,
.modal-close:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--gold) 70%, transparent);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.range {
  width: 100%;
  accent-color: var(--gold);
}

.range-val {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--gold2);
}

.live-divider {
  width: 1px;
  height: 1.75rem;
  background: var(--line);
  flex-shrink: 0;
}

.choice-panel {
  margin: 0 auto 1.25rem;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: center;
  width: 100%;
}

.choice-panel.hidden {
  display: none;
}

.choice-prompt {
  margin: 0 0 0.7rem;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.35;
}

.choice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
}

.choice-actions-equal {
  display: grid;
  grid-template-columns: repeat(var(--choice-action-count, 3), minmax(0, 1fr));
  width: min(100%, var(--choice-actions-width, 28rem));
  margin: 0 auto;
}

.choice-actions-equal .btn {
  width: 100%;
  min-width: 0;
  min-height: 2.55rem;
  padding: 0.65rem 0.85rem;
  white-space: nowrap;
}

.choice-actions .btn {
  min-width: 0;
}

@media (max-width: 520px) {
  .choice-actions-equal {
    grid-template-columns: 1fr;
    width: min(100%, 14rem);
  }
}

body.page-home.mode-complete .timer-panel {
  border-color: rgba(232, 217, 180, 0.28);
  box-shadow: 0 24px 90px rgba(201, 169, 98, 0.18), var(--shadow);
}

body.page-home.mode-complete .choice-prompt {
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 1.25rem;
  letter-spacing: 0.04em;
}

.hidden {
  display: none !important;
}

.time-display.time-extend {
  color: var(--gold2);
}

.timer-ring-wrap.ring-extend .ring-progress {
  animation: ring-breathe 3s ease-in-out infinite;
}

@keyframes ring-breathe {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

body.mode-choice .timer-panel {
  border-color: rgba(201, 169, 98, 0.18);
}

body.mode-cumulative .phase-label {
  color: var(--gold2);
}

.eyebrow {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  color: var(--gold);
  margin: 0 0 1rem;
}

.title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(2.25rem, 4vw, 3.25rem);
  line-height: 1.08;
  margin: 0 0 1rem;
  letter-spacing: 0.02em;
}

.lede {
  margin: 0;
  max-width: 34ch;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.65;
  font-weight: 300;
}

.timer-panel {
  width: min(520px, 100%);
  background: linear-gradient(160deg, var(--surface-strong), var(--surface));
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 6px);
  padding: 2rem 1.75rem 1.75rem;
  box-shadow: var(--shadow);
}

.timer-ring-wrap {
  position: relative;
  width: min(320px, 88vw);
  margin: 0 auto 1.75rem;
  aspect-ratio: 1;
}

.timer-ring {
  width: 100%;
  height: auto;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: var(--ring-track);
  stroke-width: 10;
}

.ring-progress {
  fill: none;
  stroke: url(#ringGrad);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 603.186;
  stroke-dashoffset: 603.186;
  transition: stroke-dashoffset 0.35s ease;
}

.page-flow .flow-ring-progress {
  stroke: url(#flowRingGrad);
  stroke-dashoffset: 0;
  opacity: 0.55;
}

.page-flow .flow-ring-wrap.is-flowing .flow-ring-progress {
  animation: ring-breathe 3s ease-in-out infinite;
}

.page-flow .timer-panel {
  border-color: rgba(201, 169, 98, 0.14);
}

.timer-core {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}

.phase-label {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

.time-display {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(2.75rem, 7vw, 3.6rem);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.cycle-hint {
  margin: 0.5rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 300;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
}

.controls .btn {
  will-change: opacity, transform;
}

@keyframes control-enter {
  from {
    opacity: 0;
    transform: translateY(0.35rem) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes level-emerge {
  from {
    opacity: 0;
    transform: translateX(2.4rem) scaleX(0.72);
    clip-path: inset(0 0 0 100% round 999px);
  }
  to {
    opacity: 1;
    transform: translateX(0) scaleX(1);
    clip-path: inset(0 0 0 0 round 999px);
  }
}

@keyframes level-exit {
  from {
    opacity: 1;
    transform: translateX(0) scaleX(1);
    clip-path: inset(0 0 0 0 round 999px);
  }
  to {
    opacity: 0;
    transform: translateX(2.4rem) scaleX(0.72);
    clip-path: inset(0 0 0 100% round 999px);
  }
}

@view-transition {
  navigation: auto;
}

::view-transition-old(level-picker) {
  animation: level-exit 0.24s cubic-bezier(0.4, 0, 1, 1) both;
}

::view-transition-new(level-picker) {
  animation: level-emerge 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@media (prefers-reduced-motion: reduce) {
  .nav-level {
    animation: none;
  }

  ::view-transition-old(level-picker),
  ::view-transition-new(level-picker) {
    animation: none;
  }
}

.controls.hidden {
  display: none;
}

.session-notice {
  margin: 0.95rem auto 0;
  max-width: 28rem;
  color: var(--gold2);
  font-size: 0.82rem;
  line-height: 1.45;
  text-align: center;
}

.focus-quote {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  width: min(720px, 100%);
  margin: clamp(1.9rem, 3.8vh, 3.2rem) auto 0;
  padding: 0 1rem;
  text-align: center;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.focus-quote.is-loading {
  opacity: 0;
  transform: translateY(-0.25rem);
}

.focus-quote.is-updating {
  opacity: 0.72;
}

.focus-quote blockquote {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(1.02rem, 1.6vw, 1.16rem);
  font-style: italic;
  font-weight: 400;
  line-height: 1.5;
  color: var(--quote-ink);
}

.focus-quote blockquote::before {
  content: "“";
}

.focus-quote blockquote::after {
  content: "”";
}

.focus-quote figcaption {
  margin: 0;
  font-size: 0.64rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--quote-muted);
}

.focus-quote figcaption::before {
  content: "";
  display: inline-block;
  width: 1.15rem;
  height: 1px;
  margin-right: 0.5rem;
  vertical-align: middle;
  background: var(--gold);
  opacity: 0.8;
}

.btn {
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.65rem 1.25rem;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s;
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary {
  color: #1a1208;
  background: linear-gradient(135deg, #f3e8cf, #c9a962);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 12px 40px rgba(201, 169, 98, 0.25);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 16px 48px rgba(201, 169, 98, 0.35);
}

.btn-quiet {
  color: var(--ink);
  background: var(--surface-strong);
  border-color: var(--line);
}

.btn-quiet:hover:not(:disabled) {
  background: var(--faint);
}

.btn-ghost {
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  color: var(--ink);
}

.presets-section {
  margin-top: 1rem;
}

.section-head {
  margin-bottom: 1.25rem;
}

.section-title {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 500;
  margin: 0 0 0.35rem;
}

.section-sub {
  margin: 0;
  color: var(--muted);
  font-weight: 300;
}

.preset-scroll {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.preset-card {
  flex: 0 0 auto;
  width: 200px;
  scroll-snap-align: start;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 1rem 1.1rem 1.1rem;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.preset-card:hover {
  border-color: rgba(201, 169, 98, 0.45);
  background: rgba(255, 255, 255, 0.05);
  transform: translateY(-2px);
}

.preset-card.is-active {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(201, 169, 98, 0.35);
}

.preset-kind {
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.35rem;
}

.preset-name {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  margin: 0 0 0.15rem;
}

.preset-sub {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.preset-meta {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.45;
}

.preset-vedic {
  display: block;
  margin-top: 0.45rem;
  font-size: 0.68rem;
  font-style: italic;
  opacity: 0.75;
  letter-spacing: 0.04em;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 500;
  margin: 0 0 1rem;
}

.card-lede {
  margin: -0.35rem 0 1rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
  font-weight: 300;
}

/* ---------- Settings page ---------- */

.page-settings .main {
  max-width: 1040px;
}

@media (prefers-reduced-motion: no-preference) {
  html:has(body.page-settings) {
    scroll-behavior: smooth;
  }
}

.settings-hero {
  margin-bottom: 2.5rem;
}

.title-settings {
  margin-bottom: 0.5rem;
}

.lede-narrow {
  max-width: 42ch;
}

.settings-layout {
  display: grid;
  grid-template-columns: 10.5rem minmax(0, 1fr);
  gap: 2.75rem;
  align-items: start;
}

.settings-nav {
  position: sticky;
  top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.settings-nav-link {
  display: block;
  padding: 0.5rem 0.8rem;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  text-decoration: none;
  transition: color 0.2s, background 0.2s, box-shadow 0.2s;
}

.settings-nav-link:hover,
.settings-nav-link:focus-visible {
  color: var(--ink);
  background: var(--surface);
  outline: none;
}

.settings-nav-link.is-active {
  color: var(--ink);
  background: var(--surface-strong);
  box-shadow: inset 2px 0 0 var(--gold);
}

.pref-section {
  margin-bottom: 2.75rem;
  scroll-margin-top: 1.5rem;
}

.pref-section:last-child {
  margin-bottom: 0;
}

.pref-head .card-title {
  margin: 0 0 0.25rem;
  font-size: 1.55rem;
}

.pref-head .card-lede {
  margin: 0;
}

.pref-head {
  margin-bottom: 0.9rem;
}

.pref-subhead {
  margin: 1.5rem 0 0.6rem;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.pref-group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0 1.25rem;
  transition: opacity 0.2s ease;
}

.pref-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1rem 0;
  border-top: 1px solid var(--line);
  transition: opacity 0.2s ease;
}

.pref-group > .pref-row:first-child,
.pref-group > :first-child {
  border-top: 0;
}

.pref-row-stack {
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
}

.pref-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
  flex: 1;
}

.pref-name {
  font-size: 0.98rem;
  color: var(--ink);
}

.pref-desc {
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--muted);
  font-weight: 300;
}

.is-disabled {
  opacity: 0.42;
}

/* Switches */

.toggle {
  cursor: pointer;
}

.toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.toggle-ui {
  flex: 0 0 42px;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--faint);
  border: 1px solid var(--line);
  position: relative;
  transition: background 0.2s, border-color 0.2s;
}

.toggle-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease;
}

.toggle input:checked + .toggle-ui {
  background: var(--gold);
  border-color: var(--gold);
}

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

.toggle input:focus-visible + .toggle-ui {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.toggle:has(input:disabled) {
  cursor: default;
}

/* Default level picker */

.select-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--control-bg);
  color: var(--ink);
  font: inherit;
  padding: 0.75rem 1rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.select-button:hover,
.select-button:focus-visible,
.select-button[aria-expanded="true"] {
  border-color: rgba(201, 169, 98, 0.5);
  outline: none;
}

.select-button:focus-visible {
  box-shadow: 0 0 0 3px rgba(201, 169, 98, 0.15);
}

.select-button-main {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.select-button-name {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.1;
}

.select-button-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

.select-caret {
  flex: 0 0 auto;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: 0.25rem;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-25%) rotate(45deg);
  transition: transform 0.2s ease;
}

.select-button[aria-expanded="true"] .select-caret {
  transform: translateY(25%) rotate(-135deg);
}

.settings-level-picker {
  position: relative;
}

.settings-level-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% - 0.4rem);
  z-index: 25;
  padding: 0.5rem;
  border: 1px solid rgba(232, 217, 180, 0.16);
  border-radius: calc(var(--radius) + 4px);
  background: var(--menu-bg-strong);
  box-shadow: var(--menu-shadow);
  backdrop-filter: blur(18px);
  max-height: 27rem;
  overflow: auto;
  transform-origin: top center;
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
  /* Visible at once on open so options can take focus; hidden only after the fade on close. */
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s;
}

.settings-level-menu.hidden {
  display: block !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-0.35rem);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
}

.settings-level-menu .level-option {
  grid-template-columns: minmax(7rem, 0.8fr) minmax(0, 2fr);
  gap: 0.85rem;
  padding: 0.7rem 0.85rem;
}

.settings-level-menu .level-meta {
  white-space: normal;
}

.settings-level-meta {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.35rem;
  text-align: center;
}

.settings-level-meta span {
  min-width: 0;
  padding: 0.4rem 0.3rem;
  border-radius: 9px;
  background: var(--surface-strong);
}

.settings-level-meta strong,
.settings-level-meta small {
  display: block;
}

.settings-level-meta strong {
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 500;
}

.settings-level-meta small {
  margin-top: 0.1rem;
  color: var(--muted);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.level-option.is-active .settings-level-meta span {
  background: rgba(26, 18, 8, 0.08);
}

.level-option.is-active .settings-level-meta strong {
  color: #1a1208;
}

.level-option.is-active .settings-level-meta small {
  color: rgba(26, 18, 8, 0.58);
}

/* Daily goal stepper */

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--control-bg);
  flex-shrink: 0;
}

.stepper-btn {
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s;
}

.stepper-btn:hover:not(:disabled),
.stepper-btn:focus-visible {
  background: var(--surface-strong);
  outline: none;
}

.stepper-btn:focus-visible {
  box-shadow: 0 0 0 2px var(--gold);
}

.stepper-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.stepper-value {
  min-width: 6.5rem;
  text-align: center;
  line-height: 1.1;
}

.stepper-value strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 500;
}

.stepper-value small {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* Volume */

.volume-control {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  width: min(19rem, 100%);
}

.page-settings .range {
  --fill: 70%;
  flex: 1;
  height: 6px;
  margin: 0;
  border-radius: 999px;
  appearance: none;
  -webkit-appearance: none;
  background: linear-gradient(to right, var(--gold) var(--fill), var(--faint) var(--fill));
  cursor: pointer;
}

.page-settings .range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--gold);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.page-settings .range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--gold);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.page-settings .range:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 6px;
}

.page-settings .range:disabled {
  cursor: default;
}

.page-settings .range-val {
  min-width: 2.75rem;
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 0.88rem;
  color: var(--gold2);
}

/* Segmented controls */

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--control-bg);
}

.pref-row .segmented {
  flex-shrink: 0;
  min-width: 17rem;
}

.segment {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.1rem;
  padding: 0 0.85rem;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.segment:hover:not(:disabled),
.segment:focus-visible {
  color: var(--ink);
  background: var(--surface-strong);
  outline: none;
}

.segment:focus-visible {
  box-shadow: 0 0 0 2px var(--gold);
}

.segment.is-active {
  color: #1a1208;
  background: linear-gradient(135deg, var(--gold2), var(--gold));
}

.segment:disabled {
  cursor: default;
}

.theme-swatch {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  border: 1px solid rgba(128, 118, 100, 0.55);
  flex-shrink: 0;
}

.theme-swatch-dark {
  background: #0f0d0a;
}

.theme-swatch-light {
  background: #f7f5ef;
}

.theme-swatch-system {
  background: linear-gradient(135deg, #f7f5ef 50%, #0f0d0a 50%);
}

/* Sound cues */

.cue-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(13rem, 16rem);
  gap: 1.25rem;
}

.cue-toggle {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
}

.cue-row.is-off .pref-name {
  color: var(--muted);
}

.cue-picker {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-settings .select {
  flex: 1;
  min-width: 0;
  appearance: none;
  -webkit-appearance: none;
  border-radius: 10px;
  border: 1px solid var(--line);
  background-color: var(--control-bg);
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 1.05rem) 55%, calc(100% - 0.75rem) 55%;
  background-size: 0.3rem 0.3rem;
  background-repeat: no-repeat;
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  cursor: pointer;
}

.page-settings .select:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-preview {
  display: inline-grid;
  place-items: center;
  flex: 0 0 2.25rem;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--gold2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}

.btn-preview svg {
  width: 0.85rem;
  height: 0.85rem;
  margin-left: 0.1rem;
  fill: currentColor;
}

.btn-preview:hover:not(:disabled),
.btn-preview:focus-visible {
  color: #1a1208;
  background: var(--gold);
  border-color: var(--gold);
  outline: none;
}

.btn-preview:disabled {
  opacity: 0.35;
  cursor: default;
}

.btn-preview.is-playing {
  animation: preview-pulse 0.9s ease-out;
}

@keyframes preview-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(201, 169, 98, 0.55);
  }
  100% {
    box-shadow: 0 0 0 12px rgba(201, 169, 98, 0);
  }
}

/* Notification status */

.pref-status {
  padding: 0.8rem 0 0.95rem;
}

.pref-status-text {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--muted);
}

.pref-status-text::before {
  content: "";
  flex: 0 0 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--faint);
  transform: translateY(-0.05rem);
}

.pref-status[data-tone="ok"] .pref-status-text::before {
  background: #7fb685;
}

.pref-status[data-tone="warn"] .pref-status-text::before {
  background: var(--gold);
}

/* Back up & sync: only one of its rows shows at a time */

.pref-row[hidden] {
  display: none;
}

#syncGroup > .pref-row {
  border-top: 0;
}

.sync-form {
  flex-wrap: wrap;
}

.sync-inline {
  display: flex;
  gap: 0.5rem;
  flex: 1 1 18rem;
  max-width: 24rem;
}

.sync-code {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3em;
}

.sync-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  flex-basis: 100%;
  justify-content: flex-end;
}

/* Buttons used on this page */

.btn-small {
  padding: 0.42rem 0.9rem;
  font-size: 0.8rem;
  white-space: nowrap;
}

.btn-danger {
  color: var(--danger-ink);
  border-color: var(--danger-line);
  background: var(--danger-bg);
  font-size: 0.8rem;
  padding: 0.42rem 0.9rem;
  white-space: nowrap;
}

.btn-danger:hover:not(:disabled) {
  border-color: var(--danger-ink);
}

.page-settings .btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Combinations */

.preset-form {
  display: grid;
  grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr));
  gap: 0.9rem 0.75rem;
  padding: 1.2rem 0;
}

.field-label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.input {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--control-bg);
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  padding: 0.6rem 0.8rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.input:focus,
.page-settings .select:focus-visible {
  outline: none;
  border-color: rgba(201, 169, 98, 0.6);
  box-shadow: 0 0 0 3px rgba(201, 169, 98, 0.15);
}

.input[aria-invalid="true"] {
  border-color: var(--danger-ink);
  box-shadow: 0 0 0 3px var(--danger-bg);
}

.input-unit {
  position: relative;
}

.input-unit .input {
  padding-right: 2.6rem;
  font-variant-numeric: tabular-nums;
  appearance: textfield;
  -moz-appearance: textfield;
}

.input-unit .input::-webkit-outer-spin-button,
.input-unit .input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.input-unit span {
  position: absolute;
  right: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  color: var(--muted);
  pointer-events: none;
}

.preset-form-foot {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
}

.preset-preview {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
}

.preset-preview strong {
  color: var(--gold2);
  font-weight: 500;
}

.preset-form-actions {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.preset-form-actions .btn {
  white-space: nowrap;
}

.custom-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.custom-empty {
  padding: 1.1rem 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 300;
}

.custom-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
  border-top: 1px solid var(--line);
  transition: background 0.2s;
}

.custom-item:first-child {
  border-top: 0;
}

.custom-item.is-editing {
  margin: 0 -1.25rem;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
  background: rgba(201, 169, 98, 0.08);
}

.custom-name {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.custom-name strong {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 500;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.badge {
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(201, 169, 98, 0.35);
  background: rgba(201, 169, 98, 0.12);
  color: var(--gold2);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.custom-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.custom-chips span {
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.74rem;
}

.custom-chips b {
  color: var(--ink);
  font-weight: 500;
}

.custom-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

/* Keyboard reference */

.shortcut-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 2rem;
  list-style: none;
  margin: 0;
  padding: 0.4rem 0;
}

.shortcut-grid li {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 0;
  border-top: 1px solid var(--line);
  font-size: 0.86rem;
  color: var(--muted);
}

.shortcut-grid li:nth-child(-n + 2) {
  border-top: 0;
}

.shortcut-grid .shortcut-keys {
  flex: 0 0 6.5rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.2rem;
}

.page-settings kbd {
  display: inline-block;
  min-width: 1.5rem;
  padding: 0.12rem 0.42rem;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.74rem;
  line-height: 1.4;
  text-align: center;
}

.kbd-plus,
.kbd-or {
  color: var(--muted);
  font-size: 0.7rem;
  margin: 0 0.1rem;
}

/* Save toast */

.settings-toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--menu-bg-strong);
  box-shadow: var(--menu-shadow);
  color: var(--gold2);
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 0.75rem);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.settings-toast::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--gold);
}

.settings-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.settings-toast.is-error {
  color: var(--danger-ink);
  border-color: var(--danger-line);
}

.settings-toast.is-error::before {
  background: var(--danger-ink);
}

/* Narrow screens */

@media (max-width: 880px) {
  .settings-layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .settings-nav {
    top: 0;
    z-index: 20;
    flex-direction: row;
    gap: 0.3rem;
    margin: 0 -1.5rem;
    padding: 0.6rem 1.5rem;
    overflow-x: auto;
    scrollbar-width: none;
    background: var(--topbar-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
  }

  .settings-nav::-webkit-scrollbar {
    display: none;
  }

  .settings-nav-link {
    white-space: nowrap;
    padding: 0.42rem 0.8rem;
    border-radius: 999px;
  }

  .settings-nav-link.is-active {
    box-shadow: inset 0 0 0 1px rgba(201, 169, 98, 0.45);
  }

  .pref-section {
    scroll-margin-top: 4rem;
  }
}

@media (max-width: 640px) {
  .pref-group {
    padding: 0 1rem;
  }

  .pref-row:not(.toggle):not(.pref-row-stack) {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .pref-row:not(.toggle):not(.pref-row-stack) > .pref-text {
    flex-basis: 100%;
  }

  .pref-row .segmented,
  .volume-control {
    width: 100%;
    min-width: 0;
  }

  .cue-row {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .preset-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .preset-field-name {
    grid-column: 1 / -1;
  }

  .custom-item {
    flex-direction: column;
    align-items: stretch;
  }

  .custom-item.is-editing {
    margin: 0 -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .shortcut-grid {
    grid-template-columns: 1fr;
  }

  .shortcut-grid li:nth-child(2) {
    border-top: 1px solid var(--line);
  }

  .settings-level-meta {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .settings-level-menu .level-option {
    grid-template-columns: 1fr;
  }
}

body.page-home.rest-short .phase-label,
body.page-home.rest-long .phase-label {
  color: var(--gold2);
}

body.page-home.rest-short,
body.page-home.rest-long {
  background: radial-gradient(1000px 700px at 80% 0%, #121a18 0%, transparent 55%),
    radial-gradient(800px 600px at 0% 100%, #101612 0%, transparent 50%), var(--bg0);
}

body[data-theme="light"].page-home.rest-short,
body[data-theme="light"].page-home.rest-long {
  background:
    linear-gradient(180deg, rgba(248, 251, 247, 0.86), rgba(226, 231, 222, 0.78)),
    var(--bg0);
}

@media (prefers-color-scheme: light) {
  body[data-theme="system"].page-home.rest-short,
  body[data-theme="system"].page-home.rest-long {
    background:
      linear-gradient(180deg, rgba(248, 251, 247, 0.86), rgba(226, 231, 222, 0.78)),
      var(--bg0);
  }
}

.page-dashboard .main {
  max-width: 1180px;
  --growth-0: rgba(255, 255, 255, 0.045);
  --growth-1: #b9d7aa;
  --growth-2: #73af72;
  --growth-3: #2f7e4d;
  --growth-4: #0f4f32;
  --growth-line: rgba(76, 137, 82, 0.24);
  --growth-wash: rgba(94, 151, 91, 0.14);
  --growth-track: rgba(255, 255, 255, 0.055);
  --growth-bar: linear-gradient(90deg, #b9d7aa, #0f4f32);
}

body[data-theme="light"] .page-dashboard .main {
  --growth-0: rgba(37, 57, 36, 0.075);
  --growth-1: #cfe3c5;
  --growth-2: #87bb78;
  --growth-3: #3f8a50;
  --growth-4: #145334;
  --growth-line: rgba(39, 96, 52, 0.2);
  --growth-wash: rgba(88, 133, 78, 0.12);
  --growth-track: rgba(37, 57, 36, 0.08);
  --growth-bar: linear-gradient(90deg, #cfe3c5, #145334);
}

@media (prefers-color-scheme: light) {
  body[data-theme="system"] .page-dashboard .main {
    --growth-0: rgba(37, 57, 36, 0.075);
    --growth-1: #cfe3c5;
    --growth-2: #87bb78;
    --growth-3: #3f8a50;
    --growth-4: #145334;
    --growth-line: rgba(39, 96, 52, 0.2);
    --growth-wash: rgba(88, 133, 78, 0.12);
    --growth-track: rgba(37, 57, 36, 0.08);
    --growth-bar: linear-gradient(90deg, #cfe3c5, #145334);
  }
}

.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.metric-card,
.dashboard-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.metric-card {
  position: relative;
  min-width: 0;
  padding: 1rem 1rem 0.95rem;
}

.metric-card-primary {
  background: linear-gradient(145deg, var(--growth-wash), var(--surface));
  border-color: var(--growth-line);
}

.metric-card-toggle {
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.metric-card-toggle:hover,
.metric-card-toggle:focus-visible {
  border-color: var(--growth-line);
  box-shadow: 0 0 0 3px var(--growth-wash);
}

.metric-card-toggle:active {
  transform: translateY(1px);
}

.metric-card-toggle[data-state-count="2"]::after {
  content: "";
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 999px;
  background: var(--growth-2);
  box-shadow: 0 0 0 0.22rem var(--growth-wash);
}

.metric-label,
.metric-note {
  display: block;
  color: var(--muted);
}

.metric-label {
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.metric-value {
  display: block;
  margin-top: 0.35rem;
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 3vw, 2.3rem);
  font-weight: 500;
  line-height: 1.05;
  color: var(--ink);
}

.metric-note {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  font-weight: 300;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard-panel {
  padding: 1.25rem;
}

.heatmap-panel {
  position: relative;
  margin-bottom: 1rem;
}

.panel-head {
  position: relative;
  display: grid;
  grid-template-columns: minmax(18rem, 1fr) minmax(20rem, auto) auto;
  align-items: flex-start;
  gap: 1.25rem;
  margin-bottom: 1rem;
}

.panel-head .card-title {
  margin-bottom: 0.55rem;
}

.panel-head .card-lede {
  margin-bottom: 0;
}

.heatmap-actions {
  display: contents;
  min-width: 0;
}

.year-filter-list {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 0;
}

.year-filter-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 4.3rem;
  min-height: 2rem;
  padding: 0 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.year-filter-item:hover,
.year-filter-item:focus {
  color: var(--ink);
  border-color: var(--growth-line);
  background: var(--surface-strong);
  outline: none;
}

.year-filter-item.is-active {
  color: #f6fbf1;
  border-color: rgba(255, 255, 255, 0.18);
  background: var(--growth-4);
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
  grid-column: 3;
  justify-self: end;
  padding-top: 0.25rem;
}

.heat-swatch,
.heat-cell {
  width: 0.82rem;
  height: 0.82rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.055);
}

.heat-swatch {
  width: 0.82rem;
  height: 0.82rem;
}

.heatmap-scroll {
  overflow-x: auto;
  padding-bottom: 0.2rem;
  -webkit-overflow-scrolling: touch;
}

.heatmap-wrap {
  width: calc(2.3rem + var(--heat-cols, 53) * 1.08rem);
  min-width: calc(2.3rem + var(--heat-cols, 53) * 1.08rem);
  margin: 0 auto;
}

.heatmap-months {
  display: grid;
  grid-template-columns: repeat(var(--heat-cols, 53), 0.82rem);
  gap: 0.26rem;
  margin-left: 2.3rem;
  min-height: 1.25rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.heatmap-months span {
  min-width: 0;
  overflow: visible;
}

.heatmap-body {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
}

.heatmap-days {
  display: grid;
  grid-template-rows: repeat(7, 0.82rem);
  gap: 0.26rem;
  width: 1.75rem;
  flex: 0 0 1.75rem;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 0.82rem;
  text-align: right;
}

.heatmap-grid {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 0.82rem);
  grid-auto-columns: 0.82rem;
  gap: 0.26rem;
}

.heat-cell {
  display: block;
  background: rgba(255, 255, 255, 0.045);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.heat-cell:not(.heat-empty) {
  cursor: default;
}

.heat-inactive {
  pointer-events: none;
}

.heat-cell:focus {
  outline: 2px solid var(--growth-3);
  outline-offset: 2px;
}

.heat-empty {
  opacity: 0;
}

.heat-level-0 {
  background: var(--growth-0);
}

.heat-level-1 {
  background: var(--growth-1);
  border-color: var(--growth-line);
}

.heat-level-2 {
  background: var(--growth-2);
  border-color: var(--growth-line);
}

.heat-level-3 {
  background: var(--growth-3);
  border-color: var(--growth-line);
}

.heat-level-4 {
  background: var(--growth-4);
  border-color: rgba(255, 255, 255, 0.22);
}

.heatmap-tooltip {
  position: absolute;
  z-index: 10;
  max-width: min(18rem, calc(100% - 1rem));
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--growth-line);
  background: var(--menu-bg-strong);
  box-shadow: var(--menu-shadow);
  color: var(--ink);
  font-size: 0.78rem;
  line-height: 1.35;
  pointer-events: none;
}

body[data-theme="light"] .heat-level-0 {
  background: var(--growth-0);
}

@media (prefers-color-scheme: light) {
  body[data-theme="system"] .heat-level-0 {
    background: var(--growth-0);
  }
}

.dashboard-lower {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 1rem;
  align-items: stretch;
}

.dashboard-lower .dashboard-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: clamp(20rem, 48vh, 23rem);
  padding: 0.85rem;
  overflow: hidden;
}

.dashboard-lower .panel-head {
  display: block;
  margin-bottom: 0.55rem;
}

.dashboard-lower .panel-head .card-title {
  margin-bottom: 0.25rem;
  font-size: clamp(1rem, 2vw, 1.15rem);
}

.dashboard-lower .panel-head .card-lede {
  font-size: 0.78rem;
  line-height: 1.3;
}

.recent-list,
.rhythm-list {
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  min-height: 0;
}

.recent-list,
.rhythm-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-right: 0.25rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--growth-line) transparent;
}

.recent-list::-webkit-scrollbar,
.rhythm-list::-webkit-scrollbar {
  width: 0.4rem;
}

.recent-list::-webkit-scrollbar-track,
.rhythm-list::-webkit-scrollbar-track {
  background: transparent;
}

.recent-list::-webkit-scrollbar-thumb,
.rhythm-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--growth-line);
}

.recent-row {
  display: grid;
  grid-template-columns: minmax(5.8rem, 0.7fr) minmax(8rem, 1.4fr) minmax(5.5rem, 0.65fr);
  gap: 0.6rem;
  align-items: center;
  min-height: 2.05rem;
  padding-top: 0.42rem;
  border-top: 1px solid var(--line);
}

.recent-row:first-child,
.rhythm-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.recent-date,
.recent-minutes,
.rhythm-copy {
  min-width: 0;
}

.recent-date strong,
.recent-minutes strong,
.rhythm-copy strong {
  display: block;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-date span,
.recent-minutes span,
.rhythm-copy span,
.empty-note {
  display: block;
  margin-top: 0.08rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 300;
}

.recent-minutes {
  text-align: right;
}

.rhythm-header,
.rhythm-row {
  display: grid;
  grid-template-columns: minmax(6.5rem, 0.9fr) minmax(5.2rem, 0.62fr) minmax(7rem, 1.18fr);
  gap: 0.7rem;
  align-items: center;
}

.rhythm-header {
  padding: 0 0 0.38rem;
  border-bottom: 1px solid var(--line);
}

.rhythm-heading {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1.2;
  padding: 0;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.rhythm-heading:hover,
.rhythm-heading:focus-visible {
  color: var(--ink);
}

.rhythm-heading:focus-visible {
  outline: 2px solid var(--growth-3);
  outline-offset: 0.2rem;
}

.rhythm-heading-share {
  grid-column: 2 / 4;
  text-align: center;
}

.rhythm-percent {
  min-width: 3.5rem;
  text-align: right;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
}

.recent-bar,
.rhythm-track {
  height: 0.36rem;
  border-radius: 999px;
  background: var(--growth-track);
  overflow: hidden;
}

body[data-theme="light"] .recent-bar,
body[data-theme="light"] .rhythm-track {
  background: var(--growth-track);
}

@media (prefers-color-scheme: light) {
  body[data-theme="system"] .recent-bar,
  body[data-theme="system"] .rhythm-track {
    background: var(--growth-track);
  }
}

.recent-bar span,
.rhythm-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--growth-bar);
}

.rhythm-row {
  min-height: 2.05rem;
  padding-top: 0.42rem;
  border-top: 1px solid var(--line);
}

.rhythm-focus {
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
}

.rhythm-focus {
  text-align: right;
}

.rhythm-share {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: center;
  min-width: 0;
}

@media (max-width: 980px) {
  .dashboard-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dashboard-lower {
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  }
}

/* The heatmap's year buttons and legend stop fitting beside its title well
   before the rest of the dashboard needs one column. */
@media (max-width: 840px) {
  .panel-head {
    align-items: stretch;
    display: flex;
    flex-direction: column;
  }

  .heatmap-actions {
    display: flex;
    align-items: flex-start;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
  }

  .year-filter-list {
    position: static;
    transform: none;
    justify-content: flex-start;
    flex-wrap: nowrap;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 0.15rem;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 720px) {
  .dashboard-stats,
  .dashboard-lower {
    grid-template-columns: 1fr;
  }

  .recent-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.45rem;
  }

  .recent-minutes {
    text-align: left;
  }

  .rhythm-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .rhythm-header {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.45rem;
    overflow-x: auto;
  }

  .rhythm-heading-share {
    grid-column: auto;
  }

  .rhythm-heading {
    font-size: 0.6rem;
  }

  .rhythm-focus {
    text-align: left;
  }
}

/* ── Bell Curve ────────────────────────────────────────────────── */

.bell-curve-panel {
  position: relative;
}

.bell-curve-container {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bell-curve-svg {
  width: 100%;
  height: auto;
  max-height: 100%;
  display: block;
}

.bell-curve-line {
  fill: none;
  stroke: url(#bellGrad);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bell-range-band {
  fill: #d4bc7c;
  opacity: 0.1;
}

body[data-theme="light"] .bell-range-band {
  opacity: 0.15;
}

@media (prefers-color-scheme: light) {
  body[data-theme="system"] .bell-range-band {
    opacity: 0.15;
  }
}

.bell-peak-line {
  stroke: #d4bc7c;
  stroke-width: 1.2;
  stroke-dasharray: 5, 4;
  opacity: 0.7;
}

.bell-peak-label {
  fill: #d4bc7c;
  font-size: 10.5px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
}

body[data-theme="light"] .bell-peak-label {
  fill: #8a6a35;
}

@media (prefers-color-scheme: light) {
  body[data-theme="system"] .bell-peak-label {
    fill: #8a6a35;
  }
}

.bell-p95-line {
  stroke: var(--muted, #888);
  stroke-width: 1;
  stroke-dasharray: 2, 4;
  opacity: 0.4;
}

.bell-p95-label {
  fill: var(--muted, #888);
  font-size: 9.5px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 400;
}

.bell-axis {
  stroke: var(--line, #333);
  stroke-width: 1;
}

.bell-axis-tick {
  stroke: var(--line, #333);
  stroke-width: 1;
}

.bell-axis-label {
  fill: var(--muted, #888);
  font-size: 10px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 400;
}

.bell-zone-label {
  fill: var(--muted, #888);
  font-size: 9.5px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 300;
  letter-spacing: 0.02em;
  opacity: 0.75;
}

.bell-clip-note {
  fill: var(--muted, #888);
  font-size: 9.5px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 300;
  opacity: 0.7;
}

.bell-zone-sep {
  stroke: var(--line, #333);
  stroke-width: 1;
  opacity: 0.45;
}

.bell-crosshair {
  stroke: #d4bc7c;
  stroke-width: 1;
  opacity: 0.55;
  pointer-events: none;
}

.bell-curve-dot {
  fill: #d4bc7c;
  stroke: var(--surface, #1a1a1a);
  stroke-width: 1.5;
  pointer-events: none;
}

/* The "i" beside the Rhythm profile title and its short note */
.dashboard-lower .panel-head.trend-head {
  position: relative;
  display: flex;
  flex-direction: row; /* also on narrow screens, where panel heads stack */
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
}

.dashboard-lower .panel-head.trend-head .card-title {
  margin-bottom: 0;
}

.info-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-serif);
  font-size: 0.78rem;
  font-style: italic;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.info-button:hover,
.info-button[aria-expanded="true"] {
  color: var(--gold2);
  border-color: var(--gold);
}

.info-button:focus-visible {
  outline: 1px solid var(--gold);
  outline-offset: 2px;
}

.info-pop {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  z-index: 20;
  width: min(21.5rem, calc(100vw - 3rem));
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--menu-bg-strong);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  box-shadow: var(--menu-shadow);
  color: var(--ink);
  font-size: 0.8rem;
  line-height: 1.45;
}

.info-pop.hidden {
  display: none;
}

.info-pop p {
  margin: 0;
}

.info-pop-title {
  margin-bottom: 0.55rem !important;
  font-family: var(--font-serif);
  font-size: 1rem;
}

.info-pop-keys {
  display: grid;
  gap: 0.4rem;
  margin: 0 0 0.6rem;
  padding: 0;
  list-style: none;
}

.info-pop-keys li {
  display: grid;
  grid-template-columns: 1.1rem 1fr;
  align-items: center;
  gap: 0.55rem;
}

.info-pop-keys b {
  font-weight: 500;
}

.info-key {
  display: block;
  width: 1.1rem;
}

.info-key-line {
  height: 2px;
  border-radius: 2px;
  background: #d4bc7c;
}

.info-key-band {
  height: 0.6rem;
  border-radius: 3px;
  background: rgba(212, 188, 124, 0.22);
}

.info-key-next {
  border-top: 1px dashed var(--muted);
}

.info-pop-note,
.info-pop-goal {
  color: var(--muted);
}

.info-pop-goal {
  margin-top: 0.3rem !important;
  color: var(--gold2);
}

body[data-theme="light"] .info-key-line {
  background: #8a6a35;
}

@media (prefers-color-scheme: light) {
  body[data-theme="system"] .info-key-line {
    background: #8a6a35;
  }
}

/* The usual-sitting trend (dashboard.js drawSittingTrend) */
.trend-grid {
  stroke: var(--line, #333);
  stroke-width: 1;
  opacity: 0.5;
}

.trend-band {
  fill: #d4bc7c;
  opacity: 0.09;
}

/* One steady gold, so the latest weeks are as clear as the first. */
.trend-line {
  fill: none;
  stroke: #d4bc7c;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trend-point,
.trend-now {
  fill: #d4bc7c;
  stroke: var(--surface, #1a1a1a);
  stroke-width: 1.5;
}

body[data-theme="light"] .trend-band {
  fill: #a98237;
  opacity: 0.1;
}

body[data-theme="light"] .trend-line {
  stroke: #8a6a35;
}

body[data-theme="light"] .trend-point,
body[data-theme="light"] .trend-now {
  fill: #8a6a35;
}

@media (prefers-color-scheme: light) {
  body[data-theme="system"] .trend-band {
    fill: #a98237;
    opacity: 0.1;
  }

  body[data-theme="system"] .trend-line {
    stroke: #8a6a35;
  }

  body[data-theme="system"] .trend-point,
  body[data-theme="system"] .trend-now {
    fill: #8a6a35;
  }
}

.trend-next {
  stroke: var(--muted, #888);
  stroke-width: 1;
  stroke-dasharray: 2, 4;
  opacity: 0.55;
}

.bell-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  padding: 0.32rem 0.6rem;
  background: var(--surface, #1a1a1a);
  color: var(--ink, #e8e0d0);
  font-size: 0.72rem;
  font-weight: 400;
  border: 1px solid var(--line, #333);
  border-radius: 0.4rem;
  pointer-events: none;
  white-space: nowrap;
  z-index: 10;
  transition: opacity 0.12s ease;
}

.bell-tooltip.hidden {
  opacity: 0;
  pointer-events: none;
}

.bell-curve-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.5rem;
  justify-content: center;
  padding: 0.45rem 0 0;
  font-size: 0.72rem;
  color: var(--muted, #888);
  font-weight: 300;
}

.bell-curve-stats strong {
  color: var(--ink, #e8e0d0);
  font-weight: 500;
}

.bell-stats-sep {
  opacity: 0.4;
}

.bell-curve-threshold {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 0.5rem;
  text-align: center;
}

.bell-curve-threshold-count {
  margin: 0;
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.8rem;
  font-weight: 500;
  color: var(--ink, #e8e0d0);
  line-height: 1;
}

.bell-curve-threshold-text {
  margin: 0;
  color: var(--muted, #888);
  font-size: 0.78rem;
  font-weight: 300;
}

/* Animation */
.bell-curve-enter {
  opacity: 0;
  transform: scale(0.97);
}

.bell-curve-visible {
  opacity: 1;
  transform: scale(1);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

/* ---------- History editor ---------- */

a.btn {
  display: inline-block;
  text-decoration: none;
}

.pref-desc-warn {
  color: var(--gold2);
}

.history-hero {
  margin-bottom: 2rem;
}

.history-back {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.84rem;
  text-decoration: none;
  transition: color 0.2s;
}

.history-back:hover,
.history-back:focus-visible {
  color: var(--gold2);
  outline: none;
}

.page-history .main {
  max-width: 820px;
}

.history-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.history-tabs {
  grid-template-columns: repeat(2, auto);
}

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

.history-count {
  min-width: 1.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--danger-bg);
  border: 1px solid var(--danger-line);
  color: var(--danger-ink);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.segment.is-active .history-count {
  background: rgba(26, 18, 8, 0.14);
  border-color: rgba(26, 18, 8, 0.2);
  color: #1a1208;
}

.history-hint {
  margin: -0.25rem 0 1rem;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 300;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.history-loading {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 300;
}

.history-day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.1rem 0 0.2rem;
}

.history-day-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 500;
}

.history-day-sum {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.history-day-sum b {
  color: var(--gold2);
  font-weight: 500;
}

/* 24-hour strip */

.history-timeline {
  padding: 0.6rem 0 0.9rem;
}

.history-track {
  position: relative;
  height: 0.7rem;
  border-radius: 999px;
  background:
    repeating-linear-gradient(90deg, transparent 0 calc(25% - 1px), var(--line) calc(25% - 1px) 25%),
    var(--ring-track);
  overflow: hidden;
}

.history-block {
  position: absolute;
  top: 0;
  bottom: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: filter 0.15s;
}

.history-block.is-focus {
  background: linear-gradient(90deg, var(--gold2), var(--gold));
}

.history-block.is-rest {
  background: var(--muted);
  opacity: 0.45;
}

.history-block.is-long {
  background: repeating-linear-gradient(135deg, var(--gold) 0 6px, var(--danger-ink) 6px 12px);
  opacity: 0.85;
}

.history-block:hover {
  filter: brightness(1.15);
}

.history-hours {
  display: flex;
  justify-content: space-between;
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
}

/* Entries */

.history-items .history-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.9rem;
  margin: 0 -1.25rem;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--line);
}

.history-items-flat {
  border-top: 0;
}

.history-items-flat .history-item:first-child {
  border-top: 0;
}

.history-kind {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
}

.history-kind.is-focus {
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 169, 98, 0.16);
}

.history-kind.is-rest {
  background: var(--muted);
  opacity: 0.6;
}

.history-main {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.history-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.history-range {
  font-size: 0.98rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.history-next-day {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 400;
  vertical-align: super;
}

.history-meta,
.history-on {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 300;
}

.history-on {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 400;
  color: var(--gold);
}

.history-length {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
  font-variant-numeric: tabular-nums;
}

.history-length strong {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.1;
}

.history-item.is-long .history-length strong {
  color: var(--danger-ink);
}

.history-was {
  color: var(--muted);
  font-size: 0.72rem;
  text-decoration: line-through;
  text-decoration-color: var(--faint);
}

.badge-warn {
  border-color: var(--danger-line);
  background: var(--danger-bg);
  color: var(--danger-ink);
}

.history-item.is-flash {
  animation: history-flash 1.6s ease;
}

@keyframes history-flash {
  0%,
  35% {
    background: rgba(201, 169, 98, 0.14);
  }
  100% {
    background: transparent;
  }
}

.history-empty {
  padding: 2rem 1.25rem;
  text-align: center;
}

.history-empty p {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 300;
}

.history-empty strong {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 500;
  color: var(--ink);
}

.history-more {
  display: flex;
  justify-content: center;
  margin-top: 1.5rem;
}

/* Editor sheet */

.history-sheet {
  width: min(480px, 100%);
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  background:
    linear-gradient(135deg, rgba(216, 189, 121, 0.08), transparent 46%),
    var(--bg1);
}

.history-sheet .modal-title {
  margin-bottom: 0.4rem;
  padding-right: 1.5rem;
}

.history-recorded {
  margin: 0 0 1.1rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.history-recorded b {
  color: var(--ink);
  font-weight: 500;
}

.history-field {
  margin-bottom: 1rem;
}

.history-field .segmented {
  width: 100%;
}

.history-sheet input[type="datetime-local"] {
  color-scheme: dark;
  font-variant-numeric: tabular-nums;
}

body[data-theme="light"] .history-sheet input[type="datetime-local"] {
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  body[data-theme="system"] .history-sheet input[type="datetime-local"] {
    color-scheme: light;
  }
}

.history-duration {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.history-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.6rem;
}

.history-chip {
  padding: 0.28rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font: inherit;
  font-size: 0.76rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.history-chip:hover,
.history-chip:focus-visible {
  color: var(--ink);
  border-color: rgba(201, 169, 98, 0.5);
  outline: none;
}

.history-preview {
  min-height: 1.3rem;
  margin: 0.25rem 0 1rem;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.history-preview b {
  color: var(--gold2);
  font-weight: 500;
}

.history-diff {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
}

.history-diff.is-less {
  background: rgba(201, 169, 98, 0.14);
  color: var(--gold2);
}

.history-diff.is-more {
  background: var(--surface-strong);
  color: var(--ink);
}

.history-error {
  margin: -0.4rem 0 1rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--danger-line);
  border-radius: 10px;
  background: var(--danger-bg);
  color: var(--danger-ink);
  font-size: 0.84rem;
  line-height: 1.45;
}

.history-actions {
  align-items: center;
  flex-wrap: wrap;
}

.history-actions-gap {
  flex: 1;
}

.history-actions #btnRevert {
  padding-left: 0;
}

@media (max-width: 640px) {
  .history-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .history-items .history-item {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .history-items .history-item {
    margin: 0 -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .history-items .history-item .custom-actions {
    grid-column: 2 / -1;
  }
}

/* ---------- Sign-in page ---------- */
.signin {
  display: flex;
  justify-content: center;
  padding: 3rem 0 2rem;
}

.signin-card {
  width: min(26rem, 100%);
  padding: 2.25rem 2rem 2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.signin-kicker {
  margin: 0 0 0.5rem;
  color: var(--gold);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.signin-title {
  margin: 0 0 0.6rem;
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 500;
}

.signin-lede {
  margin: 0 0 1.75rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
  font-weight: 300;
}

.signin-step {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.signin-step[hidden] {
  display: none;
}

.signin-label {
  font-size: 0.9rem;
}

.signin-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-top: 0.5rem;
}

.signin-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--gold);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.signin-link:hover {
  text-decoration: underline;
}

.signin-switch {
  margin: 0.75rem 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.signin-switch .signin-link {
  font-size: inherit;
}

.signin-hint {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.signin-submit {
  width: 100%;
}

.signin-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.signin-message {
  margin: 1rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
  text-align: center;
}

.signin-message[data-tone="error"] {
  color: var(--danger-ink);
}

@media (max-width: 520px) {
  .signin {
    padding-top: 1rem;
  }

  .signin-card {
    padding: 1.75rem 1.25rem 1.5rem;
  }
}

/* sign-in: fields */
.signin-step {
  gap: 0.9rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.signin-step .signin-label-row {
  margin-top: 0;
}

.optional {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 300;
}

.field-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.field-note[data-tone="ok"] {
  color: var(--ok-ink, #7fb685);
}

.field-note[data-tone="error"],
.caps-note {
  color: var(--danger-ink);
}

body[data-theme="light"] .field-note[data-tone="ok"] {
  color: #3f7d47;
}

body[data-theme="light"] .field-note[data-tone="error"],
body[data-theme="light"] .caps-note,
body[data-theme="light"] .signin-message[data-tone="error"] {
  color: #a33a3a;
}

.signin-submit {
  margin-top: 0.35rem;
}

.signin-code {
  text-align: center;
  font-size: 1.25rem;
}

.password-wrap,
.username-wrap {
  position: relative;
}

.password-wrap .input {
  padding-right: 4rem;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.4rem;
  transform: translateY(-50%);
  padding: 0.3rem 0.55rem;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--gold);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}

.password-toggle:hover {
  background: var(--faint);
}

.username-at {
  position: absolute;
  top: 50%;
  left: 0.8rem;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.username-wrap .input {
  padding-left: 1.75rem;
}

/* sign-in: password strength */
.strength {
  height: 3px;
  margin-top: 0.15rem;
  border-radius: 4px;
  background: var(--faint);
  overflow: hidden;
}

.strength-bar {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  transition: width 0.25s ease, background 0.25s ease;
}

.strength-bar[data-level="1"] { background: #c0504d; }
.strength-bar[data-level="2"] { background: #d08c3c; }
.strength-bar[data-level="3"] { background: #b9a24a; }
.strength-bar[data-level="4"],
.strength-bar[data-level="5"] { background: #5f9e66; }

/* sign-in: steps */
.signin-progress {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.signin-dot {
  flex: 1;
  height: 3px;
  border-radius: 3px;
  background: var(--faint);
}

.signin-dot.is-done,
.signin-dot.is-current {
  background: var(--gold);
}

.signin-dot.is-current {
  opacity: 0.6;
}

.signin {
  flex-direction: column;
  align-items: center;
}

.signin-foot {
  margin: 1.25rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

@media (max-width: 520px) {
  .field-row {
    grid-template-columns: 1fr;
  }
}

/* account: top bar and Settings */
.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-left: 0.5rem;
  padding: 0.2rem 0.7rem 0.2rem 0.2rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.85rem;
  text-decoration: none;
  max-width: 11rem;
}

.account-chip:hover {
  background: var(--faint);
}

.account-chip-initial,
.account-avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold2), var(--gold));
  color: #1a1208;
  font-size: 0.8rem;
  font-weight: 500;
}

.account-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-avatar {
  width: 2.4rem;
  height: 2.4rem;
  font-size: 1.05rem;
}

#syncSignedIn .pref-text {
  flex: 1;
}

.account-actions,
.profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.profile-form {
  flex-direction: column;
  align-items: stretch;
  gap: 0.9rem;
}

.profile-form[hidden] {
  display: none;
}

@media (max-width: 720px) {
  .account-chip-name {
    display: none;
  }

  .account-chip {
    padding-right: 0.2rem;
  }
}

.signin-progress[hidden] {
  display: none;
}

/* sign-in: where to save the password (folded until needed) */
.save-hint {
  color: var(--muted);
  font-size: 0.82rem;
}

.save-hint summary {
  width: fit-content;
  cursor: pointer;
  list-style: none;
  color: var(--muted);
}

.save-hint summary::-webkit-details-marker {
  display: none;
}

.save-hint summary::after {
  content: "›";
  display: inline-block;
  margin-left: 0.4em;
  transition: transform 0.2s ease;
}

.save-hint[open] summary::after {
  transform: rotate(90deg);
}

.save-hint summary:hover {
  color: var(--ink);
}

.save-hint-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 0 0;
}

.save-hint-text {
  margin: 0;
}

.save-hint .save-site {
  margin: 0;
  user-select: all; /* one click selects the whole address */
}

.save-hint-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.save-site {
  color: var(--ink);
  font-weight: 500;
  overflow-wrap: anywhere;
}

.save-hint-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.save-hint-actions .btn {
  flex: 1 1 8rem;
}

.save-site {
  color: var(--ink);
  font-weight: 500;
  overflow-wrap: anywhere; /* break only if it truly doesn't fit, not mid-word by default */
}

/* update required: covers the whole app until it updates */
.update-required {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: color-mix(in srgb, var(--bg0) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.update-required-card {
  width: min(26rem, 100%);
  padding: 2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg1);
  box-shadow: var(--shadow);
  text-align: center;
}

.update-required-title {
  margin: 0 0 0.75rem;
  font-family: var(--font-serif);
  font-size: 1.7rem;
  font-weight: 500;
}

.update-required-text {
  margin: 0 0 1.25rem;
  color: var(--muted);
  line-height: 1.55;
}

.update-required-card .btn {
  width: 100%;
}

.update-required-note {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

/* ---------- Timer (the simple countdown: templates/timer.html) ---------- */

/* The length: one quiet number, the same as Rhythm's, that you can click
   to retype. No boxes or lines; only the caret shows it is editable. */
.countdown-entry {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: center;
  font-variant-numeric: tabular-nums;
  caret-color: var(--gold);
  pointer-events: auto;
  cursor: text;
  transition: color 0.2s ease;
}

.countdown-entry:hover {
  color: var(--gold2);
}

.countdown-entry:focus {
  outline: none;
}

.countdown-entry::selection {
  background: rgba(201, 169, 98, 0.22);
}

.countdown-entry.hidden,
.countdown-quick.hidden {
  display: none;
}

/* Quick lengths: plain numbers, like a soft scale under the ring. */
.countdown-quick {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 0.15rem;
  margin: 0 auto 1.1rem;
}

.countdown-pick {
  min-width: 2.2rem;
  padding: 0.3rem 0.45rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: color 0.2s ease;
}

.countdown-pick:hover,
.countdown-pick.is-active {
  color: var(--gold2);
}

.countdown-pick:focus-visible {
  outline: 1px solid var(--gold);
  outline-offset: 1px;
}

body.timer-ringing .countdown-ring-wrap .ring-progress {
  animation: ring-breathe 1.2s ease-in-out infinite;
}

/* "Time's up" on pages other than Timer (static/js/timer-core.js); it looks
   like the update notice (above), near the top where the clock was. */
.timer-alarm {
  top: 5rem;
  z-index: 70;
}

.timer-alarm.hidden {
  display: none;
}


/* ---------- window sizes ----------
   The app lives in a window people resize (its own window on Mac and
   Windows, a browser app window otherwise), so every size from 420x560 up
   has to look intended, not just full screen. */

/* The clock ring follows the window's height as well as its width, so Start
   stays on screen in a short window. --ring-room is what the page needs
   above and below the ring; the type inside scales with the ring. */
:root {
  --ring-room: 330px;
}

.timer-ring-wrap {
  --ring: min(320px, 88vw, max(176px, 100vh - var(--ring-room)));
  width: var(--ring);
}

.timer-ring-wrap .time-display {
  font-size: clamp(2.1rem, calc(var(--ring) * 0.18), 3.6rem);
}

.page-timer {
  --ring-room: 370px; /* the quick lengths under the ring */
}

/* Below the width the name and all the tabs need on one line (about
   990px with the level picker), the tabs slim down to their text. */
@media (max-width: 1040px) {
  .topnav {
    flex-wrap: nowrap;
    gap: 0.4rem;
  }

  .nav-link,
  .nav-level-button {
    min-width: 0;
    padding: 0 0.85rem;
  }
}

/* Still too narrow: the tabs go on their own centred row under the name,
   on every page alike so the bar doesn't jump when switching tabs. */
@media (max-width: 880px) {
  .topbar {
    flex-direction: column;
    gap: 0.7rem;
    padding: 0.9rem 1rem;
  }

  .topnav {
    justify-content: center;
  }

  /* The level menu drops centred under the whole bar, close to its button. */
  .nav-level {
    position: static;
  }

  .page-home .nav-level-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    margin: 0 auto;
    transform-origin: top center;
  }
}

@media (max-width: 520px) {
  .topnav {
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .nav-link,
  .nav-level-button {
    min-height: 2rem;
    padding: 0 0.7rem;
    font-size: 0.8rem;
  }

  .brand-text {
    font-size: 1.15rem;
  }

  /* Rhythm's six buttons (level picker + tabs) as two even rows of three. */
  .page-home .topnav {
    display: grid;
    grid-template-columns: repeat(3, auto);
    justify-content: center;
  }

  .page-home .topnav .nav-link,
  .page-home .topnav .nav-level-button {
    width: 100%;
  }

  .session-live {
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
  }

  .live-stat {
    min-width: 0;
    flex: 1 1 0;
  }

  .live-val {
    font-size: 1.15rem;
    white-space: nowrap;
  }

  .live-key {
    letter-spacing: 0.14em;
  }
}

/* Short windows: tighter spacing, so the ring has room to stay large. */
@media (max-height: 760px) {
  .topbar {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }

  .main {
    padding-top: 1.1rem;
  }

  .hero {
    gap: 0.85rem;
  }

  .timer-panel {
    padding: 1.25rem 1.25rem 1.2rem;
  }

  .timer-ring-wrap {
    margin-bottom: 1.1rem;
  }

  .countdown-quick {
    margin-bottom: 0.75rem;
  }
}

/* sign-in: room to breathe */
.signin-card {
  padding: 2.5rem 2.25rem 2.25rem;
}

.signin-lede {
  margin-bottom: 2rem;
}

.signin-step {
  gap: 1.35rem;
}

.signin-step .field {
  gap: 0.45rem;
}

/* The name fields shown on the password step sit in a wrapper of their own:
   give it the step's spacing, and keep stacked names (phones) as far apart
   as every other field. */
#lateDetails:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.signin-step .field-row {
  gap: 1.35rem 0.75rem;
}

.signin-submit {
  margin-top: 0.5rem;
}

.pw-guide {
  transition: color 0.2s ease;
}

@media (max-width: 520px) {
  .signin-card {
    padding: 2rem 1.35rem 1.75rem;
  }
}

/* label + link (e.g. "New password" / "Suggest a strong password"): each
   stays on one line; on a narrow phone the link drops under the label. */
.signin-label-row {
  flex-wrap: wrap;
  row-gap: 0.25rem;
}

.signin-label-row > * {
  white-space: nowrap;
}

/* ---------- Admin tab ---------- */
.admin {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  max-width: 52rem;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.admin-stat {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.admin-stat-value {
  font-family: var(--font-serif);
  font-size: 1.9rem;
  line-height: 1;
}

.admin-stat-label {
  color: var(--muted);
  font-size: 0.8rem;
}

.admin-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.admin-person,
.admin-computer {
  align-items: flex-start;
  gap: 1rem;
}

.admin-person .pref-text,
.admin-computer .pref-text {
  flex: 1;
  min-width: 0;
}

.admin-facts {
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.admin-badge {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--gold);
  border-radius: 999px;
  color: var(--gold);
  font-size: 0.7rem;
  vertical-align: middle;
}

.admin-version {
  flex: none;
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.admin-version[data-tone="ok"] { color: #5f9e66; border-color: rgba(95, 158, 102, 0.4); }
.admin-version[data-tone="warn"] { color: #c08a3e; border-color: rgba(192, 138, 62, 0.4); }
.admin-version[data-tone="error"] { color: var(--danger-ink); border-color: var(--danger-line); }
body[data-theme="light"] .admin-version[data-tone="error"] { color: #a33a3a; }

.admin-empty {
  margin: 0;
  padding: 1rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.admin-error {
  margin: 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--danger-line);
  border-radius: 12px;
  background: var(--danger-bg);
  color: var(--danger-ink);
  font-size: 0.9rem;
}

body[data-theme="light"] .admin-error { color: #a33a3a; }

.admin-rules {
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
  padding: 1.35rem 1.25rem 1.25rem;
}

.admin-message {
  resize: vertical;
  min-height: 3.2rem;
}

.admin-rules-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

@media (max-width: 720px) {
  .admin-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 520px) {
  .admin-computer {
    flex-direction: column;
    gap: 0.5rem;
  }

  .admin-head {
    flex-direction: column;
  }

  .admin-rules-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ---------- Feedback (Settings) ---------- */
.feedback-form {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  padding: 1.35rem 1.25rem 1.25rem;
}

.feedback-kinds {
  grid-template-columns: repeat(4, 1fr);
}

.feedback-kinds .segment {
  padding: 0 0.6rem;
  white-space: nowrap;
}

.feedback-message {
  resize: vertical;
  min-height: 7rem;
  line-height: 1.5;
}

.feedback-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.feedback-item {
  align-items: flex-start;
}

.feedback-item-msg {
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.feedback-state {
  flex: none;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.feedback-state[data-state="seen"] { color: var(--gold); border-color: var(--gold); }
.feedback-state[data-state="done"] { color: #5f9e66; border-color: rgba(95, 158, 102, 0.4); }
body[data-theme="light"] .feedback-state[data-state="done"] { color: #3f7d47; }

/* ---------- Feedback (Admin tab) ---------- */
.admin-new {
  margin-left: 0.35rem;
  border-color: transparent;
  background: linear-gradient(135deg, var(--gold2), var(--gold));
  color: #1a1208;
  font-family: var(--font-sans);
  letter-spacing: 0;
}

.admin-new[hidden] {
  display: none;
}

.admin-feedback-filter {
  flex: none;
  min-width: 15rem;
}

.admin-feedback-counts {
  margin: -0.4rem 0 0.75rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.admin-feedback-counts:empty {
  display: none;
}

.admin-feedback {
  align-items: flex-start;
  gap: 1rem;
}

.admin-feedback-kind {
  margin-top: 0.7rem;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}

.admin-feedback-kind[data-kind="like"] { color: #5f9e66; }
.admin-feedback-kind[data-kind="dislike"] { color: var(--danger-ink); }
.admin-feedback-kind[data-kind="improve"] { color: #c08a3e; }
body[data-theme="light"] .admin-feedback-kind[data-kind="like"] { color: #3f7d47; }
body[data-theme="light"] .admin-feedback-kind[data-kind="dislike"] { color: #a33a3a; }

.admin-feedback-msg {
  margin: 0.3rem 0 0;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.admin-feedback[data-status="done"] .admin-feedback-msg {
  color: var(--muted);
}

.admin-feedback-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.admin-feedback-delete:hover:not(:disabled) {
  color: var(--danger-ink);
}

@media (max-width: 720px) {
  .feedback-kinds {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 520px) {
  .feedback-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-feedback-filter {
    min-width: 0;
    width: 100%;
  }
}

/* sign-in: Continue with Google / Microsoft */
.providers[hidden] {
  display: none;
}

.provider-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.provider-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  width: 100%;
}

.provider-button svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.providers-or {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.1rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.providers-or::before,
.providers-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.browser-wait {
  margin: 0;
  color: var(--ink);
}

.auth-done .btn {
  display: block;
  text-align: center;
  text-decoration: none;
}
