/* ==========================================================================
   Rani Lakshmi Amreen — Wikipedia Vector 2022 Stylesheet
   Supports Light (Standard), Night (Dark), and Archival (Sepia) themes,
   responsive 3-column layout, interactive previews, and clean print output.
   ========================================================================== */

:root,
[data-theme="light"] {
  --bg-page: #ffffff;
  --bg-surface: #f8f9fa;
  --bg-elevated: #ffffff;
  --bg-subtle: #eaecf0;
  --bg-hover: #eef2f6;
  --bg-highlight: #fff6c5;

  --text-primary: #202122;
  --text-secondary: #3b3e42;
  --text-muted: #54595d;

  --link-color: #3366cc;
  --link-hover: #224b9c;
  --link-visited: #6b4ba1;

  --border-strong: #a2a9b1;
  --border-subtle: #c8ccd1;
  --border-faint: #eaecf0;

  --infobox-head: #dce7f4;
  --infobox-sub: #eaf1f9;
  --infobox-text: #1c2530;

  --shadow-card: 0 8px 24px rgba(16, 20, 24, 0.14);
  --shadow-sm: 0 2px 6px rgba(16, 20, 24, 0.08);

  --map-bg: #f9f7f2;
  --map-grid: #e3ded2;
  --map-water: #b9d7ea;
  --map-water-edge: #4e88ad;
  --map-fort-fill: #e7dfd0;
  --map-fort-stroke: #3f382e;
  --map-enemy: #b32424;
  --map-accent: #1d6b47;
  --map-escape: #3366cc;
}

[data-theme="dark"] {
  --bg-page: #101418;
  --bg-surface: #181e24;
  --bg-elevated: #1e252d;
  --bg-subtle: #252d36;
  --bg-hover: #2c3641;
  --bg-highlight: #473c18;

  --text-primary: #eaecf0;
  --text-secondary: #d3d7dd;
  --text-muted: #9aa2ad;

  --link-color: #79a7ff;
  --link-hover: #a5c4ff;
  --link-visited: #b59cf0;

  --border-strong: #4e5864;
  --border-subtle: #37404a;
  --border-faint: #262e37;

  --infobox-head: #243447;
  --infobox-sub: #1c2836;
  --infobox-text: #e7eef7;

  --shadow-card: 0 12px 32px rgba(0, 0, 0, 0.55);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);

  --map-bg: #171d23;
  --map-grid: #27313b;
  --map-water: #22465c;
  --map-water-edge: #6bb2dc;
  --map-fort-fill: #282c26;
  --map-fort-stroke: #c7bfb0;
  --map-enemy: #e66a6a;
  --map-accent: #52c58c;
  --map-escape: #79a7ff;
}

[data-theme="sepia"] {
  --bg-page: #f6f0e2;
  --bg-surface: #ede4d0;
  --bg-elevated: #faf5ea;
  --bg-subtle: #e3d7be;
  --bg-hover: #ded1b5;
  --bg-highlight: #f2d98d;

  --text-primary: #2a2118;
  --text-secondary: #3f3224;
  --text-muted: #655543;

  --link-color: #204e8a;
  --link-hover: #143663;
  --link-visited: #5e3b7a;

  --border-strong: #9e8c72;
  --border-subtle: #bfb097;
  --border-faint: #dfd3bc;

  --infobox-head: #dfd1b6;
  --infobox-sub: #e9dec7;
  --infobox-text: #2a2118;

  --shadow-card: 0 10px 28px rgba(42, 33, 24, 0.18);
  --shadow-sm: 0 2px 6px rgba(42, 33, 24, 0.1);

  --map-bg: #f1e9d6;
  --map-grid: #ddd1b8;
  --map-water: #a8c7d4;
  --map-water-edge: #3e6f87;
  --map-fort-fill: #e3d6bc;
  --map-fort-stroke: #3c2f21;
  --map-enemy: #9b2626;
  --map-accent: #1d6442;
  --map-escape: #204e8a;
}

/* Font scale tokens */
[data-font-size="small"] {
  --article-font-size: 0.875rem;
  --article-line-height: 1.58;
}
[data-font-size="standard"] {
  --article-font-size: 0.96875rem;
  --article-line-height: 1.64;
}
[data-font-size="large"] {
  --article-font-size: 1.09375rem;
  --article-line-height: 1.68;
}

/* Page width tokens */
[data-width="standard"] {
  --shell-max-width: 1460px;
  --main-max-width: 960px;
}
[data-width="wide"] {
  --shell-max-width: 1740px;
  --main-max-width: 1240px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 74px;
}

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

body {
  margin: 0;
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--link-color);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  color: var(--link-hover);
}

button {
  font: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--link-color);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--link-color);
  color: #ffffff;
  padding: 0.5rem 0.875rem;
  z-index: 2000;
  border-radius: 0 0 4px 0;
  font-weight: 600;
}

.skip-link:focus {
  left: 0;
}

/* --------------------------------------------------------------------------
   Top Vector Header
   -------------------------------------------------------------------------- */
.mw-header {
  position: sticky;
  top: 0;
  z-index: 900;
  background: var(--bg-page);
  border-bottom: 1px solid var(--border-faint);
}

.mw-header-inner {
  max-width: var(--shell-max-width);
  margin: 0 auto;
  padding: 0.5rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
}

.mw-header-start {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.mw-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 0.42rem 0.55rem;
  cursor: pointer;
  color: var(--text-primary);
}

.mw-icon-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-subtle);
}

#mobile-menu-btn {
  display: none;
}

.mw-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text-primary);
  text-decoration: none;
}

.mw-logo:hover {
  text-decoration: none;
  color: var(--text-primary);
}

.mw-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.08;
}

.mw-logo-wordmark {
  font-family: "Source Serif 4", "Linux Libertine", Georgia, "Times New Roman", serif;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.mw-logo-tagline {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Search Box */
.mw-search-wrap {
  position: relative;
  flex: 1;
  max-width: 500px;
}

.mw-search-box {
  display: flex;
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.mw-search-box:focus-within {
  border-color: var(--link-color);
  box-shadow: inset 0 0 0 1px var(--link-color);
}

.mw-search-icon {
  margin-left: 0.65rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

#wiki-search-input {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  padding: 0.44rem 0.55rem;
  font-size: 0.875rem;
  outline: none;
}

#wiki-search-input::placeholder {
  color: var(--text-muted);
}

.mw-search-clear {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 0.45rem;
  font-size: 1.1rem;
  line-height: 1;
}

.mw-search-submit {
  border: 0;
  border-left: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  padding: 0.44rem 0.85rem;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.mw-search-submit:hover {
  background: var(--bg-hover);
}

.mw-search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  box-shadow: var(--shadow-card);
  max-height: 360px;
  overflow-y: auto;
  z-index: 950;
}

.mw-search-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--border-faint);
  background: transparent;
  padding: 0.6rem 0.8rem;
  cursor: pointer;
}

.mw-search-item:last-child {
  border-bottom: 0;
}

.mw-search-item:hover {
  background: var(--bg-hover);
}

.mw-search-item-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--link-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.mw-search-item-kind {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 0.1rem 0.4rem;
  border-radius: 2px;
}

.mw-search-item-snippet {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.mw-header-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.mw-action-link {
  border: 1px solid transparent;
  background: transparent;
  color: var(--link-color);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.38rem 0.6rem;
  border-radius: 2px;
  cursor: pointer;
}

.mw-action-link:hover {
  background: var(--bg-hover);
  text-decoration: underline;
}

.mw-appearance-toggle {
  font-size: 0.84rem;
  font-weight: 500;
}

/* Popover */
.mw-popover {
  position: fixed;
  top: 58px;
  right: 20px;
  width: 260px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  box-shadow: var(--shadow-card);
  padding: 0.85rem;
  z-index: 980;
}

.mw-popover-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--border-faint);
}

.mw-popover-close {
  background: transparent;
  border: 0;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   3-Column Shell Layout
   -------------------------------------------------------------------------- */
.mw-page-shell {
  max-width: var(--shell-max-width);
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3rem;
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr) 216px;
  gap: 1.75rem;
  align-items: start;
}

/* Left TOC Rail */
.mw-toc-rail {
  font-size: 0.825rem;
}

.mw-toc-sticky {
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  padding-right: 0.5rem;
}

.mw-toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.35rem;
  margin-bottom: 0.55rem;
}

.mw-toc-title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
}

.mw-toc-toggle {
  border: 0;
  background: transparent;
  color: var(--link-color);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0;
}

.mw-toc-list ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mw-toc-list ul ul {
  padding-left: 0.9rem;
}

.toc-link {
  display: block;
  padding: 0.25rem 0.45rem;
  border-left: 2px solid transparent;
  color: var(--link-color);
  line-height: 1.32;
  border-radius: 0 2px 2px 0;
}

.toc-link:hover {
  background: var(--bg-hover);
  text-decoration: none;
}

.toc-link.is-active {
  color: var(--text-primary);
  font-weight: 700;
  border-left-color: var(--link-color);
  background: var(--bg-surface);
}

.toc-num {
  color: var(--text-muted);
  margin-right: 0.25rem;
  font-size: 0.78em;
}

.mw-toc-list.is-collapsed {
  display: none;
}

/* Main Column */
.mw-main-column {
  min-width: 0;
  max-width: var(--main-max-width);
}

.mw-title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border-strong);
  padding-bottom: 0.35rem;
}

.mw-title-group {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.mw-first-heading {
  margin: 0;
  font-family: "Source Serif 4", "Linux Libertine", Georgia, "Times New Roman", serif;
  font-size: clamp(1.65rem, 2.5vw, 2.05rem);
  font-weight: 400;
  line-height: 1.22;
  color: var(--text-primary);
}

.mw-fa-star {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

/* Language Switcher */
.mw-lang-wrap {
  position: relative;
  flex-shrink: 0;
}

.mw-lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--link-color);
  font-size: 0.84rem;
  font-weight: 600;
  padding: 0.35rem 0.6rem;
  border-radius: 2px;
  cursor: pointer;
}

.mw-lang-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-subtle);
}

.mw-lang-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 220px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  box-shadow: var(--shadow-card);
  z-index: 800;
  padding: 0.35rem 0;
}

.mw-lang-option {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-primary);
}

.mw-lang-option:hover {
  background: var(--bg-hover);
}

.mw-lang-option.is-active {
  font-weight: 700;
  color: var(--link-color);
  background: var(--bg-surface);
}

.mw-lang-banner {
  margin: 0.85rem 0 1rem;
  padding: 0.9rem 1.05rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--link-color);
  border-radius: 2px;
  font-size: 0.93rem;
}

.mw-lang-banner-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.35rem;
}

.mw-lang-reset {
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--link-color);
  font-size: 0.78rem;
  padding: 0.2rem 0.55rem;
  border-radius: 2px;
  cursor: pointer;
}

/* Tabs Bar */
.mw-tabs-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  margin-top: 0.15rem;
  position: relative;
}

.mw-tabs-left,
.mw-tabs-right {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.mw-tab {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--link-color);
  font-size: 0.82rem;
  padding: 0.55rem 0.65rem 0.45rem;
  cursor: pointer;
}

.mw-tab:hover {
  border-bottom-color: var(--border-strong);
}

.mw-tab.is-active {
  color: var(--text-primary);
  font-weight: 600;
  border-bottom-color: var(--text-primary);
}

.mw-tools-popover {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 4px;
  min-width: 210px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  box-shadow: var(--shadow-card);
  z-index: 750;
  padding: 0.3rem 0;
}

.mw-tool-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0.48rem 0.85rem;
  font-size: 0.84rem;
  cursor: pointer;
  color: var(--text-primary);
}

.mw-tool-item:hover {
  background: var(--bg-hover);
  color: var(--link-color);
}

.mw-site-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0.55rem 0 0.7rem;
}

.mw-hatnote {
  font-style: italic;
  font-size: 0.89rem;
  color: var(--text-secondary);
  padding-left: 1.4rem;
  margin-bottom: 1rem;
}

/* Inline Mobile TOC */
.mw-inline-toc {
  display: none;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.15rem;
  font-size: 0.86rem;
}

.mw-inline-toc-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.mw-inline-toc-head button {
  border: 0;
  background: transparent;
  color: var(--link-color);
  font-size: 0.8rem;
  cursor: pointer;
}

.mw-inline-toc-body.is-collapsed {
  display: none;
}

.mw-inline-toc-body ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mw-inline-toc-body ul ul {
  padding-left: 1rem;
}

/* --------------------------------------------------------------------------
   Article Typography & Content
   -------------------------------------------------------------------------- */
.mw-tab-panel {
  font-size: var(--article-font-size);
  line-height: var(--article-line-height);
}

.mw-tab-panel p {
  margin: 0 0 0.9rem;
  max-width: 74ch;
}

.mw-section {
  margin-top: 1.65rem;
}

.mw-section h2 {
  font-family: "Source Serif 4", "Linux Libertine", Georgia, "Times New Roman", serif;
  font-size: 1.48rem;
  font-weight: 400;
  line-height: 1.28;
  margin: 1.5rem 0 0.7rem;
  padding-bottom: 0.22rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.mw-section h3 {
  font-size: 1.08rem;
  font-weight: 700;
  margin: 1.15rem 0 0.45rem;
  color: var(--text-primary);
}

.mw-section ul {
  margin: 0 0 0.95rem 1.35rem;
  padding: 0;
  max-width: 70ch;
}

.mw-section li {
  margin-bottom: 0.45rem;
}

.ipa {
  font-family: "Segoe UI", "Inter", Arial, sans-serif;
  color: var(--text-secondary);
}

.mw-quote {
  margin: 1.1rem 0 1.25rem;
  padding: 0.75rem 1.15rem;
  background: var(--bg-surface);
  border-left: 3px solid var(--border-strong);
  max-width: 68ch;
}

.mw-quote p {
  font-family: "Source Serif 4", Georgia, serif;
  font-style: italic;
  margin-bottom: 0.4rem;
  color: var(--text-primary);
}

.mw-quote footer {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.search-flash {
  background: var(--bg-highlight);
  border-radius: 2px;
  transition: background-color 0.5s ease;
}

/* --------------------------------------------------------------------------
   Wikipedia Infobox
   -------------------------------------------------------------------------- */
.infobox {
  float: right;
  clear: right;
  width: 312px;
  margin: 0 0 1.15rem 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  padding: 0.45rem;
  font-size: 0.83rem;
  line-height: 1.42;
}

.infobox-above {
  background: var(--infobox-head);
  color: var(--infobox-text);
  font-weight: 700;
  font-size: 1.02rem;
  text-align: center;
  padding: 0.4rem 0.5rem;
}

.infobox-subheader {
  background: var(--infobox-sub);
  color: var(--infobox-text);
  font-weight: 600;
  font-size: 0.82rem;
  text-align: center;
  padding: 0.25rem 0.5rem;
  margin-top: 2px;
}

.infobox-image {
  margin: 0.5rem 0 0.4rem;
  text-align: center;
}

.infobox-img-frame {
  position: relative;
  border: 1px solid var(--border-subtle);
  background: #1b1713;
  overflow: hidden;
}

.infobox-img-frame img {
  display: block;
  width: 100%;
  height: auto;
  cursor: zoom-in;
}

.infobox-enlarge-btn {
  position: absolute;
  right: 6px;
  bottom: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 2px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.92);
  color: #202122;
  cursor: pointer;
}

.infobox-enlarge-btn:hover {
  background: #ffffff;
  color: #3366cc;
}

.infobox-caption {
  font-size: 0.77rem;
  color: var(--text-secondary);
  margin-top: 0.4rem;
  text-align: left;
  line-height: 1.38;
}

.infobox-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.35rem;
}

.infobox-table th,
.infobox-table td {
  padding: 0.32rem 0.4rem;
  vertical-align: top;
  text-align: left;
  border-top: 1px solid var(--border-faint);
}

.infobox-table th[scope="row"] {
  width: 36%;
  font-weight: 600;
  color: var(--text-primary);
}

.infobox-section-hd {
  background: var(--infobox-head);
  color: var(--infobox-text) !important;
  text-align: center !important;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0.3rem 0.4rem !important;
  border-top: 2px solid var(--bg-surface) !important;
}

.infobox-note {
  color: var(--text-muted);
  font-size: 0.77rem;
}

.infobox-list {
  margin: 0.2rem 0 0 1rem;
  padding: 0;
}

.infobox-list li {
  margin-bottom: 0.15rem;
}

.infobox-seal-cell {
  text-align: center !important;
  padding: 0.5rem !important;
}

.royal-seal-svg {
  color: var(--text-primary);
  display: block;
  margin: 0 auto 0.3rem;
}

/* --------------------------------------------------------------------------
   Tables & Tactical Map Thumb
   -------------------------------------------------------------------------- */
.wikitable {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.25rem;
  background: var(--bg-surface);
  font-size: 0.87rem;
  line-height: 1.45;
}

.wikitable caption {
  text-align: left;
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.wikitable th,
.wikitable td {
  border: 1px solid var(--border-strong);
  padding: 0.48rem 0.62rem;
  text-align: left;
  vertical-align: top;
}

.wikitable thead th {
  background: var(--bg-subtle);
  font-weight: 700;
}

.wikitable tbody th[scope="row"] {
  background: var(--bg-elevated);
  font-weight: 600;
}

.mw-thumb-wide {
  margin: 1.15rem 0 1.35rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  padding: 0.55rem;
}

.mw-map-box {
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.mw-siege-svg {
  display: block;
  width: 100%;
  height: auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.map-river-label {
  font-size: 11px;
  fill: var(--map-water-edge);
  font-style: italic;
  font-weight: 600;
}

.map-fort-title {
  font-size: 15px;
  font-weight: 700;
  fill: var(--map-fort-stroke);
  letter-spacing: 0.04em;
}

.map-fort-sub {
  font-size: 11px;
  fill: var(--map-fort-stroke);
}

.map-callout {
  font-size: 12px;
  font-weight: 700;
  fill: var(--map-accent);
}

.map-callout-sub {
  font-size: 11px;
  fill: var(--text-secondary);
}

.map-breach-label {
  font-size: 11px;
  font-weight: 700;
  fill: var(--map-enemy);
}

.map-enemy-label {
  font-size: 11.5px;
  font-weight: 600;
  fill: var(--map-enemy);
}

.map-sortie-label {
  font-size: 11.5px;
  font-weight: 700;
  fill: var(--map-accent);
}

.map-note-label {
  font-size: 11px;
  font-weight: 600;
  fill: var(--map-escape);
}

.mw-thumb-caption {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 0.45rem;
  line-height: 1.4;
}

/* Filter Pills (Timeline & References) */
.timeline-toolbar,
.ref-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0.65rem 0 0.85rem;
}

.toolbar-label {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-right: 0.2rem;
}

.filter-pill {
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.79rem;
  padding: 0.25rem 0.62rem;
  border-radius: 2px;
  cursor: pointer;
}

.filter-pill:hover {
  background: var(--bg-hover);
}

.filter-pill.is-active {
  background: var(--link-color);
  border-color: var(--link-color);
  color: #ffffff;
  font-weight: 600;
}

/* See Also */
.mw-see-also-grid {
  columns: 2;
  column-gap: 2rem;
  max-width: none !important;
}

/* References */
.mw-refs-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  margin: 1.5rem 0 0.85rem;
}

.mw-refs-header h2 {
  border-bottom: 0;
  margin: 0;
}

.reference {
  font-size: 0.76em;
  line-height: 1;
}

.mw-references-list {
  padding-left: 1.75rem;
  font-size: 0.84rem;
  line-height: 1.5;
  column-count: 2;
  column-gap: 2.25rem;
}

.mw-references-list li {
  break-inside: avoid;
  margin-bottom: 0.55rem;
  padding: 0.25rem 0.35rem;
  border-radius: 2px;
}

.mw-references-list li.is-highlighted {
  background: var(--bg-highlight);
}

.cite-backlinks {
  margin-right: 0.25rem;
  font-weight: 600;
}

.cite-archive-id {
  font-family: "JetBrains Mono", ui-monospace, Consolas, monospace;
  font-size: 0.78em;
  color: var(--text-muted);
}

.cite-copy-btn {
  border: 0;
  background: transparent;
  color: var(--link-color);
  font-size: 0.78em;
  cursor: pointer;
  padding: 0 0.25rem;
  text-decoration: underline;
}

/* Navbox & Categories */
.mw-navbox {
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  margin: 1rem 0 1.1rem;
  font-size: 0.83rem;
}

.mw-navbox-title {
  background: var(--infobox-head);
  color: var(--infobox-text);
  padding: 0.4rem 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mw-navbox-title button {
  border: 0;
  background: transparent;
  color: var(--link-color);
  font-size: 0.8rem;
  cursor: pointer;
}

.mw-navbox-table {
  width: 100%;
  border-collapse: collapse;
}

.mw-navbox-table.is-collapsed {
  display: none;
}

.mw-navbox-table th,
.mw-navbox-table td {
  border-top: 1px solid var(--border-subtle);
  padding: 0.42rem 0.65rem;
  vertical-align: top;
}

.mw-navbox-table th {
  width: 24%;
  background: var(--infobox-sub);
  color: var(--infobox-text);
  text-align: right;
  font-weight: 600;
}

.mw-catlinks {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  padding: 0.55rem 0.75rem;
  font-size: 0.83rem;
}

.mw-cat-list {
  display: flex;
  flex-wrap: wrap;
  list-style: none;
  margin: 0 !important;
  padding: 0 !important;
  gap: 0.4rem;
  max-width: none !important;
}

.mw-cat-list li {
  margin: 0 !important;
}

.cat-chip {
  border: 0;
  border-left: 1px solid var(--border-strong);
  background: transparent;
  color: var(--link-color);
  padding: 0 0 0 0.45rem;
  cursor: pointer;
}

.cat-chip:hover {
  text-decoration: underline;
}

/* Talk, View Source, View History */
.mw-talk-banner,
.mw-source-header {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  padding: 0.85rem 1rem;
  margin: 1rem 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.mw-source-sub {
  margin: 0.25rem 0 0 !important;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.mw-primary-btn {
  border: 1px solid var(--link-color);
  background: var(--link-color);
  color: #ffffff;
  padding: 0.42rem 0.85rem;
  font-size: 0.84rem;
  font-weight: 600;
  border-radius: 2px;
  cursor: pointer;
}

.mw-primary-btn:hover {
  background: var(--link-hover);
}

.mw-talk-thread {
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  padding: 0.9rem 1.05rem;
  margin-bottom: 0.85rem;
}

.mw-talk-thread h3 {
  margin: 0 0 0.35rem;
  font-size: 1.02rem;
  border-bottom: 1px solid var(--border-faint);
  padding-bottom: 0.25rem;
}

.mw-talk-sig {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.45rem;
}

.mw-wikitext-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  padding: 1rem;
  font-family: "JetBrains Mono", ui-monospace, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.mw-history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border-subtle);
}

.mw-history-row {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border-faint);
  font-size: 0.85rem;
}

.mw-history-row:last-child {
  border-bottom: 0;
}

.mw-history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 0.2rem;
}

.mw-history-delta {
  color: #147a44;
  font-weight: 600;
}

[data-theme="dark"] .mw-history-delta {
  color: #5cd090;
}

/* Right Appearance Rail */
.mw-appearance-rail {
  font-size: 0.825rem;
}

.mw-rail-sticky {
  position: sticky;
  top: 72px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.mw-rail-card {
  border: 1px solid var(--border-faint);
  background: var(--bg-surface);
  padding: 0.75rem 0.85rem;
  border-radius: 2px;
}

.mw-rail-heading {
  font-weight: 700;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0.6rem;
}

.appearance-group {
  margin-bottom: 0.75rem;
}

.appearance-group:last-child {
  margin-bottom: 0;
}

.appearance-group-label {
  display: block;
  font-size: 0.77rem;
  color: var(--text-muted);
  margin-bottom: 0.32rem;
  font-weight: 600;
}

.appearance-radio-list {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.appearance-option {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  font-size: 0.83rem;
}

.mw-rail-tools {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mw-rail-tools li {
  margin-bottom: 0.35rem;
}

.rail-tool-btn,
.link-btn {
  border: 0;
  background: transparent;
  color: var(--link-color);
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.rail-tool-btn:hover,
.link-btn:hover {
  text-decoration: underline;
}

/* Footer */
.mw-footer {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.mw-footer p {
  margin: 0 0 0.4rem;
}

.mw-footer-links {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0;
  margin: 0.6rem 0 0;
}

/* --------------------------------------------------------------------------
   Hover Preview Card, Modals, Media Viewer, Mobile Drawer
   -------------------------------------------------------------------------- */
.mw-hover-card {
  position: fixed;
  z-index: 1200;
  width: 320px;
  max-width: calc(100vw - 24px);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  box-shadow: var(--shadow-card);
  padding: 0.75rem 0.9rem;
  font-size: 0.83rem;
  line-height: 1.45;
  pointer-events: none;
}

.mw-hover-card-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}

.mw-hover-card-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.mw-hover-card-hint {
  margin-top: 0.45rem;
  font-size: 0.74rem;
  color: var(--link-color);
}

/* Modals */
.mw-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1300;
  background: rgba(16, 20, 24, 0.56);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.mw-modal-backdrop[hidden] {
  display: none;
}

.mw-modal {
  width: 100%;
  max-width: 640px;
  max-height: 86vh;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mw-modal-sm {
  max-width: 540px;
}

.mw-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}

.mw-modal-head-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.mw-modal-eyebrow {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.mw-modal-back {
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  padding: 0.15rem 0.5rem;
  font-size: 0.78rem;
  border-radius: 2px;
  cursor: pointer;
}

.mw-modal-close {
  border: 0;
  background: transparent;
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
}

.mw-modal-body {
  padding: 1.1rem 1.25rem 1.35rem;
  overflow-y: auto;
}

.mw-modal-body h2 {
  margin: 0 0 0.25rem;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 1.45rem;
}

.mw-modal-subtitle {
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 0.55rem;
}

.mw-modal-meta {
  background: var(--bg-surface);
  border: 1px solid var(--border-faint);
  padding: 0.45rem 0.65rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.85rem;
}

.mw-modal-content p {
  margin: 0 0 0.75rem;
  font-size: 0.93rem;
  line-height: 1.58;
}

.mw-modal-related {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-faint);
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.mw-related-chip {
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--link-color);
  font-size: 0.8rem;
  padding: 0.25rem 0.55rem;
  border-radius: 2px;
  cursor: pointer;
}

.mw-related-chip:hover {
  background: var(--bg-hover);
  text-decoration: underline;
}

/* Cite modal cards */
.cite-card {
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  padding: 0.7rem 0.85rem;
  margin-bottom: 0.7rem;
  border-radius: 2px;
}

.cite-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.cite-card pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.79rem;
  font-family: "JetBrains Mono", ui-monospace, Consolas, monospace;
}

/* Media Viewer Lightbox */
.mw-media-viewer {
  position: fixed;
  inset: 0;
  z-index: 1500;
  background: rgba(11, 13, 16, 0.95);
  color: #f0f2f5;
  display: flex;
  flex-direction: column;
}

.mw-media-viewer[hidden] {
  display: none;
}

.mw-mv-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1.15rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 0.85rem;
}

.mw-mv-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mw-mv-controls button,
.mw-mv-dl {
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  padding: 0.3rem 0.65rem;
  border-radius: 2px;
  font-size: 0.82rem;
  cursor: pointer;
  text-decoration: none;
}

.mw-mv-controls button:hover,
.mw-mv-dl:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  text-decoration: none;
}

.mw-mv-stage {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.mw-mv-stage img {
  max-height: calc(100vh - 165px);
  max-width: 100%;
  width: auto;
  height: auto;
  border: 1px solid rgba(255, 255, 255, 0.22);
  transition: transform 0.2s ease;
  transform-origin: center center;
}

.mw-mv-caption {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 0.84rem;
  color: #d6dbe0;
  text-align: center;
}

/* Mobile Slide Drawer */
.mw-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1050;
  background: rgba(16, 20, 24, 0.45);
}

.mw-toc-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 85vw;
  z-index: 1060;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-strong);
  padding: 0.9rem 1rem;
  overflow-y: auto;
  box-shadow: var(--shadow-card);
}

.mw-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0.7rem;
}

.mw-drawer-header button {
  border: 0;
  background: transparent;
  font-size: 1.4rem;
  cursor: pointer;
}

/* Toast */
.mw-toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1600;
  background: #202122;
  color: #ffffff;
  padding: 0.55rem 0.95rem;
  border-radius: 3px;
  font-size: 0.84rem;
  box-shadow: var(--shadow-card);
}

/* --------------------------------------------------------------------------
   Responsive Breakpoints
   -------------------------------------------------------------------------- */
@media (max-width: 1279px) {
  .mw-page-shell {
    grid-template-columns: 210px minmax(0, 1fr);
  }
  .mw-appearance-rail {
    display: none;
  }
}

@media (max-width: 1023px) {
  #mobile-menu-btn {
    display: inline-flex;
  }
  .mw-page-shell {
    grid-template-columns: minmax(0, 1fr);
    padding: 0.9rem 1rem 2.5rem;
  }
  .mw-toc-rail {
    display: none;
  }
  .mw-inline-toc {
    display: block;
  }
  .mw-references-list {
    column-count: 1;
  }
}

@media (max-width: 719px) {
  .mw-header-inner {
    flex-wrap: wrap;
    gap: 0.55rem;
    padding: 0.5rem 0.85rem;
  }
  .mw-search-wrap {
    order: 3;
    flex-basis: 100%;
    max-width: none;
  }
  .mw-btn-label,
  #header-cite-btn,
  #header-print-btn {
    display: none;
  }
  .mw-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }
  .infobox {
    float: none;
    width: 100%;
    margin: 0 0 1.25rem;
  }
  .mw-see-also-grid {
    columns: 1;
  }
  .wikitable,
  .wikitable thead,
  .wikitable tbody,
  .wikitable th,
  .wikitable td,
  .wikitable tr {
    display: block;
    width: 100%;
  }
  .wikitable {
    border: 0;
    background: transparent;
  }
  .wikitable caption {
    display: block;
  }
  .wikitable thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }
  .wikitable tbody tr {
    border: 1px solid var(--border-strong);
    background: var(--bg-surface);
    margin-bottom: 0.75rem;
  }
  .wikitable tbody th[scope="row"],
  .wikitable tbody td {
    border: 0;
    border-top: 1px solid var(--border-faint);
    padding: 0.44rem 0.65rem;
  }
  .wikitable tbody th[scope="row"] {
    border-top: 0;
    background: var(--bg-subtle);
  }
  .wikitable tbody td[data-label]::before {
    content: attr(data-label) ": ";
    font-weight: 700;
    color: var(--text-primary);
  }
  .mw-navbox-table,
  .mw-navbox-table tbody,
  .mw-navbox-table tr,
  .mw-navbox-table th,
  .mw-navbox-table td {
    display: block;
    width: 100%;
  }
  .mw-navbox-table th {
    width: 100%;
    text-align: left;
  }
}

/* --------------------------------------------------------------------------
   Print / Save to PDF Stylesheet
   -------------------------------------------------------------------------- */
@media print {
  .mw-header,
  .mw-toc-rail,
  .mw-appearance-rail,
  .mw-tabs-bar,
  .mw-lang-wrap,
  .mw-inline-toc,
  .timeline-toolbar,
  .ref-filter-bar,
  .infobox-enlarge-btn,
  .cite-copy-btn,
  .mw-footer-links,
  .mw-popover,
  .mw-modal-backdrop,
  .mw-media-viewer,
  .mw-toast {
    display: none !important;
  }
  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 11pt;
  }
  .mw-page-shell {
    display: block;
    max-width: 100%;
    padding: 0;
  }
  .infobox {
    width: 260px;
    break-inside: avoid;
  }
  .mw-section {
    break-inside: auto;
  }
  .mw-references-list {
    column-count: 2;
    font-size: 9pt;
  }
  a {
    color: #000000 !important;
    text-decoration: none !important;
  }
}
