
:root {
  --bg: #0b0f17;
  --panel: #121827;
  --panel2: #172033;
  --text: #e9edf5;
  --muted: #aab3c5;
  --accent: #4aa3ff;
  --accent2: #7dd3fc;
  --danger: #ff6b6b;
  --ok: #4ade80;
  --warning: #fbbf24;
  --border: #2b3448;
  --shadow: rgba(0,0,0,.28);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}
.app {
  display: grid;
  grid-template-columns: 330px 1fr;
  height: 100vh;
}
.sidebar {
  background: linear-gradient(180deg, var(--panel), #0e1422);
  border-right: 1px solid var(--border);
  overflow: auto;
  padding: 18px 14px 28px;
}
.brand {
  font-weight: 800;
  font-size: 21px;
  line-height: 1.15;
  margin-bottom: 6px;
}
.subtitle {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 14px;
}
.search {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--panel);
  padding-bottom: 12px;
}
input[type="search"] {
  width: 100%;
  border: 1px solid var(--border);
  background: #0a0f1c;
  color: var(--text);
  border-radius: 12px;
  padding: 13px 12px;
  font-size: 16px;
  outline: none;
}
input[type="search"]:focus { border-color: var(--accent); }
.section {
  margin: 10px 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,.02);
  overflow: hidden;
}
.section summary {
  cursor: pointer;
  padding: 12px 12px;
  font-weight: 700;
  color: #fff;
  list-style: none;
}
.section summary::-webkit-details-marker { display: none; }
.section .desc {
  padding: 0 12px 10px;
  color: var(--muted);
  font-size: 12px;
}
.nav-item {
  display: block;
  padding: 10px 12px;
  margin: 3px 8px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}
.nav-item:hover, .nav-item.active {
  background: var(--panel2);
  color: var(--text);
}
.nav-code {
  color: var(--accent2);
  font-weight: 700;
}
.main {
  overflow: auto;
  padding: 22px;
}
.topbar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.pill {
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 8px 10px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
}
.hero {
  background: radial-gradient(circle at top left, rgba(74,163,255,.22), transparent 30%),
              linear-gradient(135deg, var(--panel), #0e1422);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 12px 32px var(--shadow);
  margin-bottom: 18px;
}
h1 { margin: 0 0 8px; font-size: 30px; }
h2 { margin: 20px 0 10px; font-size: 20px; }
h3 { margin: 18px 0 8px; font-size: 16px; color: var(--accent2); }
p { color: var(--muted); line-height: 1.5; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 8px 24px var(--shadow);
}
.card h3 { margin-top: 0; }
.card .code {
  display: inline-block;
  color: var(--accent2);
  font-weight: 800;
  margin-bottom: 6px;
}
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag {
  font-size: 12px;
  padding: 5px 8px;
  border-radius: 999px;
  background: #0b1221;
  color: var(--muted);
  border: 1px solid var(--border);
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}
button, .btn {
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  text-decoration: none;
  cursor: pointer;
  font-weight: 650;
}
button:hover, .btn:hover { border-color: var(--accent); }
.btn.primary {
  background: var(--accent);
  color: #04111f;
  border-color: var(--accent);
}
.viewer-wrap {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
iframe {
  width: 100%;
  height: 72vh;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
}
.quick-list {
  display: grid;
  gap: 9px;
}
.quick-item {
  border-left: 4px solid var(--accent);
  background: rgba(255,255,255,.03);
  padding: 10px 12px;
  border-radius: 10px;
}
.notice {
  border: 1px solid rgba(251,191,36,.35);
  background: rgba(251,191,36,.08);
  color: #ffe7a3;
  padding: 12px;
  border-radius: 14px;
}
.related a {
  display: inline-block;
  margin: 5px 6px 0 0;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--accent2);
  background: #0b1221;
}
@media (max-width: 900px) {
  body { overflow: auto; height: auto; }
  .app { grid-template-columns: 1fr; height: auto; }
  .sidebar { max-height: 42vh; }
  .main { overflow: visible; }
  iframe { height: 62vh; }
}
@media print {
  body { background: white; color: black; overflow: visible; }
  .sidebar, .topbar, .actions, iframe { display: none; }
  .app { display: block; }
  .main { padding: 0; }
  .card, .hero { border: 1px solid #ccc; box-shadow: none; background: white; color: black; }
  p, .subtitle, .tag { color: #333; }
}
.engine-run-floating {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9999;
  background: #4aa3ff;
  color: #04111f;
  padding: 15px 19px;
  border-radius: 16px;
  font-weight: 900;
  text-decoration: none;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
  border: 1px solid rgba(255,255,255,.25);
}

.engine-run-floating:hover {
  filter: brightness(1.08);
}

@media (max-width: 900px) {
  .engine-run-floating {
    left: 14px;
    right: 14px;
    bottom: 14px;
    text-align: center;
  }
}
