/* HCI-first design system: contrast, grouping, focus, readable measure */
:root {
  --ink: #172033;
  --ink-soft: #3d4758;
  --paper: #f7f4ee;
  --paper-2: #fffdf9;
  --line: #d8d0c4;
  --ai: #0b5f73;
  --ai-deep: #084656;
  --gold: #8a6914;
  --gold-soft: #c4a35a;
  --link: #0b4f86;
  --link-hover: #083a63;
  --danger: #8b1e1e;
  --header: #0c1828;
  --header-text: #f3efe6;
  --muted: #5b6574;
  --focus: #c9a227;
  --shadow: 0 10px 30px rgba(12, 24, 40, 0.12);
  --radius: 14px;
  --max: 72rem;
  --read: 44rem;
  --nav-h: 4.25rem;
  --font-ui: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", "Segoe UI", sans-serif;
  --font-read: "Noto Serif TC", "PMingLiU", "Songti TC", Georgia, serif;
  --space: 1.15rem;
}

html[data-theme="dark"] {
  --ink: #e8e4da;
  --ink-soft: #c5c0b4;
  --paper: #121821;
  --paper-2: #1a2230;
  --line: #2c3648;
  --ai: #7ec8d6;
  --ai-deep: #9bd4df;
  --gold: #e0c16a;
  --gold-soft: #c4a35a;
  --link: #8ec4ff;
  --link-hover: #c5e0ff;
  --header: #080d14;
  --header-text: #f3efe6;
  --muted: #9aa3b2;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  color-scheme: light;
  scroll-padding-top: calc(var(--nav-h) + 0.5rem);
}
html[data-theme="dark"] { color-scheme: dark; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 1.0625rem;
  line-height: 1.75;
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
}

img { max-width: 100%; height: auto; }
[hidden] { display: none !important; }
a { color: var(--link); text-underline-offset: 0.18em; }
a:hover { color: var(--link-hover); }
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -4rem;
  z-index: 1000;
  background: var(--focus);
  color: #111;
  padding: 0.6rem 1rem;
  font-weight: 700;
  text-decoration: none;
  border-radius: 0 0 8px 8px;
}
.skip-link:focus { top: 0; }

.progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 4px;
  width: 0;
  background: linear-gradient(90deg, var(--ai), var(--gold-soft));
  z-index: 80;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--header);
  color: var(--header-text);
  box-shadow: 0 1px 0 rgba(255,255,255,0.06);
}

.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  min-height: var(--nav-h);
  padding: 0.55rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  object-fit: cover;
  flex: none;
  background: #1c2b40;
}
.brand-text { min-width: 0; }
.brand-title {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 18rem;
}
.brand-tag {
  display: block;
  font-size: 0.75rem;
  color: #c9c2b4;
  margin-top: 0.05rem;
}

.header-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.icon-btn,
.menu-toggle {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  color: var(--header-text);
  min-width: 44px;
  min-height: 44px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0 0.7rem;
}
.icon-btn:hover,
.menu-toggle:hover { background: rgba(255,255,255,0.12); }

.primary-nav {
  display: none;
  flex: 1;
}
.primary-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0.15rem;
}
.primary-nav > ul > li { position: relative; }
.primary-nav a,
.nav-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 44px;
  padding: 0 0.8rem;
  color: #efe8da;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  background: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  border-radius: 10px;
}
.primary-nav a:hover,
.nav-trigger:hover,
.primary-nav a[aria-current="page"] {
  background: rgba(255,255,255,0.1);
}
.mega {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 22rem;
  background: var(--paper-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0.55rem;
  z-index: 50;
}
.mega ul { list-style: none; margin: 0; padding: 0; }
.drawer-panel ul { list-style: none; margin: 0 0 1rem; padding: 0; }
.prose ul + h3, .prose ol + h3 { margin-top: 1.35rem; }
.mega a {
  display: block;
  color: var(--ink);
  min-height: 40px;
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  font-weight: 500;
}
.mega a:hover,
.mega a[aria-current="page"] {
  background: color-mix(in srgb, var(--ai) 12%, var(--paper-2));
  color: var(--ai-deep);
}
.nav-item.open .mega,
.nav-item:hover .mega { display: block; }

@media (min-width: 980px) {
  .menu-toggle { display: none; }
  .primary-nav { display: block; }
}

.drawer {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 60;
}
.drawer.is-open { display: block; }
.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 13, 20, 0.55);
}
.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(22rem, 92vw);
  height: 100%;
  background: var(--paper-2);
  color: var(--ink);
  overflow: auto;
  padding: 1rem 1rem 2rem;
  box-shadow: var(--shadow);
}
.drawer-panel h2 { font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.drawer-panel a {
  display: block;
  padding: 0.7rem 0.2rem;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  min-height: 44px;
}
.drawer-close { margin-bottom: 0.8rem; }

.search-dialog {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: 40rem;
  width: calc(100% - 1.5rem);
}
.search-dialog::backdrop { background: rgba(8, 13, 20, 0.55); }
.search-box {
  background: var(--paper-2);
  border-radius: 16px;
  padding: 1.1rem;
  box-shadow: var(--shadow);
}
.search-box input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  font: inherit;
  background: var(--paper);
  color: var(--ink);
}
.search-results {
  list-style: none;
  margin: 0.8rem 0 0;
  padding: 0;
  max-height: 22rem;
  overflow: auto;
}
.search-results a {
  display: block;
  padding: 0.7rem 0.4rem;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}
.search-results a:hover { background: color-mix(in srgb, var(--ai) 10%, transparent); }
.search-empty { color: var(--muted); padding: 0.8rem 0.2rem; }
.search-close {
  margin-top: 0.7rem;
  color: var(--ink) !important;
  border-color: var(--line) !important;
  background: var(--paper) !important;
}

.hero[hidden] { display: none !important; }
.hero {
  background:
    linear-gradient(180deg, rgba(12,24,40,0.55), rgba(12,24,40,0.72)),
    var(--header);
  color: #f7f2e8;
  padding: 2.4rem 1.1rem 2.1rem;
}
.hero-inner { max-width: var(--max); margin: 0 auto; }
.hero-title {
  font-family: var(--font-read);
  font-size: clamp(1.6rem, 3vw, 2.35rem);
  line-height: 1.28;
  margin: 0 0 0.55rem;
  font-weight: 700;
}
.hero p { margin: 0; max-width: 42rem; color: #ddd6c8; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.1rem; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
  border: 1px solid transparent;
}
.btn-primary { background: #e8c56b; color: #1a1406; }
.btn-primary:hover { background: #f0d48a; color: #1a1406; }
.btn-ghost { background: transparent; color: #f7f2e8; border-color: rgba(255,255,255,0.35); }
.btn-ghost:hover { background: rgba(255,255,255,0.08); color: #fff; }

.page-shell {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.25rem 1.1rem 3.5rem;
}

.crumb {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0 0 1rem;
}
.crumb ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
}
.crumb li:not(:last-child)::after { content: " / "; color: var(--muted); margin-left: 0.35rem; }
.crumb a { color: inherit; }

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}
@media (min-width: 980px) {
  .layout.has-toc { grid-template-columns: minmax(0, 1fr) 16rem; align-items: start; }
}

.article {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1.1rem, 2.4vw, 2rem);
  box-shadow: 0 1px 0 rgba(255,255,255,0.5) inset;
}
.article[hidden] { display: none !important; }

.kicker {
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ai);
  font-weight: 700;
  margin: 0 0 0.35rem;
}
.article h1 {
  font-family: var(--font-read);
  font-size: clamp(1.45rem, 2.4vw, 2.05rem);
  line-height: 1.3;
  margin: 0 0 1rem;
}

.prose {
  font-size: 1.05rem;
  max-width: var(--read);
}
html[data-section="culture"] .prose { font-family: var(--font-read); }
.prose h2,
.prose h3,
.prose h4 {
  font-family: var(--font-ui);
  line-height: 1.35;
  scroll-margin-top: calc(var(--nav-h) + 0.8rem);
}
.prose h2 { font-size: 1.28rem; margin: 1.8rem 0 0.7rem; }
.prose h3 { font-size: 1.12rem; margin: 1.4rem 0 0.55rem; color: var(--ai-deep); }
html[data-section="culture"] .prose h3 { color: var(--gold); }
.prose p { margin: 0 0 1rem; }
.prose ul, .prose ol { margin: 0 0 1rem; padding-left: 1.3rem; }
.prose li { margin: 0.28rem 0; }
.prose hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.4rem 0;
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: 0.95rem;
}
.table-wrap { overflow-x: auto; margin: 0 0 1.2rem; }
.prose th, .prose td {
  border: 1px solid var(--line);
  padding: 0.55rem 0.7rem;
  vertical-align: top;
  text-align: left;
}
.prose th { background: color-mix(in srgb, var(--ai) 10%, var(--paper)); }
.prose figure { margin: 1.2rem 0; }
.prose figcaption { font-size: 0.85rem; color: var(--muted); margin-top: 0.4rem; }
.prose img.emoji-inline {
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.15em;
  margin-right: 0.25rem;
}

.page-toc,
.hex-index-box {
  background: color-mix(in srgb, var(--ai) 7%, var(--paper));
  border-left: 4px solid var(--ai);
  padding: 0.9rem 1.1rem;
  margin: 1.1rem 0 1.4rem;
  border-radius: 0 12px 12px 0;
}
.hex-index { list-style: none; margin: 0.4rem 0 0; padding: 0; }
.hex-index li { margin: 0.4rem 0; }
.hex-index a { font-weight: 700; }

.series {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 0 0 1.2rem;
}
.series a {
  display: flex;
  flex-direction: column;
  min-height: 48px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink);
  background: var(--paper);
}
.series .lbl { font-size: 0.75rem; color: var(--muted); }
.series .ttl { font-weight: 700; }

.toc-aside {
  position: sticky;
  top: calc(var(--nav-h) + 0.8rem);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem;
}
.toc-aside h2 { font-size: 0.82rem; margin: 0 0 0.5rem; letter-spacing: 0.06em; color: var(--muted); }
.toc-aside ul { list-style: none; margin: 0; padding: 0; }
.toc-aside a {
  display: block;
  font-size: 0.86rem;
  line-height: 1.4;
  padding: 0.35rem 0;
  color: var(--ink-soft);
  text-decoration: none;
}
.toc-aside a:hover,
.toc-aside a.is-active { color: var(--ai-deep); font-weight: 700; }
.toc-empty { color: var(--muted); font-size: 0.88rem; margin: 0; }

.explore {
  margin-top: 2rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
}
.explore h2 { font-size: 1.15rem; margin: 0 0 0.85rem; }
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.75rem;
}
.card {
  display: flex;
  flex-direction: column;
  min-height: 8.5rem;
  padding: 0.95rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  background: var(--paper);
}
.card:hover { border-color: var(--ai); box-shadow: var(--shadow); }
.card strong { display: block; margin-bottom: 0.3rem; }
.card span { color: var(--muted); font-size: 0.9rem; }

.contact-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 1.2rem;
  padding: 0.9rem 1rem;
  margin: 0 0 1.2rem;
  background: color-mix(in srgb, var(--gold) 10%, var(--paper));
  border-radius: 12px;
}
.contact-strip a { font-weight: 700; }

.site-footer {
  background: var(--header);
  color: #d9d3c6;
  padding: 2rem 1.1rem 2.4rem;
}
.footer-inner {
  max-width: var(--max);
  margin: 0 auto;
  display: grid;
  gap: 1.2rem;
}
@media (min-width: 800px) {
  .footer-inner { grid-template-columns: 1.2fr 1fr 1fr; }
}
.site-footer h2 { color: #f3efe6; font-size: 0.95rem; margin: 0 0 0.5rem; }
.site-footer a { color: #e8c56b; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin: 0.28rem 0; }
.back-top {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 30;
  min-width: 44px;
  min-height: 44px;
  border-radius: 999px;
  border: 0;
  background: var(--header);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--shadow);
}
@media (max-width: 720px) {
  .brand-title { max-width: 11rem; }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

@media print {
  .site-header, .hero, .toc-aside, .explore, .site-footer, .back-top, .progress, .drawer, .search-dialog, .header-tools, .series { display: none !important; }
  .article { border: 0; box-shadow: none; }
  .article[hidden] { display: none !important; }
}
