:root {
  --color-bg: #ffffff;
  --color-text: #1a1a1a;
  --color-text-secondary: #555555;
  --color-text-muted: #888888;
  --color-border: #e0e0e0;
  --color-bg-subtle: #f7f7f7;
  --color-accent: #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-accent-light: #eff6ff;
  --font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --max-width: 48rem;
  --radius: 0.375rem;
}

/* Dark mode */
[data-theme="dark"] {
  --color-bg: #121212;
  --color-text: #e4e4e4;
  --color-text-secondary: #aaaaaa;
  --color-text-muted: #777777;
  --color-border: #2e2e2e;
  --color-bg-subtle: #1a1a1a;
  --color-accent: #60a5fa;
  --color-accent-hover: #3b82f6;
  --color-accent-light: #1e293b;
}

[data-theme="dark"] .level-badge-1 { background: #94a3b8; color: #0f172a; }
[data-theme="dark"] .level-badge-2 { background: #64748b; }
[data-theme="dark"] .level-badge-3 { background: #475569; }
[data-theme="dark"] .level-badge-4 { background: #334155; }

[data-theme="dark"] .schema-level-1 { border-left-color: #94a3b8; background: #1a1a1a; }
[data-theme="dark"] .schema-level-2 { border-left-color: #64748b; background: #1a1a1a; }
[data-theme="dark"] .schema-level-3 { border-left-color: #475569; background: #1a1a1a; }
[data-theme="dark"] .schema-level-4 { border-left-color: #334155; background: #1a1a1a; }

[data-theme="dark"] .schema-phase:first-of-type { border-top-color: #94a3b8; }
[data-theme="dark"] .schema-phase:nth-of-type(2) { border-top-color: #64748b; }
[data-theme="dark"] .schema-phase:nth-of-type(3) { border-top-color: #475569; }
[data-theme="dark"] .schema-phase:nth-of-type(4) { border-top-color: #334155; }

[data-theme="dark"] .schema-phase > .section-header { background: #1e1e1e; }
[data-theme="dark"] .schema-phase > .section-header:hover { background: #252525; }

[data-theme="dark"] .tl-phase-1 { background: #94a3b8; color: #0f172a; }
[data-theme="dark"] .tl-phase-2 { background: #64748b; }
[data-theme="dark"] .tl-phase-3 { background: #475569; }
[data-theme="dark"] .tl-phase-4 { background: #334155; color: #e4e4e4; }

[data-theme="dark"] .result-header { background: #e4e4e4; color: #121212; }

[data-theme="dark"] .pill-num { background: #e4e4e4; color: #121212; }

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

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

/* --- Header --- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: 0.75rem 1rem;
}

.header-content {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.header-title h1 {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
}

.header-title p {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  line-height: 1.3;
}

.header-ref-links {
  white-space: nowrap;
}

.header-ref-links a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.header-ref-links a:hover {
  color: var(--color-accent);
  text-decoration: underline;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.btn-lang {
  font-size: var(--font-size-sm);
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  color: var(--color-text);
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}

.btn-lang:hover {
  background: var(--color-bg-subtle);
  border-color: var(--color-text-muted);
}

/* --- View Toggle --- */
.view-toggle {
  display: flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.view-toggle button {
  font-size: var(--font-size-sm);
  padding: 0.25rem 0.75rem;
  border: none;
  background: var(--color-bg);
  color: var(--color-text-secondary);
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.view-toggle button:not(:last-child) {
  border-right: 1px solid var(--color-border);
}

.view-toggle button.active {
  background: var(--color-text);
  color: var(--color-bg);
}

/* --- Main --- */
.main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

/* --- Hierarchy: toolbar --- */
.hierarchy-toolbar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.btn-sm {
  font-size: var(--font-size-xs);
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-sm:hover {
  background: var(--color-bg-subtle);
}

/* --- Hierarchy: sections --- */
.section {
  border-bottom: 1px solid var(--color-border);
}

.section:first-child {
  border-top: 1px solid var(--color-border);
}

.section-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0.5rem;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text);
  transition: background 0.15s;
  font-family: var(--font-family);
  line-height: 1.4;
}

.section-header:hover {
  background: var(--color-bg-subtle);
}

.section-header:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
  border-radius: 2px;
}

.chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  transition: transform 0.2s ease;
}

.chevron.expanded {
  transform: rotate(90deg);
}

.section-body {
  padding: 0 0.5rem 0.75rem 2.25rem;
  overflow: hidden;
}

.section-body p {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

.section-body p:last-child {
  margin-bottom: 0;
}

/* Nested sections */
.subsection {
  border-left: 2px solid var(--color-border);
  margin: 0.25rem 0;
}

.subsection .section-header {
  font-size: var(--font-size-sm);
  font-weight: 600;
  padding: 0.5rem 0.5rem;
}

.subsection .section-body {
  padding: 0 0.5rem 0.5rem 2.25rem;
}

/* Article label */
.art-label {
  display: inline-block;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-accent);
  letter-spacing: 0.02em;
}

/* Ordered items in hierarchy */
.ordered-item {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--color-bg-subtle);
  border-radius: var(--radius);
  border-left: 3px solid var(--color-border);
}

.ordered-item:last-child {
  margin-bottom: 0;
}

.ordered-item .order-num {
  font-weight: 700;
  color: var(--color-text);
  flex-shrink: 0;
  min-width: 1.5rem;
}

.ordered-item .order-content {
  flex: 1;
}

.ordered-item .order-title {
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: var(--color-text);
  margin-bottom: 0.15rem;
}

.ordered-item .order-desc {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

/* Schema notes and criteria */
.schema-note {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-style: italic;
  margin-bottom: 0.75rem;
  padding-left: 0.25rem;
}

.schema-criteria {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: 0.75rem;
  padding: 0.4rem 0.75rem;
  background: var(--color-bg-subtle);
  border-left: 2px solid var(--color-accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  line-height: 1.5;
}

/* ========== Schema: phase cards ========== */
.schema-phase {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  overflow: hidden;
  border-top: 3px solid var(--color-border);
}

.schema-phase:first-of-type { border-top-color: #1e293b; }
.schema-phase:nth-of-type(2) { border-top-color: #475569; }
.schema-phase:nth-of-type(3) { border-top-color: #94a3b8; }
.schema-phase:nth-of-type(4) { border-top-color: #cbd5e1; }

.schema-phase > .section-header {
  padding: 0.85rem 1rem;
  font-size: var(--font-size-lg);
  font-weight: 700;
  background: var(--color-bg-subtle);
}

.schema-phase > .section-header:hover {
  background: #f0f0f0;
}

.schema-phase > div > .section-body {
  padding: 0.75rem 1rem 1rem;
}

/* Schema: sub-phase (Fase 1, Fase 2, Fase 3) */
.schema-subphase {
  border-left: none;
  margin: 0.5rem 0;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.schema-subphase > .section-header {
  font-size: var(--font-size-base);
  font-weight: 600;
  padding: 0.65rem 0.85rem;
  color: var(--color-text-secondary);
}

.schema-subphase > div > .section-body {
  padding: 0.5rem 0.85rem 0.85rem 2.25rem;
}

/* Schema: level card */
.schema-level {
  border-left: none;
  margin: 0.5rem 0;
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow 0.15s;
}

.schema-level-1 { border-left: 4px solid #1e293b; background: #fafafa; }
.schema-level-2 { border-left: 4px solid #334155; background: #fafafa; }
.schema-level-3 { border-left: 4px solid #64748b; background: #fafafa; }
.schema-level-4 { border-left: 4px solid #94a3b8; background: #fafafa; }

.schema-level > .section-header {
  font-size: var(--font-size-sm);
  font-weight: 700;
  padding: 0.6rem 0.75rem;
}

.schema-level > div > .section-body {
  padding: 0.25rem 0.75rem 0.75rem 2.75rem;
}

/* Schema: prelacion pills */
.schema-prelacion {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.schema-pill {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: border-color 0.15s;
}

.schema-pill:hover {
  border-color: var(--color-text-muted);
}

.schema-pill .pill-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--color-text);
  color: var(--color-bg);
  font-size: var(--font-size-xs);
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 0.05rem;
}

.schema-pill .pill-content {
  flex: 1;
  min-width: 0;
}

.schema-pill .pill-title {
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: var(--color-text);
  line-height: 1.4;
}

.schema-pill .pill-desc {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  line-height: 1.4;
  margin-top: 0.1rem;
}

/* Level badges */
.level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

/* Schema large badges */
.schema-level .level-badge {
  width: 1.75rem;
  height: 1.75rem;
  font-size: var(--font-size-sm);
}

.level-badge-1 { background: #1e293b; }
.level-badge-2 { background: #334155; }
.level-badge-3 { background: #64748b; }
.level-badge-4 { background: #94a3b8; }

/* Schema: simple description block */
.schema-desc {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: 1.6;
  padding: 0.5rem 0.75rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

/* Schema: mid-course items */
.schema-mid-items {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.schema-mid-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.schema-mid-item .mid-letter {
  font-weight: 700;
  color: var(--color-text);
  flex-shrink: 0;
  font-size: var(--font-size-sm);
}

.schema-mid-item .mid-desc {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: 1.5;
}

/* ========== Timeline view ========== */
.tl {
  position: relative;
  padding-left: 2rem;
}

.tl::before {
  content: '';
  position: absolute;
  left: 0.55rem;
  top: 0.75rem;
  bottom: 0.75rem;
  width: 2px;
  background: var(--color-border);
}

.tl-node {
  position: relative;
  margin-bottom: 1.5rem;
}

.tl-node-last {
  margin-bottom: 0;
}

.tl-dot {
  position: absolute;
  left: -1.7rem;
  top: 1.1rem;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: var(--color-text);
  border: 2px solid var(--color-bg);
  box-shadow: 0 0 0 2px var(--color-border);
  z-index: 1;
}

.tl-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--color-bg);
}

.tl-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: var(--color-bg-subtle);
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.tl-phase-badge {
  display: inline-block;
  font-size: var(--font-size-sm);
  font-weight: 700;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  color: #fff;
  white-space: nowrap;
}

.tl-phase-1 { background: #1e293b; }
.tl-phase-2 { background: #475569; }
.tl-phase-3 { background: #94a3b8; }
.tl-phase-4 { background: #cbd5e1; color: #1e293b; }

.tl-level-badges {
  display: flex;
  gap: 0.25rem;
}

.tl-card-body {
  padding: 0.85rem 1rem;
}

.tl-level-group {
  margin-bottom: 0.85rem;
}

.tl-level-group:last-of-type {
  margin-bottom: 0.5rem;
}

.tl-level-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.4rem;
}

.tl-pills {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding-left: 2rem;
}

.tl-pill {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-size: var(--font-size-sm);
  padding: 0.35rem 0.7rem;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text-secondary);
  line-height: 1.4;
}

.tl-pill b {
  color: var(--color-text);
  flex-shrink: 0;
}

.tl-criteria {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: 0.6rem;
  padding: 0.35rem 0.6rem;
  background: var(--color-accent-light);
  border-radius: var(--radius);
  line-height: 1.5;
}

.tl-criteria > span:first-child {
  font-weight: 600;
}

.tl-desc {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin: 0;
}

.tl-note {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-style: italic;
  margin: 0 0 0.65rem 0;
  line-height: 1.5;
}

.tl-mid-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.tl-mid-row {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  padding: 0.35rem 0.6rem;
  background: var(--color-bg-subtle);
  border-radius: var(--radius);
  line-height: 1.5;
}

.tl-mid-letter {
  font-weight: 700;
  color: var(--color-text);
  flex-shrink: 0;
}

/* Timeline responsive */
@media (max-width: 639px) {
  .tl {
    padding-left: 1.5rem;
  }

  .tl-dot {
    left: -1.2rem;
    width: 0.6rem;
    height: 0.6rem;
    top: 1.15rem;
  }

  .tl::before {
    left: 0.35rem;
  }

  .tl-pills {
    padding-left: 0;
  }

  .tl-pill {
    white-space: normal;
  }

  .tl-card-body {
    padding: 0.65rem 0.75rem;
  }
}

/* --- Flowchart --- */
.flowchart-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 50vh;
}

.flow-card {
  width: 100%;
  max-width: 32rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  background: var(--color-bg);
}

.flow-question {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 1.25rem;
  line-height: 1.3;
}

.flow-info {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  background: var(--color-bg-subtle);
  border-left: 3px solid var(--color-accent);
  padding: 0.75rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.flow-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.flow-option {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: var(--font-size-base);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  font-family: var(--font-family);
  line-height: 1.4;
}

.flow-option:hover {
  background: var(--color-accent-light);
  border-color: var(--color-accent);
}

.flow-option:active {
  transform: scale(0.99);
}

.flow-option:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.flow-nav {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  max-width: 32rem;
  width: 100%;
}

.btn-nav {
  font-size: var(--font-size-sm);
  padding: 0.4rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  color: var(--color-text-secondary);
  cursor: pointer;
  font-weight: 500;
  font-family: var(--font-family);
  transition: background 0.15s;
}

.btn-nav:hover {
  background: var(--color-bg-subtle);
}

/* --- Result card --- */
.result-card {
  width: 100%;
  max-width: 32rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.result-header {
  padding: 1.25rem 1.5rem;
  background: var(--color-text);
  color: var(--color-bg);
}

.result-header h2 {
  font-size: var(--font-size-lg);
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.result-header .result-level {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.result-header .result-level-num {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  line-height: 1;
}

.result-header .result-level-label {
  font-size: var(--font-size-sm);
  opacity: 0.85;
}

.result-section {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.result-section:last-child {
  border-bottom: none;
}

.result-section-title {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 0.35rem;
}

.result-section-value {
  font-size: var(--font-size-sm);
  color: var(--color-text);
  font-weight: 500;
}

.result-section p {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: 1.6;
}

.result-ordering {
  list-style: none;
  counter-reset: ordering;
}

.result-ordering li {
  counter-increment: ordering;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-bottom: 0.25rem;
}

.result-ordering li::before {
  content: counter(ordering) ".";
  font-weight: 700;
  color: var(--color-text);
  min-width: 1.25rem;
  flex-shrink: 0;
}

/* Mini-timeline in result card */
.mini-tl {
  position: relative;
  padding-left: 1rem;
}

.mini-tl::before {
  content: '';
  position: absolute;
  left: 0.3rem;
  top: 0.45rem;
  bottom: 0.45rem;
  width: 1.5px;
  background: var(--color-border);
}

.mini-tl-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0;
  position: relative;
}

.mini-tl-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--color-border);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.mini-tl-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  line-height: 1.3;
}

.mini-tl-before .mini-tl-dot {
  background: var(--color-text-muted);
}

.mini-tl-before .mini-tl-label {
  color: var(--color-text-muted);
}

.mini-tl-active {
  padding: 0.3rem 0;
}

.mini-tl-active .mini-tl-dot {
  width: 0.6rem;
  height: 0.6rem;
  background: var(--color-text);
  box-shadow: 0 0 0 2px var(--color-bg), 0 0 0 3.5px var(--color-text);
  margin-left: -0.075rem;
}

.mini-tl-active .mini-tl-label {
  font-weight: 700;
  color: var(--color-text);
  font-size: var(--font-size-sm);
}

.mini-tl-after .mini-tl-dot {
  background: var(--color-border);
}

.mini-tl-after .mini-tl-label {
  color: var(--color-border);
}

/* Share button */
.result-share {
  text-align: center;
}

.btn-share {
  font-size: var(--font-size-sm);
  padding: 0.45rem 1.25rem;
  border: 1px solid var(--color-accent);
  border-radius: var(--radius);
  background: var(--color-accent-light);
  color: var(--color-accent);
  cursor: pointer;
  font-weight: 600;
  font-family: var(--font-family);
  transition: background 0.15s, color 0.15s;
}

.btn-share:hover {
  background: var(--color-accent);
  color: #fff;
}

/* Focus styles for flowchart */
.flow-question:focus,
.result-header:focus {
  outline: none;
}

/* Answers breadcrumb */
.answers-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.answer-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: var(--font-size-xs);
  padding: 0.15rem 0.5rem;
  background: var(--color-bg-subtle);
  border-radius: 999px;
  color: var(--color-text-secondary);
}

.answer-chip .chip-label {
  font-weight: 600;
  color: var(--color-text-muted);
}

/* Step indicator */
.step-indicator {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 1rem;
  max-width: 32rem;
  width: 100%;
}

.step-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--color-border);
}

.step-dot.active {
  background: var(--color-text);
}

.step-dot.done {
  background: var(--color-text-muted);
}

/* ========== Age view ========== */
.age-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.age-card {
  padding: 1rem 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
}

.age-card h3 {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.4rem;
}

.age-card p {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin: 0;
}

.age-card-note {
  margin-top: 0.35rem !important;
  font-style: italic;
  color: var(--color-text-muted) !important;
}

.age-card-accent {
  border-left: 3px solid var(--color-accent);
  background: var(--color-accent-light);
}

/* Calculator */
.age-calc {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  background: var(--color-bg-subtle);
}

.age-calc h3 {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 1rem;
}

.age-calc-form {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.age-calc-field {
  flex: 1;
  min-width: 140px;
}

.age-calc-field label {
  display: block;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.age-calc-field input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  background: var(--color-bg);
  color: var(--color-text);
}

.age-calc-field input:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: -1px;
}

.age-calc-toggle {
  display: flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.age-calc-toggle button {
  flex: 1;
  padding: 0.5rem 0.5rem;
  border: none;
  background: var(--color-bg);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-family);
  transition: background 0.15s, color 0.15s;
}

.age-calc-toggle button:not(:last-child) {
  border-right: 1px solid var(--color-border);
}

.age-calc-toggle button.active {
  background: var(--color-text);
  color: var(--color-bg);
}

/* Calculator result */
.age-calc-result {
  border-top: 1px solid var(--color-border);
  padding-top: 1rem;
}

.age-calc-age {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-bottom: 0.75rem;
}

.age-calc-age strong {
  color: var(--color-text);
  font-size: var(--font-size-lg);
}

.age-calc-warning {
  padding: 0.75rem 1rem;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: var(--radius);
}

[data-theme="dark"] .age-calc-warning {
  background: #451a03;
  border-color: #b45309;
}

.age-calc-warning p {
  font-size: var(--font-size-sm);
  color: var(--color-text);
  line-height: 1.5;
  margin: 0;
}

.age-calc-if-exception {
  margin-top: 0.5rem !important;
  font-style: italic;
  color: var(--color-text-secondary) !important;
}

.age-calc-ok {
  padding: 0.75rem 1rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.age-calc-level-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 0.35rem;
}

.age-calc-level {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text);
  margin-top: 0.35rem;
}

.age-section-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-text);
  margin: 2rem 0 0.75rem;
}

.age-calc-share {
  text-align: center;
  margin-top: 0.75rem;
}

/* ========== Definitions ========== */
.defs-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.def-item {
  padding: 0.75rem 1rem;
  background: var(--color-bg-subtle);
  border-radius: var(--radius);
  border-left: 3px solid var(--color-border);
}

.def-item dt {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.25rem;
}

.def-item dd {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin: 0;
}

/* --- Footer --- */
.footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1rem;
  border-top: 1px solid var(--color-border);
  text-align: center;
}

.footer p {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}

.footer a {
  color: var(--color-accent);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

.footer-links {
  margin-top: 0.25rem;
}

/* --- Responsive --- */
@media (max-width: 639px) {
  .header-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-controls {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .header-controls .btn-lang {
    font-size: var(--font-size-xs);
    padding: 0.2rem 0.5rem;
  }

  .view-toggle {
    width: 100%;
    order: 1;
  }

  .view-toggle button {
    flex: 1;
    font-size: var(--font-size-xs);
    padding: 0.3rem 0.25rem;
    text-align: center;
  }

  .header-title h1 {
    font-size: var(--font-size-base);
  }

  .header-title p {
    font-size: 0.65rem;
  }

  .header-ref-links {
    display: block;
    white-space: normal;
  }

  .flow-question {
    font-size: var(--font-size-lg);
  }

  .result-header {
    padding: 1rem;
  }

  .result-section {
    padding: 0.75rem 1rem;
  }
}

@media (min-width: 768px) {
  .header {
    padding: 1rem 1.5rem;
  }

  .main {
    padding: 2rem 1.5rem 4rem;
  }

  .section-header {
    padding: 0.85rem 0.75rem;
  }
}

/* Presentation mode */
@media (min-width: 1400px) {
  :root {
    --font-size-base: 1.2rem;
    --font-size-sm: 1rem;
    --font-size-xs: 0.875rem;
    --font-size-lg: 1.4rem;
    --font-size-xl: 1.6rem;
    --font-size-2xl: 2rem;
    --max-width: 60rem;
  }
}

body.presentation {
  --font-size-base: 1.2rem;
  --font-size-sm: 1rem;
  --font-size-xs: 0.875rem;
  --font-size-lg: 1.4rem;
  --font-size-xl: 1.6rem;
  --font-size-2xl: 2rem;
  --max-width: 60rem;
}

/* --- Print --- */
@media print {
  .header-controls,
  .hierarchy-toolbar,
  .flow-nav,
  .btn-nav {
    display: none !important;
  }

  .header {
    position: static;
    border-bottom: 2px solid #000;
  }

  .section-body {
    display: block !important;
    overflow: visible !important;
    height: auto !important;
  }

  .section-header {
    cursor: default;
  }

  .chevron {
    transform: rotate(90deg);
  }

  body {
    font-size: 11pt;
  }
}
