:root {
  --desk: #161412;
  --shell-bg: #1F1C18;
  --parchment: #F8F4E8;
  --parchment-2: #EFE7D3;
  --parchment-3: #E3D7BC;
  --surface-elevated: #FCF9F0;
  --ink: #1C1A17;
  --ink-soft: #3D3830;
  --ink-muted: #665E52;
  --ochre: #C88A4B;
  --ochre-dark: #8A5624;
  --ochre-tint: #F4E6D0;
  --rust: #C4452B;
  --rust-bg: #F7E1DC;
  --sage: #3F5E3A;
  --sage-bg: #DFEAD9;
  --border: #D2C4AA;
  --border-strong: #B8A688;
  --shadow-sm: 0 2px 6px rgba(24, 20, 14, 0.06);
  --shadow-md: 0 10px 28px rgba(18, 15, 10, 0.14);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

body.night-red {
  --desk: #050202;
  --shell-bg: #0C0404;
  --parchment: #130707;
  --parchment-2: #1B0A0A;
  --parchment-3: #270F0F;
  --surface-elevated: #180909;
  --ink: #E54B3B;
  --ink-soft: #CC4133;
  --ink-muted: #9E3429;
  --ochre: #B83527;
  --ochre-dark: #E04838;
  --ochre-tint: #260C0A;
  --rust: #FF5C4A;
  --rust-bg: #290B09;
  --sage: #CF4032;
  --sage-bg: #220A08;
  --border: #481814;
  --border-strong: #66221C;
}
body.night-red svg:not(.no-red-filter),
body.night-red img {
  filter: sepia(1) hue-rotate(-50deg) saturate(3) brightness(0.72) contrast(1.25);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: radial-gradient(circle at 50% 0%, #2B2620 0%, var(--desk) 80%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

button, input, textarea { font-family: inherit; }

/* App Shell: Desktop Full Workspace vs Phone Preview Mode */
.app-shell {
  width: 100%;
  max-width: 1480px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  background: var(--parchment);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

body.phone-preview {
  padding: 16px 10px;
  display: flex;
  justify-content: center;
  align-items: center;
}
body.phone-preview .app-shell {
  max-width: 430px;
  height: calc(100vh - 32px);
  border-radius: 30px;
  border: 6px solid var(--shell-bg);
  position: relative;
}

/* Top Bar */
.topbar {
  background: #1B1916;
  color: #F6F1E3;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 2px solid var(--ochre);
  flex-shrink: 0;
  z-index: 25;
}
body.night-red .topbar { background: #160606; color: var(--ink); }

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.brand-mark { font-size: 20px; line-height: 1; }
.brand-title {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: 16.5px;
  letter-spacing: 0.07em;
}
.brand-sub {
  font-size: 10.5px;
  color: #CBBBA0;
  letter-spacing: 0.03em;
}
body.night-red .brand-sub { color: var(--ink-muted); }

.topbar-search {
  flex: 1;
  max-width: 440px;
}
.cmdk-trigger {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #DFD5C2;
  border-radius: 10px;
  padding: 7px 11px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12.5px;
  transition: background 0.15s, border-color 0.15s;
}
.cmdk-trigger:hover {
  background: rgba(255, 255, 255, 0.13);
  border-color: var(--ochre);
}
.cmdk-placeholder { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdk-kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 1.5px 6px;
  border-radius: 5px;
  color: #F6F1E3;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.status-pill {
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
}
.member-pill {
  background: var(--sage);
  color: #FFF;
  border-color: #7FA878;
}
.member-pill.free-mode {
  background: rgba(255, 255, 255, 0.1);
  color: #E3D7BC;
  border-color: rgba(255, 255, 255, 0.22);
}
.rank-pill {
  background: var(--ochre);
  color: #1C1A17;
}
.grocy-pill {
  background: rgba(255, 255, 255, 0.1);
  color: #F6F1E3;
  border-color: rgba(255, 255, 255, 0.2);
}
.grocy-pill.live {
  background: var(--sage);
  color: #FFF;
  border-color: #7FA878;
}
.segmented-device {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 9px;
  padding: 2px;
}
.seg-btn {
  background: transparent;
  border: none;
  color: #CBBBA0;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.seg-btn.active {
  background: var(--parchment);
  color: #1C1A17;
}
body.night-red .seg-btn.active {
  background: var(--rust);
  color: #120505;
}
.icon-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #F6F1E3;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}
.icon-btn.active {
  background: var(--rust);
  border-color: var(--rust);
  color: #FFF;
}

/* Workspace Body Columns */
.workspace-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* Left Navigation Rail */
.side-rail {
  width: 224px;
  background: var(--parchment-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 10px;
  flex-shrink: 0;
  overflow-y: auto;
}
.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rail-btn {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 11px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.rail-btn:hover {
  background: var(--parchment);
  border-color: var(--border);
}
.rail-btn.active {
  background: var(--ink);
  color: var(--parchment);
  border-color: var(--ink);
  box-shadow: var(--shadow-sm);
}
body.night-red .rail-btn.active {
  background: var(--rust);
  color: #120505;
  border-color: var(--rust);
}
.rail-ico { font-size: 18px; line-height: 1; flex-shrink: 0; }
.rail-txt { display: flex; flex-direction: column; min-width: 0; }
.rail-txt strong { font-size: 13.5px; font-weight: 700; line-height: 1.2; }
.rail-txt small { font-size: 11px; opacity: 0.78; margin-top: 2px; }

.rail-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.rail-stat-box {
  background: var(--parchment);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font-size: 11.5px;
}
.rail-links {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.rail-ext-link {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ochre-dark);
  text-decoration: none;
  padding: 5px 8px;
  border-radius: 7px;
  background: var(--parchment);
  border: 1px solid var(--border);
}
.rail-ext-link:hover { background: var(--ochre-tint); }

/* Center Main Stage */
.stage-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 18px 22px 48px;
}

/* Right Split Reader Pane */
.reader-pane {
  width: 470px;
  background: var(--surface-elevated);
  border-left: 1.5px solid var(--border-strong);
  overflow-y: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.reader-pane.hidden-pane {
  display: none;
}

/* Responsive & Phone Preview Overrides */
.mobile-tabbar { display: none; }

@media (max-width: 1180px) {
  .reader-pane { display: none !important; }
  .grocy-pill { display: none; }
}

@media (max-width: 860px) {
  .side-rail { display: none; }
  .segmented-device { display: none; }
  .member-pill { display: none; }
  .stage-main { padding: 12px 12px 84px; }
  .mobile-tabbar {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    background: #1B1916;
    color: #CBBBA0;
    border-top: 2px solid var(--ochre);
    flex-shrink: 0;
    z-index: 25;
  }
}

body.phone-preview .side-rail,
body.phone-preview .reader-pane,
body.phone-preview .grocy-pill,
body.phone-preview .member-pill,
body.phone-preview .brand-sub,
body.phone-preview .cmdk-kbd {
  display: none !important;
}
body.phone-preview .topbar { padding: 10px 12px; gap: 6px; }
body.phone-preview .brand-title { font-size: 14px; }
body.phone-preview .cmdk-placeholder { font-size: 11.5px; }
body.phone-preview .stage-main { padding: 12px 12px 80px; }
body.phone-preview .mobile-tabbar {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  background: #1B1916;
  color: #CBBBA0;
  border-top: 2px solid var(--ochre);
  flex-shrink: 0;
}

.mob-tab {
  background: none;
  border: none;
  color: inherit;
  padding: 8px 4px 10px;
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.mob-tab.active {
  color: #F6F1E3;
  background: rgba(200, 138, 75, 0.2);
}
body.night-red .mob-tab.active { color: var(--rust); }

/* Reusable Section Headers & Toolbars */
.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.view-eyebrow {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ochre-dark);
}
.view-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 23px;
  font-weight: 700;
  margin: 2px 0 0;
  line-height: 1.18;
}
body.phone-preview .view-title { font-size: 19px; }

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

.btn {
  background: var(--parchment-2);
  color: var(--ink);
  border: 1px solid var(--border-strong);
  padding: 6.5px 12px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.12s, transform 0.08s;
}
.btn:hover { background: var(--parchment-3); }
.btn-primary {
  background: var(--ink);
  color: var(--parchment);
  border-color: var(--ink);
}
.btn-primary:hover { opacity: 0.92; background: var(--ink); }
body.night-red .btn-primary { background: var(--rust); color: #120505; border-color: var(--rust); }

.btn-ochre {
  background: var(--ochre);
  color: #1C1A17;
  border-color: var(--ochre-dark);
}
.btn-sage {
  background: var(--sage);
  color: #FFF;
  border-color: var(--sage);
}
.chip-sm {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
  background: var(--parchment-2);
  color: var(--ink-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  cursor: pointer;
}

/* Badges & Card IDs */
.cid {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 800;
  color: var(--ochre-dark);
  background: var(--parchment-2);
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--border);
}
.badge {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6.5px;
  border-radius: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge-ill { background: var(--sage); color: #FFF; }
.badge-bot { background: var(--sage-bg); color: var(--sage); border: 1px solid var(--sage); }
.badge-done { background: var(--ochre); color: #1C1A17; }
.badge-rust { background: var(--rust-bg); color: var(--rust); border: 1px solid var(--rust); }
.badge-muted { background: var(--parchment-3); color: var(--ink-soft); }

/* ==========================================================================
   1. READINESS DASHBOARD
   ========================================================================== */
.readiness-top-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}
@media (max-width: 900px) { .readiness-top-grid { grid-template-columns: 1fr; } }
body.phone-preview .readiness-top-grid { grid-template-columns: 1fr; }

.hero-card {
  background: linear-gradient(155deg, var(--parchment-2) 0%, var(--parchment-3) 100%);
  border: 1.5px solid var(--ochre);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}
.score-dial {
  position: relative;
  width: 92px;
  height: 92px;
  flex-shrink: 0;
}
.score-dial-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.score-pts { font-size: 22px; font-weight: 800; line-height: 1; }
.score-max { font-size: 9.5px; color: var(--ink-muted); font-weight: 700; margin-top: 2px; }

.bottleneck-panel {
  background: var(--rust-bg);
  border: 1.5px solid var(--rust);
  border-left: 5px solid var(--rust);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}
.bottleneck-panel.all-clear {
  background: var(--sage-bg);
  border-color: var(--sage);
}

/* Rung Stepper Cards (7 Rungs: L1..L6 + R0 Proof) */
.rung-stepper {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 7px;
  margin-bottom: 14px;
}
@media (max-width: 860px) { .rung-stepper { grid-template-columns: repeat(4, 1fr); } }
body.phone-preview .rung-stepper { grid-template-columns: repeat(3, 1fr); }

.rung-tab {
  background: var(--surface-elevated);
  border: 1.5px solid var(--border);
  border-radius: 11px;
  padding: 9px 10px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s, transform 0.08s;
}
.rung-tab:hover { border-color: var(--ochre-dark); }
.rung-tab.earned {
  background: var(--sage-bg);
  border-color: var(--sage);
}
.rung-tab.active {
  outline: 2.5px solid var(--ink);
  background: var(--parchment-2);
}
body.night-red .rung-tab.active { outline-color: var(--rust); }

.rung-tab-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  font-weight: 800;
}
.rung-tab-name {
  font-size: 11px;
  color: var(--ink-muted);
  margin: 3px 0 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mini-bar {
  height: 5px;
  background: var(--parchment-3);
  border-radius: 4px;
  overflow: hidden;
}
.mini-bar > div { height: 100%; border-radius: 4px; }

/* Pillar Filter Bar */
.pillar-strip {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}
.pillar-chip {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.pillar-chip.active {
  background: var(--ink);
  color: var(--parchment);
  border-color: var(--ink);
}
body.night-red .pillar-chip.active { background: var(--rust); color: #120505; }

/* Gate Checklist Card */
.gate-section {
  background: var(--surface-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.gate-sec-head {
  background: var(--parchment-2);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.gate-row {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: background 0.1s;
}
.gate-row:first-child { border-top: none; }
.gate-row:hover { background: var(--parchment); }
.gate-row.checked { background: rgba(223, 234, 217, 0.28); }
.gate-row.checked .gate-title { text-decoration: line-through; opacity: 0.72; }
.gate-row.revoked { background: var(--rust-bg); border-left: 4px solid var(--rust); }

.chk-box {
  width: 23px;
  height: 23px;
  border-radius: 7px;
  border: 2px solid var(--ochre-dark);
  background: var(--surface-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 900;
  color: #FFF;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
}
.gate-row.checked .chk-box { background: var(--sage); border-color: var(--sage); }
.gate-body { flex: 1; min-width: 0; }
.gate-title { font-size: 13.5px; font-weight: 700; cursor: pointer; line-height: 1.3; }
.gate-sub { font-size: 12px; color: var(--ink-muted); margin-top: 3px; }

/* ==========================================================================
   2. FIELD MANUAL BROWSER
   ========================================================================== */
.module-cards-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
body.phone-preview .module-cards-strip {
  display: flex;
  overflow-x: auto;
  padding-bottom: 4px;
}
body.phone-preview .mod-tile { min-width: 128px; flex-shrink: 0; }

.mod-tile {
  background: var(--surface-elevated);
  border: 1.5px solid var(--border);
  border-radius: 11px;
  padding: 9px 11px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.mod-tile:hover { border-color: var(--ochre-dark); }
.mod-tile.active {
  background: var(--ink);
  color: var(--parchment);
  border-color: var(--ink);
}
body.night-red .mod-tile.active { background: var(--rust); color: #120505; }
.mod-tile-id { font-size: 10.5px; font-weight: 800; opacity: 0.78; text-transform: uppercase; }
.mod-tile-name { font-size: 13px; font-weight: 700; margin: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mod-tile-cnt { font-size: 11px; opacity: 0.8; }

.manual-toolbar {
  background: var(--parchment-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.inline-search {
  flex: 1;
  min-width: 200px;
  background: var(--surface-elevated);
  color: var(--ink);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 13px;
  outline: none;
}
.inline-search:focus { border-color: var(--ochre-dark); }

/* Chapter Blocks & Pinned #00 Briefs */
.chapter-card {
  background: var(--surface-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.chapter-bar {
  background: var(--parchment-2);
  padding: 11px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border);
}
.brief-banner {
  background: var(--rust-bg);
  border-bottom: 1.5px solid var(--border);
  border-left: 5px solid var(--rust);
  padding: 12px 15px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.brief-banner:hover { filter: brightness(0.98); }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(265px, 1fr));
}
body.phone-preview .cards-grid { grid-template-columns: 1fr; }

.manual-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: var(--surface-elevated);
  transition: background 0.1s;
}
.manual-item:hover { background: var(--parchment-2); }
.manual-item.selected-card {
  background: var(--ochre-tint);
  box-shadow: inset 4px 0 0 var(--ochre-dark);
}
.manual-item.has-art { border-left: 3px solid var(--sage); }

/* Illustrated Showcase Gallery Mode inside Manual */
.art-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
}
.art-card {
  background: var(--surface-elevated);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
  box-shadow: var(--shadow-sm);
}
.art-card:hover { transform: translateY(-2px); border-color: var(--ochre-dark); }
.art-card.selected-card { outline: 2.5px solid var(--ochre-dark); }
.art-thumb {
  background: var(--parchment);
  padding: 7px;
  border-bottom: 1px solid var(--border);
}
.art-thumb svg { width: 100%; height: auto; display: block; border-radius: 7px; }
.art-meta { padding: 11px 13px 13px; }

/* ==========================================================================
   3. GREAT LAKES FLORA GRID (60 MONOGRAPHS + REAL MICHIGAN PHOTOS)
   ========================================================================== */
.flora-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(245px, 1fr));
  gap: 14px;
}
body.phone-preview .flora-grid { grid-template-columns: 1fr; }

.flora-card {
  background: var(--surface-elevated);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s, border-color 0.12s;
}
.flora-card:hover { transform: translateY(-2px); border-color: var(--sage); }
.flora-card.selected-card { outline: 2.5px solid var(--sage); }

.flora-img-wrap {
  position: relative;
  height: 168px;
  background: #23201C;
  overflow: hidden;
}
.flora-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.flora-chip-tl {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(24, 21, 18, 0.86);
  color: #F6F1E3;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  font-weight: 800;
  padding: 2.5px 7px;
  border-radius: 6px;
}
.flora-chip-tr {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--sage);
  color: #FFF;
  font-size: 10px;
  font-weight: 800;
  padding: 2.5px 7px;
  border-radius: 6px;
  text-transform: uppercase;
}
.flora-body {
  padding: 11px 13px 13px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}
.sci-name { font-style: italic; font-size: 12px; color: var(--ink-muted); }

/* ==========================================================================
   4. RIGHT SPLIT READER PANE & MOBILE SHEET
   ========================================================================== */
.reader-inner {
  padding: 16px 18px 36px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.reader-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.reader-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.22;
  margin-top: 5px;
}

.plate-stage {
  background: var(--parchment-2);
  border: 1.5px solid var(--border);
  border-radius: 13px;
  padding: 10px;
}
.plate-stage-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.plate-svg-box svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.plate-caption {
  font-size: 12.5px;
  font-weight: 700;
  padding: 8px 4px 4px;
  line-height: 1.38;
}
.plate-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}
.step-dots { display: flex; gap: 6px; }
.dot {
  width: 28px;
  height: 7px;
  border-radius: 4px;
  background: var(--border-strong);
  border: none;
  cursor: pointer;
}
.dot.active { background: var(--rust); }

.stacked-3up {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.stacked-panel-card {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px;
}
.stacked-panel-card svg { width: 100%; height: auto; display: block; border-radius: 6px; }

/* Reader Botanical Photo Strip */
.reader-photo-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.reader-photo-cell {
  background: var(--parchment-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  cursor: zoom-in;
}
.reader-photo-cell img {
  width: 100%;
  height: 112px;
  object-fit: cover;
  display: block;
}
.reader-photo-cap {
  padding: 4px 6px;
  font-size: 10px;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.callout {
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.44;
}
.callout-roi { background: var(--parchment-2); border-left: 4px solid var(--ochre-dark); }
.callout-trap { background: var(--rust-bg); border-left: 4px solid var(--rust); }
.callout-steward { background: var(--sage-bg); border-left: 4px solid var(--sage); }

.drill-box {
  background: var(--parchment-2);
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  padding: 11px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.chapter-adj-nav {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* ==========================================================================
   5. LAB & STUDIO (SIMULATOR + 3-UP SVG STUDIO + PACK)
   ========================================================================== */
.lab-subtabs {
  display: inline-flex;
  background: var(--parchment-2);
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  padding: 3px;
  gap: 4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.lab-subbtn {
  background: transparent;
  border: none;
  color: var(--ink-soft);
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.lab-subbtn.active {
  background: var(--ink);
  color: var(--parchment);
}
body.night-red .lab-subbtn.active { background: var(--rust); color: #120505; }

.sim-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) { .sim-grid { grid-template-columns: 1fr; } }
body.phone-preview .sim-grid { grid-template-columns: 1fr; }

.panel-card {
  background: var(--surface-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.kpi {
  background: var(--parchment-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px;
  text-align: center;
}
.kpi-val { font-size: 18px; font-weight: 800; }
.kpi-lbl { font-size: 10.5px; color: var(--ink-muted); margin-top: 2px; }

.slider-group { margin: 12px 0; }
.slider-label { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 700; margin-bottom: 4px; }
input[type=range] { width: 100%; accent-color: var(--ochre-dark); }

.three-up-row {
  background: var(--surface-elevated);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.three-up-panels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 10px;
}
@media (max-width: 820px) { .three-up-panels { grid-template-columns: 1fr; } }
body.phone-preview .three-up-panels { grid-template-columns: 1fr; }

.three-up-cell {
  background: var(--parchment);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px;
}
.three-up-cell svg { width: 100%; height: auto; display: block; border-radius: 6px; }

pre.json-view {
  background: #1B1916;
  color: #E8DFCE;
  padding: 12px;
  border-radius: 10px;
  font-size: 11px;
  overflow-x: auto;
  line-height: 1.42;
  margin: 8px 0 0;
}
textarea.dump-box {
  width: 100%;
  min-height: 78px;
  background: var(--parchment);
  color: var(--ink);
  border: 1.5px solid var(--border);
  border-radius: 9px;
  padding: 9px;
  font-size: 13px;
  margin: 8px 0;
}

/* ==========================================================================
   6. MODALS: MOBILE SHEET, COMMAND PALETTE (⌘K), PANTRY CONFIG, LIGHTBOX
   ========================================================================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(14, 11, 8, 0.68);
  z-index: 60;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.drawer-backdrop.open { display: flex; }
body.phone-preview .drawer-backdrop { position: absolute; }

.drawer-sheet {
  width: 100%;
  max-width: 640px;
  max-height: 92%;
  background: var(--surface-elevated);
  border-top: 3px solid var(--ochre);
  border-radius: 20px 20px 0 0;
  overflow-y: auto;
  box-shadow: 0 -12px 36px rgba(0, 0, 0, 0.45);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(14, 11, 8, 0.72);
  z-index: 80;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 7vh 16px 24px;
}
.modal-backdrop.open { display: flex; }

.cmdk-modal {
  width: 100%;
  max-width: 620px;
  background: var(--surface-elevated);
  border: 2px solid var(--ochre);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.cmdk-head {
  padding: 12px 14px;
  background: var(--parchment-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.cmdk-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 15px;
  color: var(--ink);
  font-weight: 600;
}
.cmdk-results {
  max-height: 390px;
  overflow-y: auto;
}
.cmdk-row {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.cmdk-row:hover,
.cmdk-row.active-hit {
  background: var(--ochre-tint);
}
.cmdk-foot {
  padding: 8px 14px;
  background: var(--parchment-2);
  font-size: 11px;
  color: var(--ink-muted);
  display: flex;
  gap: 16px;
}
.cmdk-foot kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}

.pantry-modal {
  width: 100%;
  max-width: 560px;
  background: var(--surface-elevated);
  border: 2px solid var(--ochre);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: var(--shadow-md);
  max-height: 86vh;
  overflow-y: auto;
}

.stepper-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--parchment-2);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 9px;
  font-weight: 700;
  font-size: 12.5px;
}
.step-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface-elevated);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.lightbox-card {
  width: 100%;
  max-width: 960px;
  background: var(--surface-elevated);
  border: 2px solid var(--ochre);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.lightbox-img-box {
  background: #12100E;
  max-height: 74vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}
.lightbox-img-box img {
  max-width: 100%;
  max-height: 72vh;
  object-fit: contain;
}

/* ==========================================================================
   7. READING ROOM (BOOK-PAGE EDITORIAL VIEW FOR #00 BRIEFS & 15 DRAWN CARDS)
   ========================================================================== */
.reading-room-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
@media (max-width: 960px) {
  .reading-room-layout { grid-template-columns: 1fr; }
}
body.phone-preview .reading-room-layout { grid-template-columns: 1fr; }

.toc-panel {
  background: var(--surface-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: sticky;
  top: 0;
  max-height: calc(100vh - 165px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}
@media (max-width: 960px) {
  .toc-panel { position: static; max-height: 240px; }
}
body.phone-preview .toc-panel { position: static; max-height: 220px; }

.toc-head {
  padding: 10px 12px;
  background: var(--parchment-2);
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ochre-dark);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.toc-list {
  overflow-y: auto;
  flex: 1;
}
.toc-group-lbl {
  padding: 7px 12px 4px;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  background: var(--parchment);
  border-top: 1px solid var(--border);
}
.toc-item {
  width: 100%;
  background: transparent;
  border: none;
  border-top: 1px solid rgba(184, 166, 136, 0.35);
  padding: 9px 12px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink);
  transition: background 0.1s;
}
.toc-item:hover { background: var(--parchment-2); }
.toc-item.active {
  background: var(--ochre-tint);
  box-shadow: inset 4px 0 0 var(--ochre-dark);
}
.toc-item-title {
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.28;
}

/* Book Page Card */
.book-page {
  background: var(--surface-elevated);
  border: 1.5px solid var(--border-strong);
  border-radius: 18px;
  padding: 26px 30px 28px;
  box-shadow: var(--shadow-md);
  max-width: 920px;
}
@media (max-width: 680px) {
  .book-page { padding: 16px 15px 20px; }
}
body.phone-preview .book-page { padding: 15px 14px 18px; }

.book-page-head {
  border-bottom: 2px solid var(--border);
  padding-bottom: 16px;
  margin-bottom: 18px;
}
.book-h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 27px;
  font-weight: 700;
  line-height: 1.18;
  margin: 8px 0 8px;
}
body.phone-preview .book-h1 { font-size: 20px; }

.stakes-lead {
  font-size: 15px;
  line-height: 1.52;
  color: var(--ink-soft);
  background: var(--parchment-2);
  border-left: 4px solid var(--ochre-dark);
  padding: 12px 15px;
  border-radius: 10px;
}

.section-kicker {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ochre-dark);
  margin: 20px 0 9px;
}

.materials-list,
.failure-list {
  margin: 0;
  padding: 12px 16px 12px 32px;
  border-radius: 11px;
  font-size: 13.5px;
  line-height: 1.48;
}
.materials-list {
  background: var(--parchment);
  border: 1px solid var(--border);
}
.materials-list li + li,
.failure-list li + li { margin-top: 6px; }

.failure-list {
  background: var(--rust-bg);
  border: 1px solid var(--rust);
}

/* Paired Plate + Detailed Step Prose Rows */
.step-story-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.step-story-row {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 16px;
  background: var(--parchment);
  border: 1.5px solid var(--border);
  border-radius: 13px;
  padding: 12px;
  align-items: center;
}
@media (max-width: 760px) {
  .step-story-row { grid-template-columns: 1fr; }
}
body.phone-preview .step-story-row { grid-template-columns: 1fr; }

.step-story-art svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.step-num-pill {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 800;
  background: var(--ink);
  color: var(--parchment);
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 5px;
}
body.night-red .step-num-pill { background: var(--rust); color: #120505; }
.step-story-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16.5px;
  font-weight: 700;
  margin: 0 0 6px;
  line-height: 1.25;
}
.step-story-body {
  font-size: 13.8px;
  line-height: 1.54;
  color: var(--ink);
}

/* Spec Reference Table */
.spec-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
}
.spec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--parchment);
}
.spec-table th {
  background: var(--parchment-2);
  text-align: left;
  padding: 9px 12px;
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1.5px solid var(--border-strong);
}
.spec-table td {
  padding: 9px 12px;
  border-top: 1px solid var(--border);
  line-height: 1.4;
}

/* Ranked Return-on-Sweat Ladder Cards on #00 Briefs */
.roi-ladder {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 10px;
}
.roi-step-card {
  background: var(--parchment);
  border: 1.5px solid var(--border);
  border-top: 4px solid var(--ochre-dark);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.42;
}

/* Editorial Margin & Page-Turner Bar */
.redline-bar {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.redline-note-input {
  flex: 1;
  min-width: 220px;
  background: var(--parchment);
  color: var(--ink);
  border: 1.5px solid var(--border-strong);
  border-radius: 9px;
  padding: 8px 11px;
  font-size: 13px;
}
.page-turner-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ==========================================================================
   8. QUARTERMASTER STOREFRONT & GUILD MEMBERSHIP FLYWHEEL
   ========================================================================== */
.membership-banner {
  background: linear-gradient(145deg, #231F1B 0%, #332B22 100%);
  color: #F8F4E8;
  border: 2px solid var(--ochre);
  border-radius: 16px;
  padding: 18px 20px;
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 16px;
  align-items: center;
  box-shadow: var(--shadow-md);
}
body.night-red .membership-banner {
  background: linear-gradient(145deg, #160606 0%, #240B0A 100%);
  color: var(--ink);
}
@media (max-width: 900px) { .membership-banner { grid-template-columns: 1fr; } }
body.phone-preview .membership-banner { grid-template-columns: 1fr; }

.store-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(305px, 1fr));
  gap: 16px;
}
body.phone-preview .store-grid { grid-template-columns: 1fr; }

.sku-card {
  background: var(--surface-elevated);
  border: 1.5px solid var(--border);
  border-radius: 15px;
  padding: 15px 16px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s, border-color 0.12s;
}
.sku-card:hover { transform: translateY(-2px); border-color: var(--ochre-dark); }
.sku-card.bottleneck-match {
  border-color: var(--ochre-dark);
  box-shadow: 0 0 0 2px var(--ochre-tint);
}
.sku-card.highlight-sku {
  outline: 2.5px solid var(--sage);
}
.sku-price-row {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.price-big { font-size: 20px; font-weight: 800; }
.price-strike { font-size: 12.5px; color: var(--ink-muted); text-decoration: line-through; margin-left: 6px; }

/* ==========================================================================
   9. MASTER BUILD CHAINS (PARENT PROJECT CARDS & STEPPER BREADCRUMBS)
   ========================================================================== */
.chain-banner {
  background: linear-gradient(135deg, var(--ochre-tint) 0%, var(--parchment-2) 100%);
  border: 1.5px solid var(--ochre);
  border-left: 5px solid var(--ochre-dark);
  border-radius: 12px;
  padding: 11px 14px;
  margin-bottom: 14px;
}
.chain-pills-row {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.chain-step-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface-elevated);
  color: var(--ink-soft);
  cursor: pointer;
}
.chain-step-pill.current {
  background: var(--ink);
  color: var(--parchment);
  border-color: var(--ink);
}
body.night-red .chain-step-pill.current { background: var(--rust); color: #120505; }
.step-story-row.text-only-step {
  grid-template-columns: 1fr;
  border-left: 4px solid var(--ochre-dark);
  padding: 13px 16px;
}
.chain-stage-card {
  background: var(--parchment);
  border: 1.5px solid var(--border);
  border-left: 5px solid var(--ochre-dark);
  border-radius: 12px;
  padding: 12px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.chain-stage-card:hover { background: var(--parchment-2); }


/* ==========================================================================
   10. PHONE-FIRST FLIP DECK, SAFE-AREA, QUIZZES & CROSS-LINKED CHAIN GRAPH
   ========================================================================== */
@media (max-width: 860px) {
  .mobile-tabbar {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .stage-main {
    padding: 10px 10px 132px;
    -webkit-overflow-scrolling: touch;
  }
  .view-header {
    gap: 8px;
    margin-bottom: 10px;
  }
  .lab-subtabs {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .lab-subbtn {
    white-space: nowrap;
    padding: 7px 10px;
    font-size: 12px;
  }
}

/* Collapsible Mobile TOC Toggle Pill (keeps Card Title + Art above the fold!) */
.mobile-toc-toggle {
  display: none;
  width: 100%;
  background: var(--parchment-2);
  border: 1.5px solid var(--ochre);
  border-radius: 11px;
  padding: 9px 13px;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--ink);
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  margin-bottom: 8px;
}
@media (max-width: 960px) {
  .mobile-toc-toggle { display: flex; }
  .toc-panel.mobile-collapsed { display: none; }
}
body.phone-preview .mobile-toc-toggle { display: flex; }
body.phone-preview .toc-panel.mobile-collapsed { display: none; }

/* Sticky One-Thumb Flip Bar on Phone / Tablet */
.mobile-flip-bar {
  display: none;
}
@media (max-width: 960px) {
  .mobile-flip-bar {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 6px;
    align-items: center;
    position: sticky;
    bottom: 6px;
    z-index: 22;
    margin-top: 16px;
    background: rgba(27, 25, 22, 0.96);
    color: #F6F1E3;
    border: 1.5px solid var(--ochre);
    border-radius: 14px;
    padding: 8px 9px;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(8px);
  }
}
body.phone-preview .mobile-flip-bar {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 6px;
  align-items: center;
  position: sticky;
  bottom: 6px;
  z-index: 22;
  margin-top: 14px;
  background: rgba(27, 25, 22, 0.96);
  color: #F6F1E3;
  border: 1.5px solid var(--ochre);
  border-radius: 14px;
  padding: 8px 9px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.42);
}
.flip-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #F6F1E3;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 9px;
  padding: 8px 11px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}
.flip-btn-next {
  background: var(--ochre);
  color: #1C1A17;
  border-color: var(--ochre);
}
.flip-btn-gotit {
  background: var(--sage);
  color: #FFF;
  border-color: #7FA878;
}
.flip-center-pill {
  background: transparent;
  border: none;
  color: #E8DFCE;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 4px;
}

/* Educational Mental Model & Interactive 2 AM Instinct Quiz */
.mental-model-box {
  background: linear-gradient(135deg, #EFE7D3 0%, #E6DEC8 100%);
  border: 1.5px solid var(--border-strong);
  border-left: 5px solid var(--sage);
  border-radius: 11px;
  padding: 11px 14px;
  font-size: 13.5px;
  line-height: 1.48;
  margin-top: 12px;
}
.quiz-box {
  background: var(--parchment);
  border: 1.5px solid var(--ochre);
  border-radius: 13px;
  padding: 14px 16px;
  margin-top: 16px;
}
.quiz-q {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15.5px;
  font-weight: 700;
  margin-bottom: 10px;
  line-height: 1.32;
}
.quiz-opts {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.quiz-opt {
  width: 100%;
  text-align: left;
  background: var(--surface-elevated);
  color: var(--ink);
  border: 1.5px solid var(--border-strong);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 13px;
  line-height: 1.38;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.quiz-opt:hover { background: var(--parchment-2); border-color: var(--ochre-dark); }
.quiz-opt.correct-pick {
  background: var(--sage-bg);
  border-color: var(--sage);
  color: var(--ink);
  font-weight: 800;
}
.quiz-opt.wrong-pick {
  background: var(--rust-bg);
  border-color: var(--rust);
  color: var(--ink);
}
.quiz-explain {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.42;
  background: var(--sage-bg);
  border-left: 4px solid var(--sage);
}

/* Cross-Linked Chain Dependency Graph & Stage Checkboxes */
.chain-dep-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  background: var(--parchment);
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  padding: 9px 12px;
  margin: 10px 0 14px;
  font-size: 12px;
}
.chain-stage-card.stage-done {
  background: rgba(223, 234, 217, 0.36);
  border-left-color: var(--sage);
}


/* ==========================================================================
   11. AIRTIGHT IPHONE RAIL LOCK (ZERO HORIZONTAL DRIFT) & DOCKED FLIP BAR
   ========================================================================== */
html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  position: relative;
}

.app-shell,
.workspace-body,
.stage-main {
  max-width: 100%;
  overflow-x: hidden;
}

.topbar {
  max-width: 100%;
  min-width: 0;
}
.topbar-left {
  flex-shrink: 0;
  min-width: 0;
}
.topbar-search {
  flex: 1 1 0%;
  min-width: 0;
}
.cmdk-trigger {
  min-width: 0;
  max-width: 100%;
}
.view-header,
.view-header > div,
.btn-row,
.reading-room-layout,
.book-page {
  min-width: 0;
  max-width: 100%;
}

/* Hide old inline mobile-flip-bar inside .book-page; use docked #mobileFlipBar above tabbar instead! */
.book-page .mobile-flip-bar {
  display: none !important;
}
.mobile-flip-dock {
  display: none;
}

@media (max-width: 960px) {
  .reading-room-layout {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

@media (max-width: 860px) {
  /* Keep topbar 100% inside 375px-430px phone width! */
  .topbar {
    padding: 8px 10px;
    gap: 8px;
  }
  .brand-sub,
  .cmdk-kbd,
  .grocy-pill,
  .member-pill,
  .segmented-device {
    display: none !important;
  }
  .brand-lockup { gap: 6px; }
  .brand-mark { font-size: 17px; }
  .brand-title { font-size: 14px; letter-spacing: 0.05em; }
  .cmdk-trigger { padding: 6px 9px; font-size: 12px; gap: 5px; }
  .topbar-right { gap: 5px; }
  .rank-pill { padding: 4px 8px; font-size: 10.5px; }
  .icon-btn { padding: 4px 7px; font-size: 10.5px; }

  /* Prevent horizontal blowout from subtabs, filter chips, and grids */
  .stage-main {
    padding: 10px 10px 24px !important;
  }
  .view-title {
    font-size: 19px;
    word-break: break-word;
  }
  .book-h1 {
    font-size: 21px;
    word-break: break-word;
  }
  .lab-subtabs {
    display: flex;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .pillar-strip {
    flex-wrap: nowrap;
    overflow-x: auto;
    max-width: 100%;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .pillar-chip {
    flex-shrink: 0;
  }
  .cards-grid,
  .store-grid,
  .art-gallery-grid,
  .flora-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .inline-search,
  .redline-note-input {
    min-width: 0 !important;
    width: 100%;
  }

  /* Clean full-width Chain Stage Cards on mobile (no 2-word squeezed columns!) */
  .chain-stage-card {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px 13px;
  }
  .chain-stage-card > div {
    min-width: 0 !important;
    width: 100%;
  }
  .chain-stage-card .chk-box {
    display: none;
  }
  .chain-stage-card > .btn {
    width: 100%;
    justify-content: center;
    padding: 9px 12px;
    font-size: 13px;
  }

  /* Docked One-Thumb Flip Bar cleanly anchored right above .mobile-tabbar */
  .mobile-flip-dock.active-dock {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    gap: 6px;
    align-items: center;
    width: 100%;
    background: #24201B;
    color: #F6F1E3;
    border-top: 1.5px solid var(--ochre);
    padding: 7px 10px;
    flex-shrink: 0;
    z-index: 26;
  }
}

body.phone-preview .book-page .mobile-flip-bar { display: none !important; }
body.phone-preview .mobile-flip-dock.active-dock {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 6px;
  align-items: center;
  width: 100%;
  background: #24201B;
  color: #F6F1E3;
  border-top: 1.5px solid var(--ochre);
  padding: 7px 10px;
  flex-shrink: 0;
}

/* WebKit <button> flex intrinsic-width fix & all mobile grids minmax(0, 1fr) */
.cmdk-placeholder {
  min-width: 0 !important;
}
.badge {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 900px) {
  .readiness-top-grid,
  .sim-grid,
  .three-up-panels,
  .membership-banner,
  .step-story-row,
  .step-story-row.text-only-step {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}
@media (max-width: 520px) {
  .rung-stepper {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}
