:root {
  --deep-blue: #234b66;
  --blue-jay: #3b6f91;
  --robins-egg: #82bcc1;
  --terracotta: #a7523e;
  --ivory: #fbf7ef;
  --ivory-card: #ffffff;
  --ivory-soft: #f3ede0;
  --ink: #263338;
  --muted: #52636b;
  --border: #d9d1c2;
  --green: #1e5e4b;
  --green-bg: #e7f4ef;
  --red: #9b2c2c;
  --red-bg: #fbeaea;
  --amber: #9c6513;
  --amber-bg: #fdf5e6;
  --shadow: 0 2px 10px rgba(35, 75, 102, 0.08);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--ivory);
  color: var(--ink);
  line-height: 1.55;
}

h1, h2, h3, h4 {
  font-family: 'Lora', Georgia, serif;
  color: var(--deep-blue);
  margin: 0 0 0.5rem 0;
  line-height: 1.25;
}

h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

a {
  color: #2f6282;
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--deep-blue);
}

code {
  background: var(--ivory-soft);
  padding: 0.12rem 0.35rem;
  border-radius: 5px;
  font-size: 0.88em;
}

.topbar {
  background: var(--deep-blue);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.14);
}

.topbar-inner {
  max-width: 1260px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem 0.6rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--robins-egg);
  color: var(--deep-blue);
  font-family: 'Lora', Georgia, serif;
  font-weight: 700;
  font-size: 1.25rem;
  display: grid;
  place-items: center;
}

.brand-title {
  font-family: 'Lora', Georgia, serif;
  font-weight: 700;
  font-size: 1.1rem;
}

.brand-sub {
  font-size: 0.78rem;
  color: #d7e7ee;
}

.topbar-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.pill-accent {
  background: var(--terracotta);
}

.pill-score {
  background: var(--robins-egg);
  color: var(--deep-blue);
}

.card .pill {
  background: var(--ivory-soft);
  color: var(--deep-blue);
}

.nav-tabs {
  max-width: 1260px;
  margin: 0 auto;
  padding: 0 1.25rem 0.65rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.nav-tab {
  background: transparent;
  color: #dce9ef;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-tab:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.nav-tab.active {
  background: var(--ivory);
  color: var(--deep-blue);
  border-color: var(--ivory);
}

.container {
  max-width: 1260px;
  margin: 1.25rem auto 3rem;
  padding: 0 1.25rem;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.card {
  background: var(--ivory-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.hero-strip {
  background: linear-gradient(135deg, #ffffff 0%, #eef5f7 100%);
  border: 1px solid var(--border);
  border-left: 5px solid var(--deep-blue);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.hero-strip .lead {
  max-width: 780px;
  margin: 0.35rem 0 0;
  color: var(--ink);
  font-size: 0.96rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 1.25rem 0 0.75rem;
}

.hint {
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.9rem;
}

.grid-cards-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 0.9rem;
}

.grid-cards-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.9rem;
}

.choice-card {
  background: var(--ivory-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.choice-card:hover {
  border-color: var(--blue-jay);
  transform: translateY(-1px);
}

.choice-card.selected {
  border-color: var(--deep-blue);
  background: #f2f8fa;
  box-shadow: 0 0 0 3px rgba(59, 111, 145, 0.16);
}

.choice-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.18rem 0.5rem;
  border-radius: 6px;
  background: var(--ivory-soft);
  color: var(--deep-blue);
  white-space: nowrap;
}

.badge-pilot {
  background: #f9ebe7;
  color: var(--terracotta);
}

.badge-green {
  background: var(--green-bg);
  color: var(--green);
}

.badge-red {
  background: var(--red-bg);
  color: var(--red);
}

.badge-amber {
  background: var(--amber-bg);
  color: var(--amber);
}

.scale-levels-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.scale-chip {
  font-size: 0.72rem;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  background: var(--ivory-soft);
  border: 1px solid var(--border);
  font-weight: 600;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.btn-sm {
  padding: 0.38rem 0.72rem;
  font-size: 0.8rem;
}

.btn-primary {
  background: var(--deep-blue);
  color: #fff;
}

.btn-primary:hover {
  background: var(--blue-jay);
}

.btn-secondary {
  background: var(--terracotta);
  color: #fff;
}

.btn-secondary:hover {
  background: #8e4332;
}

.btn-ghost {
  background: var(--ivory-card);
  color: var(--deep-blue);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--ivory-soft);
}

.full-width {
  width: 100%;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.84rem;
}

/* Custom role drawer */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
  margin-bottom: 0.75rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.84rem;
  font-weight: 600;
}

input[type="text"],
input[type="number"],
select,
textarea {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.drawer-actions {
  display: flex;
  gap: 0.6rem;
}

/* Assessment Layout */
.assess-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(290px, 1fr);
  gap: 1rem;
  align-items: start;
}

@media (max-width: 920px) {
  .assess-layout {
    grid-template-columns: 1fr;
  }
}

.assess-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.eyebrow {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--terracotta);
  margin-bottom: 0.2rem;
}

.assess-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toggle-inline {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  font-weight: 500;
  cursor: pointer;
}

.progress-track {
  height: 8px;
  background: var(--ivory-soft);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.65rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue-jay), var(--robins-egg));
  transition: width 0.2s ease;
}

.q-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.q-dot {
  width: 30px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.q-dot.answered {
  background: #e5f3f5;
  border-color: var(--robins-egg);
  color: var(--deep-blue);
}

.q-dot.current {
  background: var(--deep-blue);
  border-color: var(--deep-blue);
  color: #fff;
}

.question-prompt {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0.5rem 0 1rem;
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.option-btn {
  text-align: left;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 0.78rem 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--ink);
  transition: all 0.14s ease;
}

.option-btn:hover {
  border-color: var(--blue-jay);
  background: #f8fbfc;
}

.option-btn.selected {
  border-color: var(--deep-blue);
  background: #eaf3f7;
  box-shadow: 0 0 0 2px rgba(35, 75, 102, 0.15);
}

.option-key {
  min-width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--ivory-soft);
  color: var(--deep-blue);
  font-weight: 700;
  display: grid;
  place-items: center;
  font-size: 0.82rem;
}

.option-btn.selected .option-key {
  background: var(--deep-blue);
  color: #fff;
}

.coaching-box {
  margin-top: 0.9rem;
  padding: 0.75rem 0.95rem;
  border-radius: 9px;
  border-left: 4px solid var(--blue-jay);
  background: #f1f7f9;
  font-size: 0.88rem;
}

.assess-footer {
  margin-top: 1.1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
}

.kbd-hint {
  font-size: 0.78rem;
  color: var(--muted);
}

.footer-right {
  display: flex;
  gap: 0.5rem;
}

.ledger-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.ledger-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 430px;
  overflow-y: auto;
  margin: 0.65rem 0 0.9rem;
}

.ledger-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font-size: 0.82rem;
  cursor: pointer;
  background: #fcfaf6;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.ledger-item:hover {
  border-color: var(--blue-jay);
}

.ledger-item.done {
  background: #f3f9fa;
}

/* Report */
.report-top {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.15fr);
  gap: 1rem;
}

@media (max-width: 900px) {
  .report-top {
    grid-template-columns: 1fr;
  }
}

.big-score {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin: 0.4rem 0;
}

.big-score-num {
  font-family: 'Lora', Georgia, serif;
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--deep-blue);
}

.level-pill-lg {
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.88rem;
  color: #fff;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.legend-row {
  display: flex;
  gap: 0.9rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.swatch-current { background: var(--deep-blue); }
.swatch-target { background: var(--terracotta); }

.radar-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
}

.bar-row {
  margin-top: 0.5rem;
}

.bar-track {
  height: 10px;
  background: var(--ivory-soft);
  border-radius: 999px;
  position: relative;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--blue-jay);
}

.bar-target-mark {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--terracotta);
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.inline-select {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

th, td {
  text-align: left;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: var(--ivory-soft);
  color: var(--deep-blue);
  font-weight: 700;
}

/* Course Plan */
.course-banner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  border-left: 5px solid var(--terracotta);
}

.course-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-box {
  background: var(--ivory-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.95rem;
}

.stat-label {
  font-size: 0.76rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
}

.stat-val {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--deep-blue);
}

.modules-stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.module-card {
  background: var(--ivory-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  box-shadow: var(--shadow);
}

.module-card.excluded {
  opacity: 0.56;
  background: #f8f5ee;
}

.module-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.6rem;
}

.module-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.two-col-tools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.clear-form {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.65rem;
}

.clear-preview-wrap {
  margin-top: 0.85rem;
}

.clear-preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.code-box {
  background: #1d2b33;
  color: #edf4f7;
  padding: 0.85rem 1rem;
  border-radius: 9px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.code-box.tall {
  max-height: 360px;
  overflow-y: auto;
}

.drill-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: 520px;
  overflow-y: auto;
}

.drill-item {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.65rem 0.75rem;
  font-size: 0.85rem;
}

.drill-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
}

.drill-btns {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.drill-feedback {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
}

.import-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  margin: 0.65rem 0;
}

textarea {
  width: 100%;
  resize: vertical;
}

.link-list {
  margin: 0.35rem 0 0;
  padding-left: 1.2rem;
}

.link-list li {
  margin-bottom: 0.35rem;
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background: var(--deep-blue);
  color: #fff;
  padding: 0.65rem 1rem;
  border-radius: 9px;
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  z-index: 90;
}

/* Accounts-only Sign-On Gate (DCC style, no Family Passcode) */
body.auth-locked {
  overflow: hidden;
}

.topbar-auth-btn {
  padding: 0.25rem 0.65rem;
  font-size: 0.78rem;
  background: rgba(255, 255, 255, 0.92);
  color: var(--deep-blue);
  border-color: transparent;
}

.topbar-auth-btn:hover {
  background: #fff;
}

.auth-gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(20, 42, 58, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}

.auth-gate-card {
  width: 100%;
  max-width: 520px;
  background: var(--ivory);
  border: 1px solid var(--border);
  border-top: 5px solid var(--deep-blue);
  border-radius: 16px;
  padding: 1.5rem 1.6rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
}

.ds-chips {
  margin-bottom: 0.55rem;
}

.badge-accent {
  background: var(--deep-blue);
  color: #fff;
  letter-spacing: 0.04em;
}

.ds-title {
  font-size: 1.45rem;
  margin-bottom: 0.3rem;
}

.ds-sub {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 0.9rem;
}

.ds-invite {
  background: #e7f4ef;
  border: 1px solid #a3d5c3;
  color: #164b3b;
  border-radius: 9px;
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
  margin-bottom: 0.9rem;
}

.ds-invite.bad {
  background: var(--red-bg);
  border-color: #e6b8b8;
  color: var(--red);
}

.gate-try-now {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 0.85rem 0.95rem;
}

.gate-try-head {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.6rem;
}

.gate-try-head span {
  font-size: 0.82rem;
  color: var(--muted);
}

.gate-try-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.gate-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0 0.85rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.gate-divider::before,
.gate-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.ds-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ds-form .field-label {
  margin-top: 0.15rem;
}

.ds-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.ds-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.3rem;
}

.ds-link {
  background: none;
  border: none;
  padding: 0;
  color: #2f6282;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

.ds-msg {
  font-size: 0.84rem;
  margin: 0.3rem 0 0;
  color: var(--green);
  min-height: 1.1em;
}

.ds-msg.bad {
  color: var(--red);
}

@media print {
  .no-print {
    display: none !important;
  }
  body {
    background: #fff;
  }
  .tab-panel {
    display: none !important;
  }
  #tab-course {
    display: block !important;
  }
  .card, .module-card {
    box-shadow: none;
    break-inside: avoid;
  }
}
