/* ==========================================================================
   School Books — preview site
   Hand-written CSS. No frameworks, no external fonts, no network requests.
   ========================================================================== */

:root {
  --paper: #f7f3ea;
  --paper-2: #efe7d8;
  --card: #fffdf8;
  --ink: #141920;
  --ink-2: #232c37;
  --muted: #5d6878;
  --line: #e0d6c4;
  --line-strong: #ccbda5;
  --terra: #b84e28;
  --terra-2: #963d1d;
  --teal: #1c6b62;
  --gold: #c9973d;
  --ok: #2e7355;
  --warn: #a9701f;
  --bad: #a83b35;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 20px 50px -28px rgba(20, 25, 32, 0.45);
  --shadow-lg: 0 40px 90px -40px rgba(20, 25, 32, 0.55);
  --max: 1180px;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, figure { margin: 0; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
ul { margin: 0; padding: 0; list-style: none; }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
  border-radius: 6px;
}

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

.wrap {
  width: min(var(--max), calc(100% - 2.5rem));
  margin-inline: auto;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -60px;
  z-index: 200;
  background: var(--ink);
  color: #fff;
  padding: 0.7rem 1rem;
  border-radius: 8px;
}
.skip-link:focus { top: 1rem; }

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

section[id] { scroll-margin-top: 88px; }

/* ---------- scroll progress ---------- */
.scroll-progress {
  position: fixed;
  inset: 0 auto auto 0;
  height: 2px;
  width: 0;
  z-index: 120;
  background: linear-gradient(90deg, var(--gold), var(--terra));
  transition: width 0.08s linear;
}

/* ---------- top line ---------- */
.topline {
  background: var(--ink);
  color: #b9b0a1;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  padding: 0.5rem 1rem;
}
.topline a {
  color: var(--gold);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- navigation ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 80;
  background: rgba(247, 243, 234, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.nav.is-scrolled {
  border-color: var(--line);
  box-shadow: 0 12px 34px -30px rgba(20, 25, 32, 0.5);
}
.nav-inner {
  width: min(var(--max), calc(100% - 2.5rem));
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.85rem 0;
}

.brand { display: flex; align-items: center; gap: 0.65rem; }
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--ink);
  color: var(--gold);
  display: grid;
  place-items: center;
  flex: none;
}
.brand-name {
  font-family: var(--serif);
  font-size: 1.06rem;
  line-height: 1.05;
  letter-spacing: -0.01em;
}
.brand-name small {
  display: block;
  margin-top: 0.22rem;
  font-family: var(--sans);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav-links { display: flex; align-items: center; gap: 1.45rem; }
.nav-links a {
  position: relative;
  font-size: 0.87rem;
  color: var(--ink-2);
  padding: 0.25rem 0;
}
.nav-links a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: 0;
  height: 1.5px;
  background: var(--terra);
  transition: right 0.25s ease;
}
.nav-links a:hover::after { right: 0; }

.menu-btn {
  display: none;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
}
.mobile-menu {
  display: none;
  border-top: 1px solid var(--line);
  padding: 0.7rem 1.25rem 1rem;
  background: var(--paper);
}
.mobile-menu a {
  display: block;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
}
.mobile-menu a:last-child { border: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.9rem 1.35rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.btn-accent {
  background: var(--terra);
  color: #fff;
  box-shadow: 0 14px 30px -16px rgba(184, 78, 40, 0.8);
}
.btn-accent:hover { background: var(--terra-2); }

.btn-ink { background: var(--ink); color: #fff; }
.btn-ink:hover { background: var(--ink-2); }

.btn-ghost {
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #f3ecdf;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.08); }

.btn-outline { border: 1px solid var(--line-strong); color: var(--ink); }
.btn-outline:hover { border-color: var(--ink); }

.btn-sm { padding: 0.6rem 1rem; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

/* ---------- type helpers ---------- */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--terra-2);
}
.eyebrow::before {
  content: "";
  width: 26px;
  height: 1px;
  background: currentColor;
  flex: none;
}

.section { padding: clamp(4rem, 8vw, 7rem) 0; }
.section-tight { padding-top: 0; }

.section-head { max-width: 46rem; margin-bottom: clamp(2rem, 4vw, 3rem); }
.section-head h2 {
  font-family: var(--serif);
  font-size: clamp(2rem, 4.1vw, 3.15rem);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.03em;
  margin: 0.65rem 0 1rem;
}
.section-head p {
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.72;
  max-width: 40rem;
}

/* ---------- reveal ---------- */
.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition:
    opacity 0.7s ease,
    transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
  transition-delay: calc(var(--d, 0) * 1ms);
}
.reveal.is-visible { opacity: 1; transform: none; }

/* ==========================================================================
   Hero
   ========================================================================== */
.hero {
  position: relative;
  overflow: hidden;
  background: var(--ink);
  color: #f3ecdf;
  padding: clamp(3.5rem, 7vw, 6.2rem) 0 clamp(4rem, 8vw, 7rem);
}
.hero::before {
  content: "";
  position: absolute;
  inset: -20% -10% auto -10%;
  height: 90%;
  background:
    radial-gradient(circle at 18% 35%, rgba(201, 151, 61, 0.2), transparent 46%),
    radial-gradient(circle at 82% 15%, rgba(28, 107, 98, 0.28), transparent 48%),
    radial-gradient(circle at 60% 90%, rgba(184, 78, 40, 0.18), transparent 42%);
  pointer-events: none;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.5), transparent 70%);
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(50px);
  opacity: 0.55;
  pointer-events: none;
  animation: drift 18s ease-in-out infinite alternate;
}
.blob-a { width: 260px; height: 260px; background: #2f6f63; top: 12%; left: -80px; }
.blob-b { width: 320px; height: 320px; background: #7a3a1c; bottom: -120px; right: 8%; animation-delay: -6s; }
.blob-c { width: 180px; height: 180px; background: #8d6a24; top: 55%; right: 38%; animation-delay: -11s; opacity: 0.35; }

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(28px, -24px, 0) scale(1.12); }
}

.hero-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1.04fr 0.96fr;
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
}

.hero .eyebrow { color: var(--gold); }
.hero .eyebrow .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(201, 151, 61, 0.18);
}

.hero h1 {
  font-family: var(--serif);
  font-size: clamp(2.75rem, 6.3vw, 4.95rem);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.038em;
  margin: 0.9rem 0 1.15rem;
}
.hero h1 em {
  font-style: italic;
  color: var(--gold);
}
.lede {
  color: #c9c0b0;
  font-size: clamp(1rem, 1.35vw, 1.12rem);
  line-height: 1.68;
  max-width: 34rem;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.7rem;
}
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
  margin-top: 1.9rem;
  padding-top: 1.2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.hero-meta li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.76rem;
  color: #b3aa9b;
}
.hero-meta svg { color: var(--gold); flex: none; }

.hero-copy > * { animation: rise 0.85s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.hero-copy > *:nth-child(2) { animation-delay: 0.08s; }
.hero-copy > *:nth-child(3) { animation-delay: 0.16s; }
.hero-copy > *:nth-child(4) { animation-delay: 0.24s; }
.hero-copy > *:nth-child(5) { animation-delay: 0.32s; }

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

/* ---------- hero mock ---------- */
.hero-visual {
  position: relative;
  perspective: 1200px;
  animation: rise 0.9s 0.2s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.mock-window {
  position: relative;
  background: var(--card);
  color: var(--ink);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: rotate(-1.4deg);
  transition: transform 0.55s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.mock-window:hover { transform: rotate(0deg) translateY(-5px); }

.mock-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.7rem 0.9rem;
  background: #efe8db;
  border-bottom: 1px solid var(--line);
}
.mock-bar i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c9bca6;
  display: block;
}
.mock-bar i:nth-child(1) { background: #c4674b; }
.mock-bar i:nth-child(2) { background: #c9973d; }
.mock-bar i:nth-child(3) { background: #6f9583; }
.mock-bar em {
  margin-left: auto;
  font-style: normal;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.mock-body { padding: 1rem 1rem 1.15rem; }
.mock-child {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--line);
}
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #e6efe9;
  color: var(--teal);
  font-weight: 700;
  font-size: 0.78rem;
  flex: none;
}
.mock-child strong { display: block; font-size: 0.82rem; }
.mock-child small { display: block; font-size: 0.66rem; color: var(--muted); }
.mock-child .chip { margin-left: auto; }

.mock-book {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid #f1eadf;
}
.mock-book:last-of-type { border-bottom: 0; }
.mock-book strong { display: block; font-size: 0.76rem; }
.mock-book small { display: block; font-size: 0.63rem; color: var(--muted); }
.mock-book b { font-size: 0.76rem; }

.cover {
  position: relative;
  width: 34px;
  height: 44px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--serif);
  font-size: 0.8rem;
  font-weight: 700;
  overflow: hidden;
  box-shadow: inset -4px 0 0 rgba(0, 0, 0, 0.18);
  flex: none;
}
.cover::after {
  content: "";
  position: absolute;
  inset: 4px auto 4px 4px;
  width: 1px;
  background: rgba(255, 255, 255, 0.35);
}
.cover.math { background: linear-gradient(140deg, #2d5f7c, #1b3a4d); }
.cover.sci { background: linear-gradient(140deg, #2f7a5f, #1d4a3a); }
.cover.eng { background: linear-gradient(140deg, #a34f2c, #6f3018); }
.cover.hist { background: linear-gradient(140deg, #8a6a2c, #5b4418); }
.cover.lang { background: linear-gradient(140deg, #5a567f, #373453); }

.mock-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-top: 0.8rem;
  margin-top: 0.2rem;
  border-top: 1px solid var(--line);
  font-size: 0.74rem;
  color: var(--muted);
}
.mock-total strong {
  font-family: var(--serif);
  font-size: 1.15rem;
  color: var(--ink);
}
.mock-cta {
  margin-top: 0.65rem;
  background: var(--ink);
  color: #fff;
  text-align: center;
  border-radius: 9px;
  padding: 0.62rem;
  font-size: 0.75rem;
  font-weight: 650;
}

.float-card {
  position: absolute;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--card);
  color: var(--ink);
  padding: 0.6rem 0.8rem;
  border-radius: 11px;
  font-size: 0.72rem;
  font-weight: 650;
  box-shadow: var(--shadow);
  animation: float 6s ease-in-out infinite;
}
.float-card svg { color: var(--teal); flex: none; }
.fc-a { top: -2.3rem; right: -1.5rem; }
.fc-b { bottom: -2.5rem; left: -1.5rem; animation-delay: -3s; }

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

/* ==========================================================================
   School picker
   ========================================================================== */
.picker {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: clamp(1rem, 2.4vw, 1.6rem);
  box-shadow: var(--shadow);
}
.picker-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.15rem;
}
.search {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  padding: 0.6rem 1rem;
  flex: 1 1 300px;
  max-width: 380px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search:focus-within {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px rgba(201, 151, 61, 0.14);
}
.search svg { color: var(--muted); flex: none; }
.search input {
  border: 0;
  background: none;
  outline: none;
  width: 100%;
  font: inherit;
  font-size: 0.88rem;
  color: var(--ink);
}
.search input::placeholder { color: #8d8a80; }

.chips { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.chip-filter {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.42rem 0.85rem;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.chip-filter:hover { border-color: var(--line-strong); color: var(--ink); }
.chip-filter.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.school-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
}
.school-card {
  position: relative;
  text-align: left;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 0.95rem;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.school-card:hover {
  transform: translateY(-3px);
  border-color: var(--line-strong);
  box-shadow: 0 16px 30px -24px rgba(20, 25, 32, 0.5);
}
.school-card.is-selected {
  border-color: var(--terra);
  background: #fff8f3;
  box-shadow: 0 0 0 2px rgba(184, 78, 40, 0.14);
}
.school-card.is-selected::after {
  content: "✓";
  position: absolute;
  top: 0.7rem;
  right: 0.75rem;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--terra);
  color: #fff;
  font-size: 0.7rem;
  display: grid;
  place-items: center;
}
.school-card[hidden] { display: none; }

.school-top { display: flex; align-items: center; gap: 0.65rem; }
.school-mono {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 0.95rem;
  font-weight: 700;
  flex: none;
  background: #e7eee8;
  color: var(--teal);
}
.school-card:nth-child(3n + 2) .school-mono { background: #f4e9dc; color: var(--terra-2); }
.school-card:nth-child(3n + 3) .school-mono { background: #efe9d8; color: #7a5a18; }
.school-card h3 { font-size: 0.86rem; line-height: 1.25; margin: 0; }
.school-name {
  display: block;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.25;
}
.school-place { display: block; font-size: 0.68rem; color: var(--muted); margin-top: 0.15rem; }
.school-card .school-top p { font-size: 0.68rem; color: var(--muted); margin-top: 0.15rem; }
.school-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.75rem;
  font-size: 0.68rem;
  color: var(--muted);
}
.tag {
  display: inline-flex;
  padding: 0.12rem 0.42rem;
  border-radius: 5px;
  background: #ece5d8;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #6b6253;
}

.picked {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.15rem;
  padding-top: 1.15rem;
  border-top: 1px dashed var(--line-strong);
}
.picked-label { font-size: 0.8rem; color: var(--muted); }
.picked-label strong { display: block; color: var(--ink); font-size: 0.92rem; margin-top: 0.1rem; }
.picked .btn[aria-disabled="true"] { opacity: 0.4; pointer-events: none; }

.empty {
  grid-column: 1 / -1;
  padding: 2.2rem 1rem;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ==========================================================================
   Portals
   ========================================================================== */
.portal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.portal {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1.2rem;
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}
.portal:hover {
  transform: translateY(-5px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}
.portal-visual {
  position: relative;
  height: 174px;
  border-radius: 13px;
  background: var(--paper-2);
  overflow: hidden;
  padding: 0.72rem 0.9rem;
  margin-bottom: 1.1rem;
}
.portal-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 80% 10%, rgba(255, 255, 255, 0.65), transparent 55%);
  pointer-events: none;
}
.portal h3 {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.portal p {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.6;
  margin-top: 0.45rem;
  flex: 1;
}
.portal .open {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 1rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--terra-2);
}
.portal .open svg { transition: transform 0.2s ease; }
.portal:hover .open svg { transform: translateX(4px); }

.mini-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--card);
  border: 1px solid #e8dfcf;
  border-radius: 8px;
  padding: 0.45rem 0.5rem;
  margin-bottom: 0.4rem;
  box-shadow: 0 6px 14px -12px rgba(20, 25, 32, 0.4);
}
.mini-row .cover { width: 22px; height: 30px; font-size: 0.58rem; border-radius: 3px; }
.mini-row span { font-size: 0.62rem; font-weight: 600; }
.mini-row b { margin-left: auto; font-size: 0.62rem; }
.mini-row .tick {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #dfeee5;
  color: var(--ok);
  display: grid;
  place-items: center;
  font-size: 0.5rem;
  font-weight: 800;
}

.mini-drop {
  height: 100%;
  border: 1px dashed #c9bba4;
  border-radius: 10px;
  display: grid;
  place-items: center;
  text-align: center;
  background: rgba(255, 253, 248, 0.55);
  padding: 0.6rem;
}
.mini-drop strong { display: block; font-size: 0.68rem; }
.mini-drop small { display: block; font-size: 0.58rem; color: var(--muted); margin-top: 0.15rem; }
.mini-progress {
  height: 5px;
  border-radius: 999px;
  background: #e3d9c7;
  margin-top: 0.6rem;
  overflow: hidden;
}
.mini-progress i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--teal), #3c9b86);
  border-radius: inherit;
  transform-origin: left;
  animation: grow 1.6s 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes grow { from { transform: scaleX(0.05); } to { transform: scaleX(1); } }

.mini-bars {
  height: 100%;
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
  padding-top: 1rem;
}
.mini-bars i {
  flex: 1;
  border-radius: 5px 5px 2px 2px;
  background: linear-gradient(180deg, #2f7f72, #1c5a51);
  display: block;
  height: var(--h);
  transform-origin: bottom;
  animation: barUp 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.mini-bars i:nth-child(2) { animation-delay: 0.08s; }
.mini-bars i:nth-child(3) { animation-delay: 0.16s; }
.mini-bars i:nth-child(4) { animation-delay: 0.24s; }
.mini-bars i:nth-child(5) { animation-delay: 0.32s; }
@keyframes barUp { from { transform: scaleY(0.05); } to { transform: scaleY(1); } }

/* ==========================================================================
   Workflow
   ========================================================================== */
.flow {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.4rem;
  padding-top: 0.5rem;
}
.flow::before {
  content: "";
  position: absolute;
  top: 26px;
  left: 3%;
  right: 3%;
  height: 1px;
  background: linear-gradient(90deg, var(--line-strong), var(--terra), var(--line-strong));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 1.4s 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.flow.is-visible::before { transform: scaleX(1); }

.step { position: relative; padding-top: 4rem; }
.step-num {
  position: absolute;
  top: 0;
  left: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--gold);
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 700;
  border: 5px solid var(--paper);
  z-index: 1;
  transition: background 0.3s, color 0.3s;
}
.step:hover .step-num { background: var(--terra); color: #fff; }
.step h3 {
  font-size: 0.98rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  letter-spacing: -0.01em;
}
.step p { color: var(--muted); font-size: 0.84rem; line-height: 1.62; }
.step .step-tag {
  display: inline-block;
  margin-top: 0.55rem;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--terra-2);
}

/* ==========================================================================
   Features
   ========================================================================== */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem;
}
.feature {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.15rem;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.feature:hover {
  transform: translateY(-3px);
  border-color: var(--line-strong);
  box-shadow: 0 18px 34px -30px rgba(20, 25, 32, 0.5);
}
.feature-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: #f2e8db;
  color: var(--terra-2);
  margin-bottom: 0.8rem;
}
.feature h3 { font-size: 0.92rem; margin-bottom: 0.3rem; }
.feature p { color: var(--muted); font-size: 0.82rem; line-height: 1.6; }

/* ==========================================================================
   Build panel
   ========================================================================== */
.build {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 2.5rem;
  align-items: center;
  background: var(--ink);
  color: #f3ecdf;
  border-radius: 28px;
  padding: clamp(2rem, 5vw, 3.6rem);
}
.build::before {
  content: "";
  position: absolute;
  width: 380px;
  height: 380px;
  right: -120px;
  top: -160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201, 151, 61, 0.28), transparent 65%);
  pointer-events: none;
}
.build .eyebrow { color: var(--gold); }
.build h2 {
  font-family: var(--serif);
  font-size: clamp(1.9rem, 3.6vw, 2.75rem);
  font-weight: 500;
  line-height: 1.03;
  letter-spacing: -0.03em;
  margin: 0.6rem 0 0.9rem;
}
.build p { color: #b9b0a1; font-size: 0.95rem; line-height: 1.7; max-width: 30rem; }
.build .btn { margin-top: 1.4rem; }

.stats {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem 1.2rem;
}
.stat b {
  display: block;
  font-family: var(--serif);
  font-size: clamp(2.1rem, 3.6vw, 2.9rem);
  font-weight: 500;
  color: var(--gold);
  line-height: 1;
}
.stat span {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #a89f90;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.footer {
  background: var(--ink);
  color: #a89f90;
  padding: 3rem 0 1.8rem;
  margin-top: clamp(3rem, 6vw, 5rem);
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.8fr 1fr 1fr;
  gap: 2rem;
}
.footer .brand-name { color: #f3ecdf; }
.footer p { font-size: 0.82rem; line-height: 1.7; max-width: 26rem; margin-top: 0.9rem; }
.footer h3 {
  color: #f3ecdf;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 0.8rem;
}
.footer li { margin-bottom: 0.45rem; }
.footer li a { font-size: 0.84rem; transition: color 0.2s; }
.footer li a:hover { color: var(--gold); }
.legal {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: 2.2rem;
  padding-top: 1.2rem;
  font-size: 0.72rem;
}
.legal span { max-width: 34rem; }

/* ==========================================================================
   Demo page
   ========================================================================== */
.demo-body { background: var(--paper-2); }
.demo-top {
  position: sticky;
  top: 0;
  z-index: 70;
  background: rgba(247, 243, 234, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.demo-top .nav-inner { padding: 0.7rem 0; }
.demo-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--warn);
  background: #f6ecd9;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex: none;
}

.demo-hero { padding: clamp(2.2rem, 5vw, 3.5rem) 0 1.2rem; }
.demo-hero h1 {
  font-family: var(--serif);
  font-size: clamp(2.1rem, 4.4vw, 3.2rem);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.03em;
  margin: 0.5rem 0 0.7rem;
}
.demo-hero p { color: var(--muted); max-width: 42rem; font-size: 0.98rem; line-height: 1.7; }

.role-tabs {
  position: relative;
  display: inline-flex;
  gap: 0.15rem;
  padding: 0.32rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  margin: 1.4rem 0 1.6rem;
  max-width: 100%;
}
.role-tab {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 1.05rem;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 650;
  color: var(--muted);
  transition: color 0.25s ease;
}
.role-tab[aria-selected="true"] { color: #fff; }
.tab-indicator {
  position: absolute;
  top: 0.32rem;
  bottom: 0.32rem;
  left: 0;
  width: 0;
  border-radius: 999px;
  background: var(--ink);
  transition: left 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), width 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.panel:not([hidden]) { animation: panelIn 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes panelIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1rem;
}
.stat-card span {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat-card b {
  display: block;
  font-family: var(--serif);
  font-size: 1.75rem;
  font-weight: 500;
  line-height: 1.1;
  margin: 0.4rem 0 0.1rem;
}
.stat-card small { font-size: 0.68rem; color: var(--muted); }
.stat-card small.up { color: var(--ok); font-weight: 600; }

.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 0.8fr);
  gap: 1rem;
  align-items: start;
}
.stack { display: grid; gap: 1rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.15rem;
  min-width: 0;
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}
.card-head h2, .card-head h3 {
  font-family: var(--serif);
  font-size: 1.12rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.card-head p { font-size: 0.74rem; color: var(--muted); margin-top: 0.15rem; }

.child-switch { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.child {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.34rem 0.65rem 0.34rem 0.38rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.child .avatar { width: 24px; height: 24px; font-size: 0.6rem; }
.child.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.child.is-active .avatar { background: rgba(255, 255, 255, 0.16); color: #fff; }

.book-list { margin-top: 0.2rem; }
.book {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.8rem;
  padding: 0.65rem 0;
  border-top: 1px solid var(--line);
}
.book:first-child { border-top: 0; }
.book .cover { width: 44px; height: 58px; font-size: 1rem; }
.book h3 { font-size: 0.86rem; font-weight: 650; line-height: 1.3; }
.book p { font-size: 0.71rem; color: var(--muted); margin-top: 0.1rem; }
.book .price { font-size: 0.86rem; font-weight: 700; white-space: nowrap; }
.book .add {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.38rem 0.7rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--ink);
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.book .add:hover { background: var(--ink); color: #fff; border-color: var(--ink); }
.book .add.is-added {
  background: #e4f0e9;
  border-color: #bcd8c9;
  color: var(--ok);
  pointer-events: none;
}
.book .add:disabled { opacity: 1; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.chip.ok { background: #e4f0e9; color: #24614a; }
.chip.warn { background: #f6ecd9; color: #8a5a12; }
.chip.info { background: #e3ecef; color: #245a6b; }
.chip.bad { background: #f7e3e1; color: #8f2f2a; }
.chip.neutral { background: #ece7dd; color: #5d574c; }

.cart-line {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0.28rem 0;
}
.cart-line strong { color: var(--ink); }
.cart-line-end { display: inline-flex; align-items: center; gap: 0.4rem; }
.cart-line .remove {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.cart-line .remove:hover { background: #f7e3e1; color: var(--bad); }
.cart-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-top: 1px solid var(--line);
  margin-top: 0.55rem;
  padding-top: 0.65rem;
  font-weight: 700;
  font-size: 0.9rem;
}
.cart-total b { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; }
.tiny { font-size: 0.68rem; color: var(--muted); line-height: 1.5; margin-top: 0.55rem; }

.track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-top: 1.1rem;
}
.track::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 8%;
  right: 8%;
  height: 2px;
  background: var(--line);
}
.track-step { position: relative; text-align: center; padding-top: 2.1rem; }
.track-dot {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--line-strong);
  z-index: 1;
}
.track-step.done .track-dot { background: var(--teal); border-color: var(--teal); }
.track-step.current .track-dot {
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 0 5px rgba(201, 151, 61, 0.2);
  animation: pulse 2.2s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(201, 151, 61, 0.35); }
  70% { box-shadow: 0 0 0 12px rgba(201, 151, 61, 0); }
  100% { box-shadow: 0 0 0 0 rgba(201, 151, 61, 0); }
}
.track-step strong { display: block; font-size: 0.74rem; }
.track-step small { display: block; font-size: 0.64rem; color: var(--muted); margin-top: 0.1rem; }

.table-wrap { overflow-x: auto; margin: 0 -1.15rem; padding: 0 1.15rem; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  min-width: 580px;
}
th {
  text-align: left;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td {
  padding: 0.62rem 0.55rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 0.15s; }
tbody tr:hover { background: #fbf7ef; }
td strong { font-weight: 650; }
td .sub { display: block; font-size: 0.66rem; color: var(--muted); margin-top: 0.08rem; }

.row-actions { display: flex; gap: 0.3rem; }
.mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0.28rem 0.5rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.mini-btn:hover { background: var(--ink); border-color: var(--ink); color: #fff; }
.mini-btn:disabled { opacity: 0.45; pointer-events: none; }
.mini-btn.ok { color: var(--ok); border-color: #b9d6c6; }
.mini-btn.ok:hover { background: var(--teal); border-color: var(--teal); }
.mini-btn.bad { color: var(--bad); border-color: #e3bab6; }
.mini-btn.bad:hover { background: var(--bad); border-color: var(--bad); }

.import-zone {
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  padding: 1.1rem;
  text-align: center;
  background: var(--paper);
  transition: border-color 0.2s, background 0.2s;
}
.import-zone:hover { border-color: var(--teal); background: #f4f8f5; }
.import-zone strong { display: block; font-size: 0.82rem; }
.import-zone small { display: block; font-size: 0.68rem; color: var(--muted); margin-top: 0.2rem; }
.progress {
  height: 6px;
  border-radius: 999px;
  background: #e6ddcd;
  overflow: hidden;
  margin-top: 0.9rem;
}
.progress i {
  display: block;
  height: 100%;
  width: var(--p, 100%);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), #3c9b86);
  transform-origin: left;
  animation: grow 1.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.progress.sim i {
  width: 0;
  transform: none;
  animation: none;
  transition: width 1.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.progress.sim.is-done i { width: 100%; }

.chart {
  display: flex;
  align-items: flex-end;
  gap: 0.9rem;
  height: 176px;
  padding-top: 0.8rem;
}
.bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 0.35rem;
  height: 100%;
  min-width: 0;
}
.bar-fill {
  width: 100%;
  max-width: 52px;
  height: var(--h);
  border-radius: 7px 7px 3px 3px;
  background: linear-gradient(180deg, #2f7f72, #1c5a51);
  transform-origin: bottom;
  transform: scaleY(0.04);
  transition: transform 0.85s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.panel.is-active .bar-fill { transform: scaleY(1); }
.bar b { font-size: 0.68rem; }
.bar span {
  font-size: 0.62rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.chip-row { display: flex; gap: 0.3rem; flex-wrap: wrap; }

.activity { display: grid; gap: 0.65rem; }
.activity li {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  gap: 0.6rem;
  align-items: start;
  font-size: 0.76rem;
  line-height: 1.45;
}
.activity i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  margin-top: 0.35rem;
}
.activity time { font-size: 0.64rem; color: var(--muted); white-space: nowrap; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.4rem;
  z-index: 110;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: #fff;
  padding: 0.8rem 1.1rem;
  border-radius: 12px;
  font-size: 0.82rem;
  box-shadow: 0 24px 50px -20px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: calc(100% - 2rem);
  text-align: center;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.demo-note {
  margin: 1.8rem 0 3rem;
  padding: 0.8rem 1rem;
  border-left: 3px solid var(--gold);
  background: rgba(255, 253, 248, 0.7);
  font-size: 0.78rem;
  color: var(--muted);
  border-radius: 0 8px 8px 0;
}
.demo-note a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
.demo-note strong { color: var(--ink); }
.quote { font-size: 0.84rem; line-height: 1.6; color: var(--ink-2); }
.legal-flush { margin-top: 0; border-top: 0; padding-top: 0; }
.mt-sm { margin-top: 0.9rem; }
.activity i.bad { background: var(--bad); }
.activity i.warn { background: var(--warn); }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1024px) {
  .hero-grid { grid-template-columns: 1fr; gap: 2.8rem; }
  .hero-visual { max-width: 520px; }
  .portal-grid, .feature-grid { grid-template-columns: 1fr 1fr; }
  .panel-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .build { grid-template-columns: 1fr; }
  .school-grid { grid-template-columns: 1fr 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-grid > div:first-child { grid-column: 1 / -1; }

  .flow { grid-template-columns: 1fr 1fr; gap: 2.1rem 1.6rem; }
  .flow::before { display: none; }
}

/* Tablets: give the third portal a full-width row so the grid does not end
   with an empty cell. */
@media (min-width: 761px) and (max-width: 1024px) {
  .portal-grid .portal:last-child {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(220px, 0.85fr) 1.5fr;
    grid-template-rows: auto auto 1fr;
    column-gap: 1.5rem;
    align-items: start;
  }
  .portal-grid .portal:last-child .portal-visual {
    grid-column: 1;
    grid-row: 1 / -1;
    height: 100%;
    min-height: 174px;
    margin-bottom: 0;
  }
  .portal-grid .portal:last-child h3 { grid-column: 2; grid-row: 1; }
  .portal-grid .portal:last-child p { grid-column: 2; grid-row: 2; margin-top: 0.55rem; }
  .portal-grid .portal:last-child .open { grid-column: 2; grid-row: 3; align-self: end; margin-top: 0.9rem; }
}

@media (max-width: 760px) {
  .nav-links { display: none; }
  .menu-btn { display: grid; }
  .nav.is-open .mobile-menu { display: block; }
  .nav-inner { padding: 0.7rem 0; }

  .eyebrow { font-size: 0.63rem; letter-spacing: 0.13em; }
  .eyebrow::before { width: 20px; }

  .hero { padding-top: 3rem; }
  .hero-visual { margin-inline: 0.4rem; }
  .fc-a { right: -2%; }
  .fc-b { left: -2%; }

  .flow { grid-template-columns: 1fr; gap: 1.6rem; }
  .flow::before { display: none; }
  .step { padding-top: 3.3rem; }
  .step-num { width: 46px; height: 46px; }

  .portal-grid, .feature-grid, .school-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }

  .demo-hero { padding-top: 1.6rem; }
  .demo-top .brand-name small { display: none; }
  .role-tabs { display: flex; width: 100%; }
  .role-tab { flex: 1; justify-content: center; padding-inline: 0.5rem; }

  .card-head { flex-wrap: wrap; }
  .card-head .child-switch { flex: 1 0 100%; }
  .card-head .child { flex: 1; justify-content: center; }

  .table-books, .table-approvals, .table-orders { min-width: 0; }
  .table-books th:nth-child(2), .table-books td:nth-child(2),
  .table-books th:nth-child(3), .table-books td:nth-child(3),
  .table-approvals th:nth-child(2), .table-approvals td:nth-child(2),
  .table-approvals th:nth-child(3), .table-approvals td:nth-child(3),
  .table-approvals th:nth-child(4), .table-approvals td:nth-child(4),
  .table-orders th:nth-child(2), .table-orders td:nth-child(2) { display: none; }
  .table-books th, .table-approvals th, .table-orders th,
  .table-books td, .table-approvals td, .table-orders td { padding: 0.5rem 0.32rem; }
  .table-books td, .table-approvals td, .table-orders td { font-size: 0.74rem; }

  .track { grid-template-columns: 1fr; gap: 0.9rem; }
  .track::before { top: 0; bottom: 0; left: 8px; right: auto; width: 2px; height: auto; }
  .track-step { text-align: left; padding: 0 0 0 2rem; }
  .track-dot { left: 0; top: 0.15rem; transform: none; }

  .book {
    grid-template-columns: 40px minmax(0, 1fr) auto;
    gap: 0.1rem 0.65rem;
    padding: 0.7rem 0;
  }
  .book .cover { grid-row: 1 / span 2; width: 40px; height: 54px; }
  .book > div { grid-column: 2; grid-row: 1; }
  .book .price { grid-column: 2; grid-row: 2; font-size: 0.78rem; }
  .book .add { grid-column: 3; grid-row: 1 / span 2; }
  .book .stock { display: none; }

  .picked { align-items: flex-start; flex-direction: column; }
  .picked .btn { width: 100%; }

  .build { border-radius: 20px; }
  .legal { flex-direction: column; }
}

@media (max-width: 480px) {
  .wrap { width: calc(100% - 1.6rem); }
  .hero h1 { font-size: 2.55rem; }
  .hero-actions .btn { width: 100%; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .demo-badge { display: none; }
  .card { padding: 0.9rem; }
  .table-wrap { margin: 0 -0.9rem; padding: 0 0.9rem; }
  .search { max-width: none; }
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
  .flow::before { transform: none; }
  .bar-fill { transform: scaleY(1); }
}

/* ==========================================================================
   Guided walkthrough
   ========================================================================== */
.tour-launch {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}
.tour-launch .tiny { color: var(--muted); }

.role-tabs { scroll-margin-top: 90px; }

.panel-next {
  margin-top: 1.1rem;
  padding: 0.85rem 1rem;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  flex-wrap: wrap;
}
.panel-next p { margin: 0; font-size: 0.86rem; color: var(--muted); }
.panel-next-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.tour-pop {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  max-width: 430px;
  margin: 0 auto;
  padding: 1rem 1.1rem 1.1rem;
  background: #fffdf7;
  border: 1px solid var(--gold);
  border-width: 1px 1px 3px;
  border-radius: 14px;
  box-shadow: 0 18px 44px rgba(60, 42, 10, 0.28);
  z-index: 90;
  animation: tour-in 0.28s ease both;
}
@keyframes tour-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
.tour-pop[hidden] { display: none; }
.tour-pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}
.tour-step-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
}
.tour-close {
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 8px;
  display: inline-flex;
}
.tour-close:hover { background: rgba(0, 0, 0, 0.06); color: var(--ink); }
.tour-pop h2 { font-size: 1.02rem; margin: 0 0 0.3rem; }
.tour-pop p { margin: 0 0 0.8rem; font-size: 0.88rem; color: var(--muted); }
.tour-pop-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }

.tour-target {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 14px;
  scroll-margin: 150px 24px 320px 24px;
}

@media (min-width: 480px) {
  .tour-pop { left: auto; right: 1.5rem; margin: 0; }
}
@media (max-width: 640px) {
  .panel-next { flex-direction: column; align-items: flex-start; }
}

/* ==========================================================================
   AI guide (static knowledge panel)
   ========================================================================== */
.guide-fab {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 80;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 0.95rem;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fffdf7;
  font: 600 0.82rem var(--sans);
  cursor: pointer;
  box-shadow: 0 14px 30px -10px rgba(20, 25, 32, 0.55);
  transition: transform 0.18s ease, background 0.18s ease;
}
.guide-fab:hover { transform: translateY(-2px); background: var(--ink-2); }
.guide-fab[aria-expanded="true"] { background: var(--gold); color: var(--ink); }

.guide-panel {
  position: fixed;
  left: 1rem;
  bottom: 4.6rem;
  width: min(390px, calc(100vw - 2rem));
  max-height: min(560px, calc(100vh - 6.5rem));
  display: flex;
  flex-direction: column;
  background: #fffdf7;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  box-shadow: 0 22px 55px -18px rgba(20, 25, 32, 0.5);
  z-index: 85;
  overflow: hidden;
  animation: tour-in 0.26s ease both;
}
.guide-panel[hidden] { display: none; }

.guide-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem 0.7rem;
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
}
.guide-head h2 { font-size: 1rem; margin: 0 0 0.15rem; }
.guide-head p { margin: 0; font-size: 0.76rem; color: var(--muted); }

.guide-thread {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.85rem 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  overscroll-behavior: contain;
}
.guide-msg { max-width: 88%; }
.guide-msg p {
  margin: 0;
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  font-size: 0.83rem;
  line-height: 1.5;
}
.guide-msg.bot p { background: var(--paper-2); color: var(--ink); }
.guide-msg.user { align-self: flex-end; }
.guide-msg.user p { background: var(--ink); color: #fffdf7; }

.guide-typing {
  display: inline-flex;
  gap: 4px;
  padding: 0.55rem 0.75rem;
  background: var(--paper-2);
  border-radius: 12px;
}
.guide-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: guide-bounce 1s infinite ease-in-out;
}
.guide-typing i:nth-child(2) { animation-delay: 0.15s; }
.guide-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes guide-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-3px); opacity: 1; }
}

.guide-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.4rem 1rem 0.6rem;
  border-top: 1px solid var(--line);
}
.guide-chip {
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink);
  font: 500 0.74rem var(--sans);
  padding: 0.32rem 0.6rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.guide-chip:hover { background: var(--paper-2); border-color: var(--gold); }

.guide-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--card);
}
.guide-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--card);
  font: 400 0.84rem var(--sans);
  color: var(--ink);
}
.guide-input:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }
.guide-fine { margin: 0; padding: 0 1rem 0.7rem; background: var(--card); }

@media (max-width: 640px) {
  .guide-panel { left: 0.5rem; right: 0.5rem; width: auto; }
  .guide-fab { left: 0.75rem; bottom: 0.75rem; }
}
