/* ============================================================
   HABIT PLANET — brand guidelines document styles
   Deep space, gemstones in orbit: white cards, soft Material
   elevation, circular progress, one celebratory rain.
   No hex here — tokens.css is the only source of values.
   ============================================================ */

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
}

img { max-width: 100%; display: block; }
h1, h2, h3, h4 { line-height: 1.2; text-wrap: balance; margin: 0; }
p { max-width: 65ch; }

a { color: var(--accent-dark); }
a:focus-visible,
button:focus-visible,
input:focus-visible { outline: 3px solid var(--accent-dark); outline-offset: 2px; }

.skip {
  position: absolute; left: -999px; top: 0;
  background: var(--space); color: var(--paper);
  padding: var(--sp-2) var(--sp-4); z-index: 99;
}
.skip:focus { left: 0; }

/* ---- Shell ---- */
.shell { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: var(--sp-5) var(--sp-4);
  background: var(--space); color: var(--paper);
  display: flex; flex-direction: column; gap: var(--sp-5);
}
.sidebar-mark { display: flex; align-items: center; gap: var(--sp-2); margin: 0; }
.sidebar-mark img { width: 40px; height: 40px; border-radius: var(--r-sm); }
.sidebar-mark span {
  font-family: var(--font-display); font-weight: 700; letter-spacing: 0.12em;
  font-size: 0.78rem; line-height: 1.3; color: var(--accent-light);
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; gap: var(--sp-2); align-items: baseline;
  position: relative;
  padding: 0.3rem 0.55rem 0.3rem 1.3rem; border-radius: var(--r-pill);
  color: var(--paper); opacity: 0.75; text-decoration: none;
  font-family: var(--font-mono); font-size: var(--text-caption);
}
.nav a .n { font-size: var(--text-label); color: var(--accent-light); }
.nav a:hover { opacity: 1; background: color-mix(in srgb, var(--paper) 10%, transparent); }
.nav a.active { opacity: 1; background: color-mix(in srgb, var(--accent) 22%, transparent); }
/* Selection is a small moon in orbit — a pulsing dot, never a border stripe */
.nav a.active::before {
  content: '';
  position: absolute; left: 0.45rem; top: 50%; transform: translateY(-50%);
  width: 7px; height: 7px; border-radius: var(--r-round);
  background: var(--accent-light);
  animation: moon-pulse 2s var(--ease-out) infinite;
}
@keyframes moon-pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .nav a.active::before { animation: none; } }

.sidebar-actions { margin-top: auto; display: flex; flex-direction: column; gap: var(--sp-2); }
.btn {
  font-family: var(--font-display); font-size: var(--text-body-sm); font-weight: 700;
  letter-spacing: 0.02em; cursor: pointer;
  border: 0; border-radius: var(--r-pill);
  padding: 0.55rem 1.2rem;
  background: var(--accent); color: var(--ink);
  box-shadow: var(--sh-rest);
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.btn:hover { background: var(--accent-light); transform: translateY(-2px); box-shadow: var(--sh-lift); }
.btn:active { transform: translateY(0); box-shadow: var(--sh-none); }
.btn--dark { background: var(--onyx); color: var(--paper); }
.btn--dark:hover { background: var(--onyx-light); }
.btn--danger { background: var(--paper); color: var(--danger); }
.btn--quiet { background: transparent; box-shadow: none; border: var(--border-hair); color: inherit; }

.burger { display: none; position: fixed; top: var(--sp-3); right: var(--sp-3); z-index: 60; }

/* ---- Sections ---- */
.sec { padding: var(--section-pad) clamp(1.25rem, 5vw, 5rem); }
.sec--tint { background: var(--tint); }
.sec--space { background: var(--space); color: var(--paper); }
.sec--space .sec-head .sub,
.sec--space p { color: color-mix(in srgb, var(--paper) 82%, transparent); }
.sec--space h2, .sec--space h3 { color: var(--paper); }
.sec-inner { max-width: var(--max-w); margin: 0 auto; }

.sec-head { margin-bottom: var(--sp-6); max-width: var(--max-w-narrow); }
.sec-head .kicker {
  font-family: var(--font-mono); font-size: var(--text-label);
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent-dark); margin: 0 0 var(--sp-2);
}
.sec--space .sec-head .kicker { color: var(--accent-light); }
.sec-head h2 {
  font-family: var(--font-display); font-weight: 700;
  letter-spacing: 0.01em; font-size: var(--text-h1);
}
.sec-head .sub { color: var(--muted); font-size: var(--text-body-lg); margin: var(--sp-3) 0 0; }

/* ---- Cover ---- */
.cover {
  min-height: 100vh; display: flex; align-items: center;
  background:
    radial-gradient(1px 1px at 12% 22%, var(--paper) 98%, transparent),
    radial-gradient(1.5px 1.5px at 78% 12%, var(--paper) 98%, transparent),
    radial-gradient(1px 1px at 64% 68%, var(--paper) 98%, transparent),
    radial-gradient(1.5px 1.5px at 32% 82%, var(--paper) 98%, transparent),
    radial-gradient(1px 1px at 88% 48%, var(--paper) 98%, transparent),
    radial-gradient(1px 1px at 45% 38%, var(--paper) 98%, transparent),
    radial-gradient(ellipse at 70% 20%, color-mix(in srgb, var(--amethyst-dark) 34%, transparent), transparent 55%),
    linear-gradient(170deg, var(--space) 20%, var(--space-deep));
  color: var(--paper);
}
.cover-grid {
  max-width: var(--max-w); margin: 0 auto; width: 100%;
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: var(--sp-7); align-items: center;
}
.cover-title {
  font-family: var(--font-display); font-weight: 700;
  letter-spacing: 0.02em; font-size: var(--text-hero); line-height: 1.02;
}
.cover-title .accent {
  background: var(--gradient-planet);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.cover-tag { font-size: var(--text-body-lg); font-weight: 600; margin: var(--sp-4) 0 0; max-width: 34ch; }
.cover-meta { font-family: var(--font-mono); font-size: var(--text-caption); color: var(--opal); margin-top: var(--sp-2); }
.cover-art { position: relative; display: grid; place-items: center; }
.cover-art img {
  width: min(340px, 80%); border-radius: var(--r-lg);
  box-shadow: var(--sh-glow), var(--sh-lift);
}
/* the cover mark floats — a slow breath, the app's own 20s cycle */
.js .cover-art img { animation: planet-drift var(--dur-breathe) ease-in-out infinite; }
@keyframes planet-drift { 50% { transform: translateY(-14px); } }
@media (prefers-reduced-motion: reduce) { .js .cover-art img { animation: none; } }

.toc { margin-top: var(--sp-5); columns: 2; column-gap: var(--sp-6); max-width: 44rem; }
.toc a {
  display: flex; gap: var(--sp-2); align-items: baseline;
  padding: 0.26rem 0; text-decoration: none; color: var(--paper);
  font-family: var(--font-mono); font-size: var(--text-caption);
  break-inside: avoid; opacity: 0.85;
}
.toc a:hover { opacity: 1; color: var(--accent-light); }
.toc .n { font-size: var(--text-label); color: var(--accent-light); }

/* ---- Primitives ---- */
.duo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-6); align-items: start; }
.lede { font-size: var(--text-body-lg); }
.mt { margin-top: var(--sp-6); }
.mt-sm { margin-top: var(--sp-4); }
.h3 { margin-bottom: var(--sp-3); font-size: var(--text-h3); font-weight: 700; font-family: var(--font-display); }

.deflist { margin: 0; }
.deflist > div { padding: var(--sp-3) 0; border-bottom: var(--border-hair); }
.deflist dt { font-family: var(--font-display); font-weight: 700; font-size: var(--text-body); }
.deflist dd { margin: 0.25rem 0 0; color: var(--muted); }
.sec--space .deflist dd { color: color-mix(in srgb, var(--paper) 75%, transparent); }
.sec--space .deflist > div { border-bottom-color: color-mix(in srgb, var(--paper) 15%, transparent); }

.numbered { list-style: none; margin: 0; padding: 0; counter-reset: rule; }
.numbered li {
  counter-increment: rule;
  display: grid; grid-template-columns: 2.4rem minmax(0, 1fr);
  gap: var(--sp-3); padding: var(--sp-3) 0;
  border-bottom: var(--border-hair);
}
.numbered li::before {
  content: counter(rule, decimal-leading-zero);
  font-family: var(--font-mono); color: var(--accent-dark);
  font-size: var(--text-body-sm); padding-top: 0.2rem;
}
.numbered strong { display: block; }

.spec { width: 100%; border-collapse: collapse; font-size: var(--text-body-sm); }
.spec th {
  text-align: left; font-family: var(--font-mono); font-size: var(--text-label);
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
  padding: 0 var(--sp-3) var(--sp-2) 0; border-bottom: var(--border);
}
.spec td { padding: var(--sp-2) var(--sp-3) var(--sp-2) 0; border-bottom: var(--border-hair); vertical-align: top; }
.spec .mono { font-family: var(--font-mono); font-size: var(--text-caption); }
.pass, .warn, .fail { font-family: var(--font-mono); font-size: var(--text-label); letter-spacing: 0.06em; white-space: nowrap; }
.pass { color: var(--accent-dark); }
.warn { color: var(--gold-dark); }
.fail { color: var(--danger); text-decoration: underline; }

.card {
  background: var(--paper); border-radius: var(--r-card);
  box-shadow: var(--sh-rest); padding: var(--sp-4);
}

.dosdonts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-5); }
.dd-col h3 { font-family: var(--font-mono); font-size: var(--text-body-sm); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: var(--sp-3); }
.dd-col ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.dd-col li { padding-left: 1.6rem; position: relative; }
.dd-col li::before { position: absolute; left: 0; font-weight: 800; }
.dd-do li::before { content: '✓'; color: var(--accent-dark); }
.dd-dont li::before { content: '✕'; color: var(--danger); }
.sec--space .dd-do li::before { color: var(--accent-light); }
.sec--space .dd-dont li::before { color: var(--ruby-light); }

/* ---- 01 · principle demos ---- */
.principle-demos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.pdemo { display: flex; flex-direction: column; gap: var(--sp-3); }
.pdemo .pd-stage {
  border-radius: var(--r-card); background: var(--space);
  min-height: 150px; display: grid; place-items: center; overflow: hidden;
  position: relative;
}
.pdemo figcaption { font-size: var(--text-body-sm); color: var(--muted); max-width: 40ch; }
.pdemo figcaption strong { color: var(--ink); display: block; font-family: var(--font-display); }

/* orbit demo — progress is a body in orbit */
.orbit { position: relative; width: 110px; height: 110px; }
.orbit .ring { position: absolute; inset: 0; border: 2px solid color-mix(in srgb, var(--accent-light) 35%, transparent); border-radius: var(--r-round); }
.orbit .core {
  position: absolute; inset: 38px; border-radius: var(--r-round);
  background: var(--gradient-planet); box-shadow: var(--sh-glow);
}
.orbit .moon-track { position: absolute; inset: 0; }
.js .orbit .moon-track { animation: orbit-spin var(--dur-breathe) var(--ease-orbit) infinite; }
.orbit .moon {
  position: absolute; top: -5px; left: 50%; margin-left: -5px;
  width: 10px; height: 10px; border-radius: var(--r-round); background: var(--accent-light);
}
.orbit .ripple { position: absolute; inset: 0; border: 2px solid var(--accent-light); border-radius: var(--r-round); opacity: 0; }
.js .orbit .ripple { animation: orbit-ripple 4s var(--ease-out) infinite; }
.js .orbit .ripple:nth-child(5) { animation-delay: 2s; }
@keyframes orbit-spin { to { transform: rotate(360deg); } }
@keyframes orbit-ripple {
  0% { transform: scale(0.6); opacity: 0.5; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* every habit its own color — CSS-only, radios drive the card */
.hcd { display: flex; flex-direction: column; gap: var(--sp-2); align-items: center; padding: var(--sp-3); }
.hcd-card {
  --habit: var(--emerald);
  width: min(240px, 90%); border-radius: var(--r-card);
  border: var(--border);
  background: linear-gradient(100deg, color-mix(in srgb, var(--habit) 50%, var(--paper)), color-mix(in srgb, var(--habit) 30%, var(--paper)));
  color: var(--ink); padding: var(--sp-2) var(--sp-3);
  font-size: var(--text-body-sm); font-weight: 600;
  box-shadow: var(--sh-rest);
  transition: background var(--dur-normal) var(--ease-out);
}
.hcd-swatches { display: flex; gap: var(--sp-2); }
.hcd-swatches label { width: 22px; height: 22px; border-radius: var(--r-round); cursor: pointer; border: 2px solid color-mix(in srgb, var(--paper) 60%, transparent); position: relative; }
.hcd-swatches input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.hcd-swatches label:has(input:checked) { outline: 2px solid var(--paper); outline-offset: 2px; }
.hcd-l--amethyst { background: var(--amethyst); }
.hcd-l--sapphire { background: var(--sapphire); }
.hcd-l--emerald { background: var(--emerald); }
.hcd-l--gold { background: var(--gold); }
.hcd-l--ruby { background: var(--ruby-light); }
.hcd:has(.hcd-l--amethyst input:checked) .hcd-card { --habit: var(--amethyst); }
.hcd:has(.hcd-l--sapphire input:checked) .hcd-card { --habit: var(--sapphire); }
.hcd:has(.hcd-l--emerald input:checked) .hcd-card { --habit: var(--emerald); }
.hcd:has(.hcd-l--gold input:checked) .hcd-card { --habit: var(--gold); }
.hcd:has(.hcd-l--ruby input:checked) .hcd-card { --habit: var(--ruby-light); }

/* check-ins are celebrations — the StylizedCheckbox, live */
.hp-check { position: relative; width: 72px; height: 72px; display: inline-block; }
.hp-check input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; width: 100%; height: 100%; }
.hp-check .box {
  position: absolute; inset: 0; border-radius: var(--r-round);
  border: 12px solid color-mix(in srgb, var(--accent-light) 30%, transparent);
  background: transparent;
  box-shadow: var(--sh-rest);
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
  display: grid; place-items: center;
  color: transparent; font-size: 30px; font-weight: 800; line-height: 1;
}
.hp-check input:checked + .box {
  border-color: var(--accent-dark); background: var(--accent-dark);
  color: var(--paper); box-shadow: var(--sh-none);
}
.hp-check input:checked + .box::after { content: '✓'; }
.js .hp-check input:checked + .box { animation: check-pop var(--dur-normal) var(--ease-celebrate); }
@keyframes check-pop { 40% { transform: scale(1.12); } }
.hp-check input:focus-visible + .box { outline: 3px solid var(--accent-dark); outline-offset: 3px; }

/* honesty demo — the future is locked */
.honesty { display: flex; flex-direction: column; gap: var(--sp-2); align-items: center; padding: var(--sp-3); }
.honesty .days { display: flex; gap: var(--sp-2); font-family: var(--font-mono); font-size: var(--text-label); }
.honesty .day { padding: 0.3rem 0.6rem; border-radius: var(--r-sm); background: color-mix(in srgb, var(--paper) 14%, transparent); color: var(--paper); }
.honesty .day--future { opacity: 0.4; text-decoration: line-through; }
.honesty .toast {
  background: var(--onyx-dark); color: var(--paper); border-radius: var(--r-sm);
  font-size: var(--text-caption); padding: 0.4rem 0.8rem;
}

/* ---- 02 · logo ---- */
.logo-stage { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-4); }
.logo-tile {
  margin: 0; border-radius: var(--r-card); box-shadow: var(--sh-rest);
  display: grid; place-items: center; aspect-ratio: 1; padding: var(--sp-4);
  position: relative;
}
.logo-tile img { width: min(110px, 62%); border-radius: var(--r-sm); }
.logo-tile figcaption {
  position: absolute; bottom: var(--sp-2); left: 0; right: 0; text-align: center;
  font-family: var(--font-mono); font-size: var(--text-label);
}
.logo-tile--space { background: var(--space); color: var(--paper); }
.logo-tile--paper { background: var(--paper); border: var(--border-hair); }
.logo-tile--tint { background: var(--tint); }
.logo-tile--planet { background: var(--gradient-planet); color: var(--ink); }

.clearspace {
  position: relative; width: min(280px, 100%); margin: 0 auto;
  border: 1px dashed var(--subtle); border-radius: var(--r-card); padding: 13%;
}
.clearspace img { width: 100%; border-radius: var(--r-sm); }
.clearspace .cs-label {
  position: absolute; font-family: var(--font-mono); font-size: var(--text-label); color: var(--subtle);
}
.cs-label--top { top: 2%; left: 50%; transform: translateX(-50%); }
.cs-label--left { left: 2%; top: 50%; transform: translateY(-50%) rotate(-90deg); }

.minsize-row { display: flex; align-items: flex-end; gap: var(--sp-5); flex-wrap: wrap; }
.minsize-row figure { margin: 0; text-align: center; }
.minsize-row img { margin: 0 auto; border-radius: 3px; }
.minsize-row figcaption { font-family: var(--font-mono); font-size: var(--text-label); color: var(--muted); margin-top: var(--sp-1); }

/* ---- 03 · color ---- */
.gem-table { display: flex; flex-direction: column; gap: var(--sp-3); }
.gem-row { display: grid; grid-template-columns: 8rem repeat(3, minmax(0, 1fr)); gap: var(--sp-2); align-items: stretch; }
.gem-row .gem-name { font-family: var(--font-display); font-weight: 700; font-size: var(--text-body-sm); align-self: center; }
.gem-row .gem-name .role { display: block; font-family: var(--font-mono); font-weight: 400; font-size: var(--text-label); color: var(--muted); }
.gem-chip { border-radius: var(--r-sm); padding: var(--sp-2); min-height: 58px; display: flex; flex-direction: column; justify-content: flex-end; box-shadow: var(--sh-rest); }
.gem-chip .hx { font-family: var(--font-mono); font-size: var(--text-label); }
.gem-chip--onink { color: var(--ink); }
.gem-chip--onpaper { color: var(--paper); }

.surface-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-4); }
.swatch { border-radius: var(--r-card); overflow: hidden; box-shadow: var(--sh-rest); background: var(--paper); border: var(--border-hair); }
.swatch .chip { height: 72px; }
.swatch .meta { padding: var(--sp-2) var(--sp-3); }
.swatch .meta .name { font-family: var(--font-display); font-weight: 700; font-size: var(--text-body-sm); margin: 0; }
.swatch .meta .hex { font-family: var(--font-mono); font-size: var(--text-label); color: var(--muted); margin: 0.15rem 0 0; }

.gradient-strip { height: 64px; border-radius: var(--r-card); box-shadow: var(--sh-rest); }
.gradient-strip--planet { background: var(--gradient-planet); }

/* ---- 04 · typography ---- */
.type-specimen { display: flex; flex-direction: column; }
.type-row { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: var(--sp-4); align-items: baseline; padding: var(--sp-3) 0; border-bottom: var(--border-hair); }
.type-row .demo { overflow-wrap: anywhere; margin: 0; }
.type-row .spec-cell { font-family: var(--font-mono); font-size: var(--text-label); color: var(--muted); text-align: right; margin: 0; }
.t-hero { font-family: var(--font-display); font-weight: 700; font-size: var(--text-hero); line-height: 1.02; }
.t-h1 { font-family: var(--font-display); font-weight: 700; font-size: var(--text-h1); }
.t-h2 { font-family: var(--font-display); font-weight: 700; font-size: var(--text-h2); }
.t-h3 { font-family: var(--font-display); font-weight: 700; font-size: var(--text-h3); }
.t-body-lg { font-size: var(--text-body-lg); }
.t-body { font-size: var(--text-body); }
.t-body-sm { font-size: var(--text-body-sm); }
.t-caption { font-size: var(--text-caption); color: var(--muted); }
.t-mono { font-family: var(--font-mono); font-size: var(--text-body-sm); }
.t-system { font-family: var(--font-system); }

/* ---- 05 · iconography ---- */
.emoji-grid { display: flex; flex-wrap: wrap; gap: var(--sp-3); }
.emoji-grid .e {
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
  font-size: 28px; line-height: 1;
}
.emoji-grid .e small { font-family: var(--font-mono); font-size: var(--text-label); color: var(--muted); }

/* ---- 06/07 · imagery & mascots ---- */
.artifact-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-4); }
.artifact { margin: 0; border-radius: var(--r-card); overflow: hidden; box-shadow: var(--sh-rest); background: var(--paper); border: var(--border-hair); }
.artifact img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.artifact figcaption { padding: var(--sp-2) var(--sp-3); font-size: var(--text-body-sm); }
.artifact figcaption .name { font-family: var(--font-display); font-weight: 700; display: block; }
.artifact figcaption .status { font-family: var(--font-mono); font-size: var(--text-label); color: var(--danger); }

.memento-frame {
  border-radius: var(--r-lg); background: var(--space); color: var(--paper);
  aspect-ratio: 9 / 14; width: min(220px, 100%); margin: 0 auto;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: var(--sp-3); box-shadow: var(--sh-lift);
  background-image: radial-gradient(ellipse at 50% 30%, color-mix(in srgb, var(--opal-dark) 40%, transparent), transparent 70%);
}
.memento-frame .rec { display: flex; align-items: center; gap: var(--sp-1); font-family: var(--font-mono); font-size: var(--text-label); }
.memento-frame .rec i { width: 10px; height: 10px; border-radius: var(--r-round); background: var(--ruby-light); display: inline-block; }
.js .memento-frame .rec i { animation: moon-pulse 1.4s steps(1) infinite; }
.memento-frame .cap { font-size: var(--text-caption); color: var(--opal-light); }

/* ---- 08 · UI components ---- */
.ui-demo { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; }
.habit-card {
  --habit: var(--emerald);
  width: 100%; max-width: 26rem;
  border-radius: var(--r-card); border: var(--border);
  background: linear-gradient(100deg, color-mix(in srgb, var(--habit) 50%, var(--paper)), color-mix(in srgb, var(--habit) 30%, var(--paper)));
  box-shadow: var(--sh-rest); padding: var(--sp-3) var(--sp-4);
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--sp-3); align-items: center;
  transition: box-shadow var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.habit-card:hover { box-shadow: var(--sh-lift); transform: translateY(-2px); }
.habit-card .emoji { font-size: 24px; margin-right: var(--sp-2); }
.habit-card .name { font-weight: 700; }
.habit-card .streak { font-family: var(--font-mono); font-size: var(--text-caption); color: var(--ink); }
.habit-card--amethyst { --habit: var(--amethyst); }
.habit-card--sapphire { --habit: var(--sapphire); }
.habit-card--done { box-shadow: var(--sh-none); }

.chip-demo {
  font: inherit; font-size: var(--text-body-sm); cursor: pointer;
  border: 0; border-radius: var(--r-sm); padding: 0.45rem 0.8rem;
  background: var(--paper); color: var(--ink); box-shadow: var(--sh-rest);
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.chip-demo[aria-pressed='true'] { background: var(--onyx-dark); color: var(--paper); }

.input-demo { display: flex; flex-direction: column; gap: 0.35rem; width: min(280px, 100%); }
.input-demo label { font-weight: 700; font-size: var(--text-body-sm); color: var(--ink); }
.input-demo input {
  font: inherit; padding: 0.6rem 0.8rem; border-radius: 4px;
  border: var(--border-w) solid var(--line-strong); background: var(--paper); color: var(--ink);
}
.input-demo input:focus-visible { outline: none; border: var(--border-focus); }

.fab {
  width: 56px; height: 56px; border-radius: var(--r-round); border: 0; cursor: pointer;
  background: var(--paper); color: var(--danger); font-size: 22px;
  box-shadow: var(--sh-rest); display: grid; place-items: center;
  transition: box-shadow var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.fab:hover { box-shadow: var(--sh-lift); transform: translateY(-2px); }
.fab--check { color: var(--accent-dark); }

/* the composite: a Habit Planet "Today" screen, CSS only */
.phone {
  width: var(--phone-w); max-width: 100%; margin: 0 auto;
  border-radius: 34px; background: var(--space);
  box-shadow: var(--sh-lift); padding: 14px;
  border: 3px solid var(--onyx-dark);
}
.phone-screen {
  border-radius: 24px; background: var(--space); overflow: hidden;
  display: flex; flex-direction: column; gap: var(--sp-2);
  padding: var(--sp-3); min-height: 520px;
}
.phone-bar { display: flex; justify-content: space-between; align-items: center; color: var(--paper); font-family: var(--font-mono); font-size: var(--text-label); }
.phone-title { color: var(--paper); font-family: var(--font-display); font-weight: 700; font-size: var(--text-h3); }
.phone-sub { color: var(--opal); font-size: var(--text-caption); margin: 0; }
.phone-orbit { display: grid; place-items: center; padding: var(--sp-2) 0; }
.phone-cards { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: auto; }
.phone .habit-card { max-width: none; padding: var(--sp-2) var(--sp-3); font-size: var(--text-body-sm); }
.phone .hp-check { width: 44px; height: 44px; }
.phone .hp-check .box { border-width: 8px; font-size: 20px; }

/* ---- 09 · shadows & borders ---- */
.shadow-demos { display: flex; gap: var(--sp-4); flex-wrap: wrap; }
.sh-demo { width: 130px; height: 90px; background: var(--paper); border-radius: var(--r-card); display: grid; place-items: center; font-family: var(--font-mono); font-size: var(--text-label); border: var(--border-hair); }
.sh-demo--rest { box-shadow: var(--sh-rest); }
.sh-demo--lift { box-shadow: var(--sh-lift); }
.sh-demo--flat { box-shadow: var(--sh-none); }
.sh-demo--glow { box-shadow: var(--sh-glow); background: var(--space); color: var(--paper); }
.radius-row { display: flex; gap: var(--sp-4); align-items: flex-end; flex-wrap: wrap; }
.radius-row .r { width: 64px; height: 64px; border: var(--border); background: var(--tint); display: grid; place-items: end center; font-family: var(--font-mono); font-size: var(--text-label); padding-bottom: 0.3rem; }

/* ---- 10 · motion ---- */
.rain-stage {
  position: relative; overflow: hidden; border-radius: var(--r-card);
  background: var(--space); min-height: 230px;
  display: grid; place-items: center;
}
.rain-stage .emoji-drop {
  position: absolute; top: -40px; font-size: 26px; opacity: 0;
  pointer-events: none;
}
.js .rain-stage.play .emoji-drop { animation: emoji-rain var(--dur-rain) var(--ease-out) forwards; }
@keyframes emoji-rain {
  0% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(300px); opacity: 0; }
}
.rain-stage .level-chip {
  font-family: var(--font-display); font-weight: 700; color: var(--paper);
  background: color-mix(in srgb, var(--paper) 10%, transparent);
  border-radius: var(--r-pill); padding: 0.4rem 1.1rem;
}

.sine {
  height: 60px; border-radius: var(--r-sm); background: var(--space); overflow: hidden;
  display: flex; align-items: center; padding: 0 var(--sp-3);
}
.sine .dot { width: 10px; height: 10px; border-radius: var(--r-round); background: var(--flourish); margin-right: 10px; }
.js .sine .dot { animation: sine-bob var(--dur-wave) ease-in-out infinite alternate; }
.js .sine .dot:nth-child(2) { animation-delay: 0.4s; }
.js .sine .dot:nth-child(3) { animation-delay: 0.8s; }
.js .sine .dot:nth-child(4) { animation-delay: 1.2s; }
.js .sine .dot:nth-child(5) { animation-delay: 1.6s; }
.js .sine .dot:nth-child(6) { animation-delay: 2s; }
@keyframes sine-bob { from { transform: translateY(14px); } to { transform: translateY(-14px); } }

/* ---- 11 · layout ---- */
.container-diagram { display: flex; flex-direction: column; gap: var(--sp-2); }
.container-diagram .bar { border: 2px dashed var(--subtle); border-radius: var(--r-sm); padding: 0.4rem var(--sp-3); font-family: var(--font-mono); font-size: var(--text-label); color: var(--muted); }
.spacing-ruler { display: flex; align-items: flex-end; gap: var(--sp-3); }
.spacing-ruler .block { background: var(--accent); border-radius: 3px; width: 30px; box-shadow: var(--sh-rest); }
.spacing-ruler .lbl { font-family: var(--font-mono); font-size: var(--text-label); color: var(--muted); text-align: center; margin-top: 0.3rem; }
.portrait-note { display: flex; gap: var(--sp-3); align-items: center; }
.portrait-note .frame { width: 44px; height: 74px; border: var(--border); border-radius: 8px; }
.portrait-note .frame--landscape { width: 74px; height: 44px; position: relative; }
.portrait-note .frame--landscape::after { content: '✕'; color: var(--danger); font-weight: 800; position: absolute; inset: 0; display: grid; place-items: center; }

/* ---- 12/13 · voice & policy ---- */
.stance { font-family: var(--font-display); font-weight: 700; font-size: var(--text-h2); max-width: 28ch; margin: 0 0 var(--sp-5); }
.callout { border-left: 4px solid var(--accent); border-radius: 0 var(--r-card) var(--r-card) 0; background: var(--paper); box-shadow: var(--sh-rest); padding: var(--sp-4); max-width: var(--max-w-narrow); }
.sec--tint .callout { background: var(--paper); }
.vocab { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-5); }
.sample { font-size: var(--text-body-lg); border-left: 3px solid var(--flourish); padding-left: var(--sp-3); margin: var(--sp-3) 0 0; font-style: italic; }
.sample cite { display: block; font-style: normal; font-family: var(--font-mono); font-size: var(--text-label); color: var(--muted); margin-top: 0.3rem; }

/* ---- Placeholders & invitations ---- */
.placeholder {
  border: 3px dashed var(--danger); border-radius: var(--r-card);
  padding: var(--sp-3) var(--sp-4);
  font-family: var(--font-mono); font-size: var(--text-caption); color: var(--danger);
  background: color-mix(in srgb, var(--ruby-light) 6%, transparent);
}
.placeholder::before { content: 'PLACEHOLDER — '; font-weight: 700; }
.sec--space .placeholder { color: var(--ruby-light); border-color: var(--ruby-light); }

.invite {
  border: 1px dashed var(--subtle); border-radius: var(--r-card);
  padding: var(--sp-3) var(--sp-4);
  font-family: var(--font-mono); font-size: var(--text-caption); color: var(--muted);
  max-width: 34rem;
}
.js .invite { opacity: 0; transition: opacity var(--dur-slow) var(--ease-out) 2s; }
.js .invite.vis { opacity: 1; }

.alt-control {
  display: inline-flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: var(--text-caption);
  border: 2px dashed var(--subtle); border-radius: var(--r-card);
  padding: var(--sp-2) var(--sp-3); color: var(--muted);
}
.alt-control .btn { font-size: var(--text-caption); padding: 0.3rem 0.8rem; box-shadow: none; background: var(--tint); color: var(--ink); }
.alt-control .btn[aria-pressed='true'] { background: var(--space); color: var(--paper); }

/* ---- Reveal (js-gated; fails visible) ---- */
.rv { /* visible by default */ }
.js .rv { opacity: 0; transform: translateY(14px); transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out); }
.js .rv.vis { opacity: 1; transform: none; }
.js .rv-d1.vis { transition-delay: 60ms; }
.js .rv-d2.vis { transition-delay: 120ms; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .rv, .js .invite { opacity: 1; transform: none; transition: none; }
  .btn, .habit-card, .fab { transition: none; }
  .js .orbit .moon-track, .js .orbit .ripple, .js .sine .dot,
  .js .cover-art img, .js .memento-frame .rec i { animation: none; }
  .js .rain-stage.play .emoji-drop { animation: none; opacity: 0; }
  .js .hp-check input:checked + .box { animation: none; }
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .duo, .dosdonts, .vocab, .principle-demos { grid-template-columns: 1fr; }
  .logo-stage, .artifact-grid, .surface-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gem-row { grid-template-columns: 6rem repeat(3, minmax(0, 1fr)); }
  .cover-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 30% 0 0; z-index: 50; transform: translateX(-100%); transition: transform var(--dur-normal) var(--ease-out); height: 100dvh; }
  .sidebar.open { transform: none; }
  .burger { display: inline-block; }
  .logo-stage, .artifact-grid, .surface-row { grid-template-columns: 1fr; }
  .gem-row { grid-template-columns: 1fr; }
  .gem-row .gem-name { padding-top: var(--sp-2); }
  .type-row { grid-template-columns: 1fr; }
  .type-row .spec-cell { text-align: left; }
  .toc { columns: 1; }
}

/* ---- Print ---- */
@media print {
  .sidebar, .burger, .invite, .alt-control, .skip, [data-rain-replay] { display: none !important; }
  .shell { display: block; }
  .rv { opacity: 1 !important; transform: none !important; }
  .sec { break-before: page; padding: 1.5cm 0; }
  .cover { min-height: auto; break-before: auto; }
  body { background: white; }
  .cover, .sec--space, .pd-stage, .rain-stage, .sine, .memento-frame, .phone, .phone-screen,
  .gem-chip, .chip, .gradient-strip, .spacing-ruler .block, .logo-tile--space, .logo-tile--planet,
  .hcd-swatches label, .orbit .core {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
}
