:root {
  --bg: #0f1419;
  --panel: #1a222c;
  --border: #2c3848;
  --text: #e7eef7;
  --muted: #8b9bb0;
  --accent: #4ea1ff;
  --h2: #ff6b6b;
  --ch32h: #ffb020;
  --ome: #3ecf8e;
  --disabled: #556274;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; flex-direction: column; gap: 0.15rem; }
.muted { color: var(--muted); font-size: 0.8rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.toolbar label { font-size: 0.85rem; color: var(--muted); display: flex; gap: 0.35rem; align-items: center; }
.toolbar select, .toolbar button, .file-btn {
  background: #243041;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  font-size: 0.85rem;
}
.toolbar button:hover, .file-btn:hover { border-color: var(--accent); }
.toolbar button[aria-pressed="true"] { background: #1e4d7a; border-color: var(--accent); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(240px, 300px) 1fr minmax(220px, 280px);
  min-height: 0;
}
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 40vh 45vh auto; }
}

.sidebar, .meta {
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow: auto;
  padding: 0.75rem;
}
.meta { border-right: none; border-left: 1px solid var(--border); }
.filters { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.5rem; }
#searchBox {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #121820;
  color: var(--text);
}
.chips { display: flex; flex-wrap: wrap; gap: 0.6rem; font-size: 0.82rem; color: var(--muted); }
.chips label { display: flex; align-items: center; gap: 0.25rem; cursor: pointer; }
.legend { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  font-weight: 600;
}
.badge.h2 { background: color-mix(in srgb, var(--h2) 25%, transparent); color: var(--h2); }
.badge.ch32h { background: color-mix(in srgb, var(--ch32h) 25%, transparent); color: var(--ch32h); }
.badge.ome { background: color-mix(in srgb, var(--ome) 25%, transparent); color: var(--ome); }
.count { font-size: 0.78rem; color: var(--muted); margin: 0; }

.struct-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.struct-list li {
  padding: 0.55rem 0.6rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  margin-bottom: 0.35rem;
  background: #121820;
}
.struct-list li:hover { border-color: var(--border); }
.struct-list li.active { border-color: var(--accent); background: #1a2a3d; }
.struct-list li.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.struct-list .title { font-size: 0.88rem; font-weight: 600; line-height: 1.3; }
.struct-list .sub { font-size: 0.72rem; color: var(--muted); margin-top: 0.2rem; display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.struct-list .sys {
  text-transform: uppercase;
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: #2a3544;
}
.struct-list .sys.ionic { background: #3a2a4a; }
.struct-list .sys.neutral { background: #2a3a4a; }

.main {
  position: relative;
  min-height: 320px;
  background: #0a0e13;
}
.viewer { position: absolute; inset: 0; }
.drop-hint {
  position: absolute;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 0.85rem;
  pointer-events: none;
  background: rgba(15, 20, 25, 0.7);
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  border: 1px dashed var(--border);
}
.main.dragover .drop-hint {
  color: var(--accent);
  border-color: var(--accent);
}
.main.dragover::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 2px dashed var(--accent);
  border-radius: 12px;
  pointer-events: none;
}

.meta h2 { margin: 0 0 0.75rem; font-size: 1rem; }
.meta dl {
  margin: 0;
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 0.45rem 0.6rem;
  font-size: 0.85rem;
}
.meta dt { color: var(--muted); }
.meta dd { margin: 0; word-break: break-word; }
.meta a { color: var(--accent); }
.status {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--muted);
}
.status.error { color: #ff8a8a; }
.status.ok { color: var(--ome); }

.csp-banner { background:#5c3d00; color:#ffe6b0; padding:0.5rem 1rem; font-size:0.85rem; border-bottom:1px solid #8a6a20; }
.csp-banner code { background:#3a2800; padding:0.1rem 0.35rem; border-radius:4px; }
.boot-banner { background:#1e3a5f; color:#cfe6ff; padding:0.5rem 1rem; font-size:0.85rem; border-bottom:1px solid #2c5a8a; }
.boot-banner[hidden] { display: none !important; }
.static-item[role="button"] { cursor: pointer; }
.static-item[role="button"]:hover { border-color: var(--border); }
