/* =============================================
   PasteMD – Main Stylesheet
   ============================================= */

:root {
  --color-bg: #0f172a;
  --color-surface: #1e293b;
  --color-border: #334155;
  --color-border-hover: #475569;
  --color-text: #f1f5f9;
  --color-text-secondary: #cbd5e1;
  --color-text-muted: #64748b;
  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-primary-light: #1e3a5f;
  --color-success: #16a34a;
  --color-success-light: #14532d;
  --color-warning: #d97706;
  --color-warning-light: #451a03;
  --color-error: #dc2626;
  --color-error-light: #450a0a;
  --color-code-bg: #1e293b;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.4);
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, monospace;
  --transition: 150ms ease;
  --navbar-height: 60px;
}

[data-theme="light"], .light {
  --color-bg: #ffffff;
  --color-surface: #f8fafc;
  --color-border: #e2e8f0;
  --color-border-hover: #cbd5e1;
  --color-text: #0f172a;
  --color-text-secondary: #475569;
  --color-text-muted: #94a3b8;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-light: #eff6ff;
  --color-success-light: #f0fdf4;
  --color-warning-light: #fffbeb;
  --color-error-light: #fef2f2;
  --color-code-bg: #f1f5f9;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

[data-theme="dark"], .dark {
  --color-bg: #0f172a;
  --color-surface: #1e293b;
  --color-border: #334155;
  --color-border-hover: #475569;
  --color-text: #f1f5f9;
  --color-text-secondary: #cbd5e1;
  --color-text-muted: #64748b;
  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-primary-light: #1e3a5f;
  --color-success-light: #14532d;
  --color-warning-light: #451a03;
  --color-error-light: #450a0a;
  --color-code-bg: #1e293b;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.4);
}

@media (prefers-color-scheme: light) {
  [data-theme="auto"] {
    --color-bg: #ffffff;
    --color-surface: #f8fafc;
    --color-border: #e2e8f0;
    --color-border-hover: #cbd5e1;
    --color-text: #0f172a;
    --color-text-secondary: #475569;
    --color-text-muted: #94a3b8;
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-primary-light: #eff6ff;
    --color-code-bg: #f1f5f9;
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition), color var(--transition);
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; }
code { font-family: var(--font-mono); }

.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* ─── Navbar ─── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  height: var(--navbar-height);
  backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--color-bg) 90%, transparent);
}
.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  gap: 16px;
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text);
  font-weight: 600;
  font-size: 17px;
  text-decoration: none;
}
.navbar-brand:hover { text-decoration: none; }
.navbar-menu {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-link {
  color: var(--color-text-secondary);
  font-size: 14px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  text-decoration: none;
}
.nav-link:hover { color: var(--color-text); background: var(--color-surface); text-decoration: none; }
.navbar-toggle { display: none; background: none; border: none; cursor: pointer; padding: 8px; flex-direction: column; gap: 4px; }
.navbar-toggle span { display: block; width: 20px; height: 2px; background: var(--color-text); border-radius: 2px; transition: var(--transition); }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
  user-select: none;
  position: relative;
  overflow: hidden;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.btn:disabled, .btn.loading { opacity: 0.6; cursor: not-allowed; pointer-events: none; }

.btn-primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); color: #fff; }
.btn-ghost { background: transparent; color: var(--color-text-secondary); border-color: transparent; }
.btn-ghost:hover { background: var(--color-surface); color: var(--color-text); }
.btn-outline { background: transparent; color: var(--color-text); border-color: var(--color-border); }
.btn-outline:hover { background: var(--color-surface); border-color: var(--color-border-hover); }

.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-xs { padding: 3px 8px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 15px; }
.btn-xl { padding: 14px 28px; font-size: 16px; border-radius: var(--radius); }
.btn-full { width: 100%; justify-content: center; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--color-surface); color: var(--color-text); }
.btn-icon:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: none;
}
.btn.loading .btn-text { opacity: 0; }
.btn.loading .btn-spinner { display: inline-block; position: absolute; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Forms ─── */
.form-group { margin-bottom: 20px; }
.form-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 6px;
}
.form-label-link { font-size: 13px; font-weight: 400; color: var(--color-primary); }
.form-optional { font-weight: 400; color: var(--color-text-muted); font-size: 12px; }
.form-hint { font-size: 12px; color: var(--color-text-muted); margin-top: 5px; }
.form-error { font-size: 12px; color: var(--color-error); margin-top: 5px; min-height: 0; }
.form-control.is-invalid { border-color: var(--color-error); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-error) 20%, transparent); }

.form-control, .form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  box-shadow: var(--shadow-xs);
}
.form-control:hover, .form-select:hover {
  border-color: var(--color-border-hover);
}
.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 15%, transparent);
}
.form-control::placeholder { color: var(--color-text-muted); }
textarea.form-control { resize: vertical; min-height: 80px; line-height: 1.5; }

.form-select {
  cursor: pointer;
  background-color: var(--color-bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23cbd5e1' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 14px 14px;
  padding-right: 40px;
}
[data-theme="light"] .form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: light) {
  [data-theme="auto"] .form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  }
}
.form-select option, .form-select optgroup {
  background: var(--color-surface);
  color: var(--color-text);
  padding: 8px;
}

.input-group { position: relative; display: flex; }
.input-group .form-control { flex: 1; }
.input-action {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 4px;
  display: flex;
  align-items: center;
}
.input-action:hover { color: var(--color-text); }

.input-addon { display: flex; }
.input-addon-text {
  padding: 8px 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  font-size: 14px;
  color: var(--color-text-muted);
  white-space: nowrap;
}
.input-addon .form-control { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.form-alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
}
.form-alert-success { background: var(--color-success-light); color: var(--color-success); border: 1px solid color-mix(in srgb, var(--color-success) 30%, transparent); }
.form-alert-error { background: var(--color-error-light); color: var(--color-error); border: 1px solid color-mix(in srgb, var(--color-error) 30%, transparent); }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
}
.checkbox-label input[type="checkbox"] { display: none; }
.checkbox-custom {
  width: 16px;
  height: 16px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  transition: all var(--transition);
}
.checkbox-label input:checked + .checkbox-custom {
  background: var(--color-primary);
  border-color: var(--color-primary);
}
.checkbox-label input:checked + .checkbox-custom::after {
  content: '';
  width: 4px;
  height: 7px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
}

.toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}
.toggle { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--color-border);
  border-radius: var(--radius-full);
  transition: background var(--transition);
  cursor: pointer;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: transform var(--transition);
  box-shadow: var(--shadow-xs);
}
.toggle input:checked ~ .toggle-slider { background: var(--color-primary); }
.toggle input:checked ~ .toggle-slider::before { transform: translateX(18px); }

/* ─── Password strength ─── */
.password-strength { margin-top: 8px; }
.strength-bar { height: 4px; background: var(--color-border); border-radius: 2px; margin-bottom: 4px; }
.strength-fill { height: 100%; border-radius: 2px; transition: all 0.3s; width: 0; }
.strength-label { font-size: 11px; color: var(--color-text-muted); }

/* ─── Auth pages ─── */
.auth-page { background: var(--color-surface); }
.auth-container {
  min-height: calc(100vh - var(--navbar-height));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 36px;
  box-shadow: var(--shadow-lg);
}
.auth-header { text-align: center; margin-bottom: 28px; }
.auth-title { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; margin-bottom: 6px; }
.auth-subtitle { color: var(--color-text-secondary); font-size: 14px; }
.auth-form { margin-bottom: 20px; }
.auth-footer { text-align: center; font-size: 14px; color: var(--color-text-secondary); }
.auth-terms { font-size: 12px; color: var(--color-text-muted); text-align: center; margin-top: 12px; }

/* ─── Dropdown ─── */
.dropdown { position: relative; }
.dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--color-text);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-sans);
}
.dropdown-trigger:hover { background: var(--color-surface); }
.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 180px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all var(--transition);
}
.dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--color-text);
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-sans);
  text-decoration: none;
  transition: background var(--transition);
}
.dropdown-item:hover { background: var(--color-surface); text-decoration: none; }
.dropdown-divider { border: none; border-top: 1px solid var(--color-border); margin: 4px 0; }

/* ─── Avatar ─── */
.avatar { border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.avatar-xs { width: 28px; height: 28px; font-size: 11px; }
.avatar-sm { width: 32px; height: 32px; font-size: 13px; }
.avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  color: #fff;
  font-weight: 600;
}

/* ─── Badge ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-default { background: var(--color-surface); color: var(--color-text-secondary); border: 1px solid var(--color-border); }
.badge-public { background: var(--color-success-light); color: var(--color-success); }
.badge-private { background: var(--color-surface); color: var(--color-text-muted); border: 1px solid var(--color-border); }
.badge-locked { background: var(--color-warning-light); color: var(--color-warning); }
.badge-error { background: var(--color-error-light); color: var(--color-error); }
.badge-success { background: var(--color-success-light); color: var(--color-success); }
.badge-warning { background: var(--color-warning-light); color: var(--color-warning); }
.badge-admin { background: var(--color-primary-light); color: var(--color-primary); }
.badge-code { background: var(--color-code-bg); color: var(--color-text-secondary); font-family: var(--font-mono); font-size: 11px; padding: 2px 6px; border-radius: 4px; }

/* ─── Document cards ─── */
.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.doc-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
  position: relative;
}
.doc-card:hover { border-color: var(--color-border-hover); box-shadow: var(--shadow-md); }
.doc-card-link { text-decoration: none; color: inherit; }
.doc-card-link:hover { text-decoration: none; }
.doc-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.doc-card-badges { display: flex; gap: 4px; flex-wrap: wrap; }
.doc-card-actions { display: flex; gap: 2px; opacity: 0; transition: opacity var(--transition); }
.doc-card:hover .doc-card-actions { opacity: 1; }
.doc-card-body { flex: 1; min-width: 0; }
.doc-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.doc-card-desc {
  font-size: 13px;
  color: var(--color-text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.doc-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--color-text-muted);
}
.doc-stat { display: inline-flex; align-items: center; gap: 4px; }

/* ─── Hero ─── */
.hero {
  padding: 80px 0;
  text-align: center;
  background: linear-gradient(to bottom, var(--color-primary-light), transparent 60%);
}
.hero-inner { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid color-mix(in srgb, var(--color-primary) 20%, transparent);
}
.hero-title {
  font-size: clamp(36px, 5vw, 60px);
  font-weight: 700;
  letter-spacing: -1.5px;
  line-height: 1.1;
}
.hero-accent { color: var(--color-primary); }
.hero-subtitle { font-size: 18px; color: var(--color-text-secondary); max-width: 520px; line-height: 1.6; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

/* ─── Features ─── */
.features { padding: 80px 0; }
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}
.feature-card {
  padding: 24px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.feature-card:hover { border-color: var(--color-primary); box-shadow: var(--shadow-md); }
.feature-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.feature-title { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.feature-desc { font-size: 14px; color: var(--color-text-secondary); line-height: 1.6; }

/* ─── CTA ─── */
.cta-section {
  padding: 80px 0;
  background: var(--color-primary);
  text-align: center;
}
.cta-inner { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.cta-title { font-size: 32px; font-weight: 700; color: #fff; letter-spacing: -0.5px; }
.cta-subtitle { font-size: 16px; color: rgba(255,255,255,0.8); }
.cta-section .btn-primary { background: #fff; color: var(--color-primary); border-color: #fff; }
.cta-section .btn-primary:hover { background: #f0f9ff; }

/* ─── Dashboard layout ─── */
.dashboard-layout { padding: 32px 0; }
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-title { font-size: 24px; font-weight: 700; letter-spacing: -0.3px; }
.page-subtitle { font-size: 14px; color: var(--color-text-secondary); margin-top: 2px; }

/* ─── Filter bar ─── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  flex: 1;
  min-width: 200px;
}
.search-box svg { color: var(--color-text-muted); flex-shrink: 0; }
.search-input { border: none; background: none; font-size: 14px; color: var(--color-text); outline: none; flex: 1; font-family: var(--font-sans); }
.search-input::placeholder { color: var(--color-text-muted); }
.filter-group { display: flex; gap: 8px; }

/* ─── View layout (document reading) ─── */
.view-layout {
  display: grid;
  grid-template-columns: 220px 1fr 200px;
  gap: 32px;
  padding: 40px 0;
}
.view-sidebar-left, .view-sidebar-right { position: sticky; top: calc(var(--navbar-height) + 20px); align-self: start; }
.view-article { min-width: 0; }
.toc-card, .info-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.toc-title, .info-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); margin-bottom: 10px; }
.toc-nav { display: flex; flex-direction: column; gap: 2px; }
.toc-link { font-size: 13px; color: var(--color-text-secondary); padding: 3px 0; text-decoration: none; line-height: 1.4; }
.toc-link:hover { color: var(--color-primary); }
.toc-level-2 { padding-left: 10px; }
.toc-level-3 { padding-left: 20px; font-size: 12px; }
.info-list { display: flex; flex-direction: column; gap: 8px; }
.info-list dt { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); margin-top: 4px; }
.info-list dd { font-size: 13px; color: var(--color-text-secondary); }

/* ─── Document header (view page) ─── */
.doc-header { margin-bottom: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--color-border); }
.doc-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 13px; flex-wrap: wrap; }
.doc-author { display: flex; align-items: center; gap: 6px; color: var(--color-text); font-weight: 500; text-decoration: none; }
.doc-author:hover { color: var(--color-primary); }
.doc-meta-sep { color: var(--color-text-muted); }
.doc-date, .doc-views, .doc-read-time { color: var(--color-text-muted); }
.doc-title { font-size: 32px; font-weight: 700; letter-spacing: -0.5px; line-height: 1.2; margin-bottom: 10px; }
.doc-description { font-size: 16px; color: var(--color-text-secondary); margin-bottom: 16px; line-height: 1.6; }
.doc-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.doc-footer { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.doc-share { display: flex; align-items: center; gap: 6px; }
.share-btn { color: var(--color-text-muted); }
.share-btn:hover { color: var(--color-primary); }

/* ─── Markdown body ─── */
.markdown-body {
  font-size: 16px;
  line-height: 1.75;
  color: var(--color-text);
  max-width: 100%;
}
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.3;
  margin-top: 2em;
  margin-bottom: 0.75em;
  position: relative;
}
.markdown-body h1 { font-size: 2em; border-bottom: 1px solid var(--color-border); padding-bottom: 0.3em; }
.markdown-body h2 { font-size: 1.5em; border-bottom: 1px solid var(--color-border); padding-bottom: 0.2em; }
.markdown-body h3 { font-size: 1.25em; }
.markdown-body p { margin-bottom: 1.2em; }
.markdown-body ul, .markdown-body ol { padding-left: 1.5em; margin-bottom: 1.2em; }
.markdown-body li { margin-bottom: 0.4em; }
.markdown-body a { color: var(--color-primary); }
.markdown-body a:hover { text-decoration: underline; }
.markdown-body blockquote {
  border-left: 3px solid var(--color-primary);
  padding: 1em 1.2em;
  margin: 1.5em 0;
  color: var(--color-text-secondary);
  background: var(--color-primary-light);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--color-code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--color-text);
}
.markdown-body .hljs-pre {
  position: relative;
  margin: 1.5em 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: #1e293b;
}
.markdown-body .hljs-pre code {
  display: block;
  overflow-x: auto;
  padding: 20px;
  font-size: 14px;
  line-height: 1.6;
  background: transparent;
  color: #e2e8f0;
}
.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 5px 8px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 5px;
  cursor: pointer;
  color: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  transition: all var(--transition);
  font-size: 11px;
  gap: 4px;
}
.copy-btn:hover { background: rgba(255,255,255,0.2); color: #fff; }
.markdown-body table { width: 100%; border-collapse: collapse; margin: 1.5em 0; font-size: 14px; }
.markdown-body th, .markdown-body td { border: 1px solid var(--color-border); padding: 8px 12px; text-align: left; }
.markdown-body th { background: var(--color-surface); font-weight: 600; }
.markdown-body tr:nth-child(even) { background: var(--color-surface); }
.markdown-body img { max-width: 100%; border-radius: var(--radius); }
.markdown-body hr { border: none; border-top: 1px solid var(--color-border); margin: 2em 0; }
.markdown-body .task-list-item { list-style: none; margin-left: -1.5em; }
.markdown-body .task-list-item input { margin-right: 6px; }
.header-anchor { opacity: 0; color: var(--color-text-muted); margin-left: 6px; font-size: 0.8em; text-decoration: none; }
h1:hover .header-anchor, h2:hover .header-anchor, h3:hover .header-anchor { opacity: 1; }

/* ─── Section / explore ─── */
.explore-section { padding: 60px 0; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.section-title { font-size: 20px; font-weight: 700; }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--color-bg);
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border);
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--color-border); display: flex; justify-content: flex-end; gap: 8px; }

/* ─── Toast ─── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: slideIn 0.2s ease;
  min-width: 200px;
}
.toast-success { background: #1a2e1a; color: #86efac; border: 1px solid #166534; }
.toast-error { background: #2e1a1a; color: #fca5a5; border: 1px solid #991b1b; }
.toast-info { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); }
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }

/* ─── Empty & error states ─── */
.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 60px 24px;
  text-align: center;
}
.empty-state-icon { color: var(--color-text-muted); }
.empty-state-title { font-size: 18px; font-weight: 600; }
.empty-state-desc { color: var(--color-text-secondary); font-size: 14px; max-width: 300px; }

.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 80px 16px;
  text-align: center;
}
.error-code { font-size: 96px; font-weight: 800; color: var(--color-border); letter-spacing: -4px; line-height: 1; }
.error-title { font-size: 24px; font-weight: 700; }
.error-desc { color: var(--color-text-secondary); }

/* ─── Pagination ─── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 20px 0; }
.pagination-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  text-decoration: none;
  transition: all var(--transition);
}
.pagination-btn:hover { background: var(--color-surface); border-color: var(--color-border-hover); text-decoration: none; }
.pagination-info { font-size: 14px; color: var(--color-text-secondary); }

/* ─── Footer ─── */
.footer { border-top: 1px solid var(--color-border); padding: 24px 0; margin-top: auto; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; }
.footer-brand { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.footer-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.footer-link { color: var(--color-text-muted); font-size: 13px; padding: 4px 8px; border-radius: var(--radius-sm); text-decoration: none; }
.footer-link:hover { color: var(--color-text); text-decoration: none; }

/* ─── Misc ─── */
.text-muted { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-error { color: var(--color-error); }
.text-right { text-align: right; }
.text-nowrap { white-space: nowrap; }

/* ─── Theme toggle ─── */
.theme-toggle .icon-moon { display: block; }
.theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
@media (prefers-color-scheme: light) {
  [data-theme="auto"] .theme-toggle .icon-moon { display: none; }
  [data-theme="auto"] .theme-toggle .icon-sun { display: block; }
}

/* ─── User profile page ─── */
.user-cell { display: flex; align-items: center; gap: 8px; }
.user-name { font-size: 14px; font-weight: 500; }
.user-email { font-size: 12px; }

/* ─── Responsive ─── */
@media (max-width: 1024px) {
  .view-layout { grid-template-columns: 1fr; }
  .view-sidebar-left, .view-sidebar-right { position: static; display: none; }
}
@media (max-width: 768px) {
  .navbar-menu { display: none; flex-direction: column; position: absolute; top: var(--navbar-height); left: 0; right: 0; background: var(--color-bg); border-bottom: 1px solid var(--color-border); padding: 12px; z-index: 99; }
  .navbar-menu.open { display: flex; }
  .navbar-toggle { display: flex; }
  .docs-grid { grid-template-columns: 1fr; }
  .features-grid { grid-template-columns: 1fr; }
  .hero { padding: 48px 0; }
  .auth-card { padding: 24px; }
  .page-header { flex-direction: column; }
  .filter-bar { flex-direction: column; align-items: stretch; }
}
