/* Loomkeep — design system ported from theme.jsx.
   Two palettes (indigo default, amber) × light/dark (dusk) mode, driven by
   body[data-palette][data-theme]. Mobile-first; centered max-width on desktop. */

/* ── Palette tokens ───────────────────────────────────────────────────────── */
body[data-palette="indigo"][data-theme="light"] {
  --paper:#eeeef4; --surface:#fbfbfe; --surfaceAlt:#f1f1f8;
  --ink:#20202f; --inkSoft:#5c5c70; --inkFaint:#9192a4;
  --line:rgba(32,32,47,0.10); --lineStrong:rgba(32,32,47,0.16);
  --brand:#2d3157; --brandSoft:rgba(45,49,87,0.10);
  --accent:#b06a6f; --accentSoft:rgba(176,106,111,0.14);
  --onBrand:#f0eef6; --accentInk:#fff; --shadow:rgba(30,30,55,0.12);
}
body[data-palette="indigo"][data-theme="dark"] {
  --paper:#131320; --surface:#1c1c2c; --surfaceAlt:#232336;
  --ink:#e7e7f2; --inkSoft:#a3a3b9; --inkFaint:#76768c;
  --line:rgba(255,255,255,0.09); --lineStrong:rgba(255,255,255,0.15);
  --brand:#9aa0d8; --brandSoft:rgba(154,160,216,0.14);
  --accent:#c98c90; --accentSoft:rgba(201,140,144,0.16);
  --onBrand:#161624; --accentInk:#1a1208; --shadow:rgba(0,0,0,0.55);
}
body[data-palette="amber"][data-theme="light"] {
  --paper:#f3ede2; --surface:#fbf7f0; --surfaceAlt:#f6efe4;
  --ink:#2c2230; --inkSoft:#6c5f67; --inkFaint:#a2949b;
  --line:rgba(44,34,48,0.10); --lineStrong:rgba(44,34,48,0.16);
  --brand:#4a2e46; --brandSoft:rgba(74,46,70,0.10);
  --accent:#bd8836; --accentSoft:rgba(189,136,54,0.14);
  --onBrand:#fbf3e6; --accentInk:#fff; --shadow:rgba(60,40,50,0.10);
}
body[data-palette="amber"][data-theme="dark"] {
  --paper:#191418; --surface:#221b21; --surfaceAlt:#2a212a;
  --ink:#efe6ec; --inkSoft:#b6a6b0; --inkFaint:#7d6f78;
  --line:rgba(255,255,255,0.09); --lineStrong:rgba(255,255,255,0.15);
  --brand:#d9b070; --brandSoft:rgba(217,176,112,0.14);
  --accent:#d6a44e; --accentSoft:rgba(214,164,78,0.16);
  --onBrand:#211015; --accentInk:#1a1208; --shadow:rgba(0,0,0,0.5);
}

:root {
  --serif:"Spectral", Georgia, "Times New Roman", serif;
  --sans:"Hanken Grotesk", -apple-system, system-ui, sans-serif;
  --mono:"IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

/* ── Base ─────────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper); color: var(--ink);
  font-family: var(--sans); -webkit-font-smoothing: antialiased;
  font-size: 15px; line-height: 1.5;
}
a { color: inherit; }
button { font-family: inherit; }
.serif { font-family: var(--serif); }
.mono { font-family: var(--mono); }
.muted { color: var(--inkSoft); }
.faint { color: var(--inkFaint); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
img { max-width: 100%; }

/* App shell: mobile-first column, centered + framed on larger viewports. */
.app {
  max-width: 430px; margin: 0 auto; min-height: 100vh;
  display: flex; flex-direction: column; position: relative;
  background: var(--paper);
}
@media (min-width: 480px) {
  body { background: color-mix(in srgb, var(--paper) 70%, #000 6%); }
  .app { box-shadow: 0 1px 40px var(--shadow); min-height: 100dvh; }
}
.screen { flex: 1; padding: 22px 20px 110px; }
.screen.flush { padding-left: 0; padding-right: 0; }

/* ── Typography helpers ───────────────────────────────────────────────────── */
h1.title { margin: 0; font-family: var(--serif); font-size: 30px; font-weight: 600;
  letter-spacing: -0.3px; line-height: 1.05; }
h2.title { margin: 0; font-family: var(--serif); font-size: 22px; font-weight: 600; }
.kicker { font-family: var(--sans); font-size: 13px; font-weight: 600; color: var(--accent);
  letter-spacing: 0.3px; margin-bottom: 5px; }
.screen-header { padding: 8px 0 18px; display: flex; align-items: flex-start;
  justify-content: space-between; gap: 12px; }
.screen-header .sub { font-size: 14px; color: var(--inkSoft); margin-top: 6px; }
.section-label { display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin: 0 0 12px; }
.section-label > span { font-size: 12.5px; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--inkFaint); }
.section-label a, .section-label button.link { border: none; background: none; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--accent); text-decoration: none; }
.divider { height: 1px; background: var(--line); border: 0; margin: 0; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--sans); font-weight: 600; border-radius: 14px; cursor: pointer;
  border: none; letter-spacing: 0.1px; line-height: 1.1; white-space: nowrap;
  text-decoration: none; transition: transform .1s, opacity .1s;
  -webkit-tap-highlight-color: transparent; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.full { width: 100%; }
.btn.sm { padding: 8px 14px; font-size: 13.5px; }
.btn.md { padding: 13px 18px; font-size: 15.5px; }
.btn.lg { padding: 16px 20px; font-size: 16.5px; }
.btn.primary { background: var(--brand); color: var(--onBrand); }
.btn.accent  { background: var(--accent); color: var(--accentInk); }
.btn.soft    { background: var(--brandSoft); color: var(--brand); }
.btn.ghost   { background: transparent; color: var(--ink); border: 1px solid var(--lineStrong); }
.btn.quiet   { background: transparent; color: var(--inkSoft); padding-left: 2px; padding-right: 2px; }
.btn .ico { width: 18px; height: 18px; }
.btn.sm .ico { width: 16px; height: 16px; }

/* ── Chips / pills ────────────────────────────────────────────────────────── */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600;
  padding: 8px 13px; border-radius: 999px; cursor: pointer; border: 1px solid var(--line);
  background: transparent; color: var(--inkSoft); letter-spacing: 0.1px; white-space: nowrap;
  transition: all .12s; -webkit-tap-highlight-color: transparent; }
.chip .ico { width: 14px; height: 14px; }
.chip.active { border-color: transparent; background: var(--brandSoft); color: var(--brand); }
.chip.accent.active { background: var(--accentSoft); color: var(--accent); }
.chip.dashed { border-style: dashed; border-color: var(--lineStrong); }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600;
  letter-spacing: 0.3px; padding: 4px 9px; border-radius: 999px; text-transform: uppercase;
  white-space: nowrap; }
.pill.brand { background: var(--brandSoft); color: var(--brand); }
.pill.accent { background: var(--accentSoft); color: var(--accent); }
.pill.soft { background: var(--surfaceAlt); color: var(--inkSoft); }

/* ── Fields / inputs ──────────────────────────────────────────────────────── */
.field { margin-bottom: 18px; }
.field-label { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.field-label .lbl { font-size: 13.5px; font-weight: 600; color: var(--ink); letter-spacing: 0.2px; }
.field-label .opt { font-size: 12px; color: var(--inkFaint); }
.field-hint { font-size: 12px; color: var(--inkFaint); margin-top: 6px; }
.input, textarea.input, select.input {
  width: 100%; display: block; background: var(--surface); border: 1px solid var(--line);
  border-radius: 13px; padding: 12px 14px; font-family: var(--sans); font-size: 15px;
  line-height: 1.5; color: var(--ink); outline: none; }
.input::placeholder, textarea.input::placeholder { color: var(--inkFaint); }
.input:focus, textarea.input:focus, select.input:focus { border-color: var(--brand); }
textarea.input { min-height: 76px; resize: vertical; }
select.input { -webkit-appearance: none; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--inkFaint) 50%),
                    linear-gradient(135deg, var(--inkFaint) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 36px; }

/* ── Surfaces / cards ─────────────────────────────────────────────────────── */
.surface { background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 2px 10px var(--shadow); }
.surface-soft { background: var(--surfaceAlt); border-radius: 16px; }
.pad16 { padding: 16px; }
.pad { padding: 18px; }
.stat-value { font-family: var(--serif); font-size: 30px; font-weight: 600; line-height: 1; }
.stat-label { font-size: 12.5px; color: var(--inkSoft); margin-top: 5px; font-weight: 500; }
.stat-sub { font-size: 11.5px; color: var(--inkFaint); margin-top: 2px; }

/* ── Card token (abstract tarot card) ─────────────────────────────────────── */
.card-token { position: relative; flex-shrink: 0; border-radius: 8px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 4px 12px var(--shadow);
  display: flex; flex-direction: column; }
.card-token .art { flex: 1; margin: 6%; margin-bottom: 0; border-radius: 6px; position: relative;
  overflow: hidden; background: var(--accentSoft); display: flex; align-items: center;
  justify-content: center; }
.card-token .art::before { content: ""; position: absolute; inset: 0;
  background-image: repeating-linear-gradient(135deg, var(--line) 0 1px, transparent 1px 8px); }
.card-token .glyph { position: relative; color: var(--accent); line-height: 1; }
.card-token.reversed .glyph { transform: rotate(180deg); }
.card-token .plate { padding: 7% 8% 9%; text-align: center; }
.card-token .plate .nm { font-family: var(--serif); font-weight: 600; color: var(--ink);
  line-height: 1.1; letter-spacing: 0.1px; }
.card-token .rev-badge { position: absolute; top: 6%; right: 6%; color: var(--accent);
  background: var(--surface); border-radius: 999px; display: flex; align-items: center;
  justify-content: center; box-shadow: 0 1px 4px var(--shadow); }
.card-token.back { background: var(--brand); border: 1px solid var(--lineStrong); }
.card-token.back .pattern { position: absolute; inset: 0;
  background-image: repeating-linear-gradient(45deg,
    color-mix(in srgb, var(--accent) 13%, transparent) 0 2px, transparent 2px 9px); }
.card-token.back .frame { position: absolute; inset: 10%; border-radius: 6px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  display: flex; align-items: center; justify-content: center; color: var(--accent); }
.card-token.dim { opacity: 0.5; }
.card-empty { border-radius: 8px; border: 1.5px dashed var(--lineStrong); display: flex;
  align-items: center; justify-content: center; color: var(--inkFaint); flex-shrink: 0;
  background: transparent; cursor: pointer; }

/* ── Placeholder (striped image stand-in) ─────────────────────────────────── */
.placeholder { position: relative; overflow: hidden; background: var(--surfaceAlt);
  border: 1px dashed var(--lineStrong); border-radius: 16px; display: flex;
  align-items: center; justify-content: center; }
.placeholder::before { content: ""; position: absolute; inset: 0;
  background-image: repeating-linear-gradient(45deg, var(--line) 0 1px, transparent 1px 11px); }
.placeholder .label { font-family: var(--mono); font-size: 11.5px; color: var(--inkFaint);
  letter-spacing: 0.4px; position: relative; background: var(--surfaceAlt);
  padding: 3px 8px; border-radius: 6px; }

/* ── Icons ────────────────────────────────────────────────────────────────── */
.ico { display: block; flex-shrink: 0; }

/* ── Bottom tab bar ───────────────────────────────────────────────────────── */
.tabbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0;
  width: 100%; max-width: 430px; padding: 10px 0 max(18px, env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-around; z-index: 40; }
.tabbar a { border: none; background: none; cursor: pointer; text-decoration: none;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--inkFaint); width: 56px; }
.tabbar a.on { color: var(--brand); }
.tabbar a .lbl { font-size: 10.5px; font-weight: 500; letter-spacing: 0.2px; }
.tabbar a.on .lbl { font-weight: 600; }
.tabbar a.new { margin-top: -26px; width: 56px; height: 56px; border-radius: 20px;
  background: var(--brand); color: var(--onBrand); display: flex; align-items: center;
  justify-content: center; box-shadow: 0 8px 20px var(--shadow); }

/* ── Reading rows / revisit cards ─────────────────────────────────────────── */
.revisit-card { padding: 16px; border-radius: 18px; margin-bottom: 12px; }
.revisit-card .meta { display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 10px; }
.revisit-card .meta .ago { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px;
  color: var(--inkFaint); font-weight: 500; }
.revisit-card .q { font-family: var(--serif); font-size: 18px; font-weight: 600; line-height: 1.25;
  letter-spacing: 0.1px; }
.revisit-card .quote { margin-top: 10px; padding-left: 12px; border-left: 2px solid var(--accent);
  font-size: 13.5px; color: var(--inkSoft); line-height: 1.45; font-style: italic; }
.revisit-card .actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.reading-row { width: 100%; border: none; background: none; cursor: pointer; text-align: left;
  display: flex; align-items: center; gap: 14px; padding: 12px 0; text-decoration: none; color: inherit; }
.reading-row .stack { display: flex; }
.reading-row .stack > * { margin-left: -16px; }
.reading-row .stack > *:first-child { margin-left: 0; }
.reading-row .body { flex: 1; min-width: 0; }
.reading-row .body .q { font-size: 15px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reading-row .body .sub { display: flex; align-items: center; gap: 8px; margin-top: 3px;
  font-size: 12.5px; color: var(--inkFaint); }
.reading-row .body .sub .dot { width: 3px; height: 3px; border-radius: 999px; background: var(--inkFaint); }
.cap { text-transform: capitalize; }

/* ── Selectable option tiles (spreads, outcomes) ──────────────────────────── */
.option { display: flex; align-items: center; gap: 14px; text-align: left; cursor: pointer;
  width: 100%; background: var(--surface); border: 1.5px solid var(--line); border-radius: 16px;
  padding: 14px; transition: all .12s; color: inherit; }
.option.on { background: var(--brandSoft); border-color: var(--brand); }
.option .ttl { font-size: 15.5px; font-weight: 600; color: var(--ink); }
.option .desc { font-size: 12.5px; color: var(--inkSoft); margin-top: 2px; }
.radio-dot { width: 20px; height: 20px; border-radius: 999px; flex-shrink: 0;
  border: 1.5px solid var(--lineStrong); display: flex; align-items: center; justify-content: center;
  color: var(--onBrand); }
.option.on .radio-dot { border-color: var(--brand); background: var(--brand); }

/* ── Misc layout utilities ────────────────────────────────────────────────── */
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; }
.wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.gap10 { gap: 10px; } .gap12 { gap: 12px; } .gap14 { gap: 14px; }
.mt8 { margin-top: 8px; } .mt14 { margin-top: 14px; } .mt18 { margin-top: 18px; }
.mt22 { margin-top: 22px; } .mt24 { margin-top: 24px; } .mt26 { margin-top: 26px; }
.mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; } .mb20 { margin-bottom: 20px; }
.grow { flex: 1; }
.back-btn { border: none; background: var(--surface); cursor: pointer; width: 38px; height: 38px;
  border-radius: 999px; display: flex; align-items: center; justify-content: center;
  color: var(--ink); box-shadow: 0 1px 4px var(--shadow); text-decoration: none; flex-shrink: 0; }
.flow-head { display: flex; align-items: center; gap: 10px; padding: 6px 0 14px; }
.flow-head .crumb { font-size: 12px; font-weight: 600; color: var(--accent); letter-spacing: 0.3px; }
.flow-head .ttl { font-family: var(--serif); font-size: 19px; font-weight: 600; margin-top: 1px; }
.avatar { width: 38px; height: 38px; border-radius: 999px; background: var(--brandSoft);
  display: flex; align-items: center; justify-content: center; font-family: var(--serif);
  font-weight: 600; font-size: 16px; color: var(--brand); border: 1px solid var(--line);
  text-decoration: none; }

/* ── Auth screens ─────────────────────────────────────────────────────────── */
.auth-wrap { max-width: 430px; margin: 0 auto; min-height: 100vh; display: flex;
  flex-direction: column; justify-content: center; padding: 32px 24px; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
  padding: 28px 22px; box-shadow: 0 2px 10px var(--shadow); }
.error-banner { background: var(--accentSoft); color: var(--accent); border-radius: 12px;
  padding: 11px 14px; font-size: 13.5px; font-weight: 600; margin-bottom: 16px; }
.flash { background: var(--brandSoft); color: var(--brand); border-radius: 12px;
  padding: 11px 14px; font-size: 13.5px; font-weight: 600; margin-bottom: 16px; }

/* ── Insights bars ────────────────────────────────────────────────────────── */
.bar-track { height: 10px; border-radius: 999px; background: var(--surfaceAlt); overflow: hidden;
  display: flex; }
.bar-seg { height: 100%; }
.freq-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; }
.freq-row .nm { font-size: 14px; font-weight: 600; min-width: 0; flex: 0 0 38%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.freq-row .track { flex: 1; height: 8px; border-radius: 999px; background: var(--surfaceAlt); overflow: hidden; }
.freq-row .fill { height: 100%; background: var(--brand); border-radius: 999px; }
.freq-row .ct { font-size: 12.5px; color: var(--inkFaint); width: 28px; text-align: right; }

/* dotted nudge overlay used on Today empty state */
.glimpse { position: relative; }
.glimpse .dim { filter: saturate(0.7); opacity: 0.55; pointer-events: none; }
.glimpse .badge { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.glimpse .badge span { font-size: 12.5px; font-weight: 600; color: var(--inkSoft);
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 14px; box-shadow: 0 4px 14px var(--shadow); text-align: center; }

.empty-hero { text-align: center; padding: 28px 22px; border-radius: 22px; margin-bottom: 20px; }
.empty-hero .fan { display: flex; justify-content: center; margin-bottom: 18px; }
.empty-hero p { margin: 0 auto 20px; font-size: 14.5px; color: var(--inkSoft); line-height: 1.5; max-width: 280px; }

/* ── Native-input enhancements (work without JS via :has) ─────────────────── */
.chip-check input, .option input, .rev-toggle input, .outcome-tile input { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.chip-check { cursor: pointer; }
.chip-check:has(input:checked) { border-color: transparent; background: var(--brandSoft); color: var(--brand); }
.chip-check.accent:has(input:checked) { background: var(--accentSoft); color: var(--accent); }
.option:has(input:checked) { background: var(--brandSoft); border-color: var(--brand); }
.option:has(input:checked) .radio-dot { border-color: var(--brand); background: var(--brand); }
.option .radio-dot .ico { display: none; }
.option:has(input:checked) .radio-dot .ico { display: block; }

/* card position row */
.pos-row { display: flex; align-items: center; gap: 14px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.pos-row .pos-label { font-size: 11.5px; font-weight: 700; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--inkFaint); }
.pos-row select.input { margin-top: 4px; padding: 8px 32px 8px 12px; font-size: 14px; }
.rev-toggle { display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer;
  color: var(--inkFaint); border: none; background: none; -webkit-tap-highlight-color: transparent; }
.rev-toggle:has(input:checked) { color: var(--accent); }
.rev-toggle .lbl { font-size: 10px; font-weight: 600; }
.rev-toggle .up { display: inline; } .rev-toggle .rv { display: none; }
.rev-toggle:has(input:checked) .up { display: none; } .rev-toggle:has(input:checked) .rv { display: inline; }

/* prediction card */
.pred-box { background: var(--accentSoft); border-radius: 16px; padding: 16px; }
.pred-prompt { width: 100%; cursor: pointer; text-align: left; background: var(--accentSoft);
  border: 1px dashed var(--accent); border-radius: 16px; padding: 16px; display: flex;
  align-items: center; gap: 12px; color: inherit; }

/* outcome tiles (verification) */
.outcome-tiles { display: flex; flex-direction: column; gap: 10px; }
.outcome-tile { display: flex; align-items: center; gap: 14px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 16px; padding: 15px; color: inherit; }
.outcome-tile:has(input:checked) { background: var(--brandSoft); border-color: var(--brand); }
.outcome-tile .glyph { color: var(--inkSoft); flex-shrink: 0; }
.outcome-tile:has(input:checked) .glyph { color: var(--brand); }
.outcome-tile .ttl { font-size: 15.5px; font-weight: 600; color: var(--ink); }
.outcome-tile .desc { font-size: 12.5px; color: var(--inkSoft); margin-top: 2px; }
/* outcome spectrum (then & now) */
.spectrum { display: flex; gap: 6px; }
.spectrum .outcome-tile { flex: 1; flex-direction: column; align-items: center; gap: 7px;
  padding: 12px 6px; text-align: center; border-radius: 12px; }
.spectrum .outcome-tile .ttl { font-size: 10.5px; }

/* checkbox (use-as-default, generic) */
.check-line { display: flex; align-items: center; gap: 9px; cursor: pointer; border: none;
  background: none; padding: 0; margin-top: 12px; }
.check-box { width: 20px; height: 20px; border-radius: 6px; flex-shrink: 0; border: 1.5px solid var(--lineStrong);
  background: transparent; display: flex; align-items: center; justify-content: center; color: var(--accentInk); }
.check-line input { position: absolute; opacity: 0; width: 0; height: 0; }
.check-line:has(input:checked) .check-box { border-color: var(--accent); background: var(--accent); }
.check-box .ico { display: none; } .check-line:has(input:checked) .check-box .ico { display: block; }
.check-line .txt { font-size: 13px; color: var(--inkSoft); font-weight: 500; text-align: left; }

/* segmented control (Library tabs) */
.segmented { display: flex; gap: 6px; background: var(--surfaceAlt); border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.segmented a { flex: 1; text-align: center; padding: 9px; border-radius: 9px; font-size: 13.5px;
  font-weight: 600; color: var(--inkSoft); text-decoration: none; }
.segmented a.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px var(--shadow); }
.segmented { overflow-x: auto; }
.segmented a { white-space: nowrap; }

/* card grid (Library cards) — responsive columns */
.card-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

/* custom-spread builder rows */
.custom-pos-row { gap: 8px; }
.custom-pos-row .custom-pos-remove { flex-shrink: 0; padding: 8px 10px; }

/* ── Desktop / wide layout ────────────────────────────────────────────────────
   Mobile-first stays the baseline; from 900px the bottom tab bar becomes a left
   rail and the content gets room to breathe. */
@media (min-width: 900px) {
  body { background: var(--paper); padding-left: 232px; }

  /* Bottom tab bar → vertical left rail */
  .tabbar {
    flex-direction: column; justify-content: flex-start; align-items: stretch;
    left: 0; transform: none; top: 0; bottom: auto;
    width: 232px; height: 100vh; max-width: none;
    border-top: none; border-right: 1px solid var(--line);
    padding: 28px 16px; gap: 4px; overflow-y: auto;
  }
  .tabbar a { flex-direction: row; justify-content: flex-start; gap: 13px; width: auto;
    padding: 11px 14px; border-radius: 12px; }
  .tabbar a.on { background: var(--brandSoft); }
  .tabbar a .lbl { font-size: 14.5px; }
  .tabbar a.new { margin: 4px 0 8px; width: auto; height: auto; border-radius: 12px;
    padding: 12px 14px; justify-content: flex-start; gap: 13px; box-shadow: none; }
  .tabbar a.new::after { content: "New reading"; font-size: 14.5px; font-weight: 600; }

  /* Content column: centered in the space beside the rail, capped for line length */
  .app { max-width: 920px; box-shadow: none !important; min-height: 100vh; }
  .screen { padding: 40px 48px 64px; }

  /* More columns where a grid pays off on a wide screen */
  .card-grid { grid-template-columns: repeat(6, 1fr); gap: 16px; }
}

@media (min-width: 1280px) {
  .card-grid { grid-template-columns: repeat(8, 1fr); }
}

/* ── v0.3 — runes, photo capture, deep library, formulas, PWA ──────────────── */
.card-token.rune .art { background: var(--surfaceAlt); }
.card-token.rune .glyph { color: var(--ink); font-weight: 500; text-shadow: 0 1px 0 var(--surfaceAlt); }

/* Photo: take / upload buttons */
.photo-actions { display: flex; gap: 10px; }
.photo-btn { flex: 1; cursor: pointer; border: 1px solid var(--line); background: var(--surface);
  border-radius: 16px; padding: 20px 12px; display: flex; flex-direction: column; align-items: center;
  gap: 8px; color: var(--brand); -webkit-tap-highlight-color: transparent; }
.photo-btn span { font-size: 13.5px; font-weight: 600; color: var(--ink); }

/* Camera overlay */
.cam-wrap { position: relative; border-radius: 16px; overflow: hidden; background: #15110f; }
.cam-wrap video { display: block; width: 100%; max-height: 60vh; object-fit: cover; }
.cam-grid { position: absolute; inset: 0; pointer-events: none; }
.cam-frame { position: absolute; left: 12%; right: 12%; top: 16%; bottom: 16%;
  border: 1.5px solid var(--accent); border-radius: 8px; pointer-events: none; }
.cam-tip { position: absolute; top: 12px; left: 12px; display: inline-flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,.55); color: #fff; border-radius: 999px; padding: 5px 11px; font-size: 12px; font-weight: 600; }
.cam-tip .dot { width: 7px; height: 7px; border-radius: 999px; background: var(--accent); }
.cam-bar { display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 14px 8px 8px; }
.cam-shutter { width: 64px; height: 64px; border-radius: 999px; background: #fff;
  border: 4px solid rgba(255,255,255,.45); cursor: pointer; flex-shrink: 0; }
.cam-icon-btn { width: 44px; height: 44px; border-radius: 999px; border: none; background: rgba(255,255,255,.12);
  color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.cam-close { position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; border-radius: 999px;
  border: none; background: rgba(0,0,0,.5); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }

/* Kebab menu (reading detail) */
.kebab-wrap { position: relative; }
.kebab-btn { border: none; background: var(--surface); cursor: pointer; width: 38px; height: 38px;
  border-radius: 999px; display: flex; align-items: center; justify-content: center; color: var(--ink);
  box-shadow: 0 1px 4px var(--shadow); }
.kebab-menu { position: absolute; right: 0; top: 44px; z-index: 30; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 24px var(--shadow);
  min-width: 168px; overflow: hidden; }
.kebab-menu[hidden] { display: none; }
.kebab-menu a, .kebab-menu button { display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 12px 14px; font-size: 14.5px; font-weight: 500; color: var(--ink); background: none;
  border: none; cursor: pointer; text-align: left; text-decoration: none; }
.kebab-menu a:hover, .kebab-menu button:hover { background: var(--surfaceAlt); }
.kebab-menu .danger { color: var(--accent); }

/* Deep card detail */
.card-hero { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.card-hero .meta { min-width: 0; }
.card-hero .el { font-family: var(--mono); font-size: 11px; color: var(--inkFaint); letter-spacing: 0.4px; }
.kw-wrap { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.orient-toggle { display: flex; gap: 6px; background: var(--surfaceAlt); border-radius: 12px; padding: 4px; }
.orient-toggle label { flex: 1; text-align: center; padding: 9px; border-radius: 9px; font-size: 13.5px;
  font-weight: 600; color: var(--inkSoft); cursor: pointer; }
.orient-toggle label:has(input:checked) { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px var(--shadow); }
.orient-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.lens-block { display: flex; gap: 12px; padding: 14px 0; }
.lens-ico { width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0; background: var(--brandSoft);
  color: var(--brand); display: flex; align-items: center; justify-content: center; }
.lens-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.lens-label { font-size: 12.5px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--ink); }
.lens-text { font-size: 14.5px; color: var(--inkSoft); line-height: 1.6; }
/* orientation-driven show/hide of lens text (no-JS via :has) */
.card-detail:has(.orient-toggle input[value="reversed"]:checked) .lens-up { display: none; }
.card-detail:has(.orient-toggle input[value="upright"]:checked) .lens-rev { display: none; }

/* Formulas */
.formula-card { display: block; width: 100%; text-align: left; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px;
  box-shadow: 0 2px 10px var(--shadow); margin-bottom: 12px; }
.formula-glyphs { font-family: var(--serif); font-size: 30px; color: var(--brand); letter-spacing: 3px; line-height: 1; }
.formula-preview { background: var(--brand); color: var(--onBrand); border-radius: 20px; padding: 26px 18px;
  min-height: 46px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.formula-preview .glyphs { font-size: 40px; letter-spacing: 4px; line-height: 1; }
.rune-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.rune-pick { aspect-ratio: 1; border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
  font-size: 24px; color: var(--ink); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.rune-pick:active { background: var(--brandSoft); }

/* Install banner / iOS hint (global, JS-controlled) */
.install-banner { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom));
  width: calc(100% - 32px); max-width: 398px; z-index: 60; background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 14px; box-shadow: 0 8px 30px var(--shadow); }
.install-banner[hidden] { display: none; }
.install-banner .row { gap: 12px; align-items: flex-start; }
.install-icon { width: 44px; height: 44px; border-radius: 11px; flex-shrink: 0; }
.install-banner .ttl { font-size: 14.5px; font-weight: 700; }
.install-banner .sub { font-size: 12.5px; color: var(--inkSoft); line-height: 1.5; }
.install-actions { display: flex; gap: 8px; margin-top: 12px; }
.install-x { border: none; background: none; color: var(--inkFaint); cursor: pointer; flex-shrink: 0; }

/* Safe-area top padding so content clears the iOS notch / status bar in standalone */
@media (display-mode: standalone) {
  .screen { padding-top: calc(22px + env(safe-area-inset-top)); }
  .auth-wrap { padding-top: calc(32px + env(safe-area-inset-top)); }
}

.kebab-wrap { list-style: none; }
.kebab-wrap > summary { list-style: none; cursor: pointer; }
.kebab-wrap > summary::-webkit-details-marker { display: none; }
.flow-head .kebab-wrap { flex-shrink: 0; }

/* ── v0.6 — Journal, Rituals, Library hub, nav ──────────────────────────────── */
.tab-dot { position: absolute; top: -2px; right: -5px; width: 8px; height: 8px; border-radius: 999px;
  background: var(--accent); border: 1.5px solid var(--surface); }
.hdr-btn { width: 38px; height: 38px; border-radius: 999px; background: var(--brandSoft); color: var(--brand);
  display: flex; align-items: center; justify-content: center; text-decoration: none; border: 1px solid var(--line); flex-shrink: 0; }
.hdr-actions { display: flex; align-items: center; gap: 10px; }

/* Library hub */
.hub-row { display: flex; align-items: center; gap: 14px; width: 100%; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px;
  box-shadow: 0 2px 10px var(--shadow); margin-bottom: 12px; }
.hub-ico { width: 46px; height: 46px; border-radius: 13px; flex-shrink: 0; background: var(--brandSoft); color: var(--brand);
  display: flex; align-items: center; justify-content: center; }
.hub-row .body { flex: 1; min-width: 0; }
.hub-row .ttl { font-family: var(--serif); font-size: 18px; font-weight: 600; line-height: 1.1; }
.hub-row .sub { font-size: 13px; color: var(--inkSoft); margin-top: 3px; }
.hub-row .ct { font-size: 13px; color: var(--inkFaint); font-variant-numeric: tabular-nums; }
.hub-row.featured { background: var(--accentSoft); border-color: transparent; }
.hub-row.featured .hub-ico { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }

.ref-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ref-grid > :nth-child(3):last-child { grid-column: 1 / -1; }
.ref-tile { display: block; text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 14px; box-shadow: 0 2px 10px var(--shadow); }
.ref-tile.featured { background: var(--accentSoft); border-color: transparent; }
.ref-art { height: 88px; border-radius: 12px; background: var(--surfaceAlt); position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.ref-art::before { content: ""; position: absolute; inset: 0;
  background-image: repeating-linear-gradient(45deg, var(--line) 0 1px, transparent 1px 9px); }
.ref-tile.featured .ref-art { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.ref-fan { position: relative; display: flex; }
.ref-fan span { font-size: 26px; color: var(--accent); }
.ref-tile .ttl { font-family: var(--serif); font-size: 16.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.ref-tile .sub { font-size: 12px; color: var(--inkFaint); margin-top: 2px; }
.ref-spark { color: var(--accent); }

/* Pinned formulas card in the runes browser */
.pin-card { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit;
  background: var(--accentSoft); border: 1px solid transparent; border-radius: 18px; padding: 16px; margin-bottom: 18px; }
.pin-card .ico-wrap { width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, transparent); display: flex; align-items: center; justify-content: center; }

/* Rituals */
.ritual-card { display: flex; align-items: center; gap: 14px; width: 100%; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px; box-shadow: 0 2px 10px var(--shadow); margin-bottom: 12px; }
.ritual-ico { width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0; background: var(--brandSoft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; }
.ritual-card .ttl { font-family: var(--serif); font-size: 17px; font-weight: 600; line-height: 1.15; }
.ritual-card .sub { font-size: 13px; color: var(--inkSoft); margin-top: 2px; }
.ritual-meta { display: flex; align-items: center; gap: 10px; margin-top: 7px; font-size: 12px; color: var(--inkFaint); }
.ritual-meta .dur { display: inline-flex; align-items: center; gap: 4px; }
.ritual-intro { font-family: var(--serif); font-size: 18px; font-style: italic; color: var(--inkSoft); line-height: 1.5; margin: 6px 0 22px; }
.need-row { display: flex; align-items: flex-start; gap: 10px; padding: 11px 0; font-size: 14.5px; line-height: 1.45; }
.need-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--accent); flex-shrink: 0; margin-top: 7px; }
.step-row { display: flex; gap: 14px; padding: 12px 0; }
.step-n { width: 28px; height: 28px; border-radius: 999px; flex-shrink: 0; background: var(--brand); color: var(--onBrand);
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; }
.step-row .txt { font-size: 15px; line-height: 1.5; padding-top: 3px; }

/* Journal notes + follow-ups */
.note-card { display: block; width: 100%; text-align: left; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; box-shadow: 0 2px 10px var(--shadow); margin-bottom: 12px; }
.note-card .top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.note-card .ttl { font-family: var(--serif); font-size: 17px; font-weight: 600; }
.note-card .date { font-size: 12.5px; color: var(--inkFaint); flex-shrink: 0; }
.note-card .snip { font-size: 14px; color: var(--inkSoft); line-height: 1.5; margin-top: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.note-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; font-size: 11.5px; color: var(--inkFaint); }
.note-tag { font-size: 10.5px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--inkSoft);
  background: var(--surfaceAlt); padding: 3px 8px; border-radius: 6px; }
.fu-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; box-shadow: 0 2px 10px var(--shadow); margin-bottom: 12px; }
.fu-head { display: flex; gap: 12px; align-items: flex-start; }
.fu-ico { width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0; background: var(--surfaceAlt); color: var(--inkSoft);
  display: flex; align-items: center; justify-content: center; }
.fu-kind { font-size: 11.5px; color: var(--inkFaint); }
.fu-title { font-family: var(--serif); font-size: 16px; font-weight: 600; margin-top: 1px; line-height: 1.2; }
.fu-sub { font-size: 13px; color: var(--inkSoft); line-height: 1.45; margin-top: 5px; }
.fu-actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.note-rdg { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--brand);
  text-decoration: none; margin-bottom: 16px; }
.note-rdg:hover { text-decoration: underline; }
.note-body { font-size: 16px; line-height: 1.65; color: var(--ink); white-space: pre-wrap; margin-bottom: 20px; }
.note-footer { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12.5px; color: var(--inkFaint); padding-top: 16px;
  border-top: 1px solid var(--line); }
