/* Copied from StaffHandbook with same variables and features */
:root {
  --app-padding: 24px;
  --sidebar-width: 280px;
  --radius: 10px;
  --font-scale: 1;
  --sticky-offset: 100px; /* keeps sidebar below sticky header */
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #f5f5f5;
  --text: #111111;
  --muted: #555555;
  --accent: #000000;
  --accent-2: #000000;
  --border: #e5e7eb;
  --shadow: 0 6px 20px rgba(0,0,0,0.08);
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --panel: #151924;
  --panel-2: #1b2130;
  --text: #e7eaf0;
  --muted: #a9b0bf;
  --accent: #e7eaf0;
  --accent-2: #e7eaf0;
  --border: #2a3246;
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
  font-size: calc(16px * var(--font-scale));
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--app-padding);
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}
.app-title {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.3px;
}
.app-actions {
  display: flex;
  gap: 8px;
}
.nav-btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.nav-btn:hover { background: #eef2f7; border-color: #d0d7e2; }
.nav-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.nav-btn:hover { background: #f0f0f0; border-color: #dcdcdc; }
:root[data-theme="dark"] .nav-btn:hover { background: #20283b; border-color: #3a4563; }

.app-layout {
  display: grid;
  grid-template-columns: minmax(220px, var(--sidebar-width)) 1fr;
  gap: var(--app-padding);
  padding: var(--app-padding);
}

.sidebar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  min-height: calc(100vh - 160px);
  box-shadow: var(--shadow);
  position: sticky;
  top: var(--sticky-offset);
  align-self: start;
  max-height: calc(100vh - (var(--app-padding) * 2));
  overflow: auto;
}
.sidebar-header {
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  margin: 4px 4px 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.chapters {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.chapter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.05s ease;
}
.chapter-item:hover {
  background: var(--panel-2);
  border-color: var(--border);
}
.chapter-item.active {
  background: #f2f2f2;
  border-color: #dcdcdc;
}
:root[data-theme="dark"] .chapter-item.active {
  background: linear-gradient(180deg, rgba(77,163,255,0.12) 0%, rgba(77,163,255,0.06) 100%);
  border-color: #33507a;
}
.chapter-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  font-size: 12px;
  color: var(--text);
  background: #f2f2f2;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
}
:root[data-theme="dark"] .chapter-index {
  color: #7bd6ff;
  background: rgba(123,214,255,0.14);
  border: 1px solid rgba(123,214,255,0.35);
}
.chapter-title {
  flex: 1;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: calc(100vh - 160px);
  box-shadow: var(--shadow);
}
.content-inner {
  padding: calc(var(--app-padding) + 4px);
  max-width: 1120px;
}
/* line numbering disabled in ServerRulebook */
.content-inner h1, .content-inner h2, .content-inner h3 {
  line-height: 1.25;
  margin: 1.2em 0 0.4em;
}
.content-inner h1 { font-size: calc(28px * var(--font-scale)); }
.content-inner h2 { font-size: calc(22px * var(--font-scale)); }
.content-inner h3 { font-size: calc(18px * var(--font-scale)); }
.content-inner p { color: var(--text); }
.content-inner a { color: var(--text); text-decoration: underline; }
.content-inner code, .content-inner pre {
  background: #f7f7f7;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
}
.content-inner pre, .content-inner code { font-size: calc(14px * var(--font-scale)); }
:root[data-theme="dark"] .content-inner code, :root[data-theme="dark"] .content-inner pre {
  background: #0e1320;
  border: 1px solid #262f48;
}
.content-inner code { padding: 2px 6px; }
.content-inner pre { padding: 14px; overflow: auto; }

.empty-state {
  color: var(--muted);
}

.message-bar {
  position: fixed;
  left: var(--app-padding);
  right: var(--app-padding);
  bottom: var(--app-padding);
  padding: 12px 14px;
  border-radius: 10px;
  background: #f7f7f7;
  border: 1px solid #e0e0e0;
  color: #111111;
  box-shadow: 0 10px 30px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.6);
}
:root[data-theme="dark"] .message-bar {
  background: #0d1627;
  border: 1px solid #173058;
  color: #b3d7ff;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.04);
}

/* Section highlight on deep-link navigation */
.target-highlight {
  background: rgba(255, 235, 59, 0.35);
  border-radius: 8px;
  transition: background 0.6s ease;
}
:root[data-theme="dark"] .target-highlight {
  background: rgba(255, 221, 87, 0.20);
}

@media (max-width: 960px) {
  .app-layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    min-height: auto;
    position: static;
    max-height: none;
    overflow: visible;
  }
  .content {
    min-height: auto;
  }
}


