/* FGO reader — modern dark shell with FGO-portal styling.
   Deliberately self-contained: no webfonts, no CDN. Colours derive from Open
   Props tokens (vendor/open-props.min.css); every var() keeps a literal
   fallback so a missing vendor file degrades instead of breaking the page. */

:root {
  color-scheme: dark light;

  /* surfaces */
  --bg: #0d1117;
  --bg-soft: #11161f;
  --panel: var(--gray-11, #161c26);
  --panel-2: var(--gray-10, #1c2430);
  --border: var(--gray-9, #26303e);
  --border-soft: #1e2733;

  /* text */
  --fg: var(--gray-1, #e8ecf3);
  --muted: var(--gray-6, #8b98ab);

  /* FGO accents (gold / tile teal / header navy) */
  --accent: var(--yellow-5, #e8b25a);
  --accent-2: #37a3a0;
  --navy: #1f2a63;
  --navy-2: #2a3781;
  --link: var(--blue-4, #7fb4ff);
  --danger: #d4544a;

  /* geometry */
  --radius: var(--radius-2, 5px);
  --radius-lg: 8px;
  --ease: var(--ease-2, ease);
  --shadow-soft: var(--shadow-1, 0 1px 2px rgba(0, 0, 0, 0.3));
  --shadow-hover: var(--shadow-3, 0 6px 18px rgba(0, 0, 0, 0.45));
  --font-ui: var(--font-sans, "Segoe UI", system-ui, -apple-system, sans-serif);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f7;
    --bg-soft: #eceef2;
    --panel: #ffffff;
    --panel-2: #f2f4f7;
    --border: #d5dae2;
    --border-soft: #e3e7ed;
    --fg: #13181f;
    --muted: #5a6675;
    /* darkened so accent text keeps contrast on a light surface */
    --accent: #a5701c;
    --accent-2: #2b7f7c;
    --link: #1a5fd0;
    --shadow-soft: 0 1px 2px rgba(15, 23, 42, 0.08);
    --shadow-hover: 0 6px 18px rgba(15, 23, 42, 0.14);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.62 var(--font-ui);
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; }
code {
  background: var(--panel-2); border: 1px solid var(--border-soft);
  padding: 1px 5px; border-radius: 4px; font-size: 0.88em;
}
.muted { color: var(--muted); }

/* ------------------------------------------------------------------ top bar */

header.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap;
  padding: 10px 18px;
  background: var(--navy);
  border-bottom: 2px solid var(--accent);
}
header.topbar .brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 800; color: #fff; white-space: nowrap;
  letter-spacing: 0.02em; font-size: 1.02rem;
  padding: 2px 6px 2px 2px; border-radius: var(--radius);
}
header.topbar .brand:hover { text-decoration: none; color: #fff; }
header.topbar .brand-mark {
  width: 28px; height: 28px; flex: 0 0 28px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
}
.brand-mark-ring { fill: none; stroke: var(--accent); stroke-width: 1.8; }
.brand-mark-core {
  fill: rgba(255, 255, 255, 0.08); stroke: #9fc0ff; stroke-width: 1.2;
}
.brand-mark-line {
  fill: none; stroke: #9fc0ff; stroke-width: 1.2; stroke-linecap: round;
}
.brand-mark-dot { fill: var(--accent); }
header.topbar .brand:hover .brand-mark-ring { stroke: #fff; }

.server-pill {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: #dfe7ff;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px; padding: 2px 9px;
}

header.topbar form { flex: 1 1 250px; display: flex; gap: 8px; max-width: 560px; }
header.topbar input[type="search"] {
  flex: 1; padding: 8px 12px; font: inherit; font-size: 0.92rem;
  background: #fbfcfe; color: #10151d;
  border: 1px solid transparent; border-radius: var(--radius);
}
header.topbar input[type="search"]::placeholder { color: #6b7480; }
header.topbar input[type="search"]:focus {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
header.topbar button {
  padding: 8px 16px; cursor: pointer; font: inherit; font-size: 0.9rem;
  font-weight: 700; background: var(--accent); color: #1a1206;
  border: 0; border-radius: var(--radius);
}
header.topbar button:hover { background: #f3c47a; }

header.topbar .topnav { display: flex; gap: 2px; align-items: center; flex-wrap: wrap; }
header.topbar .topnav a {
  padding: 6px 10px; border-radius: var(--radius);
  color: #e8eeff; font-size: 0.9rem; white-space: nowrap;
  border: 1px solid transparent;
}
header.topbar .topnav a:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.18);
  text-decoration: none;
}

/* ------------------------------------------------ live fetch status strip */

.fetch-strip {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 7px 18px; font-size: 0.84rem;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border-soft);
  min-height: 38px;
}
.fetch-strip.idle { color: var(--muted); }
.fetch-strip.busy { color: var(--fg); }

.fetch-item {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 2px 10px 2px 8px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 999px;
}
.fetch-item strong { font-weight: 600; }
.fetch-label { font-weight: 600; }

.fetch-dot {
  width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px;
  background: var(--muted);
}
.fetch-strip.busy .fetch-dot,
.activity-item.running .fetch-dot {
  background: var(--accent-2);
  animation: fetch-pulse 1.1s ease-in-out infinite;
}
@keyframes fetch-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}
.fetch-detail { color: var(--muted); font-size: 0.8rem; }
.fetch-more { color: var(--muted); font-size: 0.8rem; }
/* Collapsed image downloads: present but visually secondary. */
.fetch-item-muted { color: var(--muted); border-style: dashed; }

@media (prefers-reduced-motion: reduce) {
  .fetch-strip.busy .fetch-dot,
  .activity-item.running .fetch-dot { animation: none; opacity: 1; }
}

/* ------------------------------------------------------------------- layout */

main { max-width: 1180px; margin: 0 auto; padding: 24px 20px 80px; }

h1.page-title {
  font-size: 1.75rem; margin: 0 0 8px; color: var(--fg);
  border-bottom: 2px solid var(--accent); padding-bottom: 8px;
}

/* FGO-style full-width section bar */
h2.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 34px 0 12px; padding: 8px 14px 8px 16px;
  background: var(--navy-2); color: #fff;
  font-size: 0.82rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  /* inset stripe instead of border-left: with rounded left corners a left
     border reads as a detached gold tab, so the left side stays square. */
  box-shadow: inset 4px 0 0 var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
}
h2.section-head:first-child { margin-top: 0; }

.hero { margin-bottom: 6px; }
.hero-sub { color: var(--muted); font-size: 0.93rem; margin: 0 0 10px; max-width: 74ch; }
.hero-meta {
  display: flex; align-items: center; gap: 4px;
  margin: 0 0 18px; font-size: 0.85rem; color: var(--muted);
}

.notice {
  background: var(--panel); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 11px 14px; border-radius: var(--radius);
  font-size: 0.9rem; color: var(--muted); margin: 0 0 18px;
}

/* stat row */
.stat-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.stat {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 14px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg); border-top: 2px solid var(--accent-2);
}
.stat-label {
  font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); font-weight: 700;
}
.stat-value { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-note { font-size: 0.78rem; color: var(--muted); }

/* --------------------------------------------------------------- portal grid */

.portal-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 900px) {
  .portal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .portal-grid { grid-template-columns: 1fr; }
}
.portal-tile {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg); color: var(--fg);
}
.portal-tile:hover {
  text-decoration: none; border-color: var(--accent);
  box-shadow: var(--shadow-hover);
}
.portal-media {
  position: relative; display: flex; align-items: center; justify-content: center;
  height: 104px; overflow: hidden;
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.09), transparent 62%),
    linear-gradient(160deg, #2b3340, #171c24);
}
.portal-media img {
  /* Wiki icons are not square (File:Quest.png is 387x85), so cap both axes
     instead of forcing a fixed 60x60 box, which squashed wide art to a sliver. */
  max-width: 74%; max-height: 72%;
  width: auto; height: auto; object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
}
.portal-mark {
  width: 54px; height: 54px;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.45));
}
.portal-mark-ring { fill: none; stroke: var(--accent); stroke-width: 2; }
.portal-mark-line {
  fill: none; stroke: #9fc0ff; stroke-width: 1.6; stroke-linecap: round;
}
.portal-mark-dot { fill: var(--accent); }
/* Banner artwork is photographic: fill the tile instead of shrinking to an
   unreadable 60px thumbnail. A dark gradient keeps the teal label readable. */
.portal-media-banner img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  /* the base rule caps icons at 74%, which also capped banners */
  max-width: none; max-height: none;
  object-fit: cover; object-position: center 35%; filter: none;
}
.portal-media-banner::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(13, 17, 23, 0) 45%, rgba(13, 17, 23, 0.55));
}
/* Tall art (a character portrait): the tile is ~3.5:1, so a 0.74-ratio
   portrait is cut to a thin band. Anchor near the top but not at 0, or the
   crop shows only hair and one eye. */
.portal-media-banner.portal-media-top img { object-position: center 15%; }
.portal-body {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 9px 12px; background: var(--accent-2); color: #f2fbfa;
}
.portal-title {
  font-size: 0.84rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap;
}
.portal-meta {
  font-size: 0.73rem; color: rgba(255, 255, 255, 0.9);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ------------------------------------------------------------ highlight cards */

.highlight-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px; align-items: stretch;
}
.highlight-card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.highlight-media { display: block; background: var(--panel-2); }
.highlight-media img {
  display: block; width: 100%; aspect-ratio: 16 / 7; object-fit: cover;
}
.highlight-body { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px 15px; }
.eyebrow {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--accent-2);
}
.highlight-title { font-weight: 600; line-height: 1.3; color: var(--fg); }

/* ---------------------------------------------------------------- two column */

.two-col-layout {
  display: grid; grid-template-columns: 1.15fr 1fr; gap: 24px; align-items: start;
}
@media (max-width: 820px) {
  .two-col-layout { grid-template-columns: 1fr; }
}

/* -------------------------------------------------------------------- panels */

.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px;
  margin-bottom: 16px;
}
.panel-block + .panel-block { margin-top: 14px; }
.panel-label {
  display: block; font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 6px;
}
.panel-note { font-size: 0.87rem; color: var(--muted); margin: 0 0 10px; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; align-items: flex-start; }
.panel-actions form { flex: 0 1 auto; margin: 0; }
/* Let the label decide the width inside a panel instead of forcing 240px. */
.panel-actions .action-button { min-width: 0; width: auto; }
.panel.danger { border-color: rgba(212, 84, 74, 0.5); }

.pill {
  display: inline-block; font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px; margin-right: 6px;
  border: 1px solid var(--border);
}
.pill.ok {
  background: rgba(55, 163, 160, 0.18); color: var(--accent-2);
  border-color: var(--accent-2);
}
.pill.warn {
  background: rgba(232, 178, 90, 0.16); color: var(--accent);
  border-color: var(--accent);
}

/* ------------------------------------------------------------------- buttons */

.action-button {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 240px; padding: 11px 18px; cursor: pointer;
  background: var(--panel-2); color: var(--fg);
  border: 1px solid var(--accent); border-radius: var(--radius);
  font: inherit; font-size: 0.9rem; font-weight: 700;
}
.action-button:hover:not(:disabled) {
  background: var(--accent); color: #1a1206; box-shadow: var(--shadow-soft);
}
.action-button-primary { background: var(--accent); color: #1a1206; }
.action-button-primary:hover:not(:disabled) { background: #f3c47a; }
.action-button:disabled { cursor: wait; opacity: 0.55; }

.chip-button {
  padding: 4px 11px; cursor: pointer; font: inherit; font-size: 0.8rem;
  font-weight: 600; color: var(--fg);
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.chip-button:hover { border-color: var(--accent); color: var(--accent); }
.chip-button.danger { border-color: rgba(212, 84, 74, 0.6); color: var(--danger); }
.chip-button.danger:hover { background: var(--danger); color: #fff; }

/* ------------------------------------------------------------- activity lists */

.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-item {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  padding: 6px 0; font-size: 0.85rem;
  border-bottom: 1px solid var(--border-soft);
}
.activity-item:last-child { border-bottom: 0; }
.activity-item.running { color: var(--fg); }
.activity-item.failed { color: var(--danger); }
.activity-label { font-weight: 600; }
.activity-detail {
  color: var(--muted); font-size: 0.8rem; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.activity-time {
  color: var(--muted); font-size: 0.75rem; font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- data table */

.data-table {
  width: 100%; border-collapse: collapse; font-size: 0.87rem; margin-bottom: 10px;
}
.data-table th, .data-table td {
  border-bottom: 1px solid var(--border-soft);
  padding: 9px 10px; text-align: left; vertical-align: middle;
}
.data-table th {
  font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); border-bottom: 1px solid var(--border);
}
.data-table td.num { font-variant-numeric: tabular-nums; font-weight: 700; }
.data-table td.note { color: var(--muted); font-size: 0.8rem; }
.data-table tr:hover td { background: var(--bg-soft); }

/* ---- wiki content ---- */
.mw-parser-output { overflow-x: auto; }
.mw-parser-output table {
  border-collapse: collapse; margin: 14px 0; max-width: 100%;
  font-size: 0.93rem;
}
.mw-parser-output th, .mw-parser-output td {
  border: 1px solid var(--border); padding: 6px 9px; vertical-align: top;
}
.mw-parser-output th { background: var(--panel-2); text-align: left; }
.mw-parser-output img { max-width: 100%; height: auto; }
.mw-parser-output .infobox, .mw-parser-output .wikitable { background: var(--panel); }
.mw-parser-output .infobox { float: right; margin: 0 0 16px 20px; }
.mw-parser-output h2, .mw-parser-output h3 {
  border-bottom: 1px solid var(--border); padding-bottom: 4px; margin-top: 30px;
}
.mw-parser-output ul { padding-left: 26px; }
.mw-parser-output .mw-collapsed { display: none; }
.mw-parser-output .navbox, .mw-parser-output .toc { font-size: 0.9rem; }
.mw-parser-output .gallery {
  display: flex; flex-wrap: wrap; gap: 12px; list-style: none; padding: 0;
}
.mw-parser-output li.gallerybox { margin: 0; }

/* Tabber: real Fandom markup is .wds-tabs__tab + .wds-tab__content.
   CSS hides inactive panels so the page is readable even with JS disabled. */
.wds-tabs__wrapper, .wds-tabs {
  display: flex; flex-wrap: wrap; gap: 4px;
  list-style: none; padding: 0; margin: 6px 0 0;
}
.wds-tabs__tab {
  display: inline-block; padding: 6px 12px;
  border: 1px solid var(--border); border-bottom: 0;
  border-radius: 6px 6px 0 0; background: var(--panel-2);
  font-size: 0.9rem;
}
.wds-tabs__tab.wds-is-current {
  background: var(--accent); color: #1a1206; font-weight: 600;
}
.wds-tabs__tab-label { display: block; }
.wds-tab__content { display: none; }
.wds-tab__content.wds-is-current {
  display: block; border-top: 1px solid var(--border); padding-top: 10px;
}
.pi-image-collection.wds-tabber { display: block; }

/* ---- search + index ---- */
ul.results { list-style: none; padding: 0; margin: 0; }
ul.results li {
  padding: 9px 13px; margin-bottom: 6px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius);
}
/* Recently opened: one panel with divided rows reads as an index, instead of
   a stack of separate boxes. Needs ul.results specificity to win. */
ul.results.recent-list {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 3px 0; margin: 0;
}
ul.results.recent-list li {
  display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
  padding: 8px 14px; margin: 0;
  border: 0; border-bottom: 1px solid var(--border-soft);
  border-radius: 0; background: transparent;
  font-size: 0.88rem; line-height: 1.45;
}
ul.results.recent-list li:last-child { border-bottom: 0; }
ul.results.recent-list li:hover { background: var(--bg-soft); }
ul.results.recent-list li a { font-weight: 500; }
/* Wide single-column rows: the timestamp anchors the right edge. */
.recent-when {
  color: var(--muted); font-size: 0.78rem; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
ul.results.two-col {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 6px;
}
.recent-list li a { font-weight: 500; }
.grid-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px;
}
.grid-cards a {
  display: block; padding: 10px 13px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ---- category navigation ---- */
.cat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px; margin-bottom: 8px;
}
.cat-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px 16px; position: relative;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg); color: var(--fg);
}
.cat-card:hover { border-color: var(--accent); text-decoration: none; }
.cat-title { font-weight: 700; color: var(--accent); }
.cat-meta { font-size: 0.82rem; color: var(--muted); line-height: 1.4; }
.cat-count {
  position: absolute; top: 10px; right: 12px;
  font-size: 0.78rem; color: var(--muted);
  background: var(--panel-2); border-radius: 10px; padding: 1px 8px;
}
.count-pill {
  font-size: 0.75rem; font-weight: 400; color: var(--muted);
  background: var(--panel-2); border-radius: 10px; padding: 1px 8px;
  vertical-align: middle;
}

/* ---- servant grids ---- */
.servant-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
}
.servant-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px; text-align: center;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg); color: var(--fg); font-size: 0.82rem;
}
.servant-card:hover { border-color: var(--accent); text-decoration: none; }
.servant-card img {
  width: 100%; aspect-ratio: 1 / 1; object-fit: cover;
  border-radius: var(--radius); background: var(--panel-2);
}
.thumb-blank {
  width: 100%; aspect-ratio: 1 / 1; border-radius: var(--radius);
  background: var(--panel-2);
}
.servant-name { line-height: 1.25; }
.servant-rarity { color: var(--accent); font-size: 0.75rem; }
.servant-meta {
  display: flex; align-items: center; gap: 6px;
  color: var(--accent); font-size: 0.75rem;
}
.servant-id { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Non-playable pages: visually secondary so they never read as obtainable. */
.npc-badge {
  display: inline-block; font-size: 0.62rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 1px 5px; border-radius: 3px;
  color: var(--muted); border: 1px solid var(--border);
  background: var(--panel-2);
}
.servant-card-npc { opacity: 0.72; }
.servant-card-npc:hover { opacity: 1; }

/* ---- servant browse modes ---- */
.mode-switch {
  display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px;
}
.mode {
  padding: 6px 14px; border-radius: 999px; font-size: 0.84rem; font-weight: 600;
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
}
.mode:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.mode-active {
  background: var(--accent); border-color: var(--accent); color: #1a1206;
}
.mode-active:hover { color: #1a1206; }

.head-note {
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.85);
}
.letter-jump {
  display: flex; flex-wrap: wrap; gap: 5px; margin: 0 0 18px;
}
.letter-jump .chip {
  padding: 3px 9px; font-weight: 700; color: var(--link);
}

/* ---- event + campaign cards ---- */
.event-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.event-card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.event-card .banner {
  display: block; width: 100%; aspect-ratio: 16 / 7;
  object-fit: cover; background: var(--panel-2);
}
.banner-blank {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 0.8rem;
}
.event-body { display: flex; flex-direction: column; gap: 5px; padding: 10px 12px 13px; }
.event-title { font-weight: 600; line-height: 1.3; color: var(--fg); }
.dates { font-size: 0.78rem; color: var(--muted); }

.badge {
  align-self: flex-start;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em;
  padding: 2px 7px; border-radius: 3px; text-transform: uppercase;
}
.badge.live { background: #1f7a4d; color: #eafff2; }
.badge.upcoming { background: #2f5fa8; color: #eef4ff; }
.badge.ended { background: var(--panel-2); color: var(--muted); }
.badge.unknown { background: var(--panel-2); color: var(--muted); }
.kind-badge {
  align-self: flex-start; font-size: 0.68rem;
  padding: 2px 7px; border-radius: 3px;
  border: 1px solid var(--border); color: var(--muted);
}

.chars { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 0.78rem; }
.chars-label { color: var(--muted); }
.chars.muted { color: var(--muted); font-style: italic; }
.chip {
  padding: 1px 8px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--border);
  font-size: 0.76rem; color: var(--link);
}

footer.attribution {
  margin-top: 44px; padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.82rem; color: var(--muted);
}

/* ---- wiki icons / logos ---- */
.cat-icon {
  width: 44px; height: 44px; object-fit: contain;
  margin-bottom: 6px; border-radius: var(--radius);
}
.class-icon { width: 40px; height: 40px; object-fit: contain; margin-bottom: 6px; }
.class-card { align-items: flex-start; }

/* ---- quest cards (banners from {{Questheader}} image) ---- */
.quest-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px; margin-bottom: 10px;
}
.quest-card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg); color: var(--fg); font-size: 0.84rem;
}
.quest-card:hover { border-color: var(--accent); text-decoration: none; }
.quest-banner {
  display: block; width: 100%; aspect-ratio: 16 / 7;
  object-fit: cover; background: var(--panel-2);
}
.quest-blank {
  background: repeating-linear-gradient(
    45deg, var(--panel-2), var(--panel-2) 8px, var(--panel) 8px, var(--panel) 16px);
}
.quest-name { padding: 8px 10px; line-height: 1.3; }
.quest-date {
  padding: 0 10px 9px; font-size: 0.72rem; color: var(--muted); margin-top: -4px;
}

/* ---- guide page ---- */
.callout {
  background: var(--panel-2); border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  padding: 12px 15px; border-radius: var(--radius); margin: 0 0 18px;
  font-size: 0.92rem;
}
.guide-toc { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }

.guide-quest {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 18px; margin-bottom: 18px;
}
.guide-quest h2 {
  margin-top: 0; border-bottom: 1px solid var(--border); padding-bottom: 6px;
}
.guide-prereq {
  margin: 10px 0 12px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
}

.guide-stats { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin-bottom: 12px; }
.guide-stats th, .guide-stats td {
  border: 1px solid var(--border); padding: 6px 9px; text-align: left;
}
.guide-stats th { background: var(--panel-2); }
.guide-stats td:first-child { font-weight: 600; }

.guide-rewards { margin-top: 12px; font-size: 0.88rem; }
.guide-rewards ul { margin: 6px 0 0; padding-left: 22px; }

details {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 12px; margin: 10px 0; background: var(--panel-2);
}
details summary { cursor: pointer; font-weight: 600; font-size: 0.88rem; }
details[open] summary { margin-bottom: 8px; }
.notes { font-size: 0.84rem; color: var(--muted); line-height: 1.6; margin: 0; }

/* Fight notes: keep the wiki's list structure, cap the height, show buff icons */
.notes-body { max-height: 480px; overflow: auto; font-size: 0.86rem; line-height: 1.7; }
.notes-body ul { padding-left: 20px; margin: 4px 0; }
.notes-body li { margin: 4px 0; }
.notes-body b, .notes-body strong { color: var(--accent); }
.notes-body a { color: var(--link); }
.buff-icon {
  display: inline-block; width: 20px; height: 20px; vertical-align: -4px;
  margin: 0 2px; border-radius: 3px; object-fit: contain;
  background: var(--panel);
}

.arrow { margin-bottom: 8px; }
.arrow-head { font-size: 0.78rem; color: var(--accent); font-weight: 700; }
.arrow ul { margin: 4px 0 0; padding-left: 20px; font-size: 0.82rem; }

/* ---- motion & depth (Open Props tokens) ---- */
.portal-tile, .cat-card, .quest-card, .servant-card, .event-card, .highlight-card,
.grid-cards a, ul.results li, header.topbar .topnav a, header.topbar button,
.action-button, .chip-button {
  transition:
    border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease),
    transform 0.18s var(--ease),
    background-color 0.18s var(--ease);
}
.cat-card:hover, .quest-card:hover, .servant-card:hover, .event-card:hover,
.grid-cards a:hover, ul.results li:hover, .highlight-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-hover);
}
.portal-tile:hover { transform: translateY(-2px); }

@media (prefers-reduced-motion: reduce) {
  .portal-tile, .cat-card, .quest-card, .servant-card, .event-card, .highlight-card,
  .grid-cards a, ul.results li, header.topbar .topnav a, header.topbar button,
  .action-button, .chip-button { transition: none; }
  .portal-tile:hover, .cat-card:hover, .quest-card:hover,
  .servant-card:hover { transform: none; }
}

/* ---- responsive ---- */
@media (max-width: 720px) {
  header.topbar { gap: 8px; padding: 8px 12px; }
  header.topbar .topnav { overflow-x: auto; width: 100%; flex-wrap: nowrap; }
  header.topbar form { max-width: none; flex-basis: 100%; }
  main { padding: 18px 14px 60px; }
  h1.page-title { font-size: 1.4rem; }
  .action-button { min-width: 100%; }
  .portal-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
