:root {
  color-scheme: dark;
  --ink: #f4f8ff;
  --muted: #9eacc2;
  --night: #06101f;
  --deep: #09182c;
  --panel: rgba(14, 31, 54, .82);
  --panel-strong: #10243d;
  --line: rgba(175, 204, 238, .15);
  --gold: #efbd5c;
  --cyan: #58d7f5;
  --magenta: #ff74c8;
  --green: #6ce5ae;
  --violet: #aa8cff;
  --orange: #ff9868;
  --blue: #72a5ff;
  --danger: #ff7787;
  --radius: 20px;
  --shadow: 0 24px 70px rgba(0, 0, 0, .32);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 77% 14%, rgba(86, 79, 177, .16), transparent 23rem),
    radial-gradient(circle at 24% 67%, rgba(25, 144, 177, .1), transparent 27rem),
    linear-gradient(135deg, #050c17 0%, var(--night) 55%, #08182b 100%);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .55;
  background-image:
    radial-gradient(circle at 15% 23%, rgba(255,255,255,.72) 0 1px, transparent 1.5px),
    radial-gradient(circle at 84% 32%, rgba(255,255,255,.5) 0 1px, transparent 1.5px),
    radial-gradient(circle at 61% 72%, rgba(255,255,255,.55) 0 1px, transparent 1.5px),
    radial-gradient(circle at 31% 86%, rgba(255,255,255,.38) 0 1px, transparent 1.5px);
  background-size: 260px 220px, 330px 290px, 220px 310px, 390px 270px;
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.skip-link { position: fixed; top: .6rem; left: .6rem; z-index: 100; transform: translateY(-150%); background: white; color: #071426; padding: .7rem 1rem; border-radius: 8px; }
.skip-link:focus { transform: none; }

.topbar {
  height: 78px;
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .55rem clamp(1rem, 3vw, 2.5rem);
  background: rgba(5, 13, 25, .88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.brand { display: inline-flex; align-items: center; gap: .8rem; text-decoration: none; min-width: 0; }
.brand img { width: 56px; height: 56px; object-fit: contain; filter: drop-shadow(0 0 18px rgba(239,189,92,.18)); }
.brand span { display: grid; min-width: 0; }
.brand strong { font-size: 1.05rem; letter-spacing: .01em; white-space: nowrap; }
.brand small { color: var(--gold); font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; }
.top-actions { display: flex; align-items: center; gap: .75rem; }
.compact-field { display: flex; align-items: center; gap: .6rem; color: var(--muted); font-size: .82rem; }
select, input, textarea {
  color: var(--ink);
  background: rgba(255,255,255,.055);
  border: 1px solid var(--line);
  border-radius: 10px;
}
select { padding: .58rem 2rem .58rem .75rem; }
select option { background: #10243d; }
.icon-button, .facebook-link { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); display: grid; place-items: center; background: rgba(255,255,255,.04); color: var(--ink); cursor: pointer; text-decoration: none; }
.facebook-link img { border-radius: 50%; }

.app-shell { display: grid; grid-template-columns: 94px minmax(0, 1fr); min-height: calc(100vh - 78px); }
.rail {
  position: sticky;
  top: 78px;
  align-self: start;
  height: calc(100vh - 78px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: .55rem;
  padding: 1rem .7rem;
  border-right: 1px solid var(--line);
  background: rgba(5, 13, 25, .58);
  backdrop-filter: blur(12px);
}
.rail-link { display: grid; justify-items: center; gap: .15rem; padding: .75rem .25rem; border: 1px solid transparent; border-radius: 14px; color: var(--muted); background: transparent; cursor: pointer; }
.rail-link span { font-size: 1.25rem; }
.rail-link b { font-size: .72rem; letter-spacing: .04em; }
.rail-link:hover, .rail-link.active { color: var(--ink); background: rgba(114,165,255,.1); border-color: rgba(114,165,255,.2); }
.rail-link.active { color: var(--gold); }

#workspace { min-width: 0; position: relative; z-index: 1; }
.view { display: none; width: min(1540px, 100%); margin: 0 auto; padding: clamp(1.25rem, 3vw, 2.5rem); animation: emerge .38s ease; }
.view.active { display: block; }
@keyframes emerge { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .5rem; font-size: clamp(1.75rem, 3.5vw, 3.15rem); line-height: 1.03; letter-spacing: -.04em; }
h2 { line-height: 1.15; letter-spacing: -.02em; }
p { color: var(--muted); }
.eyebrow { margin-bottom: .35rem; color: var(--gold); font-size: .74rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.control-deck { display: flex; justify-content: space-between; align-items: end; gap: 2rem; margin-bottom: 1.4rem; }
.search-wrap { width: min(440px, 100%); position: relative; }
.search-wrap span { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--cyan); font-size: 1.4rem; }
.search-wrap input { width: 100%; padding: .85rem 1rem .85rem 2.8rem; }

.mission-strip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1.2rem;
  padding: 1.15rem 1.35rem;
  margin-bottom: 1.2rem;
  border: 1px solid rgba(239,189,92,.28);
  border-radius: var(--radius);
  background: linear-gradient(105deg, rgba(239,189,92,.12), rgba(47,66,125,.16) 45%, rgba(29,168,190,.08));
  box-shadow: inset 0 1px rgba(255,255,255,.045);
}
.mission-orbit { width: 52px; height: 52px; display: grid; place-items: center; border: 1px solid rgba(239,189,92,.35); border-radius: 50%; box-shadow: 0 0 0 7px rgba(239,189,92,.05), 0 0 30px rgba(239,189,92,.15); color: var(--gold); font-size: 1.35rem; }
.mission-copy h2 { margin-bottom: .2rem; font-size: 1.15rem; }
.mission-copy p { margin-bottom: 0; }

.button { display: inline-flex; justify-content: center; align-items: center; gap: .45rem; min-height: 43px; padding: .62rem .95rem; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: rgba(255,255,255,.05); font-weight: 750; text-decoration: none; cursor: pointer; }
.button:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.25); }
.button.primary { color: #091321; background: var(--gold); border-color: var(--gold); }
.button.primary:hover { background: #ffd47c; }
.button.ghost { background: transparent; }
.button.compact { min-height: 36px; padding: .45rem .7rem; font-size: .8rem; }

.world-filter { display: flex; gap: .55rem; padding: .35rem 0 1.2rem; overflow-x: auto; scrollbar-width: thin; }
.filter-chip { flex: 0 0 auto; padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: rgba(255,255,255,.025); cursor: pointer; }
.filter-chip:hover, .filter-chip.active { color: var(--ink); border-color: rgba(239,189,92,.4); background: rgba(239,189,92,.1); }

.map-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 1.2rem; align-items: start; }
.world-summary { position: sticky; top: 96px; padding: 1.35rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); overflow: hidden; }
.world-summary::after { content: ""; position: absolute; width: 190px; height: 190px; right: -95px; bottom: -105px; border: 1px solid rgba(239,189,92,.18); border-radius: 50%; box-shadow: 0 0 0 24px rgba(239,189,92,.025), 0 0 0 50px rgba(88,215,245,.018); }
.orbit-mark { width: 58px; height: 58px; display: grid; place-items: center; margin-bottom: 1rem; border-radius: 50%; background: rgba(239,189,92,.12); color: var(--gold); font-size: 1.65rem; box-shadow: inset 0 0 0 1px rgba(239,189,92,.25), 0 0 32px rgba(239,189,92,.12); }
.world-summary h2 { font-size: 1.55rem; }
.summary-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; margin: 1.25rem 0; }
.summary-stats div { padding: .7rem; border-radius: 12px; background: rgba(255,255,255,.04); }
.summary-stats dt { font-size: 1.5rem; font-weight: 850; }
.summary-stats dd { margin: 0; color: var(--muted); font-size: .74rem; }
.connection-note { display: flex; gap: .7rem; position: relative; z-index: 1; }
.connection-note > span { color: var(--cyan); font-size: 1.2rem; }
.connection-note p { font-size: .82rem; margin: 0; }
.connection-note strong { color: var(--ink); }

.module-grid { display: grid; grid-template-columns: repeat(3, minmax(220px, 1fr)); gap: .85rem; }
.module-card { --accent: var(--gold); position: relative; min-height: 248px; display: flex; flex-direction: column; padding: 1.05rem; overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: linear-gradient(145deg, rgba(255,255,255,.055), rgba(255,255,255,.018)); box-shadow: inset 0 1px rgba(255,255,255,.045); transition: transform .22s ease, border-color .22s ease, background .22s ease; }
.module-card:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--accent) 48%, transparent); background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 9%, transparent), rgba(255,255,255,.025)); }
.module-card::after { content: ""; position: absolute; width: 110px; height: 110px; right: -58px; top: -58px; border-radius: 50%; background: var(--accent); opacity: .065; }
.module-top { display: flex; align-items: center; justify-content: space-between; gap: .7rem; }
.module-glyph { width: 43px; height: 43px; display: grid; place-items: center; border-radius: 13px; background: color-mix(in srgb, var(--accent) 13%, transparent); color: var(--accent); font-size: 1.3rem; }
.module-status { color: var(--muted); font-size: .68rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.module-status.complete { color: var(--green); }
.module-card h3 { margin: .9rem 0 .35rem; font-size: 1.08rem; }
.module-card p { margin-bottom: .85rem; font-size: .84rem; }
.module-tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: auto; }
.module-tags span { padding: .24rem .45rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .68rem; }
.module-actions { display: flex; align-items: center; justify-content: space-between; gap: .65rem; margin-top: .85rem; padding-top: .75rem; border-top: 1px solid var(--line); }
.module-actions button { border: 0; color: var(--accent); background: transparent; font-weight: 800; cursor: pointer; padding: .2rem 0; }
.module-age { color: var(--muted); font-size: .7rem; }
.empty-state { padding: 4rem 1rem; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }
.empty-state span { color: var(--gold); font-size: 2rem; }

.section-heading { max-width: 880px; margin-bottom: 1.8rem; }
.section-heading > p:last-child { font-size: 1.05rem; }
.path-grid { display: grid; gap: 1rem; }
.path-card { --accent: var(--gold); display: grid; grid-template-columns: 230px minmax(0,1fr) auto; gap: 1.25rem; align-items: center; padding: 1.2rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.path-intro h2 { margin: .25rem 0; }
.path-intro p { margin: 0; font-size: .85rem; }
.path-age { color: var(--accent); font-size: .74rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.path-steps { display: flex; align-items: center; gap: .4rem; min-width: 0; overflow-x: auto; }
.path-step { display: grid; grid-template-columns: auto minmax(90px, auto); align-items: center; gap: .45rem; flex: 0 0 auto; }
.path-step .node { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 9%, transparent); }
.path-step small { max-width: 115px; color: var(--muted); line-height: 1.2; }
.path-arrow { color: var(--muted); }

.thinking-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr); gap: 1rem; }
.studio-card, .mission-output, .experiment-log, .chart-card, .activity-card, .boundary-panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.studio-card { padding: 1.25rem; }
.studio-card > label, .studio-grid label { display: grid; gap: .35rem; color: var(--muted); font-size: .8rem; font-weight: 750; }
.studio-card textarea { resize: vertical; width: 100%; min-height: 118px; margin-bottom: 1rem; padding: .8rem; }
.studio-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-bottom: 1rem; }
.studio-grid select { width: 100%; }
.mission-output { position: relative; padding: 1.35rem; overflow: hidden; background: linear-gradient(155deg, rgba(239,189,92,.11), rgba(14,31,54,.87) 45%); }
.mission-output::after { content: ""; position: absolute; width: 260px; height: 260px; right: -135px; bottom: -160px; border: 1px solid rgba(239,189,92,.16); border-radius: 50%; box-shadow: 0 0 0 30px rgba(239,189,92,.025), 0 0 0 65px rgba(88,215,245,.018); }
.output-head { display: flex; gap: .9rem; align-items: center; }
.output-icon { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 50%; color: var(--gold); background: rgba(239,189,92,.12); font-size: 1.4rem; }
.output-head h2 { margin: 0; }
.mission-output ol { position: relative; z-index: 1; padding-left: 1.35rem; color: var(--muted); }
.mission-output li { margin-bottom: .65rem; padding-left: .35rem; }
.mission-output strong { color: var(--ink); }
.experiment-log { margin-top: 1rem; padding: 1.2rem; }
.log-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.log-head h2 { margin: 0; }
.log-entry { display: grid; grid-template-columns: auto 1fr; gap: .8rem; padding: .8rem 0; border-top: 1px solid var(--line); }
.log-entry time { color: var(--gold); font-size: .72rem; }
.log-entry p { margin: 0; font-size: .84rem; }

.evidence-head { max-width: none; display: flex; align-items: end; justify-content: space-between; gap: 1rem; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; margin-bottom: 1rem; }
.metric-grid article { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: .75rem; padding: 1rem; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.metric-grid span { grid-row: 1 / 3; align-self: center; color: var(--gold); font-size: 1.4rem; }
.metric-grid strong { font-size: 1.5rem; line-height: 1; }
.metric-grid small { color: var(--muted); }
.evidence-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.chart-card, .activity-card { padding: 1.15rem; }
.chart-card h2, .activity-card h2 { margin: 0; }
.world-bars { display: grid; gap: .8rem; margin-top: 1.2rem; }
.bar-row { display: grid; grid-template-columns: 100px minmax(0,1fr) 42px; gap: .65rem; align-items: center; }
.bar-row label { font-size: .78rem; }
.bar-track { height: 11px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.06); }
.bar-fill { height: 100%; border-radius: inherit; background: var(--accent); box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 35%, transparent); }
.bar-row small { color: var(--muted); text-align: right; }
#skillRadar { width: 100%; height: auto; max-height: 360px; }
.activity-card { margin-top: 1rem; }
.timeline-empty { padding: 1.4rem 0 .3rem; color: var(--muted); }
.timeline-row { display: grid; grid-template-columns: 14px 1fr auto; gap: .7rem; align-items: center; padding: .7rem 0; border-top: 1px solid var(--line); }
.timeline-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 12px rgba(88,215,245,.45); }
.timeline-row strong { display: block; font-size: .87rem; }
.timeline-row small { color: var(--muted); }

.principle-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.principle-grid article { padding: 1rem; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.028); }
.principle-grid article > span { font-size: 1.4rem; }
.principle-grid h2 { margin: .65rem 0 .3rem; font-size: 1.05rem; }
.principle-grid p { margin: 0; font-size: .84rem; }
.boundary-panel { margin-top: 1rem; padding: 1.25rem; display: flex; justify-content: space-between; gap: 1.5rem; align-items: center; }
.boundary-panel > div:first-child { max-width: 760px; }
.boundary-panel h2 { margin-bottom: .4rem; }
.boundary-panel p:last-child { margin-bottom: 0; }
.downloads { display: grid; gap: .6rem; flex: 0 0 260px; }

.module-dialog { width: min(1500px, 96vw); height: min(930px, 94vh); padding: 0; border: 1px solid rgba(255,255,255,.15); border-radius: 18px; background: #071426; color: var(--ink); box-shadow: 0 32px 120px rgba(0,0,0,.7); overflow: hidden; }
.module-dialog::backdrop, .confirm-dialog::backdrop { background: rgba(0,5,12,.8); backdrop-filter: blur(8px); }
.dialog-shell { height: 100%; display: grid; grid-template-rows: auto 1fr; }
.dialog-bar { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .65rem .8rem; border-bottom: 1px solid var(--line); background: #0b1d33; }
.dialog-bar > div { display: flex; align-items: center; gap: .65rem; }
.dialog-bar > div:first-child > span { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: rgba(239,189,92,.12); }
.dialog-bar > div:first-child > div { display: grid; }
.dialog-bar small { color: var(--gold); font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; }
.dialog-bar strong { font-size: .9rem; }
.dialog-actions { justify-content: flex-end; }
.close-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.04); color: var(--ink); font-size: 1.4rem; cursor: pointer; }
#moduleFrame { width: 100%; height: 100%; border: 0; background: white; }
.confirm-dialog { width: min(480px, 92vw); padding: 0; border: 1px solid rgba(255,255,255,.15); border-radius: var(--radius); color: var(--ink); background: #0d2037; }
.confirm-dialog form { padding: 1.4rem; text-align: center; }
.confirm-dialog form > div { display: flex; justify-content: center; gap: .7rem; }
.confirm-glyph { width: 64px; height: 64px; display: grid; place-items: center; margin: 0 auto 1rem; border-radius: 50%; background: rgba(255,119,135,.12); color: var(--danger); font-weight: 900; }
.toast { position: fixed; z-index: 80; right: 1.2rem; bottom: 1.2rem; max-width: 360px; padding: .75rem 1rem; border: 1px solid rgba(108,229,174,.35); border-radius: 12px; background: #102a31; color: #dfffee; box-shadow: var(--shadow); transform: translateY(180%); opacity: 0; transition: .25s ease; }
.toast.show { transform: none; opacity: 1; }

@media (max-width: 1180px) {
  .module-grid { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
  .path-card { grid-template-columns: 200px minmax(0,1fr); }
  .path-card > .button { grid-column: 1 / -1; justify-self: start; }
}
@media (max-width: 900px) {
  .topbar { height: auto; min-height: 72px; }
  .compact-field span { display: none; }
  .app-shell { display: block; padding-bottom: 72px; }
  .rail { position: fixed; top: auto; bottom: 0; left: 0; right: 0; width: 100%; height: 66px; display: grid; grid-template-columns: repeat(5,1fr); padding: .35rem .5rem; border: 0; border-top: 1px solid var(--line); background: rgba(5,13,25,.94); }
  .rail-link { padding: .2rem; }
  .rail-link span { font-size: 1rem; }
  .map-layout { grid-template-columns: 1fr; }
  .world-summary { position: relative; top: 0; display: grid; grid-template-columns: auto 1fr; gap: 0 1rem; align-items: start; }
  .world-summary .orbit-mark { grid-row: 1 / 4; }
  .world-summary > p:not(.eyebrow), .summary-stats, .connection-note { grid-column: 1 / -1; }
  .thinking-layout, .evidence-grid { grid-template-columns: 1fr; }
  .principle-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 650px) {
  .brand img { width: 46px; height: 46px; }
  .brand strong { font-size: .88rem; }
  .brand small { font-size: .6rem; }
  .top-actions { gap: .35rem; }
  .facebook-link { display: none; }
  .compact-field select { max-width: 140px; }
  .view { padding: 1rem; }
  .control-deck, .evidence-head, .boundary-panel { align-items: stretch; flex-direction: column; }
  .control-deck { display: grid; gap: 1rem; }
  .mission-strip { grid-template-columns: auto 1fr; }
  .mission-strip .button { grid-column: 1 / -1; }
  .module-grid { grid-template-columns: 1fr; }
  .world-summary { display: block; }
  .module-card { min-height: 220px; }
  .path-card { grid-template-columns: 1fr; }
  .path-card > .button { grid-column: auto; }
  .studio-grid, .metric-grid, .principle-grid { grid-template-columns: 1fr 1fr; }
  .dialog-bar { align-items: flex-start; }
  .dialog-actions .button { display: none; }
  .downloads { flex: auto; }
}
@media (max-width: 430px) {
  .brand small, .icon-button { display: none; }
  .studio-grid, .metric-grid, .principle-grid { grid-template-columns: 1fr; }
  .rail-link b { font-size: .65rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
