:root {
  color-scheme: light dark;
  --bg: #f8f4ec;
  --bg-accent-1: #fff0d4;
  --bg-accent-2: #e3eef0;
  --panel: #fff9f0;
  --ink: #1c1b18;
  --muted: #6b625b;
  --border: #e2d7c7;
  --accent: #0f4c5c;
  --accent-2: #b86b34;
  --accent-soft: #e2efef;
  --header-bg: linear-gradient(90deg, #fff7e6, #f2ead7);
  --input-bg: #fff;
  --chip-bg: #fffdf8;
  --hover-bg: #fff9f0;
  --hover-border: #e2d7c7;
  --active-border: #0f4c5c;
  --excerpt-ink: #433a33;
  --sidebar-scroll-thumb: #c2b39e;
  --sidebar-scroll-track: #efe5d7;
  --header-offset: 110px;
}
body.theme-dark {
  --bg: #12110f;
  --bg-accent-1: #2a231b;
  --bg-accent-2: #1c2730;
  --panel: #1a1714;
  --ink: #f3eadb;
  --muted: #b7a896;
  --border: #2b2620;
  --accent: #7cc7d3;
  --accent-2: #d8a14a;
  --accent-soft: #27393b;
  --header-bg: linear-gradient(90deg, #1f1b16, #161311);
  --input-bg: #241f19;
  --chip-bg: #221e19;
  --hover-bg: #2a221b;
  --hover-border: #2b2620;
  --active-border: #7cc7d3;
  --excerpt-ink: #e8d9c7;
  --sidebar-scroll-thumb: #5a4f43;
  --sidebar-scroll-track: #241f19;
}
@media (prefers-color-scheme: dark) {
  body:not(.theme-light):not(.theme-dark) {
    --bg: #12110f;
    --bg-accent-1: #2a231b;
    --bg-accent-2: #1c2730;
    --panel: #1a1714;
    --ink: #f3eadb;
    --muted: #b7a896;
    --border: #2b2620;
    --accent: #7cc7d3;
    --accent-2: #d8a14a;
    --accent-soft: #27393b;
    --header-bg: linear-gradient(90deg, #1f1b16, #161311);
    --input-bg: #241f19;
    --chip-bg: #221e19;
    --hover-bg: #2a221b;
    --hover-border: #2b2620;
    --active-border: #7cc7d3;
    --excerpt-ink: #e8d9c7;
    --sidebar-scroll-thumb: #5a4f43;
    --sidebar-scroll-track: #241f19;
  }
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: "Segoe UI Variable", "Segoe UI", "Calibri", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 600px at 8% -10%, var(--bg-accent-1) 0%, rgba(255, 240, 212, 0) 70%),
    radial-gradient(1000px 800px at 95% 0%, var(--bg-accent-2) 0%, rgba(227, 238, 240, 0) 65%),
    var(--bg);
}
body.theme-dark {
  background:
    radial-gradient(900px 600px at 8% -10%, #2a231b 0%, rgba(18, 17, 15, 0) 70%),
    radial-gradient(1000px 800px at 95% 0%, #1c2730 0%, rgba(18, 17, 15, 0) 65%),
    var(--bg);
}
@media (prefers-color-scheme: dark) {
  body:not(.theme-light):not(.theme-dark) {
    background:
      radial-gradient(900px 600px at 8% -10%, #2a231b 0%, rgba(18, 17, 15, 0) 70%),
      radial-gradient(1000px 800px at 95% 0%, #1c2730 0%, rgba(18, 17, 15, 0) 65%),
      var(--bg);
  }
}
.wiki-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: end;
  gap: 14px 24px;
  padding: 12px 20px;
  min-height: 96px;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  position: sticky;
  top: 0;
  z-index: 10;
}
.title-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.title-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.title-wrap h1 {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.15;
  letter-spacing: 0.2px;
}
.title-theme-toggle {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--chip-bg);
  color: var(--ink);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.title-theme-toggle:hover {
  border-color: var(--accent);
}
.theme-toggle-mobile {
  display: none;
}
.theme-toggle-desktop {
  display: inline-flex;
}
.title-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.title-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--chip-bg);
}
.title-link:visited {
  color: var(--ink);
}
.title-link:hover {
  border-color: var(--accent);
}
.title-link.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
body.theme-dark .title-link.is-active {
  color: #0f1517;
}
.search-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}
.search-wrap input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 1rem;
  min-height: 44px;
  height: 44px;
  color: var(--ink);
  background: var(--input-bg);
}
.search-wrap select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 1rem;
  min-height: 44px;
  height: 44px;
  color: var(--ink);
  background: var(--input-bg);
}
.header-controls {
  display: grid;
  grid-template-columns: minmax(220px, 420px) repeat(3, minmax(120px, 180px)) auto;
  gap: 10px;
  align-items: end;
}
.search-wrap.compact {
  min-width: 120px;
}
.control-theme-inline {
  justify-self: end;
  align-self: end;
  margin-left: 0;
}
.toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 44px;
  height: 44px;
  padding: 0 12px;
  background: var(--input-bg);
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}
.toggle-wrap input {
  margin: 0;
  width: 16px;
  height: 16px;
}
@media (min-width: 981px) {
  html,
  body {
    height: 100%;
  }
  body {
    overflow: hidden;
  }
  .control-theme-inline.title-theme-toggle {
    width: 44px;
    height: 44px;
  }
  .wiki-layout {
    height: calc(100dvh - var(--header-offset));
    max-height: calc(100dvh - var(--header-offset));
    overflow: hidden;
    align-items: stretch;
  }
  .sidebar,
  .content {
    min-height: 0;
    height: 100%;
  }
  .sidebar {
    height: 100%;
    align-self: stretch;
  }
  .content {
    overflow: auto;
  }
}
.wiki-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  max-width: 1300px;
  margin: 0 auto;
  padding: 16px;
}
.sidebar,
.content {
  min-height: calc(100vh - 120px);
}
.sidebar {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
  align-self: start;
}
.stats {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.88rem;
}
.entity-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 8px;
  padding-right: 8px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.entity-list::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}
.entity-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 9px 10px;
  cursor: pointer;
  margin-bottom: 6px;
}
.entity-item:hover {
  background: var(--hover-bg);
  border-color: var(--hover-border);
}
.entity-item.is-active {
  background: var(--accent-soft);
  border-color: var(--active-border);
}
.entity-title {
  font-weight: 600;
  margin: 0;
}
.entity-type-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--chip-bg);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.confidence-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.confidence-chip.is-high {
  border: 1px solid #9acaa4;
  background: #eef8ef;
  color: #2f6640;
}
.confidence-chip.is-medium {
  border: 1px solid #d9c48c;
  background: #fdf6df;
  color: #836625;
}
.confidence-chip.is-low {
  border: 1px solid #ddc0bf;
  background: #fdf0ef;
  color: #8f4642;
}
.entity-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
}
.content {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  overflow: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.content::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}
.entity-page {
  padding: 20px;
}
.entity-page h2 {
  margin-top: 0;
  margin-bottom: 6px;
  font-size: 1.7rem;
}
.entity-note {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 14px;
}
.entity-intro {
  margin: 0 0 16px;
  line-height: 1.6;
}
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.meta-pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--chip-bg);
  font-size: 0.82rem;
}
.section-title {
  margin: 18px 0 10px;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.related-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.related-item {
  border: 1px solid var(--border);
  background: var(--chip-bg);
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
}
.related-item:hover {
  border-color: #b7cfce;
}
.source-list {
  display: grid;
  gap: 12px;
}
.source-card {
  border: 1px solid var(--border);
  background: var(--chip-bg);
  border-radius: 12px;
  padding: 12px;
}
.source-title {
  margin: 0;
  font-size: 1.02rem;
}
.source-links {
  margin: 7px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.86rem;
}
.source-links a {
  color: var(--accent);
  text-decoration: none;
}
.source-links a:hover {
  text-decoration: underline;
}
.source-excerpt {
  margin: 6px 0 0;
  color: var(--excerpt-ink);
  line-height: 1.5;
}
.empty {
  color: var(--muted);
  font-style: italic;
}
@media (max-width: 980px) {
  .wiki-header {
    padding: 10px 12px;
    min-height: 0;
    gap: 10px;
    transition: transform 0.22s ease;
    will-change: transform;
  }
  .wiki-header.is-hidden {
    transform: translateY(calc(-100% - 4px));
  }
  .header-controls {
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
  .header-controls .search-wrap {
    min-width: 0;
  }
  .header-controls .search-wrap:first-child {
    grid-column: 1 / -1;
  }
  .toggle-wrap {
    grid-column: 1 / -1;
  }
  .title-wrap {
    width: 100%;
  }
  .title-wrap h1 {
    font-size: 1.25rem;
  }
  .theme-toggle-mobile {
    display: inline-flex;
  }
  .theme-toggle-desktop {
    display: none;
  }
  .title-theme-toggle {
    width: 34px;
    height: 34px;
    font-size: 0.95rem;
  }
  .title-link {
    font-size: 0.74rem;
    padding: 4px 9px;
  }
  .wiki-layout {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
  }
  .sidebar,
  .content {
    min-height: auto;
    max-height: none;
  }
  .sidebar {
    height: auto;
  }
  .entity-list {
    max-height: 34vh;
  }
}
