:root {
  --paper: #f7f6f2;
  --paper-2: #e6eaf2;
  --card: #ffffff;
  --ink: #10203d;
  --muted: #586276;
  --rule: #d5dae4;
  --accent: #ae1c28;
  --hero: #1e3f80;
  --hero-ink: #ffffff;
  --kpm: #21468b;
  --pool: #8a96a3;
  --kjcpl: #ae1c28;
  --nedlloyd: #e07b16;
  --link: #21468b;
  --shadow: 0 1px 2px rgb(16 32 61 / .08), 0 6px 20px rgb(16 32 61 / .08);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0c1424; --paper-2: #15213a; --card: #15203a; --ink: #eef1f7; --muted: #a3adc0;
    --rule: #2a3958; --accent: #e5484f; --hero: #132b5c; --hero-ink: #ffffff;
    --kpm: #5b86d8; --pool: #8a96a3; --kjcpl: #e5484f; --nedlloyd: #f0953a; --link: #9dbaf2;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 6px 20px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0c1424; --paper-2: #15213a; --card: #15203a; --ink: #eef1f7; --muted: #a3adc0;
  --rule: #2a3958; --accent: #e5484f; --hero: #132b5c; --hero-ink: #ffffff;
  --kpm: #5b86d8; --pool: #8a96a3; --kjcpl: #e5484f; --nedlloyd: #f0953a; --link: #9dbaf2;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 6px 20px rgb(0 0 0 / .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 17px/1.6 var(--sans); -webkit-font-smoothing: antialiased;
}
a { color: var(--link); }
h1, h2, h3 { font-family: var(--serif); line-height: 1.15; margin: 0; }
h2 { font-size: clamp(1.7rem, 3.5vw, 2.3rem); font-weight: 600; margin-bottom: .6rem; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 700px) { .wrap { padding: 0 32px; } }
section { padding: 56px 0 8px; }
.intro { max-width: 68ch; color: var(--muted); margin: 0 0 1rem; }
.note { font-size: .92rem; }

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: hidden; background: var(--hero); color: var(--hero-ink);
  padding: 72px 0 96px;
}
.hero::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 18px;
  background: linear-gradient(#ae1c28 0 33.3%, #fff 33.3% 66.6%, #21468b 66.6%);
}
.hero .eyebrow { letter-spacing: .14em; text-transform: uppercase; font-size: .8rem; color: #c9d6f0; margin: 0 0 .6rem; }
.hero h1 { font-size: clamp(3rem, 10vw, 6.5rem); font-weight: 800; letter-spacing: -.02em; }
.hero .lede { font-size: clamp(1.05rem, 2.2vw, 1.35rem); max-width: 40ch; margin: 1rem 0 2rem; opacity: .9; }
.hero-waves { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 90px; }
.hero-waves path:first-child { fill: rgb(255 255 255 / .05); }
.hero-waves path:last-child { fill: var(--paper); }
.stats { display: flex; flex-wrap: wrap; gap: 12px 40px; margin: 0; }
.stats div { display: flex; flex-direction: column-reverse; }
.stats dt { font-size: .85rem; opacity: .75; }
.stats dd { margin: 0; font: 600 2.1rem/1 var(--serif); color: #fff; }

.toc { display: flex; gap: 20px; padding-top: 20px; font-weight: 600; }
.toc a { text-decoration: none; color: var(--muted); }
.toc a:hover { color: var(--ink); }

/* ---------- legend ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: .9rem; color: var(--muted); margin: 0 0 16px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.legend i.hatch { background: repeating-linear-gradient(45deg, var(--muted) 0 2px, transparent 2px 5px); border: 1px solid var(--muted); }
.legend i.marker { border-radius: 50%; background: #fff; border: 2.5px solid var(--accent); }

/* ---------- ladder ---------- */
.ladder { position: relative; display: grid; grid-template-columns: 1fr; gap: 24px; }
@media (min-width: 900px) { .ladder { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); } }
.ladder-chart { position: relative; min-width: 0; }
.ladder-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.ladder-head {
  position: sticky; top: 0; z-index: 2; display: grid; background: var(--paper);
  border-bottom: 1px solid var(--rule); font-size: .78rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; padding: 8px 0 6px;
}
.ladder-head span { text-align: center; line-height: 1.15; }
.ladder-head span.now { color: var(--ink); }

svg .year { font: 12px var(--sans); fill: var(--muted); }
svg .year.major { font-weight: 600; fill: var(--ink); }
svg .grid { stroke: var(--rule); stroke-width: 1; }
svg .grid.minor { stroke-dasharray: 2 4; opacity: .7; }
svg .lane { fill: var(--paper-2); opacity: .45; }
svg .era { font: 600 11px var(--sans); letter-spacing: .08em; text-transform: uppercase; }
svg .era-band { opacity: .07; }
svg .path { fill: none; stroke: var(--ink); stroke-width: 1.2; opacity: .35; }
svg .path.leave { stroke-dasharray: 3 4; opacity: .25; }
svg .stint { cursor: pointer; stroke: var(--paper); stroke-width: 1; transition: opacity .15s; }
svg .stint:hover, svg .stint:focus-visible, svg .stint.hl { stroke: var(--ink); stroke-width: 2; outline: none; }
svg .label { font: 600 11.5px var(--sans); fill: var(--ink); pointer-events: none; paint-order: stroke; stroke: var(--paper); stroke-width: 3px; }
svg .label.master { font-size: 12px; }
svg .marker circle { fill: #fff; stroke: var(--accent); stroke-width: 2.5; cursor: pointer; }
svg .marker text { font: 700 11px var(--sans); fill: #ae1c28; pointer-events: none; }
svg .marker:hover circle, svg .marker:focus-visible circle, svg .marker.hl circle { fill: #ffe3e5; stroke-width: 3.5; }
svg .marker:focus-visible { outline: none; }
svg .ongoing { font: italic 12px var(--sans); fill: var(--muted); }

.ladder-stories { display: none; position: relative; list-style: none; margin: 0; padding: 0; }
@media (min-width: 900px) { .ladder-stories { display: block; } .stories-mobile { display: none; } }
.ladder-stories li { position: absolute; left: 0; right: 0; }

.story {
  background: var(--card); border: 1px solid var(--rule); border-left: 4px solid var(--accent);
  border-radius: 8px; padding: 12px 14px; box-shadow: var(--shadow); transition: border-color .15s, transform .15s;
}
.story.hl { border-color: var(--accent); transform: translateX(-3px); }
.story .when { font-size: .8rem; color: var(--muted); display: flex; gap: 8px; align-items: baseline; }
.story .num {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 700; font-size: .72rem; flex: none;
}
.story h3 { font-size: 1.12rem; margin: 4px 0 4px; }
.story p { margin: 0; font-size: .95rem; }
.story .src { margin-top: 8px; font-size: .78rem; color: var(--muted); }
.story button.shiplink {
  font: inherit; font-size: .82rem; font-weight: 600; color: var(--link); background: none; border: 0; padding: 0;
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}
.ladder-stories .story { padding: 10px 12px; }
.ladder-stories .story h3 { font-size: 1.02rem; }
.ladder-stories .story p.body { font-size: .9rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ladder-stories .story:not(.open) .src .srctext, .ladder-stories .story:not(.open) .clips { display: none; }
.ladder-stories .story .src { margin-top: 4px; }
.ladder-stories .story.open p.body { display: block; }
.ladder-stories li.open { z-index: 3; }
.story .more { font: inherit; font-size: .82rem; color: var(--link); background: none; border: 0; padding: 0; cursor: pointer; margin-right: 12px; }

.story-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }

/* ---------- fleet ---------- */
.fleet { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.fleet button {
  all: unset; box-sizing: border-box; display: block; width: 100%; cursor: pointer; background: var(--card);
  border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); transition: transform .15s;
}
.fleet button:hover, .fleet button:focus-visible { transform: translateY(-2px); outline: 2px solid var(--accent); outline-offset: 2px; }
.fleet .ph { aspect-ratio: 3 / 2; background: var(--paper-2); display: grid; place-items: center; overflow: hidden; }
.fleet img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fleet .meta { padding: 10px 12px 12px; }
.fleet .name { font: 600 1.05rem/1.2 var(--serif); }
.fleet .sub { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.badge { display: inline-block; font-size: .7rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; color: #fff; background: var(--muted); }
.badge.master { background: var(--accent); }
.silhouette { width: 70%; fill: var(--rule); }
.silhouette + small { display: block; }

/* ---------- ship sheet ---------- */
.sheet {
  border: 0; padding: 0; border-radius: 14px; width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgb(0 0 0 / .35);
}
.sheet::backdrop { background: rgb(10 18 32 / .55); }
.sheet-close {
  position: absolute; top: 10px; right: 10px; z-index: 2; width: 36px; height: 36px; border-radius: 50%; border: 0;
  background: rgb(0 0 0 / .55); color: #fff; font-size: 22px; line-height: 1; cursor: pointer;
}
.sheet figure { margin: 0; background: var(--paper-2); }
.sheet figure img { width: 100%; max-height: 420px; object-fit: contain; display: block; background: #0b0f16; }
.sheet figure .silhouette-wrap { aspect-ratio: 16 / 7; display: grid; place-items: center; color: var(--muted); font-size: .9rem; text-align: center; padding: 16px; }
.sheet figcaption { font-size: .78rem; color: var(--muted); padding: 6px 16px; }
.sheet .inner { padding: 16px 20px 22px; }
.sheet .inner > h3 { font-size: 1.9rem; }
.sheet .aka { color: var(--muted); font-size: .9rem; margin: 2px 0 12px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 16px; font-size: .95rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.sheet h4 { font: 600 1rem var(--serif); margin: 18px 0 6px; }
.service { width: 100%; border-collapse: collapse; font-size: .9rem; }
.service th, .service td { text-align: left; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.service th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.sheet .story { margin-top: 10px; box-shadow: none; }

/* ---------- tooltip ---------- */
.tip {
  position: fixed; z-index: 10; pointer-events: none; background: var(--ink); color: var(--paper);
  padding: 6px 10px; border-radius: 6px; font-size: .85rem; line-height: 1.35; max-width: 260px; box-shadow: var(--shadow);
}
.tip b { font-family: var(--serif); font-size: .95rem; }

.sources ul { max-width: 75ch; padding-left: 1.1rem; }
.sources li { margin-bottom: .5rem; }
.foot { padding: 40px 16px 56px; color: var(--muted); font-size: .9rem; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* ---------- nickname callout ---------- */
.nickname {
  display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: start; max-width: 760px;
  background: var(--card); border: 1px solid var(--rule); border-top: 4px solid var(--kpm);
  border-radius: 10px; padding: 18px 20px; box-shadow: var(--shadow); margin: 8px 0 28px;
}
.nickname svg { width: 46px; height: 46px; color: var(--kpm); }
.nickname h3 { font-size: 1.25rem; margin-bottom: 4px; }
.nickname p { margin: 0; }
.nickname p.src { margin-top: 8px; font-size: .78rem; color: var(--muted); }
.story .src a { color: var(--link); }
.story .clips { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px 10px; }
.story .clips a {
  font-size: .8rem; font-weight: 600; color: var(--link); text-decoration: none;
  border: 1px solid var(--rule); border-radius: 999px; padding: 2px 10px;
}
.story .clips a::before { content: "📰 "; }
.story .clips a:hover { border-color: var(--link); }

/* ---------- house flags & logos ---------- */
.house-flags { list-style: none; margin: 8px 0 18px; padding: 0; display: flex; flex-wrap: wrap; gap: 10px 22px; }
.house-flags li {
  display: inline-flex; align-items: center; gap: 8px; color: #dbe4f6;
  font-size: .8rem; letter-spacing: .12em; text-transform: uppercase;
}
.house-flags img { height: 26px; width: auto; border-radius: 2px; box-shadow: 0 1px 4px rgb(0 0 0 / .35); }
.legend img.flag { height: 13px; width: auto; border-radius: 1px; box-shadow: 0 0 0 1px var(--rule); }
.foot { display: grid; justify-items: start; gap: 4px; }
.foot .ril-logo { width: 240px; height: auto; border-radius: 6px; background: #fff; padding: 8px 10px; margin-bottom: 8px; }
.foot p { margin: 0; }
.foot .credits { font-size: .78rem; }

/* ---------- papers ---------- */
.papers { list-style: none; margin: 0; padding: 0; display: grid; gap: 22px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.papers li { background: var(--card); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); }
.papers a { display: block; aspect-ratio: 4 / 3; background: var(--paper-2); }
.papers img { width: 100%; height: 100%; object-fit: contain; display: block; transition: transform .2s; }
.papers a:hover img { transform: scale(1.03); }
.papers h3 { font-size: 1.05rem; margin: 12px 14px 2px; }
.papers p { margin: 0 14px 14px; font-size: .9rem; color: var(--muted); }
