/* ============================================================================
   The Spirit Pillar — reading application
   Identity: "the modern scriptorium" — vellum, iron-gall ink, lapis & gold.
   ============================================================================ */

/* ---- Tokens ------------------------------------------------------------- */
:root {
  /* type roles */
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua",
    "Sitka Text", Cambria, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Cascadia Code", ui-monospace, Menlo,
    Consolas, "Liberation Mono", monospace;

  /* neutrals — warm, chosen (a faint parchment bias), not pure grey */
  --bg: #e7e1d3;
  --bg-2: #ded7c5;
  --surface: #f7f4ec;
  --surface-2: #f1ecdf;
  --ink: #221f18;
  --ink-soft: #574f41;
  --ink-faint: #857a64;
  --line: #d3cab5;
  --line-soft: #e0d8c6;

  /* accents — lapis primary, gold secondary (illumination palette) */
  --lapis: #2a4a7f;
  --lapis-bright: #35599a;
  --gold: #9c7716;
  --gold-bright: #b98f1f;

  --accent: var(--lapis);
  --accent-ink: #fff;

  /* source-tier hues (muted in body; the legend shows them at full strength) */
  --t-canon: #2a4a7f;      /* lapis — the anchor */
  --t-deutero: #3f7386;    /* teal-blue */
  --t-noncanon: #9a6b16;   /* ochre — caution */
  --t-cross: #4f7a3f;      /* green — another tradition */
  --t-esoteric: #6b4a86;   /* violet — mystical */
  --t-history: #5b6472;    /* slate — scholarship */
  --t-sci-est: #2f7d74;    /* teal — solid science */
  --t-sci-dec: #47617f;    /* steel blue — declassified */
  --t-sci-con: #b26a1f;    /* orange — contested */
  --t-spec: #a4512f;       /* rust — anecdotal */
  --t-unverified: #b23636; /* red — flagged */

  /* geometry & motion */
  --measure: 66ch;
  --sidebar-w: 20rem;
  --radius: 7px;
  --radius-lg: 12px;
  --shadow: 0 1px 2px rgba(34, 31, 24, .05), 0 8px 24px -12px rgba(34, 31, 24, .18);
  --ease: cubic-bezier(.22, .61, .36, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14120c;
    --bg-2: #1a1710;
    --surface: #201d14;
    --surface-2: #262218;
    --ink: #ece5d3;
    --ink-soft: #b0a88f;
    --ink-faint: #7d745e;
    --line: #34301f;
    --line-soft: #2a2618;
    --lapis: #7ea6d8;
    --lapis-bright: #97b8e2;
    --gold: #d3ac53;
    --gold-bright: #e2bd68;
    --accent: var(--lapis);
    --accent-ink: #14120c;
    --t-canon: #86a9db;
    --t-deutero: #6fabc0;
    --t-noncanon: #ca9a3f;
    --t-cross: #82b26a;
    --t-esoteric: #b18edd;
    --t-history: #98a3b3;
    --t-sci-est: #58b3a6;
    --t-sci-dec: #8aa4c4;
    --t-sci-con: #dc9a4c;
    --t-spec: #d98a63;
    --t-unverified: #e06a6a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .6);
  }
}
/* explicit toggle wins over the media query in both directions */
:root[data-theme="light"] {
  --bg: #e7e1d3; --bg-2: #ded7c5; --surface: #f7f4ec; --surface-2: #f1ecdf;
  --ink: #221f18; --ink-soft: #574f41; --ink-faint: #857a64;
  --line: #d3cab5; --line-soft: #e0d8c6;
  --lapis: #2a4a7f; --lapis-bright: #35599a; --gold: #9c7716; --gold-bright: #b98f1f;
  --accent: var(--lapis); --accent-ink: #fff;
  --t-canon:#2a4a7f; --t-deutero:#3f7386; --t-noncanon:#9a6b16; --t-cross:#4f7a3f;
  --t-esoteric:#6b4a86; --t-history:#5b6472; --t-sci-est:#2f7d74; --t-sci-dec:#47617f;
  --t-sci-con:#b26a1f; --t-spec:#a4512f; --t-unverified:#b23636;
  --shadow: 0 1px 2px rgba(34,31,24,.05), 0 8px 24px -12px rgba(34,31,24,.18);
}
:root[data-theme="dark"] {
  --bg: #14120c; --bg-2: #1a1710; --surface: #201d14; --surface-2: #262218;
  --ink: #ece5d3; --ink-soft: #b0a88f; --ink-faint: #7d745e;
  --line: #34301f; --line-soft: #2a2618;
  --lapis: #7ea6d8; --lapis-bright: #97b8e2; --gold: #d3ac53; --gold-bright: #e2bd68;
  --accent: var(--lapis); --accent-ink: #14120c;
  --t-canon:#86a9db; --t-deutero:#6fabc0; --t-noncanon:#ca9a3f; --t-cross:#82b26a;
  --t-esoteric:#b18edd; --t-history:#98a3b3; --t-sci-est:#58b3a6; --t-sci-dec:#8aa4c4;
  --t-sci-con:#dc9a4c; --t-spec:#d98a63; --t-unverified:#e06a6a;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -14px rgba(0,0,0,.6);
}

/* ---- Reset & base ------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--lapis); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--lapis-bright); outline-offset: 2px; border-radius: 3px; }
img { max-width: 100%; }

/* ---- App shell ---------------------------------------------------------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* ---- Sidebar ------------------------------------------------------------ */
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow: hidden;
  display: flex; flex-direction: column;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: .7rem;
  padding: 1.15rem 1.25rem 1rem; border-bottom: 1px solid var(--line);
}
.brand-mark {
  flex: none; width: 2.1rem; height: 2.1rem; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, var(--lapis-bright), var(--lapis) 70%);
  color: #fff; box-shadow: inset 0 0 0 2px var(--gold);
  font-family: var(--serif); font-size: 1.1rem; font-weight: 600;
}
.brand-text b { font-family: var(--serif); font-size: 1.02rem; letter-spacing: .01em; display: block; line-height: 1.15; }
.brand-text span { font-size: .68rem; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-faint); }

.side-tools { display: flex; gap: .5rem; padding: .75rem 1rem; }
.search-btn {
  flex: 1; display: flex; align-items: center; gap: .5rem;
  padding: .5rem .7rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink-soft); font-size: .85rem;
  transition: border-color .15s;
}
.search-btn:hover { border-color: var(--lapis); }
.search-btn kbd {
  margin-left: auto; font-family: var(--mono); font-size: .68rem;
  padding: .1rem .35rem; border: 1px solid var(--line); border-radius: 4px; color: var(--ink-faint);
}
.icon-btn {
  flex: none; width: 2.3rem; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  transition: border-color .15s, color .15s;
}
.icon-btn:hover { border-color: var(--lapis); color: var(--lapis); }

.nav { flex: 1; overflow-y: auto; padding: .35rem .6rem 2rem; scrollbar-width: thin; }
.nav-group { margin-top: .55rem; }
.nav-label {
  font-size: .66rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-faint); padding: .5rem .65rem .3rem; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: .55rem; width: 100%;
  padding: .42rem .65rem; border-radius: var(--radius); border: 0; background: none;
  color: var(--ink-soft); text-align: left; font-size: .9rem; line-height: 1.25;
  transition: background .13s, color .13s;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--surface); color: var(--ink); box-shadow: inset 3px 0 0 var(--lapis); font-weight: 600; }
.nav-item .wk-num {
  flex: none; font-family: var(--mono); font-size: .7rem; width: 1.5rem;
  color: var(--ink-faint); text-align: right;
}
.nav-item.active .wk-num { color: var(--lapis); }
.nav-module { font-weight: 600; color: var(--ink); }
.nav-module .m-num {
  flex: none; width: 1.4rem; height: 1.4rem; border-radius: 5px; display: grid; place-items: center;
  background: var(--lapis); color: #fff; font-size: .72rem; font-family: var(--mono);
}
:root[data-theme="dark"] .nav-module .m-num, @media (prefers-color-scheme: dark) { }
.nav-weeks { margin: .1rem 0 .3rem; }
.nav-check { margin-left: auto; flex: none; color: var(--gold); font-size: .8rem; opacity: 0; }
.nav-check.done { opacity: 1; }

/* progress meter in sidebar footer */
.side-progress { padding: .8rem 1.1rem; border-top: 1px solid var(--line); background: var(--bg-2); }
.side-progress .pl { display: flex; justify-content: space-between; font-size: .72rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .1em; margin-bottom: .4rem; }
.meter { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--lapis), var(--gold)); transition: width .5s var(--ease); }

/* ---- Main / reading column --------------------------------------------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: none;
  align-items: center; gap: .6rem; padding: .6rem .9rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.topbar b { font-family: var(--serif); }
.content { flex: 1; padding: clamp(1.5rem, 4vw, 3.5rem) clamp(1.1rem, 5vw, 3rem) 6rem; }
.view { max-width: 78rem; margin: 0 auto; animation: rise .32s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .view { animation: none; } }

/* ---- Reading typography ------------------------------------------------- */
.reading { max-width: var(--measure); margin: 0 auto; font-family: var(--serif); color: var(--ink); }
.reading.wide { max-width: 72rem; } /* for the master table / bibliography */
.reading > * + * { margin-top: 1.05em; }
.reading p { font-size: 1.15rem; line-height: 1.72; }
.reading h1 {
  font-size: clamp(1.9rem, 3.4vw, 2.7rem); line-height: 1.12; font-weight: 600;
  letter-spacing: -.012em; text-wrap: balance; margin-top: 0; color: var(--ink);
}
.reading h2 {
  font-size: 1.7rem; line-height: 1.2; font-weight: 600; text-wrap: balance;
  margin-top: 2.4rem; padding-top: 1.3rem; border-top: 1px solid var(--line-soft);
}
.reading h3 { font-size: 1.34rem; line-height: 1.25; font-weight: 600; margin-top: 2rem; color: var(--ink); }
.reading h4 { font-family: var(--sans); font-size: .82rem; text-transform: uppercase; letter-spacing: .12em; color: var(--gold); margin-top: 1.8rem; }
.reading strong { font-weight: 600; }
.reading em { font-style: italic; }
.reading ul, .reading ol { padding-left: 1.4em; }
.reading li { font-size: 1.12rem; line-height: 1.62; margin-top: .35em; }
.reading hr { border: 0; height: 1px; background: var(--line); margin: 2.2rem 0; }
.reading a { color: var(--lapis); border-bottom: 1px solid color-mix(in srgb, var(--lapis) 35%, transparent); }
.reading a:hover { text-decoration: none; border-bottom-color: var(--lapis); }

/* drop cap on a week's opening paragraph */
.reading.is-week > h1 + p::first-letter {
  float: left; font-weight: 600; font-size: 3.5em; line-height: .82;
  padding: .06em .12em 0 0; color: var(--lapis);
  font-family: var(--serif);
}

/* scripture — the illuminated element */
.reading blockquote {
  margin-left: 0; margin-right: 0; padding: .85rem 1.25rem;
  border-left: 3px solid var(--gold);
  background: linear-gradient(90deg, color-mix(in srgb, var(--gold) 7%, var(--surface)), var(--surface));
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 1.14rem; line-height: 1.66; color: var(--ink);
}
.reading blockquote p { font-size: inherit; }
.reading blockquote > *:first-child { margin-top: 0; }

/* inline code / verse fragments */
.reading code {
  font-family: var(--mono); font-size: .86em;
  background: var(--surface-2); padding: .08em .35em; border-radius: 4px;
}

/* tables (covenant master table, translation maps, week source lists) */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.reading table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: .9rem; background: var(--surface); }
.reading thead th { background: var(--surface-2); text-align: left; font-weight: 600; }
.reading th, .reading td { padding: .6rem .75rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; line-height: 1.45; }
.reading tbody tr:last-child td { border-bottom: 0; }
.reading td:first-child, .reading th:first-child { position: sticky; left: 0; }

/* ---- Source-tier chips (the "apparatus") -------------------------------- */
.tag {
  display: inline-flex; align-items: center; gap: .32em;
  font-family: var(--mono); font-size: .72em; font-weight: 500;
  line-height: 1.4; letter-spacing: .02em; text-transform: none;
  padding: .05em .5em .05em .42em; border-radius: 99px;
  background: color-mix(in srgb, var(--tc) 12%, transparent);
  color: var(--tc); border: 1px solid color-mix(in srgb, var(--tc) 28%, transparent);
  white-space: nowrap; vertical-align: baseline;
}
.tag::before { content: ""; width: .46em; height: .46em; border-radius: 50%; background: var(--tc); flex: none; }
.tag .conf {
  font-weight: 600; padding-left: .3em; margin-left: .05em;
  border-left: 1px solid color-mix(in srgb, var(--tc) 30%, transparent);
}
.tag-canon { --tc: var(--t-canon); }
.tag-deutero { --tc: var(--t-deutero); }
.tag-noncanon { --tc: var(--t-noncanon); }
.tag-cross { --tc: var(--t-cross); }
.tag-esoteric { --tc: var(--t-esoteric); }
.tag-history { --tc: var(--t-history); }
.tag-sci-est { --tc: var(--t-sci-est); }
.tag-sci-dec { --tc: var(--t-sci-dec); }
.tag-sci-con { --tc: var(--t-sci-con); }
.tag-spec { --tc: var(--t-spec); }
.tag-unverified { --tc: var(--t-unverified); font-weight: 700; }

/* ---- Reading toolbar (day sub-nav + progress) --------------------------- */
.reading-head { max-width: var(--measure); margin: 0 auto 1.6rem; }
.crumb { font-family: var(--sans); font-size: .72rem; text-transform: uppercase; letter-spacing: .14em; color: var(--ink-faint); margin-bottom: .9rem; display: flex; gap: .5rem; align-items: center; }
.crumb .sep { color: var(--line); }
.daybar {
  position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; gap: .4rem;
  padding: .7rem 0; margin: 0 auto 1.4rem; max-width: var(--measure);
  background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(6px);
}
.daychip {
  font-family: var(--sans); font-size: .8rem; padding: .3rem .7rem; border-radius: 99px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  display: inline-flex; align-items: center; gap: .4rem;
}
.daychip:hover { border-color: var(--lapis); color: var(--ink); }
.daychip.done { border-color: color-mix(in srgb, var(--gold) 55%, transparent); color: var(--gold); }
.daychip .dot { width: .5rem; height: .5rem; border-radius: 50%; border: 1.5px solid currentColor; }
.daychip.done .dot { background: var(--gold); border-color: var(--gold); }

/* per-unit completion control injected after each Day / Sunday heading */
.unit-toggle {
  display: inline-flex; align-items: center; gap: .5rem; margin-top: .7rem;
  font-family: var(--sans); font-size: .82rem; color: var(--ink-soft);
  padding: .35rem .75rem; border: 1px solid var(--line); border-radius: 99px; background: var(--surface);
  transition: all .14s;
}
.unit-toggle:hover { border-color: var(--gold); color: var(--ink); }
.unit-toggle.done { background: color-mix(in srgb, var(--gold) 12%, var(--surface)); border-color: var(--gold); color: var(--gold); }
.unit-toggle .box { width: 1rem; height: 1rem; border-radius: 4px; border: 1.5px solid currentColor; display: grid; place-items: center; font-size: .7rem; }

/* week pager */
.pager { display: flex; justify-content: space-between; gap: 1rem; max-width: var(--measure); margin: 3rem auto 0; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.pager a { display: flex; flex-direction: column; gap: .15rem; padding: .7rem 1rem; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); flex: 1; max-width: 48%; transition: border-color .15s, transform .15s; border-bottom: 1px solid var(--line); }
.pager a:hover { border-color: var(--lapis); text-decoration: none; transform: translateY(-1px); }
.pager a.next { text-align: right; align-items: flex-end; }
.pager .pl { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-faint); font-family: var(--sans); }
.pager .pt { font-family: var(--serif); color: var(--ink); font-size: .98rem; }

/* ---- Overview (home) ---------------------------------------------------- */
.hero { text-align: center; padding: clamp(1rem, 4vw, 2.5rem) 0 2.5rem; border-bottom: 1px solid var(--line); }
.hero .eyebrow { font-family: var(--sans); font-size: .74rem; text-transform: uppercase; letter-spacing: .24em; color: var(--gold); }
.hero h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(2.4rem, 6vw, 4rem); line-height: 1.04; letter-spacing: -.02em; margin: .6rem 0 .4rem; text-wrap: balance; }
.hero .sub { max-width: 42rem; margin: .6rem auto 0; color: var(--ink-soft); font-family: var(--serif); font-size: 1.2rem; line-height: 1.6; }
.hero .rule { width: 4rem; height: 2px; margin: 1.6rem auto 0; background: linear-gradient(90deg, var(--lapis), var(--gold)); }
.hero-cta { display: inline-flex; gap: .7rem; margin-top: 1.8rem; flex-wrap: wrap; justify-content: center; }
.btn { display: inline-flex; align-items: center; gap: .5rem; padding: .7rem 1.3rem; border-radius: 99px; font-family: var(--sans); font-size: .92rem; font-weight: 600; border: 1px solid transparent; transition: transform .14s, box-shadow .14s, background .14s; }
.btn.primary { background: var(--lapis); color: #fff; box-shadow: var(--shadow); }
:root[data-theme="dark"] .btn.primary { color: #14120c; }
.btn.primary:hover { text-decoration: none; transform: translateY(-1px); background: var(--lapis-bright); }
.btn.ghost { border-color: var(--line); background: var(--surface); color: var(--ink); }
.btn.ghost:hover { border-color: var(--lapis); text-decoration: none; }

.section-h { font-family: var(--sans); font-size: .74rem; text-transform: uppercase; letter-spacing: .18em; color: var(--ink-faint); margin: 3rem 0 1.1rem; display: flex; align-items: center; gap: .8rem; }
.section-h::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; }
.mcard { display: block; padding: 1.15rem 1.2rem 1.1rem; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); transition: transform .16s var(--ease), border-color .16s; position: relative; overflow: hidden; }
.mcard:hover { transform: translateY(-3px); border-color: var(--lapis); text-decoration: none; }
.mcard .mtop { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.mcard .mno { font-family: var(--mono); font-size: .72rem; color: var(--gold); letter-spacing: .05em; }
.mcard .mwk { font-family: var(--mono); font-size: .72rem; color: var(--ink-faint); }
.mcard h3 { font-family: var(--serif); font-size: 1.28rem; line-height: 1.2; font-weight: 600; margin: .3rem 0 .4rem; color: var(--ink); text-wrap: balance; }
.mcard p { font-size: .92rem; color: var(--ink-soft); line-height: 1.5; margin: 0; }
.mcard .mmeter { height: 4px; border-radius: 99px; background: var(--line); margin-top: 1rem; overflow: hidden; }
.mcard .mmeter > i { display: block; height: 100%; background: linear-gradient(90deg, var(--lapis), var(--gold)); border-radius: 99px; transition: width .5s var(--ease); }
.mcard .mmeta { display: flex; justify-content: space-between; margin-top: .5rem; font-size: .72rem; color: var(--ink-faint); font-family: var(--sans); }

/* rhythm + legend panels */
.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.panel { padding: 1.3rem 1.4rem; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.panel h4 { font-family: var(--serif); font-size: 1.15rem; margin: 0 0 .8rem; font-weight: 600; }
.rhythm-row { display: flex; gap: .8rem; padding: .55rem 0; border-top: 1px solid var(--line-soft); }
.rhythm-row:first-of-type { border-top: 0; }
.rhythm-row .rk { font-family: var(--mono); font-size: .78rem; color: var(--lapis); flex: none; width: 5.5rem; }
.rhythm-row .rv { font-size: .92rem; color: var(--ink-soft); }
.legend-list { display: flex; flex-direction: column; gap: .5rem; }
.legend-row { display: flex; align-items: center; gap: .6rem; font-size: .84rem; }
.legend-row .swatch { width: .8rem; height: .8rem; border-radius: 50%; flex: none; }
.legend-row .lname { font-family: var(--mono); font-size: .76rem; color: var(--ink); }
.legend-row .ldesc { color: var(--ink-faint); font-size: .8rem; }

/* generic prose page wrapper for READMEs/orientation/sources/mind/body */
.prose-page { }

/* ---- Search modal ------------------------------------------------------- */
.modal-scrim { position: fixed; inset: 0; z-index: 100; background: rgba(10, 8, 4, .5); backdrop-filter: blur(3px); display: none; align-items: flex-start; justify-content: center; padding: 8vh 1rem 1rem; }
.modal-scrim.open { display: flex; }
.modal { width: min(38rem, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: 0 24px 60px -20px rgba(0,0,0,.5); overflow: hidden; animation: rise .2s var(--ease) both; }
.modal input { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--ink); font-family: var(--serif); font-size: 1.2rem; padding: 1rem 1.2rem; }
.modal input:focus { outline: 0; }
.results { max-height: 55vh; overflow-y: auto; }
.result { display: block; padding: .75rem 1.2rem; border-top: 1px solid var(--line-soft); }
.result:hover, .result.sel { background: var(--surface-2); text-decoration: none; }
.result .rt { font-family: var(--serif); color: var(--ink); font-size: .98rem; }
.result .rc { font-family: var(--sans); font-size: .72rem; color: var(--gold); text-transform: uppercase; letter-spacing: .1em; }
.result .rs { font-size: .84rem; color: var(--ink-soft); margin-top: .2rem; line-height: 1.4; }
.result mark { background: color-mix(in srgb, var(--gold) 30%, transparent); color: inherit; border-radius: 2px; padding: 0 .1em; }
.results .empty { padding: 1.5rem 1.2rem; color: var(--ink-faint); font-size: .9rem; }

/* ---- Mobile drawer ------------------------------------------------------ */
.scrim { display: none; }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; width: min(20rem, 84vw); left: 0; top: 0; transform: translateX(-102%); transition: transform .28s var(--ease); box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .topbar { display: flex; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(10,8,4,.45); opacity: 0; pointer-events: none; transition: opacity .25s; }
  .scrim.open { opacity: 1; pointer-events: auto; }
  .content { padding-top: 1.5rem; }
  .panels { grid-template-columns: 1fr; }
  .reading td:first-child, .reading th:first-child { position: static; }
}
@media (max-width: 480px) {
  .reading p, .reading li { font-size: 1.06rem; }
  .pager { flex-direction: column; }
  .pager a { max-width: 100%; }
}

/* print — a clean reading copy */
@media print {
  .sidebar, .topbar, .daybar, .unit-toggle, .pager, .modal-scrim { display: none !important; }
  .app { display: block; }
  .content { padding: 0; }
  .reading { max-width: 100%; }
  .reading blockquote { border-left: 2px solid #999; background: none; }
}

/* ===========================================================================
   Multi-user additions — account, forms, modals, journal, cohorts, admin
   =========================================================================== */

.boot { max-width: var(--measure); margin: 4rem auto; color: var(--ink-faint); font-family: var(--serif); font-size: 1.15rem; text-align: center; }

/* sidebar footer holds the account panel + progress */
.side-foot { border-top: 1px solid var(--line); }
.side-foot .side-progress { border-top: 1px solid var(--line-soft); }

#account-slot { padding: .7rem .9rem .55rem; }
.acct {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  padding: .45rem .55rem; border-radius: var(--radius); border: 1px solid transparent; background: none;
  text-align: left; transition: background .13s, border-color .13s;
}
.acct:hover { background: var(--surface); border-color: var(--line); }
.avatar {
  flex: none; width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, var(--lapis-bright), var(--lapis) 75%);
  color: #fff; font-family: var(--serif); font-size: .95rem; font-weight: 600;
}
.acct .who { min-width: 0; }
.acct .who b { display: block; font-family: var(--sans); font-size: .86rem; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct .who span { font-size: .72rem; color: var(--ink-faint); }
.acct.signin { color: var(--lapis); font-weight: 600; font-size: .9rem; justify-content: center; border: 1px dashed color-mix(in srgb, var(--lapis) 40%, transparent); }
.acct.signin:hover { border-style: solid; }
.role-pill { margin-left: auto; font-family: var(--mono); font-size: .6rem; text-transform: uppercase; letter-spacing: .08em; color: var(--gold); border: 1px solid color-mix(in srgb, var(--gold) 40%, transparent); border-radius: 99px; padding: .05rem .4rem; }

/* generic modal body padding + forms */
.modal-pad { padding: 1.6rem 1.7rem 1.5rem; }
.modal h2 { font-family: var(--serif); font-weight: 600; font-size: 1.5rem; margin: 0 0 .3rem; }
.modal .lede { color: var(--ink-soft); font-size: .95rem; margin: 0 0 1.1rem; line-height: 1.55; }
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .9rem; }
.field label { font-family: var(--sans); font-size: .74rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-faint); font-weight: 600; }
.input {
  width: 100%; font-family: var(--sans); font-size: 1rem; color: var(--ink);
  padding: .7rem .8rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2);
}
.input:focus { outline: 0; border-color: var(--lapis); box-shadow: 0 0 0 3px color-mix(in srgb, var(--lapis) 18%, transparent); }
textarea.input { resize: vertical; min-height: 6rem; font-family: var(--serif); font-size: 1.05rem; line-height: 1.6; }
.form-actions { display: flex; gap: .6rem; align-items: center; margin-top: .3rem; }
.btn.small { padding: .5rem .9rem; font-size: .84rem; }
.btn.danger { background: none; border-color: color-mix(in srgb, var(--t-unverified) 45%, transparent); color: var(--t-unverified); }
.btn.danger:hover { background: color-mix(in srgb, var(--t-unverified) 12%, transparent); text-decoration: none; }
.muted { color: var(--ink-faint); font-size: .85rem; }
.modal-close { position: absolute; top: .7rem; right: .8rem; width: 2rem; height: 2rem; border-radius: 50%; border: 0; background: none; color: var(--ink-faint); font-size: 1.3rem; line-height: 1; }
.modal-close:hover { background: var(--surface-2); color: var(--ink); }
#app-modal .modal { position: relative; width: min(30rem, 100%); }

/* toast */
#toast { position: fixed; bottom: 1.3rem; left: 50%; transform: translateX(-50%) translateY(2rem); z-index: 200; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast .t { background: var(--ink); color: var(--bg); font-size: .9rem; padding: .65rem 1.1rem; border-radius: 99px; box-shadow: var(--shadow); font-family: var(--sans); }
#toast .t.err { background: var(--t-unverified); color: #fff; }

/* the reading-view journal affordance */
.journal-hook { max-width: var(--measure); margin: 2.2rem auto 0; padding-top: 1.4rem; border-top: 1px solid var(--line); }
.journal-hook h3 { font-family: var(--serif); font-size: 1.2rem; margin: 0 0 .3rem; }
.journal-hook .muted { margin-bottom: .8rem; }
.jentry { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); padding: .9rem 1rem; margin-top: .8rem; }
.jentry .jmeta { display: flex; justify-content: space-between; align-items: center; font-size: .72rem; color: var(--ink-faint); font-family: var(--sans); margin-bottom: .4rem; }
.jentry .jbody { font-family: var(--serif); font-size: 1.05rem; line-height: 1.6; white-space: pre-wrap; }
.jentry .jactions { display: flex; gap: .5rem; margin-top: .6rem; }
.jentry .link { background: none; border: 0; color: var(--lapis); font-size: .8rem; padding: 0; }
.jentry .link:hover { text-decoration: underline; }
.jentry .link.del { color: var(--t-unverified); }
.signin-nudge { max-width: var(--measure); margin: 2.2rem auto 0; padding: 1rem 1.2rem; border: 1px dashed var(--line); border-radius: var(--radius-lg); background: var(--surface); color: var(--ink-soft); font-size: .92rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

/* cohorts */
.cohort-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 1rem; }
.cohort-card { display: block; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); transition: transform .15s, border-color .15s; }
.cohort-card:hover { transform: translateY(-2px); border-color: var(--lapis); text-decoration: none; }
.cohort-card h3 { font-family: var(--serif); font-size: 1.2rem; margin: 0 0 .3rem; }
.cohort-card .cmeta { font-size: .8rem; color: var(--ink-faint); }
.member-row { display: flex; align-items: center; gap: .8rem; padding: .7rem 0; border-top: 1px solid var(--line-soft); }
.member-row:first-of-type { border-top: 0; }
.member-row .mavatar { width: 2rem; height: 2rem; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); font-family: var(--serif); color: var(--ink-soft); }
.member-row .mname { font-weight: 600; font-size: .92rem; }
.member-row .mbar { flex: 1; height: 7px; border-radius: 99px; background: var(--line); overflow: hidden; max-width: 16rem; }
.member-row .mbar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--lapis), var(--gold)); border-radius: 99px; }
.member-row .mpct { font-family: var(--mono); font-size: .78rem; color: var(--ink-soft); width: 3rem; text-align: right; }
.member-row .mprivate { font-size: .78rem; color: var(--ink-faint); font-style: italic; }
.code-chip { font-family: var(--mono); font-size: 1rem; letter-spacing: .12em; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: .35rem .7rem; color: var(--ink); }

/* admin table */
.admin-table { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: .9rem; }
.admin-table th, .admin-table td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line-soft); }
.admin-table th { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); }
.admin-table select { font: inherit; padding: .3rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); color: var(--ink); }
.admin-note { margin-top: 1.5rem; padding: 1rem 1.2rem; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); font-size: .9rem; color: var(--ink-soft); }

/* page header used by app pages (journal/cohorts/admin/account) */
.page-head { max-width: 72rem; margin: 0 auto 1.6rem; }
.page-head h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.8rem, 3.4vw, 2.5rem); margin: 0 0 .3rem; }
.page-head p { color: var(--ink-soft); max-width: 46rem; }
.page-wrap { max-width: 72rem; margin: 0 auto; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--ink-faint); }
.empty-state .btn { margin-top: 1rem; }

/* ---- Downloadable guides ------------------------------------------------- */
.guide-dl { margin: 1.4rem 0 .4rem; }
.guide-dl .btn svg { width: 1rem; height: 1rem; }
.guide-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .6rem; }
.guide-row { display: flex; align-items: center; gap: .75rem; padding: .8rem .95rem; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); color: var(--ink); text-decoration: none; transition: border-color .14s, transform .14s; }
.guide-row:hover { border-color: var(--lapis); transform: translateY(-1px); text-decoration: none; }
.guide-row svg { width: 1.15rem; height: 1.15rem; flex: 0 0 auto; color: var(--gold); }
.guide-row span { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.guide-row b { font-family: var(--serif, var(--sans)); font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.guide-row em { font-family: var(--sans); font-style: normal; font-size: .74rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-faint); }
.guide-row.complete { background: color-mix(in srgb, var(--gold) 12%, var(--surface)); border-color: color-mix(in srgb, var(--gold) 35%, var(--line)); grid-column: 1 / -1; }
