@font-face {
  font-family: 'Iberia Headline';
  src: url('/assets/fonts/IberiaHeadline-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Iberia Headline';
  src: url('/assets/fonts/IberiaHeadline-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Iberia Text';
  src: url('/assets/fonts/IberiaText-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Iberia Text';
  src: url('/assets/fonts/IberiaText-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root,
:root[data-theme='light'] {
  color-scheme: light;
  --font-body: 'Iberia Text', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --font-heading: 'Iberia Headline', 'Iberia Text', 'Segoe UI', Arial, sans-serif;
  --font-mono: 'SF Mono', Menlo, Consolas, monospace;
  --layout-max: 1460px;
  --measure-text: 78ch;
  --diagram-min: 760px;
  --diagram-wide-min: 1040px;
  --diagram-xwide-min: 1280px;
  --bg: #f6f3f1;
  --bg-alt: #efeae5;
  --bg-glow-1: #f7e0e6;
  --bg-glow-2: #f1e9de;
  --surface: #ffffff;
  --surface-alt: #faf7f5;
  --surface-raised: #ffffff;
  --ink: #1f2630;
  --ink-soft: #4f5d6b;
  --ink-muted: #5f7784;
  --primary: #dc002e;
  --primary-2: #ad001f;
  --border: #d7d2cd;
  --border-soft: #e2eaee;
  --link: #0f5a79;
  --link-hover: #0d4d67;
  --focus-ring: #0a5fcc;
  --focus-soft: #92c7db;
  --header-bg: linear-gradient(120deg, #fff 0%, #fff8f9 40%, #fffef5 100%);
  --progress-track: #d7e3e9;
  --progress-track-border: #c6d5dd;
  --card-kicker: #55707f;
  --ref-modules: #59707d;
  --teachair-border: #d1dee5;
  --field-border: #b8c8d1;
  --field-bg: #fff;
  --pill-bg: #e3f1f6;
  --pill-ink: #13485d;
  --btn-secondary-bg: #eff4f6;
  --table-break-bg: #eef6fa;
  --chip-ink: #0e4a5e;
  --chip-bg: #ddedf4;
  --status-loading-border: #d6e2e9;
  --status-loading-bg: #f4f9fc;
  --status-loading-ink: #355264;
  --status-error-border: #efc5bf;
  --status-error-bg: #fff4f2;
  --flow-border: #c7d8e2;
  --flow-bg: linear-gradient(180deg, #f4f9fc 0%, #eef5f9 100%);
  --flow-wait: #17455a;
  --flow-phase-border: #d7e5ec;
  --flow-phase-bg: #fff;
  --flow-support: #1d4f65;
  --media-border: #d6e1e7;
  --media-bg: #fff;
  --table-frame-border: #dce6ec;
  --table-frame-bg: #fff;
  --diagram-frame-border: #c9d8e1;
  --diagram-frame-bg: linear-gradient(180deg, #f7fbfd 0%, #eef5f8 100%);
  --diagram-title: #0e4a5e;
  --diagram-scroll-border: #d8e4eb;
  --diagram-scroll-bg: #fff;
  --diagram-note: #446272;
  --feedback-ok-bg: #edf9f1;
  --feedback-ok-border: #b7deca;
  --feedback-ko-bg: #fff1ef;
  --feedback-ko-border: #f0c5be;
  --callout-bg: #f4f9fc;
  --callout-border: #b9d2df;
  --details-bg: #f7fbfd;
  --details-border: #d5e3ea;
  --theme-toggle-bg: #eff4f6;
  --theme-toggle-bg-hover: #e3edf2;
  --theme-toggle-border: #c8d6de;
  --theme-toggle-ink: #1f2630;
  --code-bg: #f3f7fa;
  --ok: #1b6a3c;
  --ko: #9a3a30;
  --shadow: 0 10px 30px rgba(31, 38, 48, 0.1);
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #10161f;
  --bg-alt: #0c1118;
  --bg-glow-1: rgba(220, 0, 46, 0.2);
  --bg-glow-2: rgba(252, 209, 0, 0.14);
  --surface: #17202b;
  --surface-alt: #1d2936;
  --surface-raised: #253342;
  --ink: #edf3f8;
  --ink-soft: #b3c4d3;
  --ink-muted: #9cafbf;
  --primary: #ff3f66;
  --primary-2: #dc002e;
  --border: #304153;
  --border-soft: #3b4f63;
  --link: #9fd4fb;
  --link-hover: #c6e5ff;
  --focus-ring: #7ab7ff;
  --focus-soft: #507fa8;
  --header-bg: linear-gradient(120deg, #1f2c3a 0%, #242233 45%, #2a2732 100%);
  --progress-track: #2a3a4a;
  --progress-track-border: #3a4d60;
  --card-kicker: #a7bdcd;
  --ref-modules: #9ab0bf;
  --teachair-border: #44586d;
  --field-border: #4f6478;
  --field-bg: #202c39;
  --pill-bg: #2a4252;
  --pill-ink: #d2edf9;
  --btn-secondary-bg: #263544;
  --table-break-bg: #223444;
  --chip-ink: #d5effc;
  --chip-bg: #294254;
  --status-loading-border: #3f5569;
  --status-loading-bg: #223242;
  --status-loading-ink: #c4d8e8;
  --status-error-border: #8b4f57;
  --status-error-bg: #3b2328;
  --flow-border: #40566a;
  --flow-bg: linear-gradient(180deg, #1f2c3b 0%, #182430 100%);
  --flow-wait: #cbe4f7;
  --flow-phase-border: #4b6074;
  --flow-phase-bg: #223142;
  --flow-support: #bdd8eb;
  --media-border: #475d73;
  --media-bg: #f7f9fb;
  --table-frame-border: #455a6e;
  --table-frame-bg: #1f2b38;
  --diagram-frame-border: #41576a;
  --diagram-frame-bg: linear-gradient(180deg, #1f2f3f 0%, #192835 100%);
  --diagram-title: #d6ebf9;
  --diagram-scroll-border: #4d6377;
  --diagram-scroll-bg: #f7f9fb;
  --diagram-note: #bdd2e1;
  --feedback-ok-bg: #1f3a2d;
  --feedback-ok-border: #3e6f56;
  --feedback-ko-bg: #432329;
  --feedback-ko-border: #82515a;
  --callout-bg: #202f3c;
  --callout-border: #4e6c80;
  --details-bg: #1f2d3a;
  --details-border: #4a6075;
  --theme-toggle-bg: #22303d;
  --theme-toggle-bg-hover: #2d3e4f;
  --theme-toggle-border: #4c6072;
  --theme-toggle-ink: #f0f5f9;
  --code-bg: #22303e;
  --ok: #6fe0a3;
  --ko: #ff8f8f;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 10% 5%, var(--bg-glow-1) 0%, transparent 42%),
    radial-gradient(circle at 90% 0%, var(--bg-glow-2) 0%, transparent 38%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-alt) 100%);
  color: var(--ink);
  min-height: 100vh;
}

a {
  color: var(--link);
}

a:hover {
  color: var(--link-hover);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

#app {
  max-width: var(--layout-max);
  margin: 0 auto;
  padding: 24px clamp(16px, 2.3vw, 34px) 40px;
  animation: fade-in 360ms ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--header-bg);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

.header h1 {
  margin: 2px 0 0;
  font-size: clamp(1.2rem, 2vw, 1.6rem);
  font-family: var(--font-heading);
}

h2,
h3,
h4 {
  font-family: var(--font-heading);
}

.header-main {
  min-width: 0;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-home-link {
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
}

.brand-home-link:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.brand-logo {
  width: clamp(200px, 26vw, 320px);
  height: auto;
  display: block;
  object-fit: contain;
  border-radius: 6px;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.header-side {
  min-width: 260px;
  width: min(36vw, 460px);
  display: grid;
  justify-items: stretch;
  align-content: center;
  gap: 10px;
}

.header-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.progress-label {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-align: right;
}

.theme-toggle {
  border: 1px solid var(--theme-toggle-border);
  background: var(--theme-toggle-bg);
  color: var(--theme-toggle-ink);
  border-radius: 999px;
  min-width: 92px;
  padding: 7px 14px;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.theme-toggle:hover {
  background: var(--theme-toggle-bg-hover);
}

.theme-toggle:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.session-chip {
  margin: 0;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.75rem;
  max-width: 30ch;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.btn-ghost {
  padding: 7px 12px;
  font-size: 0.78rem;
}

.progress-wrap {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: var(--progress-track);
  border: 1px solid var(--progress-track-border);
  overflow: hidden;
}

.progress-value {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  transition: width 260ms ease;
}

.panel {
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: clamp(22px, 2.1vw, 34px);
}

.hero {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 24px;
}

.subtitle {
  font-size: 1.1rem;
  margin-top: -4px;
  color: var(--ink-soft);
}

.card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: var(--surface-alt);
}

.landing-stack {
  display: grid;
  gap: 14px;
}

.landing-card h3 {
  margin: 0 0 8px;
}

.card-kicker {
  margin: 8px 0 6px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--card-kicker);
  font-weight: 700;
}

.reference-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.reference-list a {
  color: var(--link);
  font-weight: 700;
  text-decoration: none;
}

.reference-list a:hover {
  text-decoration: underline;
}

.ref-modules {
  display: block;
  font-size: 0.78rem;
  color: var(--ref-modules);
}

.teachair-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.teachair-item {
  border: 1px solid var(--teachair-border);
  border-radius: 10px;
  background: var(--surface-raised);
  padding: 10px 12px;
}

.teachair-item h4 {
  margin: 0 0 4px;
  font-size: 0.95rem;
}

.teachair-item a {
  color: var(--link);
  text-decoration: none;
  font-weight: 600;
}

.teachair-item a:hover {
  text-decoration: underline;
}

.empty-note {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.9rem;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 12px;
}

input {
  font: inherit;
  border: 1px solid var(--field-border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--field-bg);
}

input:focus {
  outline: 2px solid var(--focus-soft);
  border-color: var(--primary);
}

.pill-list {
  padding: 0;
  margin: 18px 0 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill-list li {
  background: var(--pill-bg);
  color: var(--pill-ink);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 700;
}

.actions {
  margin-top: 20px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.actions-inline {
  justify-content: flex-start;
  flex-wrap: wrap;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 700;
}

.btn-primary {
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  color: #fff;
}

.btn-secondary {
  background: var(--btn-secondary-bg);
  color: var(--ink);
  border: 1px solid var(--border);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

th,
td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid var(--border-soft);
}

th {
  background: var(--surface-alt);
}

.agenda-row.agenda-break td {
  background: var(--table-break-bg);
  font-weight: 700;
}

.agenda-row.agenda-module td:nth-child(2) {
  font-weight: 700;
}

.module-head {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.chip {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--chip-ink);
  background: var(--chip-bg);
  border-radius: 999px;
  padding: 4px 10px;
}

.module-content {
  margin-top: 8px;
  line-height: 1.66;
}

.module-content a {
  color: var(--link);
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

.module-content a:hover {
  color: var(--link-hover);
}

.module-status {
  margin: 0;
  border-radius: 12px;
  border: 1px solid var(--status-loading-border);
  background: var(--status-loading-bg);
  padding: 12px;
}

.module-status.loading {
  color: var(--status-loading-ink);
}

.module-status.error {
  border-color: var(--status-error-border);
  background: var(--status-error-bg);
}

.module-status.error p {
  margin: 0 0 10px;
}

.learning-flow {
  margin-top: 16px;
  border: 1px solid var(--flow-border);
  border-radius: 14px;
  background: var(--flow-bg);
  padding: 14px;
}

.flow-wait {
  margin: 0;
  font-weight: 700;
  color: var(--flow-wait);
}

.flow-grid {
  margin-top: 12px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.flow-phase {
  border: 1px solid var(--flow-phase-border);
  background: var(--flow-phase-bg);
  border-radius: 12px;
  padding: 12px;
}

.flow-label {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.flow-duration {
  margin: 4px 0 8px;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary);
}

.flow-phase p:last-child {
  margin-bottom: 0;
}

.flow-support {
  margin: 12px 0 0;
  color: var(--flow-support);
}

.module-content h2,
.module-content h3 {
  margin-top: 18px;
}

.module-content figure {
  margin: 24px 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 6px;
  scrollbar-gutter: stable both-edges;
}

.module-content img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--media-border);
  background: var(--media-bg);
  padding: 8px;
}

.module-content figure > svg {
  display: block;
  width: max(100%, var(--diagram-min));
  min-width: var(--diagram-min);
  max-width: none;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--media-border);
  background: var(--media-bg);
  padding: 8px;
}

.module-content figcaption {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.module-content table {
  display: block;
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--table-frame-border);
  background: var(--table-frame-bg);
}

.module-content table tr {
  background: var(--table-frame-bg);
}

.module-content blockquote {
  margin: 16px 0;
  border: 1px solid var(--callout-border);
  border-left-width: 4px;
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--callout-bg);
}

.module-content blockquote > :first-child {
  margin-top: 0;
}

.module-content blockquote > :last-child {
  margin-bottom: 0;
}

.module-content details {
  margin: 16px 0;
  border: 1px solid var(--details-border);
  border-radius: 12px;
  background: var(--details-bg);
  padding: 10px 12px;
}

.module-content details summary {
  cursor: pointer;
  font-weight: 700;
}

.module-content details[open] summary {
  margin-bottom: 8px;
}

.diagram-frame {
  margin: 16px 0;
  border: 1px solid var(--diagram-frame-border);
  border-radius: 14px;
  background: var(--diagram-frame-bg);
  padding: 12px;
}

.diagram-frame .diagram-title {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--diagram-title);
}

.diagram-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--diagram-scroll-border);
  border-radius: 12px;
  background: var(--diagram-scroll-bg);
  padding: clamp(8px, 1.2vw, 14px);
  scrollbar-gutter: stable both-edges;
}

.diagram-scroll img,
.diagram-scroll svg {
  min-width: var(--diagram-min);
  width: max(100%, var(--diagram-min));
  max-width: none;
  height: auto;
  display: block;
  margin: 0 auto;
  border: 0;
  padding: 0;
  border-radius: 0;
}

.diagram-scroll--wide img,
.diagram-scroll--wide svg {
  min-width: var(--diagram-wide-min);
  width: max(100%, var(--diagram-wide-min));
}

.diagram-scroll--xwide img,
.diagram-scroll--xwide svg {
  min-width: var(--diagram-xwide-min);
  width: max(100%, var(--diagram-xwide-min));
}

.diagram-note {
  margin: 8px 0 0;
  font-size: 0.82rem;
  color: var(--diagram-note);
}

.diagram-link {
  margin: 8px 0 0;
  font-size: 0.82rem;
}

.diagram-link a {
  color: var(--link);
  font-weight: 700;
  text-decoration: none;
}

.diagram-link a:hover {
  text-decoration: underline;
}

.list {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
}

.question {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-top: 12px;
  background: var(--surface-alt);
}

.question-meta {
  display: flex;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  margin-bottom: 10px;
}

.options {
  display: grid;
  gap: 8px;
}

.option {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-weight: 500;
}

.feedback-grid {
  display: grid;
  gap: 10px;
}

.feedback {
  border-radius: 12px;
  padding: 12px;
  border: 1px solid;
}

.feedback.ok {
  background: var(--feedback-ok-bg);
  border-color: var(--feedback-ok-border);
}

.feedback.ko {
  background: var(--feedback-ko-bg);
  border-color: var(--feedback-ko-border);
}

.explanation {
  color: var(--ink-soft);
}

.score {
  font-size: 1.4rem;
  font-weight: 800;
}

.status-pass {
  color: var(--ok);
}

.status-fail {
  color: var(--ko);
}

.loading {
  text-align: center;
  padding: 56px 24px;
}

code {
  font-family: var(--font-mono);
  background: var(--code-bg);
  border-radius: 6px;
  padding: 0.1em 0.35em;
}

@media (min-width: 1160px) {
  .module-content > :where(p, ul, ol, blockquote, details) {
    max-width: var(--measure-text);
  }

  .module-content > :where(h2, h3, h4) {
    max-width: calc(var(--measure-text) + 4ch);
  }
}

@media (max-width: 840px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-side {
    justify-items: stretch;
  }

  .header-controls {
    justify-content: space-between;
  }

  .brand-row {
    flex-wrap: wrap;
  }

  .brand-logo {
    width: 220px;
  }

  .progress-wrap {
    width: 100%;
  }

  .progress-label {
    text-align: left;
  }

  .theme-toggle {
    justify-self: start;
  }

  .actions {
    justify-content: stretch;
    flex-wrap: wrap;
  }

  .actions button {
    flex: 1;
  }

  .panel {
    padding: 18px;
  }

  .flow-grid {
    grid-template-columns: 1fr;
  }

  .diagram-scroll img,
  .diagram-scroll svg {
    min-width: 560px;
    width: max(100%, 560px);
  }

  .module-content figure > svg {
    min-width: 560px;
    width: max(100%, 560px);
  }

  .diagram-scroll--wide img,
  .diagram-scroll--wide svg {
    min-width: 760px;
    width: max(100%, 760px);
  }

  .diagram-scroll--xwide img,
  .diagram-scroll--xwide svg {
    min-width: 900px;
    width: max(100%, 900px);
  }
}

/* Login page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-brand {
  display: flex;
  justify-content: center;
}

.login-brand .brand-logo {
  height: 40px;
  width: auto;
}

.login-card h1 {
  font-size: 1.2rem;
  text-align: center;
  margin: 0;
}

.login-subtitle {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin: 0;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-form .btn-primary {
  width: 100%;
  margin-top: 4px;
}

.login-error {
  background: var(--status-error-bg);
  border: 1px solid var(--status-error-border);
  color: var(--ko);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.9rem;
  margin: 0;
}

.landing-actions {
  margin-top: 24px;
  justify-content: flex-end;
}
