:root {
  --navy: #1f3a5f;
  --navy-deep: #16293f;
  --gold: #e8b64c;
  --gold-deep: #c9922b;
  --ink: #1c2430;
  --muted: #5c6773;
  --line: #e2e6ec;
  --paper: #ffffff;
  --canvas: #f4f6f9;
  --canvas-2: #eef1f6;
  --ok: #2e7d5b;
  --serif: "Spectral", Georgia, serif;
  --sans: "Source Sans 3", system-ui, -apple-system, sans-serif;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,29,47,.06), 0 8px 24px rgba(16,29,47,.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--canvas);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .7rem 1.4rem;
  background: rgba(255,255,255,.82); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .7rem; }
.brand-name { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; color: var(--navy); line-height: 1.1; }
.brand-sub { font-size: .78rem; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: .8rem; }
.save-status { font-size: .8rem; color: var(--ok); min-width: 90px; text-align: right; }

/* ── Layout ─────────────────────────────────────────────── */
.layout {
  display: grid; grid-template-columns: 260px 1fr;
  gap: 1.6rem; max-width: 1080px; margin: 1.6rem auto; padding: 0 1.4rem;
  align-items: start;
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .rail { position: static !important; flex-direction: row; overflow-x: auto; }
}

/* ── Progress rail ──────────────────────────────────────── */
.rail {
  position: sticky; top: 78px;
  display: flex; flex-direction: column; gap: .35rem;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .6rem; box-shadow: var(--shadow);
}
.rail-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .6rem; border-radius: 9px; cursor: pointer;
  border: 1px solid transparent; white-space: nowrap;
}
.rail-item:hover { background: var(--canvas-2); }
.rail-item.active { background: var(--navy); color: #fff; }
.rail-item.active .rail-code { background: var(--gold); color: var(--navy-deep); }
.rail-item.done .rail-code { background: var(--ok); color: #fff; }
.rail-code {
  flex: none; width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center; font-weight: 700; font-size: .8rem;
  background: var(--canvas-2); color: var(--navy);
}
.rail-text { display: flex; flex-direction: column; line-height: 1.15; }
.rail-title { font-weight: 600; font-size: .9rem; }
.rail-tag { font-size: .72rem; opacity: .8; }

/* ── Stage ──────────────────────────────────────────────── */
.stageWrap { min-width: 0; }
.stage {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.8rem; box-shadow: var(--shadow);
}
.stage-eyebrow { font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--gold-deep); font-weight: 700; }
.stage h1 { font-family: var(--serif); font-size: 1.8rem; margin: .2rem 0 .1rem; color: var(--navy-deep); }
.stage-tagline { font-family: var(--serif); font-style: italic; color: var(--muted); margin: 0 0 .9rem; }
.stage-intro { color: var(--ink); margin: 0 0 1.4rem; }

.field { margin-bottom: 1.2rem; }
.field label { display: block; font-weight: 600; margin-bottom: .3rem; }
.field .help { font-size: .82rem; color: var(--muted); margin: -.15rem 0 .4rem; }
.field input, .field select, .field textarea {
  width: 100%; font-family: inherit; font-size: .95rem; color: var(--ink);
  padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 9px; background: #fdfefe;
}
.field textarea { min-height: 92px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(31,58,95,.12);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  font-family: inherit; font-weight: 600; font-size: .92rem; cursor: pointer;
  border-radius: 9px; padding: .55rem 1rem; border: 1px solid transparent; transition: .12s;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--navy-deep); }
.btn-gold { background: var(--gold); color: var(--navy-deep); }
.btn-gold:hover:not(:disabled) { background: var(--gold-deep); color: #fff; }
.btn-ghost { background: transparent; color: var(--navy); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--canvas-2); }
.stageNav { display: flex; justify-content: space-between; margin-top: 1.2rem; }

/* ── AI assist panel ────────────────────────────────────── */
.assistBar { display: flex; align-items: center; gap: .7rem; margin: .4rem 0 1rem; flex-wrap: wrap; }
.assistBar .hint { font-size: .82rem; color: var(--muted); }
.assist {
  border: 1px solid var(--line); border-left: 3px solid var(--gold);
  background: #fffdf7; border-radius: 10px; padding: 1rem 1.1rem; margin-bottom: 1.2rem;
}
.assist-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .4rem; }
.assist-head strong { color: var(--gold-deep); font-size: .82rem; letter-spacing: .08em; text-transform: uppercase; }
.assist-body { font-size: .95rem; }
.assist-body h2 { font-family: var(--serif); font-size: 1.1rem; color: var(--navy-deep); margin: .9rem 0 .3rem; }
.assist-body ul, .assist-body ol { margin: .3rem 0 .3rem 1.1rem; padding: 0; }
.assist-body p { margin: .4rem 0; }
.assist-actions { display: flex; gap: .6rem; margin-top: .8rem; flex-wrap: wrap; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--gold); border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Deliverables (export stage) ────────────────────────── */
.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tab { border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: .4rem .9rem; cursor: pointer; font-weight: 600; font-size: .85rem; }
.tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.deliverable { border: 1px solid var(--line); border-radius: 10px; padding: 1.2rem 1.4rem; background: #fff; min-height: 160px; }
.deliverable.empty { color: var(--muted); display: grid; place-items: center; text-align: center; }
.doc h1 { font-family: var(--serif); color: var(--navy-deep); font-size: 1.5rem; }
.doc h2 { font-family: var(--serif); color: var(--navy); font-size: 1.2rem; margin-top: 1.3rem; }
.doc h3 { font-size: 1.02rem; color: var(--navy-deep); }
.doc table { border-collapse: collapse; width: 100%; margin: .8rem 0; font-size: .9rem; }
.doc th, .doc td { border: 1px solid var(--line); padding: .45rem .6rem; text-align: left; vertical-align: top; }
.doc th { background: var(--canvas-2); }
.doc code { background: var(--canvas-2); padding: .1rem .3rem; border-radius: 4px; font-size: .88em; }
.doc pre { background: var(--canvas-2); padding: .8rem; border-radius: 8px; overflow-x: auto; }
.exportBar { display: flex; gap: .6rem; margin-top: 1rem; flex-wrap: wrap; }

/* ── Syllabus import zone ───────────────────────────────── */
.import-zone {
  border: 1px dashed var(--gold); background: #fffdf7; border-radius: 10px;
  padding: 1rem 1.1rem; margin-bottom: 1.6rem;
}
.import-row { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.import-hint { display: block; font-size: .82rem; color: var(--muted); margin-top: .5rem; }

/* ── Outcomes engine (D1) ───────────────────────────────── */
.extract-callout {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  background: #fffdf7; border: 1px solid var(--line); border-left: 3px solid var(--gold);
  border-radius: 10px; padding: .8rem 1rem; margin-bottom: 1rem; font-size: .9rem;
}
.outcome-summary { font-size: .88rem; color: var(--muted); margin: .2rem 0 1rem; }
.outcome-summary strong { color: var(--navy-deep); }
.outcome-summary .summary-warn { color: var(--gold-deep); font-weight: 600; }
.outcome-list { display: flex; flex-direction: column; gap: .9rem; }

.outcome-card {
  border: 1px solid var(--line); border-radius: 11px; background: #fff;
  padding: .9rem 1rem 1rem; box-shadow: var(--shadow);
}
.outcome-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.outcome-index {
  flex: none; width: 34px; height: 26px; border-radius: 7px; background: var(--navy); color: #fff;
  font-weight: 700; font-size: .8rem; display: grid; place-items: center;
}
.badge { font-size: .76rem; font-weight: 600; padding: .18rem .5rem; border-radius: 999px; white-space: nowrap; }
.badge.ok { background: #e6f4ee; color: var(--ok); }
.badge.warn { background: #fbf1dc; color: var(--gold-deep); }
.badge.muted { background: var(--canvas-2); color: var(--muted); }
.outcome-actions { margin-left: auto; display: flex; gap: .25rem; }
.icon-btn {
  border: 1px solid var(--line); background: var(--paper); color: var(--navy);
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: .9rem; line-height: 1;
  display: grid; place-items: center; transition: .12s;
}
.icon-btn:hover:not(:disabled) { background: var(--canvas-2); }
.icon-btn:disabled { opacity: .35; cursor: default; }

.outcome-statement {
  width: 100%; font-family: inherit; font-size: .98rem; color: var(--ink);
  padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 9px; background: #fdfefe;
  min-height: 62px; resize: vertical;
}
.outcome-statement:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(31,58,95,.12); }
.outcome-meta { margin-top: .5rem; }
.outcome-bloom {
  font-family: inherit; font-size: .85rem; padding: .35rem .6rem;
  border: 1px solid var(--line); border-radius: 8px; background: #fdfefe; color: var(--ink);
}
.outcome-details { margin-top: .6rem; }
.outcome-details > summary {
  cursor: pointer; font-size: .82rem; color: var(--muted); font-weight: 600;
  list-style: none; user-select: none;
}
.outcome-details > summary::before { content: '▸ '; color: var(--gold-deep); }
.outcome-details[open] > summary::before { content: '▾ '; }
.outcome-detgrid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .7rem; margin-top: .6rem; }
@media (max-width: 620px) { .outcome-detgrid { grid-template-columns: 1fr; } }
.mini-field { display: flex; flex-direction: column; gap: .25rem; }
.mini-field > span { font-size: .78rem; font-weight: 600; color: var(--muted); }
.mini-field textarea {
  font-family: inherit; font-size: .88rem; color: var(--ink); min-height: 52px; resize: vertical;
  padding: .45rem .55rem; border: 1px solid var(--line); border-radius: 8px; background: #fdfefe;
}
.mini-field textarea:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(31,58,95,.12); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 1.4rem; transform: translateX(-50%) translateY(140%);
  background: var(--navy-deep); color: #fff; padding: .7rem 1.1rem; border-radius: 10px;
  font-size: .88rem; max-width: min(560px, 92vw); box-shadow: var(--shadow); z-index: 100;
  opacity: 0; transition: transform .25s ease, opacity .25s ease;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

.callout { background: var(--canvas-2); border-radius: 9px; padding: .8rem 1rem; font-size: .9rem; color: var(--muted); margin-bottom: 1rem; }
.foot { max-width: 1080px; margin: 2rem auto; padding: 0 1.4rem 2rem; color: var(--muted); font-size: .85rem; text-align: center; }

/* ── Structured builders (course map, AI posture) ───────── */
.builder { border: 1px solid var(--line); border-radius: 11px; background: #fbfcfe; padding: 1rem 1.1rem; margin-bottom: 1.4rem; }
.builder-head { margin-bottom: .5rem; }
.builder-head strong { display: block; color: var(--navy-deep); }
.builder-sub { font-size: .82rem; color: var(--muted); }
.cm-list, .ap-list { display: flex; flex-direction: column; gap: .5rem; }
.cm-row { display: grid; grid-template-columns: 28px 1fr 210px 1fr 30px; gap: .5rem; align-items: center; }
.ap-row { display: grid; grid-template-columns: 92px 1fr 150px 1fr 30px; gap: .5rem; align-items: center; }
@media (max-width: 680px) { .cm-row, .ap-row { grid-template-columns: 1fr; } }
.cm-row input, .cm-row select, .ap-row input, .ap-row select {
  font-family: inherit; font-size: .88rem; padding: .42rem .5rem; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; width: 100%;
}
.cm-idx { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; font-weight: 700; font-size: .8rem; background: var(--canvas-2); color: var(--navy); }
.cm-idx.m-inperson { background: #e6f0fb; color: #1f3a5f; }
.cm-idx.m-sync { background: #ece7f8; color: #5b3fb0; }
.cm-idx.m-async { background: #e6f4ee; color: var(--ok); }
.cm-idx.m-ai { background: #fbf1dc; color: var(--gold-deep); }
.ap-badge { font-size: .7rem; font-weight: 700; padding: .25rem .4rem; border-radius: 999px; text-align: center; background: var(--canvas-2); color: var(--muted); white-space: nowrap; }
.ap-badge.p-resistant { background: #fdeceb; color: #b3261e; }
.ap-badge.p-assisted { background: #fbf1dc; color: var(--gold-deep); }
.ap-badge.p-required { background: #e6f4ee; color: var(--ok); }

/* ── Sign-in (OAuth) ────────────────────────────────────── */
.signin-layout { display: block; max-width: 480px; margin: 6vh auto; }
.signin-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 2.4rem 2rem; text-align: center;
}
.signin-card h1 { font-family: var(--serif); color: var(--navy-deep); font-size: 1.6rem; margin: .8rem 0 .3rem; }
.signin-sub { color: var(--muted); margin: 0 0 1.4rem; }
.signin-btn { display: inline-block; text-decoration: none; padding: .7rem 1.4rem; font-size: 1rem; }
.signin-note { border-radius: 9px; padding: .7rem .9rem; margin-bottom: 1.1rem; font-size: .9rem; }
.signin-note.err { background: #fdeceb; color: #b3261e; border: 1px solid #f3c7c3; }
.signin-note.ok { background: #e6f4ee; color: var(--ok); border: 1px solid #b8e0cd; }

/* ── Admin panel ────────────────────────────────────────── */
.admin-overlay {
  position: fixed; inset: 0; background: rgba(16,29,47,.5); z-index: 200;
  display: none; align-items: flex-start; justify-content: center; padding: 5vh 1rem; overflow-y: auto;
}
.admin-modal {
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow);
  width: 100%; max-width: 760px; padding: 1.4rem 1.6rem;
}
.admin-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.admin-head h2 { font-family: var(--serif); color: var(--navy-deep); margin: 0; font-size: 1.3rem; }
.admin-add { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.admin-add input {
  flex: 1 1 180px; font-family: inherit; font-size: .9rem; padding: .5rem .6rem;
  border: 1px solid var(--line); border-radius: 8px; background: #fdfefe;
}
.admin-table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.admin-table th, .admin-table td { border-bottom: 1px solid var(--line); padding: .5rem .5rem; text-align: left; vertical-align: middle; }
.admin-table th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.admin-actions-cell { display: flex; gap: .35rem; flex-wrap: wrap; }
.btn-sm { padding: .3rem .6rem; font-size: .8rem; }
.status-badge { font-size: .74rem; font-weight: 700; padding: .15rem .5rem; border-radius: 999px; text-transform: capitalize; }
.status-badge.s-pending { background: #fbf1dc; color: var(--gold-deep); }
.status-badge.s-approved { background: #e6f4ee; color: var(--ok); }
.status-badge.s-denied { background: #fdeceb; color: #b3261e; }
.user-chip {
  font-size: .82rem; color: var(--navy-deep); background: var(--canvas-2);
  padding: .3rem .7rem; border-radius: 999px; max-width: 220px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}

/* ── Landing page ───────────────────────────────────────── */
.landing { display: block; max-width: 960px; margin: 2.5vh auto 4rem; padding: 0 1.4rem; }
.lp-hero { text-align: center; padding: 2rem 1rem 1rem; }
.lp-kicker { font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-deep); font-weight: 700; margin-top: .6rem; }
.lp-hero h1 { font-family: var(--serif); font-size: 2.2rem; line-height: 1.15; color: var(--navy-deep); margin: .5rem auto .6rem; max-width: 16em; }
.lp-sub { color: var(--muted); font-size: 1.05rem; max-width: 40em; margin: 0 auto 1.4rem; }
.google-btn { display: inline-flex; align-items: center; gap: .6rem; text-decoration: none; padding: .7rem 1.3rem; font-size: 1rem; }
.google-btn svg { background: #fff; border-radius: 3px; padding: 2px; box-sizing: content-box; }
.lp-fine { font-size: .82rem; color: var(--muted); margin-top: .9rem; }
.lp-section { margin-top: 2.6rem; }
.lp-section h2 { font-family: var(--serif); color: var(--navy-deep); text-align: center; font-size: 1.5rem; margin-bottom: 1.2rem; }
.lp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 1rem; }
.lp-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); }
.lp-badge { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--navy); color: #fff; font-weight: 800; margin-bottom: .5rem; }
.lp-card h3 { font-family: var(--serif); color: var(--navy); margin: .2rem 0 .3rem; font-size: 1.1rem; }
.lp-card p { font-size: .88rem; color: var(--muted); margin: 0; }
.lp-features { max-width: 44em; margin: 0 auto; line-height: 1.7; }
.lp-features li { margin-bottom: .4rem; }
@media (max-width: 560px) { .lp-hero h1 { font-size: 1.7rem; } }

/* ── Tutorial ───────────────────────────────────────────── */
.tour-overlay { position: fixed; inset: 0; background: rgba(16,29,47,.55); z-index: 300; display: none; align-items: center; justify-content: center; padding: 1rem; }
.tour-card { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); max-width: 520px; width: 100%; padding: 1.6rem 1.7rem; }
.tour-progress { font-size: .78rem; color: var(--gold-deep); font-weight: 700; letter-spacing: .08em; }
.tour-card h2 { font-family: var(--serif); color: var(--navy-deep); font-size: 1.35rem; margin: .3rem 0 .5rem; }
.tour-card p { color: var(--ink); line-height: 1.6; margin: 0; }
.tour-dots { display: flex; gap: .35rem; justify-content: center; margin: 1.2rem 0; }
.tour-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.tour-dot.on { background: var(--gold); }
.tour-nav { display: flex; align-items: center; gap: .5rem; }
.tour-spacer { flex: 1; }

/* ── Print / PDF ────────────────────────────────────────── */
@media print {
  .topbar, .rail, .stageNav, .assistBar, .assist, .tabs, .exportBar, .foot, .btn { display: none !important; }
  body { background: #fff; }
  .layout { display: block; margin: 0; padding: 0; max-width: none; }
  .stage { border: none; box-shadow: none; padding: 0; }
  .deliverable { border: none; padding: 0; }
  #printArea .doc { page-break-after: always; }
}
