/* === CSS variables for easy theming === */
:root {
  --bg: #0a0812;
  --surface: #120d1f;
  --surface-elevated: #1b132c;
  --border: #2d2247;
  --text: #efe9f8;
  --muted: #a89bc2;
  --accent: #8b5cf6;
  --accent-bright: #a78bfa;
  --accent-dim: #6d28d9;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
}

/* === reset and base === */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

/* === typography === */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Playfair Display', serif;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 0.75rem;
}
h1 { font-size: clamp(2rem, 7vw, 3rem); }
h2 { font-size: clamp(1.75rem, 6vw, 2.5rem); }
h3 { font-size: clamp(1.4rem, 4vw, 1.75rem); }
h4 { font-size: clamp(1.1rem, 3vw, 1.25rem); }
p { color: var(--muted); margin-bottom: 1rem; }
a:not(.nav-external) {
  color: var(--accent-bright);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s;
}
a:not(.nav-external):hover { color: var(--accent); }
strong { color: var(--text); }
em { color: var(--muted); }
code {
  background: var(--surface-elevated);
  color: var(--accent-bright);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 0.9em;
}
pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
  margin-bottom: 1.25rem;
}
ul, ol { margin: 0 0 1rem 1.5rem; color: var(--muted); }
li { margin-bottom: 0.35rem; }
blockquote {
  border-left: 4px solid var(--accent);
  background: var(--surface);
  padding: 0.75rem 1rem;
  border-radius: 0 8px 8px 0;
  margin-bottom: 1rem;
  color: var(--muted);
}
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* === top navigation === */
nav {
  background: var(--surface);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.nav-brand {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.5rem, 5vw, 1.85rem);
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.5px;
}

/* === nav buttons and external link === */
.nav-buttons {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
button, .nav-external {
  background: var(--surface-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.65rem 1.1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  min-height: 44px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
button:hover, .nav-external:hover {
  background: #261c3d;
  border-color: var(--accent);
  color: var(--text);
}
button.active, .nav-external.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.nav-external {
  background: transparent;
  color: var(--accent-bright);
  border: 1px dashed var(--accent);
}
.nav-external:hover {
  background: rgba(139, 92, 246, 0.12);
  color: var(--accent-bright);
}

/* === hamburger menu === */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 28px;
  height: 22px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  min-height: auto;
}
.hamburger span {
  display: block;
  height: 3px;
  width: 100%;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}
.hamburger.active span:nth-child(1) { transform: translateY(9.5px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: translateY(-9.5px) rotate(-45deg); }

/* === layout: main content + sidebar === */
.content-wrapper {
  flex: 1;
  display: flex;
  gap: 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  padding: 2.5rem 1.25rem;
}

main {
  flex: 1;
  min-width: 0;
}

.tab {
  display: none;
  animation: fadeIn 0.25s ease;
}
.tab.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === sidebar === */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  height: fit-content;
  position: sticky;
  top: 1.5rem;
}
.sidebar h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}
.sidebar h4 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: var(--accent-bright);
}
.sidebar p {
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}
.sidebar ul {
  margin: 0 0 0.75rem 1.25rem;
  font-size: 0.9rem;
}

/* === future-proof form and table styles === */
input, textarea, select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  font-family: inherit;
  font-size: 1rem;
  width: 100%;
  margin-bottom: 0.75rem;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
}
label {
  display: block;
  color: var(--muted);
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.25rem;
}
th, td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
th {
  color: var(--accent-bright);
  font-weight: 600;
  border-bottom: 2px solid var(--accent);
}
tr:hover td { background: var(--surface); }

/* === footer === */
footer {
  background: var(--surface);
  color: var(--muted);
  padding: 1.25rem;
  text-align: center;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

/* === mobile layout === */
@media (max-width: 640px) {
  .hamburger { display: flex; }
  .nav-buttons {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem;
    gap: 0.5rem;
  }
  .nav-buttons.open { display: flex; }
  .nav-buttons button, .nav-buttons .nav-external {
    width: 100%;
  }
  .content-wrapper {
    flex-direction: column;
    padding: 1.5rem 1.25rem;
  }
  .sidebar {
    width: 100%;
    position: static;
  }
}

/* === bookmark buttons in sidebar === */
.bookmark-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}
.bookmark {
  display: block;
  background: var(--surface-elevated);
  color: var(--accent-bright);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 0.6rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s;
}
.bookmark:hover {
  background: rgba(139, 92, 246, 0.12);
  border-color: var(--accent);
}
.hidden {
  display: none !important;
}