:root {
  --bg: #f6f1e8;
  --surface: #fffdf8;
  --surface-2: #efe8db;
  --ink: #1f1a14;
  --muted: #6a5f52;
  --line: #ddd2c1;
  --accent: #b5532f;          /* Alhambra terracotta */
  --focus: #1d6fd6;
  --sky: #0c1222;
  --sky-ink: #dfe6f5;
  --sky-muted: #8d97b0;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 16px rgba(60, 40, 20, .06);
  --radius: 14px;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14120f; --surface: #1d1a16; --surface-2: #26221c; --ink: #eee7dc; --muted: #a79c8d;
    --line: #37312a; --accent: #e27d55; --focus: #6aa8ff; --sky: #080c18;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14120f; --surface: #1d1a16; --surface-2: #26221c; --ink: #eee7dc; --muted: #a79c8d;
  --line: #37312a; --accent: #e27d55; --focus: #6aa8ff; --sky: #080c18;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25); color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 16px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { animation: none !important; transition: none !important; } }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 32px; } }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 10px 14px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }

/* ── Hero ── */
.hero { padding: 64px 0 40px; border-bottom: 1px solid var(--line);
  background: radial-gradient(1200px 400px at 80% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%); }
.eyebrow { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 600; margin: 0 0 10px; }
h1 { font-family: var(--serif); font-weight: 700; font-size: clamp(44px, 8vw, 88px); line-height: 1; margin: 0 0 18px; letter-spacing: -.02em; }
.lede { font-size: clamp(17px, 2vw, 20px); max-width: 720px; color: var(--muted); margin: 0 0 28px; }
.lede em { color: var(--ink); font-style: normal; font-weight: 500; }
.stats { display: flex; flex-wrap: wrap; gap: 12px 36px; margin: 0 0 32px; }
.stats div { display: flex; flex-direction: column-reverse; }
.stats dt { font-size: 13px; color: var(--muted); }
.stats dd { margin: 0; font-family: var(--serif); font-size: 34px; font-weight: 600; line-height: 1.1; }
.toc { display: flex; flex-wrap: wrap; gap: 10px; }
.toc a { text-decoration: none; padding: 12px 16px; min-height: 44px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); font-weight: 500; display: inline-flex; align-items: center; gap: 8px; }
.toc a:hover { border-color: var(--accent); }
.toc span { font-family: var(--serif); color: var(--accent); }

/* ── Section headings ── */
section { padding: 56px 0 24px; }
h2 { font-family: var(--serif); font-size: clamp(30px, 4vw, 44px); margin: 0 0 8px; font-weight: 600; letter-spacing: -.01em; }
h2 small { display: block; font-family: var(--sans); font-size: 15px; color: var(--muted); font-weight: 400; letter-spacing: 0; margin-top: 4px; }
h2 .num { color: var(--accent); margin-right: 10px; }
.section-lede { color: var(--muted); max-width: 760px; margin: 0 0 24px; }

/* ── Constellation ── */
.sky-section { background: var(--sky); color: var(--sky-ink); padding-bottom: 48px; }
.sky-section h2 .num { color: #f0a36f; }
.sky-section h2 small, .sky-section .section-lede { color: var(--sky-muted); }
.sky-layout { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 1200px) { .sky-layout { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; } }
.sky-scroll { overflow-x: auto; border-radius: var(--radius); background: radial-gradient(ellipse at 50% 40%, #16203a 0%, var(--sky) 75%);
  border: 1px solid #1c2640; }
#sky-svg { display: block; width: 100%; min-width: 700px; height: auto; }
#sky-svg .edge { stroke: rgba(200, 215, 255, .16); stroke-width: 1.3; transition: stroke .2s, stroke-width .2s, opacity .2s; }
#sky-svg .edge.on { stroke-width: 2.4; }
#sky-svg .edge.off { opacity: .25; }
#sky-svg .dlabel { font: 600 13px var(--sans); letter-spacing: .16em; text-transform: uppercase; opacity: .55; }
#sky-svg .star { cursor: pointer; transition: opacity .2s; }
#sky-svg .star .halo { opacity: .28; }
#sky-svg .star .core { stroke: rgba(255,255,255,.85); stroke-width: 1.2; }
#sky-svg .star text { font: 600 14px var(--sans); fill: var(--sky-ink); text-anchor: middle; paint-order: stroke; stroke: var(--sky); stroke-width: 4px; }
#sky-svg .star.off { opacity: .28; }
#sky-svg .star.sel .halo { opacity: .6; }
#sky-svg .star:hover .halo { opacity: .5; }
#sky-svg .star:focus { outline: none; }
#sky-svg .star:focus-visible .ring { stroke: var(--focus); stroke-width: 3; }
#sky-svg .twinkle { animation: tw 5s ease-in-out infinite; }
@keyframes tw { 50% { opacity: .15; } }
.sky-panel { background: #121a2e; border: 1px solid #1c2640; border-radius: var(--radius); padding: 20px; min-height: 200px; }
.sky-panel h3 { font-family: var(--serif); font-size: 24px; margin: 6px 0 2px; line-height: 1.2; }
.sky-panel .sub { color: var(--sky-muted); margin: 0 0 12px; font-size: 14px; }
.sky-panel p { margin: 0 0 12px; }
.sky-panel ul { margin: 0 0 14px; padding-left: 18px; }
.sky-panel li { margin: 3px 0; }
.sky-panel .rel { font-size: 13px; color: var(--sky-muted); margin: 12px 0 6px; text-transform: uppercase; letter-spacing: .08em; }
.sky-panel .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sky-panel button.chip { font: 600 14px var(--sans); color: var(--sky-ink); background: #1a2440; border: 1px solid #2a3860; border-radius: 999px;
  padding: 8px 12px; min-height: 40px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.sky-panel button.chip:hover { border-color: #5a6fa8; }
.sky-panel .go { display: inline-block; margin-top: 14px; color: #f0a36f; font-weight: 600; padding: 8px 0; }
.legend { list-style: none; padding: 0 !important; display: grid; gap: 6px; }
.legend li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.dot { width: 11px; height: 11px; border-radius: 50%; flex: none; display: inline-block; }

/* ── Timeline ── */
.track { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0 12px; position: relative; }
@media (min-width: 900px) { .track { grid-template-columns: repeat(8, 1fr); } }
.track a { text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-height: 56px;
  display: flex; flex-direction: column; justify-content: center; }
.track a:hover { border-color: var(--accent); }
.track b { font-family: var(--serif); font-size: 18px; }
.track span { font-size: 12px; color: var(--muted); }
.semester { padding-top: 36px; padding-bottom: 8px; }
.sem-head { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; border-top: 2px solid var(--ink); padding-top: 14px; margin-bottom: 18px; }
.sem-head .big { font-family: var(--serif); font-size: 56px; line-height: .9; color: var(--accent); font-weight: 700; }
.sem-head h3 { font-family: var(--serif); font-size: 26px; margin: 0; font-weight: 600; }
.sem-head p { margin: 2px 0 0; color: var(--muted); }
.cards { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1180px) { .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 14px; box-shadow: var(--shadow);
  border-top: 5px solid var(--c); scroll-margin-top: 16px; }
.card:target { outline: 3px solid var(--c); outline-offset: 2px; }
.card header { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 8px; }
.acr { font: 700 13px var(--sans); letter-spacing: .04em; padding: 5px 8px; border-radius: 7px; flex: none;
  background: color-mix(in srgb, var(--c) 22%, var(--surface)); color: var(--ink); border: 1px solid color-mix(in srgb, var(--c) 55%, transparent); }
.card h4 { font-family: var(--serif); font-size: 20px; line-height: 1.2; margin: 0; font-weight: 600; }
.card .en { font-size: 13px; color: var(--muted); margin: 2px 0 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.tag.hl { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); color: var(--accent); font-weight: 600; }
.card .about { margin: 0 0 10px; font-size: 15px; }
.concepts { list-style: none; margin: 0; padding: 0; border-top: 1px dashed var(--line); }
.concepts li { padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 14.5px; line-height: 1.45; }
.concepts li:last-child { border-bottom: 0; }
.concepts b { font-weight: 600; }
.concepts .g { color: var(--muted); }
.card.tfg { grid-column: 1 / -1; background: linear-gradient(135deg, color-mix(in srgb, var(--c) 14%, var(--surface)), var(--surface) 60%); }
.card.tfg h4 { font-size: 28px; }
.card.tfg .concepts { columns: 2 280px; column-gap: 28px; }
.card.tfg .concepts li { break-inside: avoid; }

/* ── Atlas ── */
.mosaic { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 40px; }
.tile { flex: var(--w) 1 170px; min-height: 150px; text-decoration: none; border-radius: var(--radius); padding: 14px 16px;
  background: color-mix(in srgb, var(--c) 20%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  display: flex; flex-direction: column; justify-content: space-between; gap: 10px; transition: transform .15s; }
.tile:hover { transform: translateY(-2px); }
.tile h3 { font-family: var(--serif); font-size: 20px; margin: 0; line-height: 1.15; font-weight: 600; }
.tile .es { font-size: 12px; color: var(--muted); }
.tile .n { font-family: var(--serif); font-size: 30px; font-weight: 700; line-height: 1; }
.tile .n small { font: 400 12px var(--sans); color: var(--muted); margin-left: 4px; }
.tile .acrs { font-size: 12px; font-weight: 600; letter-spacing: .03em; opacity: .8; }
.domains { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .domains { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.domain { background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--c); border-radius: var(--radius); padding: 20px 22px; scroll-margin-top: 16px; }
.domain:target { outline: 3px solid var(--c); outline-offset: 2px; }
.domain h3 { font-family: var(--serif); font-size: 24px; margin: 0; font-weight: 600; }
.domain .es { color: var(--muted); font-size: 14px; margin: 0 0 10px; }
.domain .courses { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.domain .courses a { font-size: 13.5px; text-decoration: none; padding: 7px 10px; border-radius: 8px; background: var(--surface-2); min-height: 36px; display: inline-flex; align-items: center; }
.domain .courses a:hover { background: color-mix(in srgb, var(--c) 25%, var(--surface)); }
.domain .courses b { margin-right: 6px; }
.domain h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 14px 0 6px; }
.domain ul { margin: 0; padding-left: 20px; }
.domain li { margin: 4px 0; }

/* ── Threads ── */
.thread-list { display: grid; gap: 18px; }
.thread { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; }
.thread h3 { font-family: var(--serif); font-size: 24px; margin: 0 0 4px; font-weight: 600; }
.thread p { margin: 0 0 16px; color: var(--muted); }
.chain { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px 0; align-items: stretch; }
.chain li { display: flex; align-items: center; }
.chain li + li::before { content: "→"; color: var(--c); font-weight: 700; margin: 0 10px; font-size: 18px; }
.chain a { text-decoration: none; display: flex; flex-direction: column; padding: 8px 12px; border-radius: 10px; min-height: 44px; justify-content: center;
  background: color-mix(in srgb, var(--c) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); }
.chain a b { font-size: 12px; letter-spacing: .05em; }
.chain a span { font-size: 14px; }

.foot { padding: 40px 16px 64px; color: var(--muted); font-size: 14px; border-top: 1px solid var(--line); margin-top: 40px; }
.foot a { color: var(--accent); }

/* ── Language switch ── */
.lang { position: fixed; top: 12px; right: 12px; z-index: 20; display: flex; padding: 4px; gap: 4px; border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); border: 1px solid var(--line); box-shadow: var(--shadow);
  backdrop-filter: blur(8px); }
.lang button { font: 600 14px var(--sans); color: var(--muted); background: transparent; border: 0; border-radius: 999px;
  min-width: 48px; min-height: 40px; cursor: pointer; letter-spacing: .04em; }
.lang button:hover { color: var(--ink); }
.lang button[aria-pressed="true"] { background: var(--accent); color: #fff; }
