/* Component styles. All colours, radii and fonts come from css/themes.css. */

[hidden] {
  display: none !important;
}

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

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  background-image: var(--bg-image);
  background-attachment: fixed;
  background-repeat: no-repeat;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}

img,
svg {
  max-width: 100%;
  display: block;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--accent-ink);
  text-underline-offset: 3px;
}

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

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

.skip {
  position: absolute;
  left: 8px;
  top: -48px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  z-index: 20;
}
.skip:focus {
  top: 8px;
}

/* ---------- Layout ---------- */
.app {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
  padding-bottom: calc(var(--nav-h) + 16px);
}

.app.is-onboarding {
  padding-bottom: 28px;
}

.app.is-onboarding .bottom-nav {
  display: none !important;
}

.screen {
  padding: 6px 18px 24px;
}

.screen:focus {
  outline: none;
}

/* Gentle entrance when a screen renders */
.screen > * {
  animation: rise 0.32s var(--ease) both;
}
.screen > *:nth-child(2) { animation-delay: 0.03s; }
.screen > *:nth-child(3) { animation-delay: 0.06s; }
.screen > *:nth-child(4) { animation-delay: 0.09s; }
.screen > *:nth-child(n + 5) { animation-delay: 0.12s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Header ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  padding: calc(10px + env(safe-area-inset-top, 0px)) 18px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: none;
}
.brand-mark .bm-tile { fill: var(--accent-soft); }
.brand-mark .bm-steps {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.brand-mark .bm-dot { fill: var(--gold); }

.brand-text {
  min-width: 0;
}

.brand-text strong {
  display: block;
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: 1.08rem;
  letter-spacing: var(--display-tracking);
  line-height: 1.15;
}

.brand-text span {
  display: block;
  font-size: 0.76rem;
  color: var(--ink-soft);
}

.privacy-pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.74rem;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-radius: 999px;
  padding: 5px 10px 5px 8px;
  white-space: nowrap;
}
.privacy-pill svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
  opacity: 0.85;
}

/* ---------- Type ---------- */
h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  letter-spacing: var(--display-tracking);
  line-height: 1.18;
  margin: 0 0 8px;
}

h1 {
  font-size: 1.85rem;
}

h2 {
  font-size: 1.2rem;
}

h3 {
  font-size: 1.05rem;
}

.lede,
.muted {
  color: var(--ink-soft);
}

.lede {
  font-size: 1.04rem;
  margin: 0 0 16px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.74rem;
  color: var(--accent-ink);
  font-weight: 700;
  margin: 0 0 4px;
}

.hint {
  font-size: 0.86rem;
  color: var(--ink-soft);
  font-weight: 400;
}

.small {
  font-size: 0.87rem;
}

.footer-note {
  font-size: 0.84rem;
  color: var(--ink-soft);
  margin: 22px 4px 8px;
  text-align: center;
}

.center-tight { text-align: center; margin: 0; }
.mt-12 { margin-top: 12px; }
.mt-18 { margin-top: 22px; }
.row-gap { gap: 12px; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--bg-2);
  padding: 1px 5px;
  border-radius: 5px;
}

/* ---------- Welcome ---------- */
.hero {
  padding: 22px 4px 6px;
}

.hero-mark {
  width: 76px;
  height: 76px;
  margin-bottom: 18px;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.12));
  animation: float 6s ease-in-out infinite;
}
.hero-mark .bm-tile { fill: var(--surface); }
.hero-mark .bm-steps { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.hero-mark .bm-dot { fill: var(--gold); }

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.hero h1 {
  font-size: 2.2rem;
}

.checklist {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}

.checklist li {
  position: relative;
  padding: 9px 0 9px 34px;
}

.checklist li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-soft);
}

.checklist li::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 16px;
  width: 8px;
  height: 5px;
  border-left: 2px solid var(--accent-ink);
  border-bottom: 2px solid var(--accent-ink);
  transform: rotate(-45deg);
}

/* ---------- Surfaces ---------- */
.card {
  background: var(--surface);
  border: var(--card-border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin: 14px 0;
}

.card > h2:not(:first-child) {
  margin-top: 22px;
}

.disclaimer {
  position: relative;
  background: var(--gold-soft);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 12px 14px 12px 44px;
  font-size: 0.92rem;
  margin: 16px 0;
}
.disclaimer::before {
  content: "i";
  position: absolute;
  left: 13px;
  top: 12px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  border: 2px solid var(--gold-ink);
  color: var(--gold-ink);
  font: 700 0.8rem/17px var(--font-body);
  text-align: center;
}

.banner {
  background: var(--gold-soft);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 0.92rem;
  margin: 0 0 12px;
}

.error {
  color: var(--clay);
  font-weight: 700;
  font-size: 0.92rem;
  margin: 0 0 10px;
}

.empty {
  text-align: center;
  padding: 26px 12px;
  color: var(--ink-soft);
}

.empty-state {
  text-align: center;
  padding: 26px 18px 22px;
}
.empty-state svg {
  width: 120px;
  height: 90px;
  margin: 0 auto 10px;
}
.empty-state .es-ground { fill: var(--accent-soft); }
.empty-state .es-stem { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; }
.empty-state .es-leaf { fill: var(--accent); opacity: 0.85; }
.empty-state .es-sun { fill: var(--gold); opacity: 0.9; }
.empty-state h2 { margin-bottom: 6px; }
.empty-state p { color: var(--ink-soft); margin: 0 0 14px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ---------- Forms ---------- */
.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 14px;
}

.field label,
.field .label {
  font-weight: 700;
  font-size: 0.96rem;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  min-height: var(--tap);
  border: 1.5px solid var(--line-strong);
  background: var(--field-bg);
  color: var(--ink);
  border-radius: var(--radius-input);
  padding: 10px 13px;
  font-size: 16px;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  outline: none;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

input[type="checkbox"] {
  width: 24px;
  height: 24px;
  accent-color: var(--accent);
  flex: none;
}

label.row {
  min-height: var(--tap);
  cursor: pointer;
}

/* Journal: ruled lines on the note, like a notebook page */
[data-theme="journal"] textarea {
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(1.5em + 9px),
    var(--line) calc(1.5em + 9px),
    var(--line) calc(1.5em + 10px)
  );
  background-attachment: local;
  line-height: calc(1.5em + 10px);
  padding-top: 4px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 12px 18px;
  border-radius: var(--radius-btn);
  border: 1.5px solid transparent;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  width: 100%;
  box-shadow: var(--shadow-pop);
  transition: transform 0.12s var(--ease), background-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.btn:hover {
  background: var(--accent-hover);
}

.btn:active {
  transform: scale(0.98);
}

.btn.secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: none;
}

.btn.secondary:hover {
  background: var(--surface-2);
}

.btn.ghost {
  background: transparent;
  color: var(--accent-ink);
  width: auto;
  min-height: 44px;
  padding: 8px 12px;
  box-shadow: none;
}

.btn.danger {
  background: var(--clay-soft);
  color: var(--clay);
  border-color: var(--clay-line);
  box-shadow: none;
}

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn + .btn,
a.btn + a.btn {
  margin-top: 10px;
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ---------- Chips ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 44px;
  padding: 8px 15px;
  border-radius: 999px;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.93rem;
  transition: transform 0.12s var(--ease), background-color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.chip:active {
  transform: scale(0.95);
}

.chip[aria-pressed="true"],
.chip.is-on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.chip.se[aria-pressed="true"] {
  background: var(--clay-soft);
  border-color: var(--clay-line);
  color: var(--clay);
}

.chip[aria-pressed="true"]::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 11px;
  margin: 0 8px 2px 0;
  border-right: 2.5px solid currentColor;
  border-bottom: 2.5px solid currentColor;
  transform: rotate(45deg);
  vertical-align: middle;
  animation: pop 0.25s var(--ease);
}

/* ---------- Today ---------- */
.date-nav {
  display: grid;
  grid-template-columns: var(--tap) 1fr var(--tap);
  gap: 8px;
  align-items: center;
  margin: 4px 0 12px;
}

.date-nav button {
  width: var(--tap);
  height: var(--tap);
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1;
  box-shadow: var(--shadow);
  transition: transform 0.12s var(--ease);
}

.date-nav button:active:not([disabled]) {
  transform: scale(0.92);
}

.date-nav button[disabled] {
  opacity: 0.35;
  cursor: default;
  box-shadow: none;
}

.date-nav .current-date {
  text-align: center;
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  letter-spacing: var(--display-tracking);
  font-size: 1.12rem;
}

.dose-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 700;
  font-size: 0.93rem;
  margin: 0 0 8px;
}

.dose-pill::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

.take-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.take {
  min-height: 60px;
  border-radius: var(--radius-btn);
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  font-size: 1rem;
  transition: transform 0.12s var(--ease), background-color 0.15s var(--ease), border-color 0.15s var(--ease);
}

[data-theme="dusk"] .take {
  border-radius: var(--radius-sm);
}

.take:active {
  transform: scale(0.97);
}

.take[aria-pressed="true"][data-value="yes"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-pop);
}

.take[aria-pressed="true"][data-value="yes"]::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 14px;
  margin: 0 10px 3px 0;
  border-right: 3px solid currentColor;
  border-bottom: 3px solid currentColor;
  transform: rotate(45deg);
  vertical-align: middle;
  animation: pop 0.3s var(--ease);
}

.take[aria-pressed="true"][data-value="no"] {
  background: var(--bg-2);
  border-color: var(--line-strong);
}

.rating {
  margin: 0 0 18px;
}

.rating-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 7px;
}

.rating-head strong {
  font-size: 1rem;
}

.rating-scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.rating-scale button {
  min-height: 52px;
  aspect-ratio: auto;
  border-radius: var(--radius-rating);
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  font-size: 1.08rem;
  transition: transform 0.12s var(--ease), background-color 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease);
}

[data-theme="dusk"] .rating-scale button {
  aspect-ratio: 1;
  min-height: 48px;
  justify-self: center;
  width: 100%;
  max-width: 58px;
}

.rating-scale button:active {
  transform: scale(0.92);
}

.rating-scale button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
  box-shadow: var(--shadow-pop);
  animation: pop 0.28s var(--ease);
}

@keyframes pop {
  0% { transform: scale(0.88); }
  60% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

.ends {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 5px;
}

.saved {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-ink);
  min-height: 1.4em;
  margin: 6px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.saved:not(:empty)::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cdefs%3E%3Cmask id='m'%3E%3Ccircle cx='10' cy='10' r='10' fill='%23fff'/%3E%3Cpath d='M5.5 10.5l3 3 6-6.5' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/mask%3E%3C/defs%3E%3Crect width='20' height='20' fill='%23fff' mask='url(%23m)'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cdefs%3E%3Cmask id='m'%3E%3Ccircle cx='10' cy='10' r='10' fill='%23fff'/%3E%3Cpath d='M5.5 10.5l3 3 6-6.5' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/mask%3E%3C/defs%3E%3Crect width='20' height='20' fill='%23fff' mask='url(%23m)'/%3E%3C/svg%3E") center / contain no-repeat;
  animation: pop 0.3s var(--ease);
}

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(460px, 100%);
  height: var(--nav-h);
  padding: 8px 10px env(safe-area-inset-bottom, 8px);
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(1.4) blur(16px);
  backdrop-filter: saturate(1.4) blur(16px);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  z-index: 8;
}

.bottom-nav a,
.bottom-nav button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  min-height: 50px;
  border-radius: 16px;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.bottom-nav a[aria-current="page"],
.bottom-nav button[aria-current="page"] {
  color: var(--nav-active-ink);
  background: var(--nav-active-bg);
}

.bottom-nav a[aria-current="page"] .nav-ico {
  transform: translateY(-1px) scale(1.06);
  stroke-width: 2.2;
}

[data-theme="journal"] .bottom-nav a[aria-current="page"] {
  box-shadow: inset 0 -3px 0 var(--clay);
  border-radius: 4px;
}

.nav-ico {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.2s var(--ease);
}

/* ---------- Charts ---------- */
.charts {
  display: grid;
  gap: 10px;
}

.chart-card {
  margin: 0;
  background: var(--surface);
  border: var(--card-border);
  border-radius: var(--radius-sm);
  padding: 10px 10px 6px;
  box-shadow: var(--shadow);
}

.chart-card figcaption {
  font-size: 0.9rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px 0;
}

.chart-card svg .grid { stroke: var(--chart-grid); }
.chart-card svg .axis { fill: var(--chart-text); font-family: var(--font-body); }
.chart-card svg .band { fill: var(--chart-band); }
.chart-card svg .line { fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.chart-card svg .area { opacity: 0.12; }
.chart-card svg .line.bridge { stroke-width: 1.6; stroke-dasharray: 3 4; opacity: 0.55; }
.chart-card svg .dot { stroke: var(--surface); stroke-width: 1.4; }

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  display: inline-block;
}

.swatch-focus, .s-focus .dot, .s-focus .area { background: var(--c-focus); fill: var(--c-focus); }
.swatch-mood, .s-mood .dot, .s-mood .area { background: var(--c-mood); fill: var(--c-mood); }
.swatch-energy, .s-energy .dot, .s-energy .area { background: var(--c-energy); fill: var(--c-energy); }
.swatch-sleep, .s-sleep .dot, .s-sleep .area { background: var(--c-sleep); fill: var(--c-sleep); }
.swatch-appetite, .s-appetite .dot, .s-appetite .area { background: var(--c-appetite); fill: var(--c-appetite); }
.s-focus .line { stroke: var(--c-focus); }
.s-mood .line { stroke: var(--c-mood); }
.s-energy .line { stroke: var(--c-energy); }
.s-sleep .line { stroke: var(--c-sleep); }
.s-appetite .line { stroke: var(--c-appetite); }

.stage-legend {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}

/* ---------- History timeline ---------- */
.timeline {
  list-style: none;
  padding: 0;
  margin: 0;
}

.stage-block {
  margin: 0 0 20px;
  padding-left: 16px;
  border-left: 3px solid var(--accent-soft);
}

.stage-block h3 {
  font-size: 1.02rem;
  margin-bottom: 8px;
  position: relative;
}

.stage-block h3::before {
  content: "";
  position: absolute;
  left: -24px;
  top: 4px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--bg);
}

.day-row {
  background: var(--surface);
  border: var(--card-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 0 0 8px;
  box-shadow: var(--shadow);
  transition: transform 0.12s var(--ease);
}

.day-row:has(button.linkish):active {
  transform: scale(0.99);
}

.day-row button.linkish {
  all: unset;
  cursor: pointer;
  display: block;
  width: 100%;
}

.day-row button.linkish:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 6px;
  border-radius: 4px;
}

.day-row .when {
  font-weight: 700;
  font-size: 0.97rem;
}

.day-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 0.86rem;
  color: var(--ink-soft);
  margin-top: 4px;
}

.mini-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.mini-chips span {
  background: var(--clay-soft);
  color: var(--clay);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.8rem;
  font-weight: 700;
}

.med-switch {
  width: 100%;
  margin-bottom: 12px;
  font-weight: 700;
}

/* ---------- Report ---------- */
.report-toolbar {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.report-doc {
  background: var(--surface);
  border: var(--card-border);
  border-radius: var(--radius);
  padding: 20px 18px 24px;
  box-shadow: var(--shadow);
}

.report-doc section {
  margin-top: 20px;
}

.report-head h1 {
  font-size: 1.45rem;
}

.report-meta {
  color: var(--ink-soft);
  margin: 0 0 12px;
}

.report-notes-in span {
  font-weight: 700;
}

.report-table-wrap {
  overflow-x: auto;
  margin: 8px 0 16px;
}

.report-table-wrap .report-table {
  margin: 0;
  min-width: 280px;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin: 8px 0 16px;
  font-variant-numeric: tabular-nums;
}

.report-table th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  font-weight: 700;
}

.report-table th,
.report-table td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 7px 5px;
  vertical-align: top;
}

.report-table td:first-child {
  white-space: nowrap;
  font-weight: 700;
}

.report-table tbody tr:nth-child(even) td {
  background: var(--surface-2);
}

.note-list {
  padding-left: 18px;
  margin: 0;
}

.note-list li {
  margin: 0 0 10px;
}

/* ---------- Unlock ---------- */
.unlock {
  text-align: left;
}

.unlock .price {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: 1.45rem;
  margin: 8px 0;
}

/* ---------- Settings: look & feel ---------- */
.theme-options {
  display: grid;
  gap: 10px;
  margin: 6px 0 16px;
}

.theme-option {
  position: relative;
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 14px;
  align-items: center;
  padding: 10px 12px 10px 10px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  min-height: 72px;
  transition: border-color 0.15s var(--ease), transform 0.12s var(--ease);
}

.theme-option:active {
  transform: scale(0.99);
}

.theme-option:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.theme-option:has(input:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.theme-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-option .t-name {
  font-weight: 700;
  display: block;
}

.theme-option .t-blurb {
  font-size: 0.86rem;
  color: var(--ink-soft);
  display: block;
}

.theme-option .t-check {
  position: absolute;
  right: 12px;
  top: 10px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 1px 8px;
  display: none;
}

.theme-option:has(input:checked) .t-check {
  display: inline-block;
}

/* The preview is rendered with the theme's own tokens via data-theme on the element itself. */
.theme-preview {
  width: 76px;
  height: 56px;
  border-radius: 10px;
  background-color: var(--bg);
  background-image: var(--bg-image);
  border: 1px solid rgba(0, 0, 0, 0.08);
  padding: 7px;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 5px;
  overflow: hidden;
}

.theme-preview .tp-card {
  background: var(--surface);
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 5px;
}

.theme-preview .tp-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-rating);
  background: var(--accent);
}

.theme-preview .tp-dot.alt { background: var(--c-mood); }
.theme-preview .tp-dot.alt2 { background: var(--c-sleep); }

.theme-preview .tp-bar {
  height: 7px;
  border-radius: 99px;
  background: var(--accent-soft);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: calc(var(--radius-sm) + 4px);
  background: color-mix(in srgb, var(--ink) 7%, var(--surface));
  border: 1px solid var(--line);
}

.segmented label {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.93rem;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label:has(input:checked) {
  background: var(--accent-soft);
  color: var(--accent-ink);
  box-shadow: var(--shadow);
}

.segmented label:has(input:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

.segmented label:has(input:disabled) {
  opacity: 0.5;
  cursor: default;
}

/* ---------- Motion & print ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

/* Used by tests/test_app.py for full-page screenshots */
body.screenshotting .topbar,
body.screenshotting .bottom-nav {
  position: static;
  transform: none;
  left: auto;
  width: 100%;
  max-width: none;
  backdrop-filter: none;
}

body.screenshotting .app {
  padding-bottom: 0;
  min-height: 0;
}

body.screenshotting .bottom-nav {
  height: auto;
}

@media print {
  html {
    --bg: #ffffff !important;
    --bg-image: none !important;
    --surface: #ffffff !important;
    --surface-2: #f5f5f2 !important;
    --ink: #111111 !important;
    --ink-soft: #444444 !important;
    --line: #cccccc !important;
    --accent-ink: #1d4d3d !important;
    --gold-soft: #f4f1e8 !important;
    --gold-ink: #555555 !important;
    --chart-grid: rgba(0, 0, 0, 0.12) !important;
    --chart-text: #444444 !important;
    --chart-band: rgba(0, 0, 0, 0.05) !important;
    --c-focus: #2c735c !important;
    --c-mood: #b5532f !important;
    --c-energy: #96701a !important;
    --c-sleep: #6b56b8 !important;
    --c-appetite: #2f6f9f !important;
    --shadow: none !important;
    color-scheme: light;
  }
  body {
    background: #fff;
    font-size: 12pt;
    color: #111;
  }
  .topbar,
  .bottom-nav,
  .skip,
  .report-toolbar,
  .no-print,
  .privacy-pill,
  .screen > h1,
  .screen > .lede {
    display: none !important;
  }
  .screen > * {
    animation: none !important;
  }
  .app {
    max-width: none;
    padding: 0;
    background: #fff;
  }
  .screen {
    padding: 0;
  }
  .report-doc {
    border: 0;
    box-shadow: none;
    padding: 0;
  }
  .chart-card {
    break-inside: avoid;
    border: 1px solid #ddd;
  }
  .charts {
    grid-template-columns: repeat(2, 1fr);
  }
  h1, h2, h3 {
    color: #111;
  }
  a {
    color: inherit;
    text-decoration: none;
  }
}
