:root {
  --page: #f5f1ec;
  --surface: #ffffff;
  --surface-soft: #eaf2fc;
  --ink: #073b70;
  --muted: #647b91;
  --line: #d8e0e8;
  --blue: #0868b9;
  --blue-dark: #06477f;
  --gold: #e5a91a;
  --shadow: 0 8px 22px rgba(25, 44, 62, .12);
  --code-bg: #eef3f8;
}

body.dark-mode {
  --page: #111827;
  --surface: #1e293b;
  --surface-soft: #253955;
  --ink: #e5eef8;
  --muted: #a4b2c3;
  --line: #35465b;
  --blue: #2563c8;
  --blue-dark: #174b98;
  --gold: #f0b92d;
  --shadow: 0 8px 22px rgba(0, 0, 0, .24);
  --code-bg: #101827;
}

* { box-sizing: border-box; margin: 0; }
html { scroll-behavior: smooth; }
body {
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: Arial, "Segoe UI", sans-serif;
  transition: background-color .2s, color .2s;
}
button, input { font: inherit; }

.site-header { background: var(--surface); box-shadow: 0 2px 9px rgba(0,0,0,.08); }
.masthead {
  max-width: 1600px; min-height: 132px; margin: auto; padding: 14px 28px;
  display: grid; grid-template-columns: 112px minmax(220px,1fr) minmax(320px,490px) 0;
  align-items: center; gap: 24px;
}
.brand-mark {
  width: 100px; height: 100px; display: grid; place-items: center;
  text-decoration: none; border-radius: 24px; box-shadow: 0 10px 24px rgba(9,38,71,.24);
  transition: transform .2s, box-shadow .2s;
}
.brand-mark:hover { transform: translateY(-2px); box-shadow: 0 14px 28px rgba(9,38,71,.3); }
.brand-mark img { display: block; width: 100%; height: 100%; }
.brand-copy .brand-kicker { color: var(--blue); font-size: .76rem; font-weight: 800; letter-spacing: .12em; }
.brand-copy h1 { margin: 5px 0; color: var(--blue-dark); font-size: 2rem; }
.brand-copy p:last-child { color: var(--muted); font-size: .94rem; }
.masthead-tools { display: flex; align-items: center; gap: 18px; }
.search-box {
  height: 44px; flex: 1; display: flex; align-items: center; gap: 9px; padding: 0 13px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--muted);
}
.search-box > span { font-size: 1.65rem; line-height: 1; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; }
.search-box input::placeholder { color: var(--muted); }
.theme-control { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--muted); white-space: nowrap; }
.switch { position: relative; display: inline-block; width: 38px; height: 21px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #aab7c5; border-radius: 20px; cursor: pointer; transition: .2s; }
.slider::before { content: ""; position: absolute; width: 15px; height: 15px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--blue); }
.switch input:checked + .slider::before { transform: translateX(17px); }
.mobile-menu-toggle { display: none; }

.site-nav {
  min-height: 42px; padding: 5px max(24px, calc((100% - 1320px)/2)); display: flex; justify-content: center; align-items: center; gap: 4px;
  background: var(--blue); overflow-x: auto; scrollbar-width: thin;
}
.nav-section-title { display: none; }
.nav-item {
  flex: 0 0 auto; padding: 8px 13px; border: 0; border-radius: 18px; background: transparent;
  color: #fff; font-size: .92rem; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.nav-item:hover, .nav-item.active { background: var(--gold); color: #fff; }

.main-wrapper { width: min(1540px, 100%); margin: 0 auto; padding: 18px 22px 40px; }
.home-grid { display: grid; grid-template-columns: minmax(330px, 1.04fr) minmax(300px, .76fr) minmax(460px, 1.32fr); gap: 22px; align-items: start; }
.feature-column, .latest-column, .discovery-column { min-width: 0; }
.feature-column { padding-right: 18px; border-right: 1px solid #b7c2cc; }
.feature-image {
  width: 100%; aspect-ratio: 2.05; display: block; object-fit: contain; padding: 8px 0; background: var(--surface-soft);
}
.feature-title { margin: 16px 12px 8px; color: var(--blue-dark); text-align: center; font-size: 1.38rem; line-height: 1.28; }
.feature-rule { width: 30px; height: 3px; margin: 12px auto; background: var(--gold); }
.feature-desc { color: var(--ink); font-size: 1.05rem; line-height: 1.72; text-align: center; }
.feature-read { display: inline-block; margin-top: 12px; color: var(--blue); font-weight: 700; text-decoration: none; }
.feature-read:hover { text-decoration: underline; }

.section-heading { margin: 2px 0 12px; color: var(--blue-dark); font-size: 1.05rem; letter-spacing: .04em; text-transform: uppercase; }
.section-heading::after { content: ""; display: block; width: 30px; height: 3px; margin-top: 10px; background: var(--gold); }
.latest-list { display: flex; flex-direction: column; }
.latest-item {
  display: grid; grid-template-columns: 74px 1fr; gap: 12px; padding: 11px 0 12px;
  border-bottom: 1px solid var(--line); color: var(--blue-dark); text-decoration: none;
}
.latest-item img { width: 68px; height: 48px; object-fit: contain; padding: 2px; background: var(--surface-soft); }
.latest-item strong { display: block; font-size: .98rem; line-height: 1.35; font-weight: 500; }
.latest-item small { display: block; margin-top: 7px; color: var(--muted); font-size: .75rem; }
.latest-item:hover strong { color: var(--blue); text-decoration: underline; }
.latest-more { margin-top: 13px; padding: 9px 13px; border: 1px solid var(--blue); border-radius: 4px; background: transparent; color: var(--blue); font-weight: 700; cursor: pointer; }
.latest-more:hover { background: var(--blue); color: #fff; }

.illustration-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 15px; }
.illustration-card { display: block; position: relative; overflow: hidden; background: var(--surface); box-shadow: var(--shadow); text-decoration: none; }
.illustration-card img { display: block; width: 100%; aspect-ratio: 2.15; object-fit: contain; padding: 8px; background: var(--surface-soft); transition: filter .2s; }
.illustration-card:hover img { filter: brightness(1.04); }
.illustration-card span { display: block; padding: 9px 11px; color: var(--blue-dark); font-size: .88rem; font-weight: 700; line-height: 1.35; }
.discover-box { margin-top: 18px; border: 1px solid var(--line); background: var(--surface); }
.discover-heading { padding: 12px 16px; background: var(--surface-soft); color: var(--blue-dark); font-weight: 700; }
.discover-link { width: 100%; padding: 13px 16px; display: flex; justify-content: space-between; border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.discover-link:hover { background: var(--surface-soft); color: var(--blue); }
.site-footer { margin-top: 34px; padding-top: 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; text-align: center; }

/* Article and category views */
.category-card { margin: 0 0 20px; padding: 22px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.category-header { display: flex; align-items: center; gap: 10px; padding-bottom: 12px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.category-header h2 { color: var(--blue-dark); font-size: 1.3rem; }
.sub-group { margin-bottom: 20px; }
.sub-group:last-child { margin-bottom: 0; }
.sub-group-title { margin-bottom: 10px; color: var(--blue-dark); font-size: 1rem; font-weight: 700; }
.button-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.link-btn { display: inline-flex; padding: 8px 14px; border: 1px solid var(--blue); border-radius: 5px; color: var(--blue); text-decoration: none; font-size: .88rem; }
.link-btn:hover { background: var(--blue); color: white; }
.note-list { display: grid; grid-template-columns: repeat(auto-fill,minmax(280px,1fr)); gap: 14px; }
.note-item { min-width: 0; padding: 14px; border: 1px solid var(--line); background: var(--surface); }
.note-thumb { width: 100%; aspect-ratio: 2.25; height: auto; display: block; margin-bottom: 12px; padding: 8px; object-fit: contain; background: var(--surface-soft); }
.note-item-title { margin-bottom: 7px; font-size: .98rem; font-weight: 700; line-height: 1.35; }
.note-item-desc { margin-bottom: 8px; color: var(--muted); font-size: .9rem; line-height: 1.55; }
.article-link { margin-top: 10px; font-size: .9rem; }
.article-link a { color: var(--blue); text-decoration: none; }
.article-link a:hover { text-decoration: underline; }
.article-open-btn { display: inline-block; border: 0; padding: 0; background: transparent; color: var(--blue); cursor: pointer; font: inherit; text-decoration: none; }
.code-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px; border-radius: 4px; background: var(--code-bg); font: .84rem Consolas,Monaco,monospace; overflow-x: auto; }
.code-text { flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-word; }
.copy-btn { flex-shrink: 0; padding: 5px 9px; border: 0; border-radius: 4px; background: var(--blue); color: #fff; cursor: pointer; white-space: nowrap; }
.copy-btn:hover { background: var(--blue-dark); }
.empty-state { padding: 50px 20px; color: var(--muted); text-align: center; }
.article-page { max-width: 1020px; margin: 0 auto; }
.article-page h1 { margin: 15px 0; color: var(--blue-dark); line-height: 1.3; }
.article-page-kicker { margin-top: 20px; color: var(--muted); font-size: .9rem; }
.article-back-btn { padding: 9px 13px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-soft); color: var(--ink); cursor: pointer; }
.article-hero-image { display: block; width: 100%; aspect-ratio: 2.25; max-height: 380px; margin-top: 20px; padding: 10px; object-fit: contain; background: var(--surface-soft); }
.article-diagram, .article-ui-map { margin: 22px 0; }
.article-diagram img, .article-ui-map svg { display: block; width: 100%; max-height: 380px; object-fit: contain; border: 1px solid var(--line); background: var(--surface-soft); }
.article-diagram figcaption, .article-ui-map figcaption { margin-top: 7px; color: var(--muted); font-size: .84rem; text-align: center; }
.article-body { margin: 24px 0; line-height: 1.75; }
.article-body p { margin: 9px 0; }
.article-body .article-section-title { margin: 25px 0 10px; padding-bottom: 7px; border-bottom: 1px solid var(--line); color: var(--blue); font-size: 1.08rem; }
.article-body .article-step, .article-body .article-bullet { padding-left: 12px; }
.article-body .article-bullet { color: var(--muted); }
.map-bg { fill: var(--surface-soft); }.map-panel { fill: var(--surface); stroke: var(--line); }.map-bar { fill: var(--blue-dark); }.map-title,.map-focus { fill: var(--blue); font-weight: 700; }.map-subtitle,.map-hint { fill: var(--muted); }.map-window,.map-row { fill: var(--ink); }

@media (max-width: 1180px) {
  .home-grid { grid-template-columns: minmax(300px,1fr) minmax(280px,.85fr); }
  .feature-column { grid-row: span 2; }
  .discovery-column { grid-column: 2; }
}
@media (max-width: 760px) {
  .masthead { min-height: auto; padding: 12px 14px; grid-template-columns: 58px 1fr 38px; gap: 12px; }
  .brand-mark { width: 54px; height: 54px; border-radius: 14px; }
  .brand-copy .brand-kicker { font-size: .58rem; }
  .brand-copy h1 { font-size: 1.35rem; }
  .brand-copy p:last-child { font-size: .76rem; }
  .masthead-tools { grid-column: 1 / -1; grid-row: 2; }
  .theme-control { font-size: .8rem; }
  .mobile-menu-toggle { display: block; grid-column: 3; grid-row: 1; padding: 7px; border: 0; border-radius: 4px; background: var(--blue); color: #fff; }
  .site-nav { display: none; justify-content: flex-start; padding: 8px 10px; }
  .site-nav.open { display: flex; }
  .nav-item { padding: 8px 11px; font-size: .82rem; }
  .main-wrapper { padding: 15px 12px 30px; }
  .home-grid { display: flex; flex-direction: column; gap: 24px; }
  .feature-column { padding: 0 0 20px; border-right: 0; border-bottom: 1px solid var(--line); }
  .feature-title { font-size: 1.2rem; }
  .feature-desc { font-size: .96rem; }
  .latest-column, .discovery-column { width: 100%; }
  .illustration-grid { gap: 10px; }
  .illustration-card span { padding: 7px; font-size: .78rem; }
  .category-card { padding: 15px; }
  .note-list { grid-template-columns: 1fr; }
  .article-page h1 { font-size: 1.5rem; }
}
