:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --panel: #0f141a;
  --text: #e6edf3;
  --muted: #9aa6b2;
  --accent: #3b82f6;
  --accent-2: #22c55e;
  --border: #1e2630;
  --code-bg: #0b1220;
  --code-border: #1b2330;
}
* { box-sizing: border-box; }
body { font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Apple Color Emoji", "Segoe UI Emoji"; margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column; }
header { padding: 1.5rem 2rem; border-bottom: 1px solid var(--border); background: var(--panel); position: sticky; top: 0; z-index: 5; }
main { padding: 2rem; max-width: 1520px; margin: 0 auto; flex: 1 0 auto; }
h1 { margin: 0 0 0.25rem; font-weight: 650; }
.sub { color: var(--muted); font-size: .95rem; }
form { display: flex; gap: .5rem; margin: 1rem 0 1.25rem; }
input[type=text] { flex: 1; padding: .7rem .9rem; background: var(--code-bg); color: var(--text); border: 1px solid var(--code-border); border-radius: .5rem; }
button, .btn { padding: .65rem 1rem; background: var(--accent); color: white; border: 1px solid #2b62c0; border-radius: .5rem; cursor: pointer; text-decoration: none; }
button.secondary, .btn.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
button:disabled, .btn[aria-disabled=true] { opacity: .6; cursor: not-allowed; }
/* Pill buttons */
.btn.pill { border-radius: 999px; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: .75rem; padding: 1rem; }
.code { background: var(--code-bg); border: 1px solid var(--code-border); border-radius: .5rem; overflow-y: auto; overflow-x: auto; position: relative; max-height: 60vh; }
/* Reserve space for the main header block to avoid shrink on refresh */
.code.header-block { min-height: 40vh; }
.code.header-block pre { min-height: 100%; }
pre { margin: 0; padding: 1rem 0 1rem 3.5rem; counter-reset: line; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 13px; line-height: 1.6; }
pre code { display: block; white-space: pre-wrap; word-break: break-word; }
pre code .line { display: block; padding-right: 1rem; position: relative; }
/* Defensive fallback to ensure lines render block-level even if selector fails */
.line { display: block; }
pre code .line::before { counter-increment: line; content: counter(line); position: absolute; left: -2.5rem; color: var(--muted); }
.section { margin-top: .75rem; }
details { border: 1px solid var(--code-border); border-radius: .5rem; background: var(--panel); }
details summary { list-style: none; cursor: pointer; padding: .5rem .75rem; border-bottom: 1px solid var(--code-border); user-select: none; }
details[open] summary { border-bottom-color: var(--border); }
details summary::marker, details > summary::-webkit-details-marker { display:none; }
.actions { margin-top: .5rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: .9rem; }
.spinner { width: 18px; height: 18px; border: 2px solid #2b62c0; border-top-color: transparent; border-radius: 50%; animation: spin 0.9s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: none; gap: .5rem; align-items: center; color: var(--muted); }
.hidden { display: none !important; }
/* Header layout: left (title/summary) + right (subheader controls) */
.header-grid { display: flex; gap: 1rem; align-items: flex-start; }
.header-left { flex: 1; min-width: 0; }
/* Subheader fixed-width column */
.subheader { width: 420px; max-width: 480px; }
/* Main layout with right sidebar */
.main-grid { display: flex; gap: 1rem; align-items: flex-start; }
.main-left { flex: 1; min-width: 0; min-height: 80vh; display: flex; flex-direction: column; }
.main-right { width: 420px; max-width: 480px; border-left: 1px solid var(--border); padding-left: 1rem; }
/* Syntax highlight tokens (fallback if styles.css missing) */
.tok-key { color: #93c5fd; }
.tok-type { color: #86efac; }
.tok-num { color: #fca5a5; }
.tok-com { color: #9aa6b2; }
.tok-func { color: #facc15; }
.tok-str { color: #f9a8d4; }
/* Badges */
.badge { display: inline-block; padding: .1rem .4rem; border-radius: .4rem; font-size: .75rem; line-height: 1; vertical-align: middle; margin-left: .4rem; }
.badge-latest { background: var(--accent-2); color: #0b0f14; }
/* Struct summary styling */
.summary-card { margin-top: .5rem; }
.summary-header { display:flex; align-items:center; gap:.5rem; flex-wrap:wrap; }
.summary-title { font-weight: 600; }
.summary-meta { color: var(--muted); }
.pill { display:inline-block; padding:.25rem .55rem; border:1px solid var(--code-border); border-radius:999px; font-size:.8rem; line-height:1; margin:.25rem .25rem 0 0; background: linear-gradient(180deg, #0f141a, #0b1220); }
.pill-accent { border-color:#2b62c0; color:#cfe3ff; }
.pill-green { border-color:#197a45; color:#c9f6db; }
.pill-yellow { border-color:#7a6b19; color:#f7f0c2; }
/* Additional pill colors */
.pill-red { border-color:#7a1e1e; color:#f7d4d4; }
.pill-purple { border-color:#53359a; color:#e6d7fa; }
.pill-orange { border-color:#7a4f19; color:#f9e0c2; }
.pill-pink { border-color:#7a1e5a; color:#f7d0e6; }
.pill-cyan { border-color:#1b6d7a; color:#d3f5f7; }
.pill-gray { border-color:#3a4654; color:#cbd5e1; }
.summary-grid { display:flex; flex-wrap:wrap; gap:.25rem; margin-top:.25rem; }
.summary-base { margin-left:.5rem; padding:.1rem .4rem; border-radius:.4rem; background:#1e2630; color:#cbd5e1; font-size:.8rem; }
/* Footer */
.footer { padding: 1rem 2rem; border-top: 1px solid var(--border); background: var(--panel); color: var(--muted); }
.footer-inner { max-width: 1520px; margin: 0 auto; font-size: .85rem; display:flex; align-items:center; justify-content:space-between; gap:1rem; flex-wrap:wrap; }
.footer-left { display:flex; flex-direction:column; gap:.25rem; }
.footer-right { text-align:right; }
/* Toast notifications */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; }
.toast { background: #11161d; border: 1px solid var(--border); color: var(--text); padding: .5rem .75rem; border-radius: .5rem; box-shadow: 0 6px 12px rgba(0,0,0,.35); font-size: .9rem; min-width: 240px; }
.toast.success { border-color: #197a45; color: #c9f6db; }
.toast.error { border-color: #7a1e1e; color: #f7d4d4; }
.toast.info { border-color: #2b62c0; color: #cfe3ff; }
.btn .spinner { margin-left: .4rem; border-color: #cfe3ff; border-top-color: transparent; }

/* Moved inline styles → CSS */
.header-right { display:flex; flex-direction:column; }
#headerGlobal { margin-top:.5rem; gap:.4rem; align-items:center; flex-wrap:wrap; }
.row.tight-gap { gap:.4rem; }
.header-right .row.tight-gap { justify-content: flex-end; }
.btn.compact { padding:.25rem .5rem; }

/* Admin panel spacing and inputs */
#admin-panel { margin-top:.75rem; }
#adminConfigStatus { margin-bottom:.5rem; }
#adminOutput { margin-top:.5rem; }
#adminLogs { margin-top:.75rem; }
.update-group { margin-top:.5rem; }

#adminExeArgs,
#adminCacheClasses,
#searchBox,
#historyFilter,
#pastedHeader {
  flex: 1;
  padding: .5rem .75rem;
  background: var(--code-bg);
  color: var(--text);
  border: 1px solid var(--code-border);
  border-radius: .5rem;
}
#pastedHeader { width:100%; min-height:160px; }

#logsKeepInput {
  width:84px;
  padding:.4rem .5rem;
  background: var(--code-bg);
  color: var(--text);
  border:1px solid var(--code-border);
  border-radius:.4rem;
}

/* Lists and sections */
#searchResults { list-style:none; padding:.5rem; margin:.5rem 0 0; max-height:300px; overflow-y:auto; border:1px solid var(--code-border); border-radius:.5rem; }
#logsList { list-style:none; padding:0; margin:.5rem 0 0; max-height:240px; overflow-y:auto; border:1px solid var(--code-border); border-radius:.5rem; }
#dumpsList { list-style:none; padding:0; margin:.5rem 0 0; max-height:240px; overflow-y:auto; border:1px solid var(--code-border); border-radius:.5rem; }
#historyList { list-style:none; padding:0; margin:.5rem 0 0; }

/* Compare section summary spacing */
#compare-section > summary.muted { margin-bottom:.5rem; }
#compare-section { min-width: 90vh;}
/* Auto & search suggestions */
#autoSuggestions { margin-top:-.75rem; }
.search-item.selected,
.auto-item.selected { background: var(--code-bg); }

/* Separator */
.sep { border:none; border-top:1px solid var(--code-border); margin:.5rem 0; }

/* Header section details spacing */
details.section.card > summary.muted { margin-bottom:.5rem; }

/* Header-right rows spacing */
.header-right .row { margin-top:.5rem; }

/* History item row */
.history-item .row { gap:.5rem; margin:.5rem 0; }

/* Utility classes */
.row.between { justify-content: space-between; }
.row.mt-05 { margin:.5rem 0; }
.gap-1 { gap: 1rem; }
.mt-035 { margin-top: .35rem; }
.flex-1 { flex: 1; }
.section-title { margin-bottom:.25rem; }

/* Specific element tweaks */
h2#filename { margin: 0; }
#compareResult { margin-top:.5rem; }
#searchSuggestions { list-style:none; }
#adminConfigList { list-style:none; padding:0; margin:0; display:flex; flex-direction:column; gap:.35rem; }
#autoList, .searchList { list-style:none; padding:0; margin:0; max-height:240px; overflow-y:auto; border:1px solid var(--code-border); border-radius:.5rem; }

/* Card stacking spacing */
.card + .card { margin-top: .75rem; }
