:root {
  --bg: #0b1020;
  --panel: #101a33;
  --panel2: #0f1830;
  --text: #e8ecff;
  --muted: rgba(232, 236, 255, 0.65);
  --border: rgba(232, 236, 255, 0.12);
  --accent: #7c5cff;
  --accent2: #2ee9a6;
  --danger: #ff5c7a;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Liberation Sans",
    sans-serif;
}

html {
  background: var(--bg);
}

body {
  position: relative;
  min-height: 100vh;
}

/* Fixed gradient background (doesn't scroll with content) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(1000px 700px at 10% 0%, rgba(124, 92, 255, 0.18), transparent),
    radial-gradient(800px 500px at 80% 20%, rgba(46, 233, 166, 0.12), transparent),
    var(--bg);
}

.topbar {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(16, 26, 51, 0.7);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 800;
  letter-spacing: 0.2px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.link {
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}
.link:hover {
  border-color: rgba(124, 92, 255, 0.55);
}

/* Mobile hamburger + drawer nav (shown only on small screens) */
.hamburger {
  display: none;
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 40;
  width: 54px;
  height: 54px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(16, 26, 51, 0.78);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  cursor: pointer;
  padding: 0;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-direction: column;
}

.hamburger__line {
  width: 22px;
  height: 2px;
  background: rgba(232, 236, 255, 0.92);
  border-radius: 999px;
}

.hamburger:active {
  transform: translateY(1px);
}

.drawer {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 60;
}

.drawer.is-open {
  display: block;
}

.drawer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.drawer__panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 92vh;
  background: rgba(16, 26, 51, 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.drawer__title {
  font-weight: 900;
  letter-spacing: 0.3px;
}

.drawer__iconbtn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.drawer__iconbtn:active {
  transform: translateY(1px);
}

.drawer__body {
  padding: 12px;
  overflow: auto;
}

.drawer__section[hidden] {
  display: none !important;
}

body.nav-lock {
  overflow: hidden;
}

.layout {
  display: grid;
  grid-template-columns: 320px 320px 1fr;
  /* One global scrollbar: remove fixed viewport height so the page scrolls as a whole */
  align-items: start;
}

.panel {
  border-right: 1px solid var(--border);
  background: rgba(16, 26, 51, 0.45);
  backdrop-filter: blur(8px);
}

.panel__header {
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--border);
}

.panel__title {
  font-weight: 700;
  margin-bottom: 8px;
}

.panel__body {
  padding: 10px;
  /* One global scrollbar */
  overflow: visible;
  height: auto;
}

.input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  outline: none;
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
}
.input:focus {
  border-color: rgba(124, 92, 255, 0.65);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.15);
}

.grid {
  display: grid;
  gap: 8px;
}

.group + .group {
  margin-top: 12px;
}

.group__title {
  margin: 6px 2px 8px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.6px;
  color: var(--muted);
  text-transform: uppercase;
}

.grid--books {
  /* Same tile size as chapters */
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
}

.grid--chapters {
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
}

.tile {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: transform 80ms ease, border-color 120ms ease, background 120ms ease;
  box-shadow: 0 0 0 rgba(0, 0, 0, 0);
}

.tile:hover {
  transform: translateY(-1px);
  border-color: rgba(124, 92, 255, 0.55);
  background: rgba(124, 92, 255, 0.08);
}

.tile.is-active {
  border-color: rgba(46, 233, 166, 0.6);
  background: rgba(46, 233, 166, 0.08);
}

.tile--book {
  font-weight: 900;
  letter-spacing: 0.6px;
  font-size: 12px;
}

.tile--chapter {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
  font-size: 14px;
}

.tile--chapter[data-chapter="README"] {
  border-color: rgba(124, 92, 255, 0.35);
  background: rgba(124, 92, 255, 0.06);
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item {
  text-align: left;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
  padding: 10px 12px;
  color: var(--text);
  cursor: pointer;
  transition: transform 80ms ease, border-color 120ms ease, background 120ms ease;
}
.item:hover {
  transform: translateY(-1px);
  border-color: rgba(124, 92, 255, 0.55);
  background: rgba(124, 92, 255, 0.08);
}
.item.is-active {
  border-color: rgba(46, 233, 166, 0.6);
  background: rgba(46, 233, 166, 0.08);
}

.item__title {
  font-weight: 700;
  line-height: 1.2;
}

.item__meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(124, 92, 255, 0.45);
  background: rgba(124, 92, 255, 0.12);
  color: var(--text);
  vertical-align: middle;
}

.content {
  /* One global scrollbar */
  overflow: visible;
  padding: 16px 18px 60px;
}

.content__header {
  padding: 4px 0 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.content__title {
  font-size: 18px;
  font-weight: 900;
  margin-bottom: 6px;
}

.loading,
.empty,
.hint {
  color: var(--muted);
  padding: 12px;
}

.error {
  border: 1px solid rgba(255, 92, 122, 0.35);
  background: rgba(255, 92, 122, 0.08);
  border-radius: 14px;
  padding: 12px;
}
.error__title {
  font-weight: 800;
  margin-bottom: 6px;
  color: rgba(255, 92, 122, 0.95);
}
.error__msg {
  color: rgba(232, 236, 255, 0.85);
}

.markdown {
  max-width: 980px;
  line-height: 1.55;
}

.markdown h1,
.markdown h2,
.markdown h3 {
  line-height: 1.25;
}
.markdown h1 {
  font-size: 28px;
  margin: 18px 0 10px;
}
.markdown h2 {
  font-size: 22px;
  margin: 18px 0 10px;
}
.markdown h3 {
  font-size: 18px;
  margin: 16px 0 8px;
}
.markdown p {
  margin: 10px 0;
}
.markdown ul,
.markdown ol {
  margin: 10px 0 10px 22px;
}
.markdown li {
  margin: 6px 0;
}
.markdown a {
  color: var(--accent2);
}
.markdown code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95em;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(232, 236, 255, 0.12);
  padding: 2px 6px;
  border-radius: 8px;
}
.markdown pre {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(232, 236, 255, 0.12);
  border-radius: 14px;
  padding: 12px;
  overflow: auto;
  box-shadow: var(--shadow);
}
.markdown pre code {
  background: transparent;
  border: 0;
  padding: 0;
}
.markdown blockquote {
  margin: 14px 0;
  padding: 10px 12px;
  border-left: 4px solid rgba(124, 92, 255, 0.7);
  background: rgba(124, 92, 255, 0.08);
  border-radius: 10px;
}
.markdown hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 300px 300px 1fr;
  }
}

@media (max-width: 980px) {
  .hamburger {
    display: flex;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  /* Mobile nav lives in drawer; keep reading area clean */
  .panel--books,
  .panel--chapters {
    display: none;
  }

  .panel {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .panel__body {
    height: auto;
    max-height: none;
  }

  /* Make sure fixed hamburger doesn't cover the last lines */
  .content {
    padding-bottom: 120px;
  }
}


