/* ===== The Threshing Floor — Design Language ===== */
/* A Jacob E. Thomas artifact. Dark ground, ember gold, ritual composure. */
/* Cloudflare Pages Edition — zero-dependency, no-code deployment. */

/* --- CSS Custom Properties --- */
:root {
  --ground: #0A0A0F;
  --surface: #131318;
  --surface-raised: #1A1A22;

  --ember: #C9A227;
  --ember-dim: #8B7121;
  --ember-glow: #E8C547;

  --ash: #6B6B7B;
  --smoke: #3D3D4A;
  --bone: #E8E4DC;
  --bone-muted: #A8A49C;

  --success: #4A9B6E;
  --warning: #D4943A;
  --error: #C44B4B;
  --link: #7BA3C9;
  --link-hover: #A8C8E8;

  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 8px;

  --shadow-deep: 0 4px 24px rgba(0, 0, 0, 0.5);
  --border-ember: 1px solid rgba(201, 162, 39, 0.15);
  --border-smoke: 1px solid var(--smoke);
  --focus-ring: 0 0 0 2px rgba(201, 162, 39, 0.3);
  --sidebar-width: 260px;
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
}

/* --- Base Reset --- */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--ground);
  color: var(--bone);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* --- Grain Texture Overlay --- */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* --- Custom Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--smoke); border-radius: 3px; }
::-webkit-scrollbar-thumb { background: var(--ash); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--ember); }
* { scrollbar-width: thin; scrollbar-color: var(--ash) var(--smoke); }


/* ==========================================================
   CINEMATIC INTRO
   ========================================================== */

#intro {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: var(--ground);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  transition: opacity 1.2s ease, visibility 1.2s ease;
}

#intro.intro-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.intro-line {
  font-family: var(--font-display);
  color: var(--bone);
  font-size: clamp(1.25rem, 3vw, 2rem);
  font-weight: 400;
  line-height: 1.5;
  max-width: 700px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1.2s ease, transform 1.2s ease;
  margin-bottom: 0.5rem;
}

.intro-line.visible {
  opacity: 1;
  transform: translateY(0);
}

.intro-line.intro-emphasis {
  color: var(--ember);
  font-weight: 600;
  font-size: clamp(1.5rem, 3.5vw, 2.5rem);
}

.intro-line.intro-dim {
  color: var(--ash);
  font-size: clamp(1rem, 2.5vw, 1.5rem);
}

.intro-sigil {
  width: 80px;
  height: 80px;
  opacity: 0;
  transform: scale(0.5) rotate(-90deg);
  transition: opacity 1.5s ease, transform 1.5s ease;
  margin: 2rem 0;
}

.intro-sigil.visible {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.intro-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  color: var(--ember);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1.2s ease, transform 1.2s ease;
  margin-bottom: 0.25rem;
  letter-spacing: 0.02em;
}

.intro-title.visible {
  opacity: 1;
  transform: translateY(0);
}

.intro-subtitle {
  font-family: var(--font-body);
  font-size: clamp(0.875rem, 2vw, 1.125rem);
  color: var(--bone-muted);
  opacity: 0;
  transition: opacity 1.2s ease;
  margin-bottom: 2.5rem;
}

.intro-subtitle.visible {
  opacity: 1;
}

.intro-enter {
  padding: 0.75rem 2.5rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ground);
  background: var(--ember);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1s ease, transform 1s ease, background 0.2s ease, box-shadow 0.2s ease;
  letter-spacing: 0.03em;
}

.intro-enter.visible {
  opacity: 1;
  transform: translateY(0);
}

.intro-enter:hover {
  background: var(--ember-glow);
  box-shadow: 0 0 24px rgba(201, 162, 39, 0.35);
}

.intro-skip {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  color: var(--ash);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem 1rem;
  transition: color var(--transition-fast);
  z-index: 10001;
}

.intro-skip:hover {
  color: var(--bone-muted);
}


/* ==========================================================
   TYPOGRAPHY
   ========================================================== */

h1, h2, h3, .heading-display {
  font-family: var(--font-display);
  line-height: 1.15;
  color: var(--bone);
  font-weight: 600;
  margin: 0;
}

h1, .h1 { font-size: clamp(2rem, 4vw, 3.5rem); letter-spacing: -0.01em; }
h2, .h2 { font-size: clamp(1.5rem, 3vw, 2.25rem); }
h3, .h3 { font-size: clamp(1.25rem, 2.5vw, 1.75rem); font-weight: 500; }

h4, h5, h6 { font-family: var(--font-body); font-weight: 500; line-height: 1.3; color: var(--bone); margin: 0; }
h4, .h4 { font-size: 1.125rem; }
h5, .h5 { font-size: 1rem; }
h6, .h6 { font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--bone-muted); }

p { margin: 0 0 1rem 0; line-height: 1.6; }
small, .text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }

code, pre, .font-data, .data-text {
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--link-hover); }
a:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-xs); }


/* ==========================================================
   NAVIGATION SIDEBAR
   ========================================================== */

.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background-color: var(--ground);
  border-right: 1px solid var(--smoke);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(201, 162, 39, 0.12);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--ember);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  width: 100%;
}
.sidebar-brand:hover { color: var(--ember-glow); }

.sidebar-sigil { flex-shrink: 0; width: 36px; height: 36px; }

.sidebar-title {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0.75rem 0;
  flex: 1;
}

.sidebar-nav li { margin: 0; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  margin: 1px 0.5rem;
  color: var(--bone-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
  transition: all var(--transition-fast);
  cursor: pointer;
  background: none;
  border-top: none;
  border-right: none;
  border-bottom: none;
  font-family: var(--font-body);
  font-size: inherit;
  width: calc(100% - 1rem);
}

.sidebar-link:hover {
  color: var(--bone);
  background-color: var(--surface);
}

.sidebar-link.active {
  color: var(--ember);
  background-color: var(--surface-raised);
  border-left: 3px solid var(--ember);
}

.sidebar-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  color: var(--ash);
  transition: color var(--transition-fast);
}

.sidebar-link:hover .sidebar-icon { color: var(--bone-muted); }
.sidebar-link.active .sidebar-icon { color: var(--ember); }

.sidebar-label { display: flex; flex-direction: column; min-width: 0; }
.sidebar-label-primary { font-size: 0.9375rem; font-weight: 500; line-height: 1.3; }
.sidebar-label-sub { font-size: 0.75rem; color: var(--ash); line-height: 1.3; }
.sidebar-link.active .sidebar-label-sub { color: var(--ember-dim); }

.sidebar-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--ember);
  background: rgba(201, 162, 39, 0.12);
  border-radius: 50%;
  margin-right: 0.25rem;
  flex-shrink: 0;
  line-height: 1;
}
.sidebar-link.active .sidebar-step { background: rgba(201, 162, 39, 0.25); }

/* --- Rate Limit Sentinel --- */
.rate-sentinel {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--smoke);
  margin-top: auto;
}

.rate-sentinel-label {
  font-family: var(--font-body);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--bone-muted);
  margin-bottom: 0.375rem;
}

.rate-sentinel-gauge {
  height: 6px;
  background: var(--smoke);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.25rem;
}

.rate-gauge-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--ember);
  transition: width 0.4s ease, background-color 0.4s ease;
}

.rate-gauge-fill.low {
  background: var(--warning);
}

.rate-gauge-fill.critical {
  background: var(--error);
  animation: pulse-critical 1.5s ease-in-out infinite;
}

@keyframes pulse-critical {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.rate-sentinel-info {
  font-family: var(--font-data);
  font-size: 0.6875rem;
  color: var(--ash);
  text-align: right;
}

.rate-blocked-msg {
  font-family: var(--font-data);
  font-size: 0.6875rem;
  color: var(--error);
  margin-top: 0.25rem;
  text-align: center;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--smoke);
  text-align: center;
}


/* --- Mobile Bottom Navigation --- */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background-color: var(--ground);
  border-top: 1px solid var(--smoke);
  z-index: 100;
  padding: 0.375rem 0;
}

.mobile-nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  padding: 0.375rem 0.5rem;
  color: var(--ash);
  text-decoration: none;
  font-size: 0.625rem;
  font-family: var(--font-body);
  font-weight: 500;
  transition: color var(--transition-fast);
  background: none;
  border: none;
  cursor: pointer;
}

.mobile-nav-link svg { width: 20px; height: 20px; }
.mobile-nav-link:hover { color: var(--bone-muted); }
.mobile-nav-link.active { color: var(--ember); }


/* ==========================================================
   MAIN CONTENT AREA
   ========================================================== */

.main-content {
  margin-left: var(--sidebar-width);
  padding: 2rem 2.5rem;
  min-height: 100vh;
}

/* --- Page Header --- */
.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid rgba(201, 162, 39, 0.12);
}

.page-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 600;
  color: var(--bone);
  margin: 0 0 0.375rem 0;
  line-height: 1.15;
}

.page-subtitle {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--bone-muted);
  margin: 0;
}

.page-epigraph {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.9375rem;
  color: var(--ash);
  margin: 0.75rem 0 0 0;
  max-width: 600px;
  line-height: 1.6;
}

.page-epigraph .epigraph-source {
  display: block;
  font-style: normal;
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--smoke);
  margin-top: 0.25rem;
}

.page-section { display: none; }
.page-section.active { display: block; }


/* ==========================================================
   CARDS
   ========================================================== */

.card {
  background-color: var(--surface);
  border: 1px solid rgba(201, 162, 39, 0.15);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  transition: border-color var(--transition-base);
}

.card:hover { border-color: rgba(201, 162, 39, 0.35); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--smoke);
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--bone);
  margin: 0;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}


/* ==========================================================
   BUTTONS
   ========================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn:disabled, .btn.disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background-color: var(--ember);
  color: var(--ground);
  border-color: var(--ember);
  font-weight: 600;
}
.btn-primary:hover {
  background-color: var(--ember-glow);
  border-color: var(--ember-glow);
  color: var(--ground);
  box-shadow: 0 0 16px rgba(201, 162, 39, 0.25);
}

.btn-secondary {
  background-color: transparent;
  color: var(--bone);
  border-color: var(--ember-dim);
}
.btn-secondary:hover {
  background-color: var(--smoke);
  border-color: var(--ember);
}

.btn-ghost {
  background-color: transparent;
  color: var(--bone-muted);
  border-color: transparent;
}
.btn-ghost:hover { color: var(--bone); background-color: rgba(255,255,255,0.04); }

.btn-sm { padding: 0.3125rem 0.75rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.625rem 1.75rem; font-size: 1rem; }


/* ==========================================================
   FORM INPUTS
   ========================================================== */

.form-group { margin-bottom: 1.25rem; }

.label {
  display: block;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--bone-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.375rem;
}

.input, .select, .textarea {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--bone);
  background-color: var(--surface-raised);
  border: 1px solid var(--smoke);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--ember);
  box-shadow: var(--focus-ring);
}

.input::placeholder, .textarea::placeholder { color: var(--ash); }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B6B7B' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px;
  padding-right: 2.5rem;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9375rem;
  color: var(--bone);
}

.checkbox input {
  appearance: none;
  width: 18px; height: 18px;
  border: 1px solid var(--smoke);
  border-radius: var(--radius-xs);
  background-color: var(--surface-raised);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.checkbox input:checked {
  background-color: var(--ember);
  border-color: var(--ember);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-help {
  font-size: 0.75rem;
  color: var(--ash);
  margin-top: 0.25rem;
}


/* ==========================================================
   TABLES
   ========================================================== */

.data-table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.data-table thead { background-color: var(--surface); border-bottom: 1px solid var(--smoke); }

.data-table th {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--bone-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.75rem 1rem;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
}

.data-table th:hover { color: var(--ember); }

.data-table td {
  padding: 0.625rem 1rem;
  color: var(--bone);
  border-bottom: 1px solid rgba(61, 61, 74, 0.5);
  vertical-align: top;
}

.data-table tbody tr:nth-child(even) { background-color: var(--surface-raised); }
.data-table tbody tr:hover { background-color: rgba(201, 162, 39, 0.04); }

.table-wrapper {
  overflow-x: auto;
  border: 1px solid rgba(201, 162, 39, 0.15);
  border-radius: var(--radius-md);
}


/* ==========================================================
   TOAST NOTIFICATIONS
   ========================================================== */

.toast-container {
  position: fixed;
  top: 1rem; right: 1rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 400px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background-color: var(--surface-raised);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--ash);
  box-shadow: var(--shadow-deep);
  transform: translateX(120%);
  opacity: 0;
  transition: transform 300ms ease, opacity 300ms ease;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--bone);
}

.toast-visible { transform: translateX(0); opacity: 1; }
.toast-success { border-left-color: var(--success); }
.toast-error   { border-left-color: var(--error); }
.toast-warning { border-left-color: var(--warning); }
.toast-info    { border-left-color: var(--link); }

.toast-message { flex: 1; }

.toast-close {
  background: none; border: none;
  color: var(--ash); cursor: pointer;
  font-size: 1.25rem; line-height: 1; padding: 0;
}
.toast-close:hover { color: var(--bone); }


/* ==========================================================
   EMPTY STATES & LOADING
   ========================================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 2rem;
  min-height: 40vh;
}

.empty-state-sigil { width: 80px; height: 80px; opacity: 0.4; margin-bottom: 1.5rem; }
.empty-state-heading {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--bone);
  margin: 0 0 0.75rem 0;
}
.empty-state-text {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--bone-muted);
  max-width: 400px;
  margin: 0 0 1.5rem 0;
}

/* Rotating sigil loader */
.loading-sigil {
  width: 48px; height: 48px;
  animation: sigil-spin 2s linear infinite, sigil-pulse 2s ease-in-out infinite;
}

@keyframes sigil-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes sigil-pulse { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  gap: 1rem;
}

.loading-text {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--bone-muted);
}


/* ==========================================================
   PROGRESS BAR
   ========================================================== */

.progress {
  width: 100%;
  height: 6px;
  background-color: var(--smoke);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background-color: var(--ember);
  border-radius: 3px;
  transition: width 300ms ease;
}


/* ==========================================================
   BADGES
   ========================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
  white-space: nowrap;
}

.badge-ember { background-color: rgba(201, 162, 39, 0.15); color: var(--ember); }
.badge-success { background-color: rgba(74, 155, 110, 0.15); color: var(--success); }
.badge-warning { background-color: rgba(212, 148, 58, 0.15); color: var(--warning); }
.badge-error { background-color: rgba(196, 75, 75, 0.15); color: var(--error); }


/* ==========================================================
   STAT DISPLAY
   ========================================================== */

.stat { display: flex; flex-direction: column; gap: 0.25rem; }

.stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  color: var(--ember);
  line-height: 1.1;
}

.stat-label {
  font-family: var(--font-body);
  font-size: 0.8125rem;
  color: var(--bone-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}

.stat-card {
  padding: 1rem;
  background-color: var(--surface-raised);
  border-radius: var(--radius-sm);
  text-align: center;
}

.stat-card .stat-value { font-size: 1.5rem; }
.stat-card .stat-label { font-size: 0.6875rem; }


/* ==========================================================
   DIVIDERS & UTILITIES
   ========================================================== */

.divider { border: none; border-top: 1px solid var(--smoke); margin: 1.5rem 0; }
.divider-ember { border-top-color: rgba(201, 162, 39, 0.3); }

.text-ember { color: var(--ember); }
.text-bone { color: var(--bone); }
.text-bone-muted { color: var(--bone-muted); }
.text-ash { color: var(--ash); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }

.font-display { font-family: var(--font-display); }
.font-mono { font-family: var(--font-mono); }

.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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


/* ==========================================================
   MODAL
   ========================================================== */

.modal-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface);
  border: 1px solid rgba(201, 162, 39, 0.2);
  border-radius: var(--radius-md);
  padding: 2rem;
  max-width: 500px;
  width: 100%;
  box-shadow: var(--shadow-deep);
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.modal-overlay.visible .modal {
  transform: translateY(0);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ember);
  margin: 0 0 0.5rem 0;
}

.modal-text {
  color: var(--bone-muted);
  font-size: 0.9375rem;
  margin-bottom: 1.5rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}


/* ==========================================================
   HARVEST — RESULTS TABLE ENHANCEMENTS
   ========================================================== */

.harvest-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.5rem;
  align-items: start;
}

.post-title-link {
  color: var(--bone);
  text-decoration: none;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  transition: color var(--transition-fast);
}

.post-title-link:hover { color: var(--ember-glow); }

.post-body-preview {
  display: none;
  padding: 0.75rem 1rem;
  background: var(--ground);
  border-left: 2px solid rgba(201, 162, 39, 0.2);
  margin: 0.5rem 0;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  color: var(--bone-muted);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
}

.post-body-preview.visible { display: block; }

.comment-tree {
  padding: 0.5rem 0 0.5rem 1rem;
  border-left: 1px solid var(--smoke);
  margin-left: 0.5rem;
}

.comment-item {
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(61, 61, 74, 0.3);
}

.comment-meta {
  font-size: 0.75rem;
  color: var(--ash);
  margin-bottom: 0.25rem;
}

.comment-body {
  font-size: 0.8125rem;
  color: var(--bone-muted);
  white-space: pre-wrap;
  word-break: break-word;
}


/* ==========================================================
   GLEAN — EXPORT SECTION
   ========================================================== */

.export-preview {
  background: var(--surface);
  border: var(--border-ember);
  border-radius: var(--radius-md);
  padding: 1rem;
  max-height: 300px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--bone-muted);
  white-space: pre-wrap;
  word-break: break-all;
}


/* ==========================================================
   CLAUDE ANALYSIS — AI PANEL
   ========================================================== */

.claude-panel {
  background: var(--surface);
  border: 1px solid rgba(201, 162, 39, 0.2);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-top: 1.5rem;
}

.claude-response {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--bone);
  line-height: 1.7;
  white-space: pre-wrap;
}

.claude-response h1, .claude-response h2, .claude-response h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.claude-response ul, .claude-response ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.claude-response li {
  margin-bottom: 0.25rem;
}


/* ==========================================================
   ABOUT PAGE
   ========================================================== */

.about-section {
  margin-bottom: 2rem;
}

.about-section h3 {
  color: var(--ember);
  margin-bottom: 0.75rem;
}

.about-section p, .about-section li {
  color: var(--bone-muted);
  line-height: 1.7;
}

.about-section ul {
  padding-left: 1.5rem;
}

.about-section li {
  margin-bottom: 0.5rem;
}


/* ==========================================================
   RESPONSIVE
   ========================================================== */

@media (max-width: 1024px) {
  .sidebar { width: 220px; }
  :root { --sidebar-width: 220px; }
  .main-content { padding: 1.5rem; }
  .harvest-layout { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .mobile-nav {
    display: flex;
    justify-content: space-around;
    align-items: stretch;
  }
  .main-content {
    margin-left: 0;
    padding: 1.25rem 1rem;
    padding-bottom: 5rem;
  }
  .page-title { font-size: 1.75rem; }
  .card-grid { grid-template-columns: 1fr; }
  .harvest-layout { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .toast-container {
    top: auto; bottom: 4.5rem;
    right: 0.5rem; left: 0.5rem;
    max-width: none;
  }
}

@media (max-width: 480px) {
  .main-content { padding: 1rem 0.75rem; padding-bottom: 5rem; }
  .empty-state { padding: 2rem 1rem; }
  .btn-lg { width: 100%; }
  .stats-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

/* --- Print --- */
@media print {
  .sidebar, .mobile-nav, .toast-container, #intro { display: none !important; }
  .main-content { margin-left: 0 !important; }
  body { background: white; color: black; }
  body::before { display: none; }
}
