/*
 * Paideia City Beautiful visual system
 * This layer intentionally overrides the original application skin while
 * preserving its information architecture and interaction contracts.
 */

:root {
  color-scheme: light;
  --civic-canvas: #f7f5ef;
  --civic-surface: #fffdf8;
  --civic-surface-raised: #ffffff;
  --civic-navy: #102c44;
  --civic-navy-deep: #071b2b;
  --civic-green: #245b3c;
  --civic-green-bright: #34744e;
  --civic-verdigris: #3f7f77;
  --civic-gold: #b58a35;
  --civic-gold-soft: #d8bf7b;
  --civic-clay: #b85f3f;
  --civic-text: #17252d;
  --civic-muted: #5f6b70;
  --civic-line: #d8cfb9;
  --civic-line-strong: #b9aa81;
  --civic-shadow: 0 18px 45px rgb(35 42 40 / 9%);
  --civic-plan-image: url("assets/civic-plan-light-v1.png");

  /* Map the original component tokens into the City Beautiful system. */
  --ink: var(--civic-navy);
  --ink-deep: var(--civic-navy-deep);
  --slate: #35454d;
  --sky: var(--civic-green);
  --sky-brand: var(--civic-verdigris);
  --sky-soft: #e8f0e9;
  --teal: var(--civic-verdigris);
  --teal-soft: #e5f0ed;
  --amber: var(--civic-gold);
  --amber-soft: #f5eedc;
  --coral: var(--civic-clay);
  --coral-soft: #f8e9e2;
  --mist: #f0eee6;
  --cloud: var(--civic-canvas);
  --white: var(--civic-surface);
  --graphite: var(--civic-text);
  --muted: var(--civic-muted);
  --line: var(--civic-line);
  --line-dark: var(--civic-line-strong);
  --shadow: var(--civic-shadow);
  --radius-sm: 3px;
  --radius: 4px;
  --radius-lg: 6px;
  --sidebar-width: 270px;
  --topbar-height: 78px;
  --display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --body: "Aptos", "Segoe UI Variable Text", "Segoe UI", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --civic-canvas: #07131f;
  --civic-surface: #0c1d2a;
  --civic-surface-raised: #102532;
  --civic-navy: #f3ead5;
  --civic-navy-deep: #fff7e8;
  --civic-green: #6c9b72;
  --civic-green-bright: #83af88;
  --civic-verdigris: #72a39a;
  --civic-gold: #c99a3e;
  --civic-gold-soft: #e0bd70;
  --civic-clay: #d17758;
  --civic-text: #edf1e9;
  --civic-muted: #b5c0c0;
  --civic-line: #314554;
  --civic-line-strong: #5e6e72;
  --civic-shadow: 0 20px 55px rgb(0 0 0 / 32%);
  --civic-plan-image: url("assets/civic-plan-dark-v1.png");

  --ink: var(--civic-navy);
  --ink-deep: var(--civic-navy-deep);
  --slate: #c9d1cd;
  --sky: var(--civic-verdigris);
  --sky-brand: var(--civic-green-bright);
  --sky-soft: #17342f;
  --teal: var(--civic-verdigris);
  --teal-soft: #16322f;
  --amber: var(--civic-gold);
  --amber-soft: #332a18;
  --coral: var(--civic-clay);
  --coral-soft: #3b211b;
  --mist: #102532;
  --cloud: var(--civic-canvas);
  --white: var(--civic-surface);
  --graphite: var(--civic-text);
  --muted: var(--civic-muted);
  --line: var(--civic-line);
  --line-dark: var(--civic-line-strong);
}

html {
  background: var(--civic-canvas);
}

body {
  min-width: 320px;
  color: var(--civic-text);
  background:
    linear-gradient(90deg, rgb(181 138 53 / 3%) 1px, transparent 1px),
    linear-gradient(rgb(181 138 53 / 3%) 1px, transparent 1px),
    var(--civic-canvas);
  background-size: 44px 44px;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  accent-color: var(--civic-green);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--civic-gold-soft);
  outline-offset: 3px;
}

h1,
h2,
h3 {
  color: var(--ink);
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -.018em;
}

h1 {
  letter-spacing: -.03em;
}

/* Civic shell */
.sidebar {
  width: var(--sidebar-width);
  padding: 22px 18px 18px;
  border-right: 1px solid rgb(201 154 62 / 42%);
  color: #f5f0e5;
  background:
    radial-gradient(circle at 50% -12%, rgb(72 120 107 / 32%), transparent 36%),
    linear-gradient(180deg, #0d2a3d 0%, #081d2d 58%, #061521 100%);
  box-shadow: 10px 0 35px rgb(1 12 20 / 12%);
}

.sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 16px, rgb(201 154 62 / 9%) 17px, transparent 18px),
    linear-gradient(90deg, transparent calc(100% - 18px), rgb(201 154 62 / 9%) calc(100% - 17px), transparent calc(100% - 16px));
}

.brand-block,
.nav-list,
.sidebar-landscape,
.sidebar-footer {
  position: relative;
  z-index: 1;
}

.brand-block {
  padding: 0 10px 16px;
}

.brand-mark-row {
  min-height: 48px;
}

.brand-mark {
  width: 72px;
  height: 48px;
}

.civic-kicker {
  margin-top: 12px;
  color: #d9bc70;
  font-size: .64rem;
  font-weight: 800;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.brand-name {
  margin-top: 4px;
  color: #fffaf0;
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -.035em;
}

.brand-line {
  max-width: 200px;
  margin-top: 7px;
  color: #c5d6d4;
  font-size: .79rem;
  line-height: 1.5;
}

.brand-line::before {
  content: "";
  width: 42px;
  height: 2px;
  margin: 0 0 10px;
  display: block;
  background: var(--civic-gold);
}

.sponsor-lockup {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgb(201 154 62 / 34%);
}

.sponsor-lockup strong {
  color: #f7ecd2;
  font-size: .69rem;
  letter-spacing: .035em;
  text-transform: uppercase;
}

.sponsor-lockup span {
  color: #cad7d4;
  font-size: .67rem;
}

.sponsor-lockup small {
  color: #d8bc74;
  font-size: .6rem;
}

.nav-list {
  gap: 2px;
  margin-top: 2px;
}

.nav-item {
  min-height: 44px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 2px;
  color: #d9e4e1;
  gap: 12px;
  font-size: .84rem;
  font-weight: 650;
  letter-spacing: .01em;
}

.nav-item .icon {
  width: 20px;
  height: 20px;
  color: #a9c2bc;
}

.nav-item:hover {
  color: #fffaf0;
  background: rgb(255 255 255 / 6%);
  border-color: rgb(201 154 62 / 22%);
}

.nav-item.is-active {
  color: #fffaf0;
  background: linear-gradient(90deg, rgb(58 112 78 / 72%), rgb(49 91 70 / 35%));
  border-color: rgb(201 154 62 / 58%);
  border-left: 4px solid var(--civic-gold);
  box-shadow: 0 7px 18px rgb(0 0 0 / 16%);
}

.nav-item.is-active .icon {
  color: #efd184;
}

.sidebar-landscape {
  min-height: 108px;
  margin: 14px 10px 0;
  border-top: 1px solid rgb(201 154 62 / 28%);
  border-bottom: 1px solid rgb(201 154 62 / 28%);
  background:
    linear-gradient(180deg, rgb(7 27 43 / 12%), rgb(7 27 43 / 66%)),
    url("assets/rural-virginia-vignette-v1.png") center 43% / cover no-repeat;
  filter: sepia(.15) saturate(.82);
  opacity: .83;
}

.sidebar-footer {
  margin-top: 0;
  padding: 14px 10px 0;
  border-top: 0;
}

.saved-status {
  color: #c8d8d4;
  font-size: .67rem;
}

.saved-status .icon {
  color: #d8bc74;
}

.sidebar-link {
  margin-top: 10px;
  color: #d8bc74 !important;
  font-size: .65rem !important;
  text-decoration-color: rgb(216 188 116 / 55%);
}

/* Top controls */
.topbar {
  height: var(--topbar-height);
  padding: 0 30px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--civic-surface) 92%, transparent);
  box-shadow: 0 3px 18px rgb(21 35 43 / 4%);
}

.mobile-brand {
  display: none;
  color: var(--ink);
  font-family: var(--display);
  font-size: 1.14rem;
  font-weight: 700;
}

.mobile-brand small {
  margin-left: 7px;
  color: var(--muted);
  font-family: var(--body);
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.access-tools {
  gap: 10px;
}

.control-cluster {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.control-cluster + .control-cluster {
  margin-left: 4px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.tool-label {
  margin-right: 6px;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 750;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.theme-segment {
  display: inline-flex;
  border: 1px solid var(--line);
  background: var(--civic-canvas);
}

.theme-button,
.access-button,
.icon-button {
  min-width: 38px;
  height: 38px;
  border: 1px solid transparent;
  border-radius: 2px;
  color: var(--muted);
}

.theme-button {
  width: 38px;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.theme-button:last-child {
  border-right: 0;
}

.theme-button:hover,
.theme-button.is-active,
.access-button:hover,
.access-button.is-active {
  color: var(--civic-green);
  background: var(--sky-soft);
  border-color: var(--line-dark);
}

.theme-button.is-active {
  box-shadow: inset 0 -3px 0 var(--civic-gold);
}

.switch {
  background: var(--line-dark);
}

.switch span {
  background: var(--civic-surface-raised);
}

.switch.is-on {
  background: var(--civic-green);
}

.planner-label {
  display: grid;
  color: var(--ink);
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: right;
}

.planner-label small {
  margin-top: 4px;
  color: var(--muted);
  font-family: var(--body);
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.main-content {
  padding: 28px 30px 54px;
}

/* Shared civic components */
.panel,
.module-topic,
.source-table-wrap,
.case-list {
  border: 1px solid var(--line);
  border-top-color: var(--civic-gold-soft);
  background: var(--civic-surface);
  box-shadow: 0 1px 0 rgb(181 138 53 / 10%), var(--civic-shadow);
}

.panel,
.module-topic,
.source-table-wrap,
.case-list,
.callout,
.notice-panel,
.sponsor-notice {
  position: relative;
}

.panel::before,
.module-topic::before,
.source-table-wrap::before,
.case-list::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 22px;
  width: 46px;
  height: 2px;
  background: var(--civic-gold);
  pointer-events: none;
}

.button {
  min-height: 46px;
  border-radius: 2px;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .025em;
}

.button.primary {
  color: #fffaf0;
  background: linear-gradient(135deg, var(--civic-green-bright), var(--civic-green));
  border-color: #214f36;
  box-shadow: 0 8px 20px rgb(36 91 60 / 20%);
}

.button.secondary {
  color: var(--ink);
  background: transparent;
  border-color: var(--civic-gold);
}

.button.secondary:hover:not(:disabled) {
  color: var(--civic-green);
  background: var(--amber-soft);
}

.text-link,
.back-link,
a {
  color: var(--civic-green);
}

.feature-icon,
.mini-icon,
.week-icon,
.week-number,
.lesson-index,
.concept-row > span,
.transfer-icon,
.check-icon,
.question-dot,
.case-year {
  border-radius: 50%;
}

.page-header {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.page-header::after {
  content: "";
  width: 74px;
  height: 3px;
  margin-top: 18px;
  display: block;
  background: linear-gradient(90deg, var(--civic-gold), var(--civic-green));
}

/* City Beautiful dashboard */
.dashboard-page {
  width: min(1320px, 100%);
  margin: 0 auto;
}

.civic-hero {
  position: relative;
  min-height: 330px;
  padding: clamp(30px, 4.6vw, 68px);
  border: 1px solid var(--line-strong, var(--line-dark));
  overflow: hidden;
  isolation: isolate;
  background-image:
    linear-gradient(90deg, color-mix(in srgb, var(--civic-surface) 96%, transparent) 0%, color-mix(in srgb, var(--civic-surface) 88%, transparent) 48%, color-mix(in srgb, var(--civic-surface) 35%, transparent) 100%),
    var(--civic-plan-image);
  background-position: center;
  background-size: cover;
  box-shadow: var(--civic-shadow);
}

.civic-hero::before {
  content: "";
  position: absolute;
  top: 20px;
  right: 20px;
  bottom: 20px;
  left: 20px;
  z-index: -1;
  border: 1px solid rgb(181 138 53 / 44%);
  pointer-events: none;
}

.civic-hero::after {
  content: "";
  position: absolute;
  top: 0;
  left: clamp(30px, 4.6vw, 68px);
  width: 118px;
  height: 5px;
  background: linear-gradient(90deg, var(--civic-gold) 0 54%, var(--civic-green) 54%);
}

.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 720px;
}

.hero-eyebrow,
.panel-kicker {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--civic-green);
  font-size: .68rem;
  font-weight: 850;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.hero-eyebrow::before,
.panel-kicker::before {
  content: "";
  width: 28px;
  height: 2px;
  background: var(--civic-gold);
}

.civic-hero h1 {
  max-width: 660px;
  margin: 14px 0 16px;
  font-size: clamp(2.75rem, 5.7vw, 5.5rem);
  line-height: .94;
  text-wrap: balance;
}

.hero-intro {
  max-width: 620px;
  margin: 0;
  color: var(--slate);
  font-size: clamp(.98rem, 1.4vw, 1.16rem);
  line-height: 1.65;
}

.hero-facts {
  margin: 30px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  list-style: none;
}

.hero-facts li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: .73rem;
  font-weight: 750;
}

.hero-facts .icon {
  color: var(--civic-green);
}

.dashboard-panels {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 18px;
}

.dashboard-panels > .panel {
  padding: clamp(20px, 2.5vw, 30px);
}

.recommendation-panel {
  grid-column: span 7;
}

.blueprint-panel {
  grid-column: span 5;
}

.retrieval-panel {
  grid-column: span 5;
}

.week-panel {
  grid-column: span 7;
}

.dashboard-panel-header {
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.dashboard-panel-header h2 {
  margin: 5px 0 0;
  font-size: clamp(1.3rem, 2vw, 1.75rem);
}

.panel-number {
  color: var(--civic-gold);
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 700;
}

.recommendation-card {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 18px;
  align-items: start;
}

.recommendation-card .feature-icon {
  width: 58px;
  height: 58px;
  color: var(--civic-green);
  border: 1px solid var(--civic-gold-soft);
  background: var(--amber-soft);
}

.recommendation-card h3 {
  margin: 0 0 6px;
  font-size: clamp(1.35rem, 2.2vw, 2rem);
}

.recommendation-card p {
  margin: 0;
  color: var(--muted);
}

.recommendation-panel .button-row {
  margin: 23px 0 25px;
}

.route-progress {
  margin-top: 8px;
  padding-top: 14px;
}

.route-progress::before {
  top: 27px;
  background: repeating-linear-gradient(90deg, var(--civic-gold-soft) 0 6px, transparent 6px 11px);
}

.route-dot {
  background: var(--civic-surface);
}

.route-step.is-current .route-dot {
  color: #fffaf0;
  background: var(--civic-green);
  border-color: var(--civic-green);
}

.route-step strong {
  color: var(--ink);
}

.topic-rail {
  grid-template-columns: minmax(118px, 1.35fr) 1fr 34px;
  min-height: 40px;
}

.rail-stack {
  height: 18px;
}

.learner-rail,
.learner-rail.sky {
  background: var(--civic-green);
}

.learner-rail.amber {
  background: var(--civic-gold);
}

.learner-rail.coral {
  background: var(--civic-clay);
}

.retrieval-list {
  border-top-color: var(--civic-gold-soft);
}

.retrieval-row:hover {
  background: var(--mist);
}

.review-label {
  border-color: var(--civic-gold-soft);
  border-radius: 2px;
  color: var(--civic-green);
  background: var(--amber-soft);
}

.week-step {
  min-height: 145px;
}

.week-step:not(:last-child)::after {
  border-top-color: var(--civic-gold-soft);
}

.day-label,
.week-step:nth-child(2) .day-label,
.week-step:nth-child(3) .day-label,
.week-step:nth-child(4) .day-label {
  color: var(--ink);
  background: var(--amber-soft);
  border: 1px solid var(--civic-gold-soft);
  border-radius: 2px;
}

.week-icon {
  color: var(--civic-green);
  border-color: var(--civic-gold-soft);
  background: var(--civic-surface-raised);
}

.dashboard-attribution {
  margin: 20px 0 0;
  padding: 15px 4px 0;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  color: var(--muted);
  font-size: .65rem;
}

.dashboard-attribution strong {
  color: var(--ink);
}

/* Existing modules in the new system */
.planner-strip input,
select,
textarea,
.formula-fields input,
.day-button,
.lesson-row,
.confidence-button,
.certainty-buttons button,
.answer-row,
.mode-switch button,
.question-dot,
.rating-row button,
.planner-grid article,
.boundary-grid article,
.notice-panel,
.source-table-wrap,
.case-list {
  color: var(--graphite);
  background: var(--civic-surface);
}

.module-topic-header {
  background: linear-gradient(90deg, var(--civic-surface), var(--mist));
}

.topic-number,
.path-status,
.source-type {
  color: var(--civic-green);
  background: var(--teal-soft);
  border-radius: 2px;
}

.lesson-row:hover,
.formula-list button:hover {
  background: var(--mist);
}

.lesson-row.is-complete {
  background: color-mix(in srgb, var(--teal-soft) 52%, var(--civic-surface));
}

.callout,
.sponsor-notice {
  border-radius: 0;
  border-left-color: var(--civic-gold);
  background: var(--mist);
}

.sponsor-notice {
  border-color: var(--line);
  border-left-color: var(--civic-gold);
  background: linear-gradient(135deg, var(--civic-surface), var(--mist));
}

.lesson-time,
.rail-section,
.evidence-item,
.calibration,
.case-warning,
.planner-grid article,
.boundary-grid article {
  border-radius: 3px;
}

.transfer-block {
  border-color: var(--civic-gold-soft);
  border-radius: 3px;
  background: var(--amber-soft);
}

.answer-row:hover:not(:disabled),
.answer-row.is-selected {
  border-color: var(--civic-green);
  background: var(--sky-soft);
}

.answer-row.is-selected {
  border-width: 2px;
}

.answer-row.is-correct {
  border-color: var(--civic-green);
  background: var(--teal-soft);
}

.feedback-panel {
  background: color-mix(in srgb, var(--civic-surface) 90%, var(--mist));
}

.card-front {
  background: linear-gradient(145deg, var(--civic-surface-raised), var(--mist));
}

.card-back {
  background: linear-gradient(145deg, var(--teal-soft), var(--civic-surface));
}

.flashcard,
.rating-row,
.confidence-options,
.certainty-buttons,
.mode-switch,
.source-table-wrap,
.case-list {
  border-radius: 3px;
}

.tabs button.is-active,
.formula-list button.is-active,
.mode-switch button.is-active,
.day-button.is-active,
.confidence-button.is-active,
.certainty-buttons button.is-active {
  color: var(--civic-green);
  background: var(--sky-soft);
  border-color: var(--civic-gold-soft);
}

.source-table th {
  color: var(--muted);
  background: var(--mist);
}

.chain-steps article > span {
  color: #fffaf0;
  background: var(--civic-navy-deep);
}

.formula-result,
.feedback {
  border-left-color: var(--civic-green);
  background: var(--teal-soft);
}

.case-warning,
.callout.warning {
  color: var(--ink);
  border-color: var(--civic-gold-soft);
  background: var(--amber-soft);
}

/* Dark-mode corrections for legacy literal colors. */
:root[data-theme="dark"] body {
  background:
    linear-gradient(90deg, rgb(201 154 62 / 3%) 1px, transparent 1px),
    linear-gradient(rgb(201 154 62 / 3%) 1px, transparent 1px),
    var(--civic-canvas);
  background-size: 44px 44px;
}

:root[data-theme="dark"] .topbar {
  background: rgb(12 29 42 / 94%);
}

:root[data-theme="dark"] .civic-hero {
  background-image:
    linear-gradient(90deg, rgb(7 19 31 / 96%) 0%, rgb(7 19 31 / 88%) 50%, rgb(7 19 31 / 34%) 100%),
    var(--civic-plan-image);
}

:root[data-theme="dark"] .button.primary {
  color: #fffaf0;
  border-color: #6c9b72;
}

:root[data-theme="dark"] .button.secondary,
:root[data-theme="dark"] .button.danger,
:root[data-theme="dark"] .planner-strip input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] .formula-fields input,
:root[data-theme="dark"] .day-button,
:root[data-theme="dark"] .lesson-row,
:root[data-theme="dark"] .confidence-button,
:root[data-theme="dark"] .certainty-buttons button,
:root[data-theme="dark"] .answer-row,
:root[data-theme="dark"] .mode-switch button,
:root[data-theme="dark"] .question-dot,
:root[data-theme="dark"] .rating-row button {
  color: var(--civic-text);
  background: var(--civic-surface);
}

:root[data-theme="dark"] .answer-row:hover:not(:disabled),
:root[data-theme="dark"] .answer-row.is-selected,
:root[data-theme="dark"] .lesson-row:hover,
:root[data-theme="dark"] .formula-list button:hover,
:root[data-theme="dark"] .retrieval-row:hover {
  background: var(--mist);
}

:root[data-theme="dark"] .answer-row.is-wrong,
:root[data-theme="dark"] .feedback.incorrect {
  background: var(--coral-soft);
}

:root[data-theme="dark"] .answer-row.is-correct,
:root[data-theme="dark"] .feedback,
:root[data-theme="dark"] .formula-result {
  background: var(--teal-soft);
}

:root[data-theme="dark"] .source-table a,
:root[data-theme="dark"] .text-link,
:root[data-theme="dark"] .back-link {
  color: #8bbab0;
}

:root[data-theme="dark"] .chain-steps article > span {
  color: #07131f;
  background: var(--civic-gold-soft);
}

:root[data-theme="dark"] .radio-indicator {
  color: #07131f;
}

/* High contrast remains independent of the selected palette. */
:root[data-theme="dark"] body.high-contrast {
  --civic-canvas: #000;
  --civic-surface: #000;
  --civic-surface-raised: #050505;
  --civic-text: #fff;
  --civic-muted: #f0f0f0;
  --civic-line: #fff;
  --civic-line-strong: #fff;
  --ink: #fff;
  --ink-deep: #fff;
  --graphite: #fff;
  --muted: #f0f0f0;
  --line: #fff;
  --line-dark: #fff;
  --sky: #8fffc1;
  --teal: #8fffc1;
  --amber: #ffe36e;
  --coral: #ff9b8e;
  --white: #000;
  --cloud: #000;
  --mist: #0a0a0a;
}

/* Mobile accessibility dock */
.mobile-access-dock {
  display: none;
}

@media (max-width: 1240px) {
  .tool-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .control-cluster + .control-cluster {
    padding-left: 9px;
  }
}

@media (max-width: 1160px) {
  .dashboard-panels {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .recommendation-panel,
  .blueprint-panel,
  .retrieval-panel,
  .week-panel {
    grid-column: span 1;
  }
}

@media (max-width: 900px) {
  :root {
    --sidebar-width: 0px;
    --topbar-height: 64px;
  }

  .sidebar {
    width: min(290px, 88vw);
  }

  .topbar {
    height: var(--topbar-height);
    padding: 0 16px;
  }

  .topbar .access-tools,
  .topbar .planner-label {
    display: none;
  }

  .mobile-brand {
    display: inline-flex;
    align-items: baseline;
  }

  .mobile-menu {
    color: var(--ink);
  }

  html {
    scroll-padding-bottom: 96px;
  }

  .main-content {
    padding: 18px 18px 112px;
  }

  .mobile-access-dock {
    position: fixed;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    left: 12px;
    z-index: 24;
    min-height: 70px;
    padding: 7px;
    border: 1px solid var(--civic-gold-soft);
    background: color-mix(in srgb, var(--civic-surface) 94%, transparent);
    box-shadow: 0 14px 36px rgb(0 0 0 / 24%);
    backdrop-filter: blur(16px);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
  }

  .mobile-dock-button {
    min-width: 0;
    min-height: 54px;
    padding: 5px 3px;
    border: 1px solid transparent;
    border-radius: 2px;
    color: var(--muted);
    background: transparent;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 3px;
    cursor: pointer;
    font-size: .58rem;
    font-weight: 750;
  }

  .mobile-dock-button.is-active {
    color: var(--civic-green);
    border-color: var(--civic-gold-soft);
    background: var(--sky-soft);
  }

  .toast-region {
    bottom: calc(96px + env(safe-area-inset-bottom));
  }

  .focus-mode .mobile-access-dock {
    display: grid;
  }
}

@media (max-width: 720px) {
  .dashboard-panels {
    grid-template-columns: 1fr;
  }

  .civic-hero {
    min-height: 420px;
    padding: 40px 28px 34px;
    background-image:
      linear-gradient(180deg, color-mix(in srgb, var(--civic-surface) 98%, transparent) 0%, color-mix(in srgb, var(--civic-surface) 90%, transparent) 66%, color-mix(in srgb, var(--civic-surface) 60%, transparent) 100%),
      var(--civic-plan-image);
    background-position: 62% center;
  }

  :root[data-theme="dark"] .civic-hero {
    background-image:
      linear-gradient(180deg, rgb(7 19 31 / 98%) 0%, rgb(7 19 31 / 91%) 66%, rgb(7 19 31 / 64%) 100%),
      var(--civic-plan-image);
  }

  .civic-hero::before {
    inset: 13px;
  }

  .civic-hero::after {
    left: 28px;
  }

  .civic-hero h1 {
    font-size: clamp(2.65rem, 14vw, 4rem);
    line-height: .96;
  }

  .hero-facts {
    display: grid;
    gap: 8px;
  }

  .recommendation-card {
    grid-template-columns: 48px 1fr;
    gap: 13px;
  }

  .recommendation-card .feature-icon {
    width: 46px;
    height: 46px;
  }

  .recommendation-panel .button-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .recommendation-panel .button {
    width: 100%;
  }

  .dashboard-panel-header {
    gap: 10px;
  }

  .dashboard-attribution {
    display: grid;
  }
}

@media (max-width: 500px) {
  .main-content {
    padding: 12px 10px 108px;
  }

  .mobile-brand small {
    display: none;
  }

  .civic-hero {
    min-height: 330px;
    padding: 34px 22px 24px;
  }

  .civic-hero::after {
    left: 22px;
    width: 90px;
  }

  .hero-facts {
    display: none;
  }

  .dashboard-panels {
    margin-top: 10px;
    gap: 10px;
  }

  .dashboard-panels > .panel {
    padding: 18px 16px;
  }

  .topic-rail {
    min-height: 46px;
    grid-template-columns: minmax(94px, 1.25fr) 1fr 30px;
  }

  .route-progress {
    grid-template-columns: repeat(5, minmax(62px, 1fr));
    overflow-x: auto;
    padding-bottom: 10px;
  }

  .week-rail {
    grid-template-columns: repeat(2, 1fr);
  }

  .week-step:nth-child(2)::after {
    display: none;
  }

  .mobile-access-dock {
    right: 7px;
    bottom: calc(7px + env(safe-area-inset-bottom));
    left: 7px;
  }
}

@media (max-height: 780px) and (min-width: 901px) {
  .sidebar-landscape {
    display: none;
  }

  .sidebar-footer {
    margin-top: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .page-enter,
  .card-face {
    animation: none !important;
    transition: none !important;
  }
}
