
:root {
  --bg: #0d1117;
  --bg-alt: #161b22;
  --bg-inset: #161b22;
  --fg: #e6edf3;
  --fg-muted: #9198a1;
  --border: #30363d;
  --accent: #4493f8;
  --accent-bg: #0c2d6b;
  --sidebar-w: 280px;
  --topbar-h: 56px;
  --code-bg: #161b22;
  --tk-key: #79c0ff;
  --tk-str: #a5d6ff;
  --tk-num: #ffa657;
  --tk-bool: #d2a8ff;
  --tk-com: #8b949e;
  --tk-table: #7ee787;
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-size: 15px;
  line-height: 1.55;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 30;
}
.topbar .brand {
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
  font-size: 15px;
}
.topbar .brand:hover { text-decoration: none; color: var(--accent); }
.menu-btn {
  display: none;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--fg);
  border-radius: 6px;
  width: 32px; height: 32px;
  align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 16px;
}

.topbar-secondary { display: contents; }
.search-wrap { position: relative; flex: 1; max-width: 480px; }
#search {
  width: 100%;
  padding: 7px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-inset);
  color: var(--fg);
  font-size: 14px;
}
#search:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--bg); }
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 420px;
  overflow-y: auto;
  z-index: 40;
}
.search-results .sr-item {
  display: block;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.search-results .sr-item:last-child { border-bottom: none; }
.search-results .sr-item:hover,
.search-results .sr-item.sel { background: var(--bg-alt); }
.sr-title { font-weight: 600; font-size: 13.5px; }
.sr-title mark, .sr-key mark { background: var(--accent-bg); color: inherit; border-radius: 2px; }
.sr-path { color: var(--fg-muted); font-size: 12px; }
.sr-key { font-size: 12px; color: var(--fg-muted); margin-top: 2px; }
.sr-empty { padding: 14px 12px; color: var(--fg-muted); font-size: 13px; }

.layout { display: flex; align-items: flex-start; }
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  border-right: 1px solid var(--border);
  height: calc(100vh - var(--topbar-h));
  position: sticky;
  top: var(--topbar-h);
  overflow-y: auto;
  padding: 14px 10px 40px;
  background: var(--bg-alt);
}
.content {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 80px;
  max-width: 1200px;
}

.breadcrumb { font-size: 13px; color: var(--fg-muted); margin-bottom: 18px; }
.crumb { color: var(--fg-muted); }
.crumb:hover { color: var(--accent); }
.crumb.current { color: var(--fg); font-weight: 600; }
.crumb-sep { margin: 0 6px; color: var(--fg-muted); }

h1 { font-size: 22px; margin: 0 0 16px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }

.listing { width: 100%; border-collapse: collapse; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.listing td { padding: 9px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
.listing tr:last-child td { border-bottom: none; }
.listing tr:hover { background: var(--bg-alt); }
.listing .muted { color: var(--fg-muted); text-align: right; font-size: 12.5px; white-space: nowrap; }
.muted { color: var(--fg-muted); }
.ic { margin-right: 7px; opacity: 0.85; }

.parse-warning {
  background: var(--accent-bg);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--fg);
}

.file-layout { display: flex; align-items: flex-start; gap: 24px; }
.toml-source {
  flex: 1;
  min-width: 0;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.6;
}
.toml-source code { white-space: pre; }
.l { display: inline-block; width: 100%; scroll-margin-top: 76px; border-radius: 3px; }
.l:target { background: var(--accent-bg); outline: 1px solid var(--accent); }
.tk-key { color: var(--tk-key); font-weight: 600; }
.tk-str { color: var(--tk-str); }
.tk-num { color: var(--tk-num); }
.tk-bool { color: var(--tk-bool); font-weight: 600; }
.tk-com { color: var(--tk-com); font-style: italic; }
.tk-table { color: var(--tk-table); font-weight: 700; }

.keys-panel {
  flex: 0 0 220px;
  position: sticky;
  top: 76px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--bg-alt);
  max-height: calc(100vh - 110px);
  overflow-y: auto;
}
.keys-panel h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--fg-muted); margin: 0 0 8px; }
.keys-panel ul { list-style: none; margin: 0; padding: 0; }
.keys-panel li { margin: 0; }
.keys-panel a { display: block; padding: 4px 6px; border-radius: 4px; font-size: 13px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.keys-panel a:hover { background: var(--bg); text-decoration: none; }

.sidebar-tree a { color: var(--fg); font-size: 13.5px; }
.sidebar-tree summary { cursor: pointer; list-style: none; padding: 4px 6px; border-radius: 6px; display: flex; }
.sidebar-tree summary::-webkit-details-marker { display: none; }
.sidebar-tree summary a { flex: 1; display: flex; align-items: center; }
.sidebar-tree summary:hover { background: var(--bg); }
.sidebar-tree details { margin-bottom: 1px; }
.sidebar-tree summary::before {
  content: "▸";
  display: inline-block;
  width: 14px;
  color: var(--fg-muted);
  font-size: 10px;
  transition: transform 0.1s;
}
.sidebar-tree details[open] > summary::before { transform: rotate(90deg); }
.sidebar-tree .tree-children { margin-left: 16px; border-left: 1px solid var(--border); padding-left: 4px; }
.sidebar-tree .file-link { display: flex; align-items: center; padding: 4px 6px 4px 24px; border-radius: 6px; }
.sidebar-tree .file-link:hover { background: var(--bg); text-decoration: none; }
.sidebar-tree a.active { color: var(--accent); font-weight: 600; background: var(--accent-bg); }

@media (max-width: 860px) {
  .menu-btn { display: flex; }
  .topbar {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 16px;
    row-gap: 8px;
  }
  .topbar-secondary {
    display: flex;
    flex: 1 1 100%;
    align-items: center;
    gap: 12px;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: var(--topbar-h-live, 100px);
    height: calc(100vh - var(--topbar-h-live, 100px));
    z-index: 25;
    transform: translateX(-100%);
    transition: transform 0.15s ease;
    box-shadow: var(--shadow);
  }
  .layout.sidebar-open .sidebar { transform: translateX(0); }
  .content { padding: 20px 16px 60px; }
  .file-layout { flex-direction: column; }
  .keys-panel { flex: none; width: 100%; position: static; max-height: none; }
  .search-wrap { max-width: none; }
}

.tool-nav { display: flex; align-items: center; gap: 6px; position: relative; }
.tool-nav .nav-link {
  white-space: nowrap;
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--nav-color, var(--border));
  color: var(--nav-color, var(--fg-muted));
  background: transparent;
}
.tool-nav .nav-link:hover { text-decoration: none; background: color-mix(in srgb, var(--nav-color) 16%, transparent); }
.tool-nav .nav-link.current {
  color: #0d1117;
  background: var(--nav-color);
  border-color: var(--nav-color);
  font-weight: 700;
}
.nav-toggle { font: inherit; cursor: default; margin: 0; }
.nav-caret { display: none; }
.nav-dropdown { display: contents; }
.game-version {
  white-space: nowrap;
  font-size: 11.5px;
  color: var(--fg-muted);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px 8px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
@media (max-width: 860px) {
  .game-version { display: none; }
  .nav-toggle { cursor: pointer; }
  .nav-caret {
    display: inline-block;
    margin-left: 5px;
    font-size: 9px;
    transition: transform 0.15s ease;
  }
  .tool-nav.open .nav-caret { transform: rotate(180deg); }
  .nav-dropdown {
    display: none;
    flex-direction: column;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 170px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
    z-index: 50;
  }
  .tool-nav.open .nav-dropdown { display: flex; }
  .nav-dropdown .nav-link {
    border: none;
    border-radius: 0;
    background: transparent;
    padding: 9px 12px;
  }
  .nav-dropdown .nav-link:hover { background: var(--bg-alt); }
}
