@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;600;700&family=Noto+Serif+KR:wght@600;700&display=swap");

:root {
  --ink: #172c2b;
  --ink-soft: #49605d;
  --paper: #f4efe4;
  --paper-light: #fbf8f0;
  --forest: #183f3a;
  --forest-light: #2f6159;
  --gold: #ba8a45;
  --gold-light: #dcc28c;
  --line: rgba(23, 44, 43, 0.18);
  --white: #fffef9;
  --shadow: 0 20px 60px rgba(20, 40, 37, 0.14);
  --serif: "Noto Serif KR", Georgia, serif;
  --sans: "Noto Sans KR", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  line-height: 1.7;
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid #c89443;
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 16px;
  transform: translateY(-150%);
  background: var(--white);
  border-radius: 4px;
}
.skip-link:focus { transform: translateY(0); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  position: absolute;
  z-index: 10;
  top: 0;
  left: 50%;
  width: min(1180px, calc(100% - 48px));
  height: 86px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--white);
  border-bottom: 1px solid rgba(255,255,255,.2);
}

.brand { display: flex; align-items: center; gap: 12px; font-family: var(--serif); font-size: 18px; font-weight: 700; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 36px;
  aspect-ratio: 1;
  color: var(--white);
  background: var(--gold);
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 50%;
}
.brand-mark.small { width: 30px; margin-right: 8px; }

nav { display: flex; align-items: center; gap: 32px; font-size: 14px; }
.nav-quiz { padding: 10px 18px; color: var(--white); border: 1px solid rgba(255,255,255,.5); border-radius: 999px; background: transparent; cursor: pointer; }

.hero {
  position: relative;
  min-height: 720px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  align-items: center;
  padding: 132px max(6vw, calc((100vw - 1180px) / 2)) 72px;
  color: var(--white);
  background:
    radial-gradient(circle at 75% 40%, rgba(188,141,73,.22), transparent 27%),
    linear-gradient(135deg, #102e2b 0%, #19423d 65%, #0e2825 100%);
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .08;
  background-image: repeating-linear-gradient(90deg, transparent 0 59px, #fff 60px), repeating-linear-gradient(0deg, transparent 0 59px, #fff 60px);
}

.hero-copy { position: relative; z-index: 1; max-width: 650px; }
.eyebrow { margin: 0 0 22px; color: var(--gold-light); font-size: 11px; font-weight: 700; letter-spacing: .25em; }
.hero h1, .section-heading h2, .quiz-callout h2 { margin: 0; font-family: var(--serif); font-weight: 600; line-height: 1.25; letter-spacing: -.045em; }
.hero h1 { font-size: clamp(48px, 6.2vw, 82px); }
.hero h1 em { color: var(--gold-light); font-style: normal; }
.hero-description { max-width: 590px; margin: 30px 0 38px; color: rgba(255,255,255,.72); font-size: 16px; }
.hero-actions { display: flex; align-items: center; gap: 28px; }
.primary-button, .light-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 36px;
  padding: 15px 22px;
  border: 0;
  background: var(--gold);
  cursor: pointer;
  font-weight: 700;
}
.text-button { padding: 8px 0; color: var(--white); border: 0; border-bottom: 1px solid rgba(255,255,255,.55); background: transparent; cursor: pointer; }

.hero-art { position: relative; z-index: 1; min-height: 440px; }
.orbit { position: absolute; left: 50%; top: 50%; border: 1px solid rgba(220,194,140,.35); border-radius: 50%; transform: translate(-50%,-50%); }
.orbit-one { width: 390px; height: 390px; }
.orbit-two { width: 275px; height: 275px; border-style: dashed; }
.compass {
  position: absolute;
  left: 50%; top: 50%;
  width: 128px; height: 310px;
  transform: translate(-50%,-50%);
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  color: var(--gold-light); font-family: var(--serif); font-size: 13px;
}
.compass-line { position: relative; width: 1px; flex: 1; margin: 14px 0; background: linear-gradient(var(--gold-light), rgba(220,194,140,.15)); }
.compass-line::before { content: ""; position: absolute; top: -2px; left: -5px; width: 11px; height: 11px; transform: rotate(45deg); background: var(--gold-light); }
.floating-year { position: absolute; color: rgba(255,255,255,.35); font-family: var(--serif); font-size: 14px; }
.year-one { right: 2%; top: 18%; }
.year-two { left: 7%; top: 36%; }
.year-three { right: 10%; bottom: 18%; }

.explore-section { padding: 110px max(5vw, calc((100vw - 1120px) / 2)) 120px; }
.section-heading { display: grid; grid-template-columns: 1fr 1fr; align-items: end; gap: 80px; margin-bottom: 54px; }
.section-heading .eyebrow { color: var(--gold); }
.section-heading h2, .quiz-callout h2 { font-size: clamp(34px, 4vw, 52px); }
.section-heading > p { max-width: 480px; margin: 0 0 6px; color: var(--ink-soft); }

.filters {
  display: grid;
  grid-template-columns: minmax(240px, 1.8fr) 1fr 1fr auto;
  gap: 10px;
  margin-bottom: 22px;
}
.search-box, .select-box { min-height: 62px; display: flex; align-items: center; gap: 12px; padding: 0 18px; background: var(--paper-light); border: 1px solid var(--line); }
.search-box input { width: 100%; color: var(--ink); border: 0; outline: 0; background: transparent; }
.select-box { justify-content: space-between; }
.select-box span { color: var(--ink-soft); font-size: 12px; }
.select-box select { min-width: 100px; color: var(--ink); border: 0; outline: 0; background: transparent; cursor: pointer; }
.reset-button { padding: 0 22px; border: 1px solid var(--line); background: transparent; cursor: pointer; }

.timeline-shell { overflow: hidden; background: var(--paper-light); border: 1px solid var(--line); box-shadow: var(--shadow); }
.timeline-toolbar, .timeline-footer { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 17px 24px; font-size: 12px; letter-spacing: .04em; }
.timeline-toolbar { border-bottom: 1px solid var(--line); }
.timeline-toolbar p { margin: 0; }
.ontology-overview-button { display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; color: var(--white); background: var(--forest); border: 1px solid var(--forest); border-radius: 999px; white-space: nowrap; cursor: pointer; font-size: 11px; font-weight: 700; letter-spacing: .05em; transition: transform .18s, background .18s; }
.ontology-overview-button:hover { transform: translateY(-1px); background: var(--forest-light); }
.ontology-overview-button span { color: var(--gold-light); font-size: 14px; }
.timeline-legend { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px 16px; margin-left: auto; }
.timeline-legend span { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-soft); white-space: nowrap; }
.importance-guide { color: var(--ink-soft); white-space: nowrap; }
.legend-dot { width: 10px; height: 10px; display: inline-block; border-radius: 3px; }
.legend-dot.event-color { background: linear-gradient(135deg, #d78c88 0 25%, #d7bb72 25% 50%, #8fc6a6 50% 75%, #a896c7 75%); }
.direction-guide { color: var(--forest-light); }
.direction-guide span { display: inline-block; margin-right: 8px; color: var(--gold); font-size: 18px; animation: rise 1.6s ease-in-out infinite; }
@keyframes rise { 50% { transform: translateY(-4px); } }

.timeline {
  position: relative;
  height: min(690px, 75vh);
  min-height: 500px;
  overflow-y: auto;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  background:
    linear-gradient(90deg, transparent calc(50% - .5px), rgba(186,138,69,.38) 50%, transparent calc(50% + .5px));
}
.timeline-track { display: flex; flex-direction: column; gap: 44px; padding: 64px 7% 80px; }
.timeline-era {
  align-self: center;
  position: relative;
  z-index: 2;
  margin: 18px 0 2px;
  padding: 7px 18px;
  color: var(--white);
  background: var(--forest);
  border-radius: 999px;
  font-family: var(--serif);
  font-size: 13px;
}
.timeline-item { position: relative; width: calc(50% - 64px); }
.timeline-item.left { align-self: flex-start; text-align: right; }
.timeline-item.right { align-self: flex-end; }
.timeline-item::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: 34px;
  width: 65px;
  height: 26px;
  border-top: 1.5px solid #243331;
}
.timeline-item.left::before {
  right: -65px;
  border-right: 1.5px solid #243331;
  border-radius: 0 18px 0 0;
}
.timeline-item.right::before {
  left: -65px;
  border-left: 1.5px solid #243331;
  border-radius: 18px 0 0 0;
}
.timeline-item::after {
  content: "";
  position: absolute;
  z-index: 2;
  top: 28px;
  width: 11px;
  height: 11px;
  background: var(--event-color, #ded8ca);
  border: 4px solid var(--paper-light);
  border-radius: 50%;
  box-shadow: 0 0 0 1px #1d2928;
}
.timeline-item.left::after { right: -73px; }
.timeline-item.right::after { left: -73px; }
.event-button {
  position: relative;
  overflow: hidden;
  width: 100%;
  padding: 22px 24px;
  text-align: inherit;
  color: var(--ink);
  background: var(--event-color, #ded8ca);
  border: 1px solid rgba(24,35,33,.3);
  border-radius: 18px 18px 18px 4px;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.event-button::after { content: ""; position: absolute; right: 0; bottom: 0; left: 0; height: 5px; background: rgba(24,35,33,.18); }
.right .event-button { border-radius: 18px 18px 4px 18px; }
.event-button:hover { transform: translateY(-3px); filter: brightness(1.08); box-shadow: 0 13px 32px rgba(23,44,43,.2); }
.event-topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.left .event-topline { flex-direction: row-reverse; }
.event-year { color: rgba(24,35,33,.78); font-family: var(--serif); font-size: 19px; font-weight: 700; }
.event-category { padding: 3px 8px; color: var(--ink); background: rgba(255,255,255,.25); border: 1px solid rgba(24,35,33,.22); border-radius: 999px; font-size: 10px; }
.event-button h3 { margin: 0 0 8px; font-family: var(--serif); font-size: 19px; }
.event-button p { margin: 0; color: rgba(24,35,33,.72); font-size: 13px; line-height: 1.65; }
.importance-label { display: block; margin: -2px 0 5px; color: rgba(24,35,33,.58); font-size: 9px; letter-spacing: .05em; }
.timeline-item.left .event-button { margin-left: auto; }
.timeline-item.right .event-button { margin-right: auto; }
.timeline-item .event-button { text-align: center; border-radius: 15px; }
.timeline-item .event-topline { display: block; margin-bottom: 1px; }
.timeline-item .event-category,
.timeline-item .event-button p { display: none; }
.timeline-item .importance-label { margin: 0 0 3px; }
.timeline-item .event-button h3 { margin: 0; }
.timeline-item.importance-1 .event-button { width: 56%; padding: 8px 10px; }
.timeline-item.importance-2 .event-button { width: 66%; padding: 9px 12px; }
.timeline-item.importance-3 .event-button { width: 76%; padding: 11px 14px; }
.timeline-item.importance-4 .event-button { width: 88%; padding: 13px 16px; }
.timeline-item.importance-5 .event-button { width: 100%; padding: 16px 18px; box-shadow: 0 10px 28px rgba(23,44,43,.18); }
.timeline-item.importance-1 .event-year { font-size: 11px; }
.timeline-item.importance-2 .event-year { font-size: 12px; }
.timeline-item.importance-3 .event-year { font-size: 14px; }
.timeline-item.importance-4 .event-year { font-size: 16px; }
.timeline-item.importance-5 .event-year { font-size: 18px; }
.timeline-item.importance-1 .event-button h3 { font-size: 11px; }
.timeline-item.importance-2 .event-button h3 { font-size: 13px; }
.timeline-item.importance-3 .event-button h3 { font-size: 15px; }
.timeline-item.importance-4 .event-button h3 { font-size: 17px; }
.timeline-item.importance-5 .event-button h3 { font-size: 20px; }
.branch-card.importance-1 { width: 70%; margin-inline: auto; transform: scale(.86); }
.branch-card.importance-2 { width: 78%; margin-inline: auto; transform: scale(.9); }
.branch-card.importance-3 { width: 86%; margin-inline: auto; transform: scale(.94); }
.branch-card.importance-4 { width: 94%; margin-inline: auto; transform: scale(.97); }
.branch-card.importance-5 { width: 100%; margin-inline: auto; }
.timeline-item,
.timeline-item.left,
.timeline-item.right {
  align-self: center;
  width: 100%;
  text-align: center;
}
.timeline-item::before,
.timeline-item::after { display: none; }
.timeline-item .event-button,
.timeline-item.left .event-button,
.timeline-item.right .event-button { margin-inline: auto; }
.timeline-item.importance-1 .event-button { width: 22%; }
.timeline-item.importance-2 .event-button { width: 28%; }
.timeline-item.importance-3 .event-button { width: 34%; }
.timeline-item.importance-4 .event-button { width: 40%; }
.timeline-item.importance-5 .event-button { width: 48%; }
.kingdom-branch {
  position: relative;
  align-self: stretch;
  height: 1500px;
  margin: 8px 0 20px;
}
.branch-lines { position: absolute; z-index: 0; inset: 0; width: 100%; height: 100%; overflow: visible; }
.branch-lines path { fill: none; stroke: #243331; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.branch-period-heading { position: absolute; z-index: 3; top: 0; left: 50%; display: grid; justify-items: center; gap: 2px; min-width: 210px; padding: 9px 18px; transform: translateX(-50%); color: var(--white); background: var(--forest); border-radius: 14px; text-align: center; }
.branch-period-heading strong { font-family: var(--serif); font-size: 15px; }
.branch-period-heading span { color: rgba(255,255,255,.68); font-size: 9px; }
.branch-unified {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 50%;
  width: 32%;
  transform: translateX(-50%);
}
.branch-unified .event-button {
  border-radius: 18px;
  text-align: center;
}
.kingdom-line {
  position: absolute;
  z-index: 0;
  top: 194px;
  bottom: 120px;
  width: 1.5px;
  transform: translateX(-50%);
  background: #243331;
}
.line-goguryeo { left: 23.33%; }
.line-baekje { left: 54%; }
.line-silla { left: 84.67%; }
.branch-table {
  position: absolute;
  z-index: 1;
  top: 70px;
  bottom: 76px;
  left: 0;
  width: 100%;
  display: grid;
  grid-template-columns: 8% repeat(var(--lane-count), minmax(0, 1fr));
  grid-template-rows: 44px repeat(var(--branch-rows), 1fr);
}
.branch-head {
  z-index: 2;
  align-self: center;
  justify-self: center;
  padding: 5px 14px;
  color: var(--white);
  background: var(--forest);
  border-radius: 999px;
  font-family: var(--serif);
  font-size: 12px;
}
.year-head {
  color: var(--ink-soft);
  background: transparent;
  font-family: var(--sans);
  font-size: 10px;
}
.branch-guide {
  z-index: 0;
  grid-column: 1 / -1;
  align-self: center;
  width: 100%;
  border-top: 1px dashed rgba(23, 44, 43, .13);
}
.branch-year {
  z-index: 2;
  grid-column: 1;
  align-self: center;
  padding-right: 9px;
  color: var(--ink-soft);
  background: var(--paper-light);
  text-align: right;
  font-family: var(--serif);
  font-size: 10px;
  white-space: nowrap;
}
.branch-event {
  z-index: 2;
  align-self: center;
  justify-self: center;
  width: 86%;
}
.branch-event-shared { width: 100%; }
.branch-event-shared .branch-card { max-width: 440px; }
.branch-card { min-height: 76px; padding: 11px 9px; border-radius: 13px; text-align: center; }
.branch-card .event-topline { display: block; margin-bottom: 4px; }
.branch-card .event-year { display: block; font-size: 11px; }
.branch-card .event-category { display: none; }
.branch-card h3 { margin: 2px 0 0; font-size: 15px; line-height: 1.45; }
.branch-caption { position: absolute; z-index: 1; bottom: 3px; left: 50%; width: 82%; transform: translateX(-50%); margin: 0; color: var(--ink-soft); text-align: center; font-size: 10px; }
.timeline-footer { color: var(--ink-soft); border-top: 1px solid var(--line); }
.timeline-footer .up-arrow { color: var(--gold); font-size: 21px; }
.empty-state { padding: 150px 20px; text-align: center; color: var(--ink-soft); }

.quiz-callout {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  align-items: end;
  gap: 90px;
  padding: 90px max(6vw, calc((100vw - 1120px) / 2));
  color: var(--white);
  background: var(--forest);
}
.quiz-callout p:not(.eyebrow) { max-width: 420px; color: rgba(255,255,255,.68); }
.light-button { margin-top: 20px; color: var(--ink); background: var(--paper-light); }

footer { display: flex; justify-content: space-between; align-items: center; padding: 30px max(6vw, calc((100vw - 1120px) / 2)); color: rgba(255,255,255,.62); background: #102a27; font-size: 12px; }
footer p:first-child { display: flex; align-items: center; color: var(--white); font-family: var(--serif); font-size: 15px; }

dialog { width: min(720px, calc(100% - 32px)); max-height: calc(100vh - 32px); padding: 0; color: var(--ink); background: var(--paper-light); border: 0; box-shadow: 0 28px 90px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(8,25,23,.74); backdrop-filter: blur(4px); }
.dialog-close { position: absolute; z-index: 3; right: 16px; top: 14px; width: 40px; height: 40px; color: var(--ink); background: rgba(255,255,255,.85); border: 1px solid var(--line); border-radius: 50%; cursor: pointer; font-size: 25px; line-height: 1; }
.detail-hero { padding: 48px 52px 34px; color: var(--ink); background: var(--event-color, #ded8ca); }
.detail-meta { color: rgba(24,35,33,.72); font-size: 12px; letter-spacing: .14em; }
.detail-hero h2 { margin: 8px 0 14px; font-family: var(--serif); font-size: 38px; }
.detail-hero p { margin: 0; color: rgba(24,35,33,.75); }
.detail-body { padding: 38px 52px 50px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px 38px; }
.detail-section h3 { margin: 0 0 8px; color: var(--gold); font-size: 12px; letter-spacing: .14em; }
.detail-section p { margin: 0; color: var(--ink-soft); font-size: 14px; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 30px; padding-top: 24px; border-top: 1px solid var(--line); }
.tag-button, .related-button { padding: 6px 10px; border: 1px solid var(--line); background: transparent; font-size: 11px; }
.tag-button { border-color: var(--tag-border, var(--line)); border-radius: 999px; cursor: pointer; transition: transform .18s, filter .18s; }
.tag-button:hover { transform: translateY(-2px); filter: saturate(1.18); }
.tag-button.colored-tag { color: #172c2b; background: var(--tag-color); }
.tag-button.person-tag { color: var(--ink-soft); background: #ece7dc; border-style: dashed; }
.tag-mixture { position: relative; width: 100%; height: 25px; overflow: hidden; background: var(--tag-mixture); border-radius: 7px; }
.tag-mixture::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(255,255,255,.28), transparent 50%, rgba(0,0,0,.08)); }
.tag-mixture span { position: relative; z-index: 1; display: inline-block; padding: 4px 9px; color: #172c2b; font-size: 10px; font-weight: 700; }
.related-button { cursor: pointer; }
.source-note { margin: 22px 0 0; color: var(--ink-soft); font-size: 11px; }
.source-note a { color: var(--forest-light); border-bottom: 1px solid var(--forest-light); }

.ontology-dialog { width: min(1180px, calc(100% - 28px)); }
.ontology-header { padding: 34px 54px 25px; border-bottom: 1px solid var(--line); }
.ontology-header h2 { margin: 3px 0 8px; font-family: var(--serif); font-size: 34px; }
.ontology-header p:last-child { margin: 0; color: var(--ink-soft); font-size: 12px; }
.ontology-header code { color: var(--forest); background: #e7e1d5; }
.ontology-layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; min-height: 570px; }
.ontology-graph-wrap { position: relative; min-width: 0; padding: 16px; border-right: 1px solid var(--line); }
.ontology-graph { width: 100%; height: 530px; overflow: visible; }
.ontology-graph line { stroke: rgba(34, 54, 52, .25); stroke-width: 1.5; }
.ontology-graph .tag-event-edge { stroke: rgba(34, 54, 52, .2); }
.ontology-graph .event-event-edge { stroke: #b16e2d; stroke-width: 2.3; stroke-dasharray: 5 4; }
.ontology-graph .event-event-edge.related_event { stroke: #7a438d; stroke-width: 3; stroke-dasharray: none; }
.ontology-graph .event-event-edge.next_event { stroke: #287f89; stroke-dasharray: 2 3; }
.ontology-event-node { cursor: pointer; outline: none; }
.ontology-event-node circle { stroke: rgba(25, 43, 42, .44); stroke-width: 1.5; transition: transform .18s, filter .18s; }
.ontology-event-node:hover circle, .ontology-event-node:focus circle { transform: scale(1.12); filter: saturate(1.22); stroke-width: 3; }
.ontology-event-node text { fill: var(--ink); text-anchor: middle; font-size: 9px; font-weight: 700; pointer-events: none; }
.ontology-event-node .node-label { paint-order: stroke; stroke: rgba(255,255,255,.5); stroke-width: 2px; stroke-linejoin: round; }
.ontology-center-node circle { stroke: rgba(25,43,42,.58); stroke-width: 2; }
.ontology-center-node text { fill: var(--ink); text-anchor: middle; font-size: 13px; font-weight: 800; pointer-events: none; }
.ontology-center-node .center-year { font-size: 10px; font-weight: 500; }
.ontology-limit { position: absolute; left: 24px; bottom: 12px; margin: 0; color: var(--ink-soft); font-size: 10px; }
.ontology-sidebar { max-height: 570px; overflow: auto; padding: 24px 20px; }
.ontology-sidebar h3 { margin: 0 0 12px; color: var(--gold); font-size: 11px; letter-spacing: .1em; }
.ontology-sidebar h3:not(:first-child) { margin-top: 28px; }
.ontology-edge-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; color: var(--ink-soft); font-size: 10px; }
.ontology-edge-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ontology-edge-legend i { width: 24px; height: 0; border-top: 2px solid rgba(34,54,52,.3); }
.ontology-edge-legend .event-edge-sample { border-color: #b16e2d; border-top-style: dashed; }
.ontology-related-tags { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 7px 5px; }
.ontology-related-tags .tag-button { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ontology-related-tags > span { color: var(--ink-soft); font-size: 10px; }
.ontology-event-list { display: grid; gap: 6px; }
.ontology-event-list button { position: relative; overflow: hidden; padding: 9px 10px 9px 15px; color: var(--ink); background: rgba(255,255,255,.55); border: 1px solid var(--line); text-align: left; cursor: pointer; font-size: 11px; }
.ontology-event-list button::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 6px; background: var(--event-mix); }
.ontology-event-list button span { display: block; margin-bottom: 2px; color: var(--ink-soft); font-size: 9px; }
.ontology-focus-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.ontology-detail-button { width: 100%; margin-bottom: 24px; padding: 12px; color: var(--white); background: var(--forest); border: 0; cursor: pointer; }
.ontology-empty { position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, 95px); color: var(--ink-soft); font-size: 12px; }
.ontology-open-button { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin: 0 0 30px; padding: 13px 18px; color: var(--white); background: var(--forest); border: 1px solid var(--forest); border-radius: 8px; cursor: pointer; font-weight: 700; }
.ontology-open-button:hover { background: var(--forest-light); }
.overview-header { background: linear-gradient(135deg, rgba(186,138,69,.13), transparent 56%); }
.overview-layout { grid-template-columns: minmax(0, 1fr) 260px; }
.overview-graph-wrap { overflow: hidden; padding: 10px; background: radial-gradient(circle at 50% 45%, rgba(186,138,69,.09), transparent 58%); }
.ontology-graph.overview-graph { width: 100%; min-width: 760px; height: 660px; }
.overview-graph .overview-edge { stroke: rgba(34,54,52,.13); stroke-width: 1; }
.overview-event-node circle { stroke: rgba(25,43,42,.5); stroke-width: 1; }
.overview-event-node:hover circle, .overview-event-node:focus circle { transform: scale(1.8); }
.overview-tag-node { cursor: pointer; outline: none; }
.overview-tag-node circle { stroke: rgba(25,43,42,.55); stroke-width: 1.5; transition: transform .18s, filter .18s; }
.overview-tag-node:hover circle, .overview-tag-node:focus circle { transform: scale(1.12); filter: saturate(1.2); stroke-width: 2.5; }
.overview-tag-node text { fill: var(--ink); text-anchor: middle; font-size: 8px; font-weight: 800; pointer-events: none; paint-order: stroke; stroke: rgba(255,255,255,.58); stroke-width: 2px; }
.overview-tag-node .overview-count { font-size: 7px; font-weight: 600; }
.overview-tag-node.is-other { cursor: default; }
.overview-help { margin: 0 0 24px; padding: 14px; color: var(--ink-soft); background: rgba(255,255,255,.55); border: 1px solid var(--line); font-size: 11px; line-height: 1.7; }
.overview-help strong { color: var(--ink); }
.overview-era-list { display: grid; gap: 7px; }
.overview-era-list span { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 7px; color: var(--ink-soft); border-bottom: 1px solid var(--line); font-size: 11px; }
.overview-era-list strong { color: var(--forest); }
.network-graph-wrap { position: relative; padding: 0; background-color: #eee9dd; background-image: radial-gradient(rgba(23,44,43,.13) .8px, transparent .8px); background-size: 18px 18px; touch-action: none; }
.ontology-graph.overview-graph.network-graph { width: 100%; min-width: 0; height: 660px; cursor: grab; user-select: none; touch-action: none; }
.network-graph.is-panning { cursor: grabbing; }
.network-controls { position: absolute; z-index: 5; top: 14px; left: 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.network-controls button { min-height: 34px; padding: 7px 11px; color: var(--ink); background: rgba(248,245,237,.92); border: 1px solid rgba(23,44,43,.25); border-radius: 7px; box-shadow: 0 3px 12px rgba(23,44,43,.08); cursor: pointer; font-size: 10px; font-weight: 700; }
.network-controls button:hover { color: var(--white); background: var(--forest); }
.network-edge { pointer-events: none; vector-effect: non-scaling-stroke; }
.network-edge.verified { stroke: rgba(122,67,141,.6); stroke-width: 2.1; }
.network-edge.concept { stroke: rgba(43,105,95,.3); stroke-width: 1.2; stroke-dasharray: 3 3; }
.network-event-node { cursor: move; }
.network-event-node circle { stroke: rgba(23,44,43,.58); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.network-event-node text { fill: var(--ink); text-anchor: middle; opacity: .82; font-size: 11px; font-weight: 750; pointer-events: none; paint-order: stroke; stroke: rgba(248,245,237,.96); stroke-width: 4px; stroke-linejoin: round; transition: opacity .16s, font-size .16s; }
.network-event-node:hover text, .network-event-node:focus text, .network-event-node.is-dragging text { opacity: 1; font-size: 14px; }
.network-event-node.is-start circle { stroke: var(--gold); stroke-width: 4; filter: drop-shadow(0 0 8px rgba(186,138,69,.72)); }
.network-event-node.is-start text { opacity: 1; font-size: 15px; }
.network-event-node.is-dragging circle { transform: scale(1.45); stroke-width: 3; }
.network-legend { display: grid; gap: 10px; margin-bottom: 26px; color: var(--ink-soft); font-size: 11px; }
.network-legend span { display: flex; align-items: center; gap: 9px; }
.network-legend i { width: 30px; height: 0; border-top: 2px solid rgba(34,54,52,.28); }
.network-legend i.verified { border-color: rgba(122,67,141,.75); }
.network-legend i.concept { border-color: rgba(43,105,95,.7); border-top-style: dashed; }

.quiz-dialog { width: min(640px, calc(100% - 32px)); }
.quiz-inner { padding: 48px 54px 54px; }
.quiz-kicker { margin: 0 0 10px; color: var(--gold); font-size: 11px; font-weight: 700; letter-spacing: .18em; }
.quiz-inner h2 { margin: 0; font-family: var(--serif); font-size: 32px; line-height: 1.4; }
.quiz-progress { height: 4px; margin: 28px 0 34px; overflow: hidden; background: #e1ddd3; }
.quiz-progress span { display: block; height: 100%; background: var(--gold); transition: width .3s; }
.answers { display: grid; gap: 10px; margin-top: 28px; }
.answer-button { padding: 15px 18px; text-align: left; color: var(--ink); background: var(--white); border: 1px solid var(--line); cursor: pointer; }
.answer-button:hover:not(:disabled) { border-color: var(--gold); }
.answer-button.correct { color: #174d36; background: #e4f1e8; border-color: #65a47c; }
.answer-button.wrong { color: #7a2d28; background: #f8e6e2; border-color: #c67d72; }
.answer-button:disabled { cursor: default; }
.quiz-feedback { min-height: 70px; margin-top: 22px; padding: 14px 16px; color: var(--ink-soft); background: #eee9dd; font-size: 13px; }
.quiz-next, .quiz-restart { width: 100%; margin-top: 16px; padding: 14px; color: var(--white); background: var(--forest); border: 0; cursor: pointer; }
.quiz-result { padding: 28px 0 5px; text-align: center; }
.score-circle { display: grid; place-items: center; width: 150px; height: 150px; margin: 20px auto 28px; color: var(--gold); border: 1px solid var(--gold); border-radius: 50%; font-family: var(--serif); font-size: 40px; }
.quiz-result p { color: var(--ink-soft); }

.toast { position: fixed; z-index: 50; left: 50%; bottom: 28px; padding: 11px 18px; transform: translate(-50%, 140%); color: var(--white); background: var(--ink); border-radius: 4px; box-shadow: var(--shadow); opacity: 0; transition: .3s; font-size: 13px; }
.toast.show { transform: translate(-50%,0); opacity: 1; }

@media (max-width: 780px) {
  .site-header { width: calc(100% - 32px); }
  nav a { display: none; }
  .hero { min-height: 760px; grid-template-columns: 1fr; padding: 132px 24px 54px; }
  .hero-art { position: absolute; right: -130px; bottom: -80px; width: 430px; opacity: .55; }
  .hero-copy { align-self: start; }
  .hero h1 { font-size: clamp(43px, 13vw, 64px); }
  .hero-description { max-width: 92%; }
  .explore-section { padding: 82px 18px; }
  .section-heading { grid-template-columns: 1fr; gap: 24px; margin-bottom: 38px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .search-box { grid-column: 1 / -1; }
  .reset-button { min-height: 52px; grid-column: 1 / -1; }
  .direction-guide { display: none; }
  .timeline-toolbar { align-items: flex-start; flex-wrap: wrap; }
  .ontology-overview-button { margin-left: auto; }
  .timeline-legend { order: 3; width: 100%; margin-left: 0; justify-content: flex-start; }
  .timeline { height: 650px; background-position: 24px 0; }
  .timeline-track { gap: 30px; padding: 50px 20px 65px 52px; }
  .timeline-era { align-self: flex-start; margin-left: -42px; }
  .timeline-item, .timeline-item.left, .timeline-item.right { width: 100%; align-self: auto; text-align: left; }
  .left .event-topline { flex-direction: row; }
  .timeline-item::before, .timeline-item.left::before, .timeline-item.right::before { left: -28px; right: auto; width: 28px; border-left: 0; border-right: 0; border-radius: 0; }
  .timeline-item::after, .timeline-item.left::after, .timeline-item.right::after { left: -36px; right: auto; }
  .event-button, .right .event-button { border-radius: 4px 18px 18px 18px; }
  .timeline-item .event-button, .timeline-item.right .event-button { border-radius: 12px; }
  .timeline-item.importance-1 .event-button { width: 62%; }
  .timeline-item.importance-2 .event-button { width: 71%; }
  .timeline-item.importance-3 .event-button { width: 80%; }
  .timeline-item.importance-4 .event-button { width: 90%; }
  .timeline-item, .timeline-item.left, .timeline-item.right { align-self: center; text-align: center; }
  .timeline-item::before, .timeline-item::after,
  .timeline-item.left::before, .timeline-item.left::after,
  .timeline-item.right::before, .timeline-item.right::after { display: none; }
  .timeline-item.importance-1 .event-button { width: 64%; }
  .timeline-item.importance-2 .event-button { width: 72%; }
  .timeline-item.importance-3 .event-button { width: 80%; }
  .timeline-item.importance-4 .event-button { width: 90%; }
  .timeline-item.importance-5 .event-button { width: 100%; }
  .kingdom-branch { height: 1380px; margin-left: -32px; width: calc(100% + 32px); }
  .polity-branch { min-width: 620px; margin-left: 0; width: 100%; }
  .branch-unified { left: 50%; width: 58%; }
  .kingdom-line { top: 194px; bottom: 120px; }
  .branch-table { top: 70px; bottom: 76px; grid-template-rows: 44px repeat(var(--branch-rows), 1fr); }
  .branch-head { padding: 4px 7px; font-size: 9px; }
  .branch-year { padding-right: 3px; font-size: 7px; }
  .branch-event { width: 94%; }
  .branch-card { min-height: 70px; padding: 8px 3px; border-radius: 9px; }
  .branch-card .event-year { font-size: 8px; }
  .branch-card h3 { font-size: 10px; line-height: 1.4; }
  .branch-caption { width: 82%; font-size: 8px; }
  .ontology-header { padding: 32px 46px 20px 22px; }
  .ontology-header h2 { font-size: 27px; }
  .ontology-layout { grid-template-columns: 1fr; }
  .overview-layout { grid-template-columns: 1fr; }
  .ontology-graph-wrap { padding: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .ontology-graph { height: 390px; }
  .ontology-graph.overview-graph { width: 760px; height: 500px; }
  .ontology-graph.overview-graph.network-graph { width: 100%; min-width: 0; height: 500px; }
  .ontology-sidebar { max-height: none; }
  .timeline-toolbar { padding: 14px 16px; }
  .quiz-callout { grid-template-columns: 1fr; gap: 22px; padding: 72px 24px; }
  footer { display: block; padding: 28px 24px; }
  footer p:last-child { margin-top: 12px; }
  .detail-hero, .detail-body { padding-left: 26px; padding-right: 26px; }
  .detail-hero h2 { font-size: 29px; }
  .detail-grid { grid-template-columns: 1fr; gap: 24px; }
  .quiz-inner { padding: 44px 24px 34px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
