:root {
  --bg: #0f1115;
  --panel: #171b22;
  --panel-2: #202635;
  --line: #323949;
  --text: #e9edf5;
  --muted: #aab3c5;
  --accent: rgba(124, 196, 255, 0.18);
  --accent-strong: rgba(124, 196, 255, 0.45);
  --radius: 14px;
  --shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  --sidebar-width: 340px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(180deg, #0c0f14 0%, #111521 100%);
  color: var(--text);
}

body {
  overflow: hidden;
}

body.resizing {
  cursor: col-resize;
  user-select: none;
}

.app {
  width: 100vw;
  height: 100vh;
  display: flex;
  gap: 0;
  padding: 12px;
}

.sidebar,
.main {
  background: rgba(23, 27, 34, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  min-width: 0;
}

.sidebar {
  flex: 0 0 var(--sidebar-width);
  min-width: 280px;
  max-width: 640px;
  display: flex;
  flex-direction: column;
}

.sidebar-resizer {
  flex: 0 0 10px;
  cursor: col-resize;
  position: relative;
  align-self: stretch;
}

.sidebar-resizer::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-1px);
  background: rgba(255, 255, 255, 0.05);
}

.main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.panel-header h1 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
}

.sidebar-tools {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.sidebar-tools input {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0f131b;
  color: var(--text);
  padding: 9px 11px;
  font-size: 13px;
}

.sidebar-tools input::placeholder {
  color: #8d96a8;
}

.sidebar-tools input:focus {
  outline: none;
  border-color: rgba(124, 196, 255, 0.5);
  box-shadow: 0 0 0 2px rgba(124, 196, 255, 0.12);
}

.sidebar-tools button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.sidebar-tools button:hover,
button:hover,
a.btn:hover {
  transform: translateY(-1px);
  background: #2a3141;
  border-color: #46506a;
}

.panel-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.sidebar-content {
  padding: 12px;
  overflow: auto;
  min-height: 0;
}

.search-results {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.search-results[hidden] {
  display: none;
}

.search-results-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.search-group {
  margin-top: 10px;
}

.search-group-title {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.search-result-item {
  width: 100%;
  text-align: left;
  display: block;
  margin: 0 0 8px;
}

.search-result-title {
  font-size: 13px;
  font-weight: 700;
}

.search-result-meta {
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
}

.search-result-snippet {
  margin-top: 5px;
  font-size: 12px;
  color: var(--text);
  opacity: 0.92;
  line-height: 1.45;
}

.search-empty {
  color: var(--muted);
  font-size: 12px;
  padding: 8px 2px;
}

details {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 10px;
}

details.flash-highlight,
.nested-block.flash-highlight {
  box-shadow: 0 0 0 1px var(--accent-strong), 0 0 0 3px rgba(124, 196, 255, 0.12);
}

summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 14px;
  font-weight: 700;
  user-select: none;
  background: rgba(255, 255, 255, 0.03);
}

summary::-webkit-details-marker {
  display: none;
}

.section-body {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.5;
}

.section-body > p {
  margin: 0 0 12px;
  color: var(--muted);
}

.nested-block {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 10px;
  padding: 10px;
  margin-top: 10px;
}

.nested-title {
  font-weight: 700;
  font-size: 13px;
  margin: 0 0 6px;
}

.nested-text {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.nested-body {
  display: block;
}

.stack,
.tabs,
.pages {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button,
a.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.active {
  background: var(--accent) !important;
  border-color: var(--accent-strong) !important;
}

.tabs {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  overflow: auto;
  flex: 0 0 auto;
}

.viewer-shell {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  flex: 1 1 auto;
}

.topbar {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  background: rgba(255, 255, 255, 0.015);
  flex: 0 0 auto;
}

.viewer-title {
  font-weight: 800;
  margin-right: 8px;
}

.frame {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background: #0b0d12;
  position: relative;
}

.viewer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  visibility: hidden;
  pointer-events: none;
}

.viewer.active {
  visibility: visible;
  pointer-events: auto;
}

iframe.pdf-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #fff;
}

code {
  color: #cfe7ff;
}

@media (max-width: 980px) {
  body { overflow: auto; }
  .app {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }
  .sidebar {
    flex: 0 0 auto;
    max-width: none;
  }
  .sidebar-resizer {
    display: none;
  }
  .main {
    min-height: 70vh;
  }
}
