/* ============================================================
   DIGITAL EVOLUTION JOURNAL — Brand Design System v2.0
   Palette: Warm Earthy — Primary Orange #DA7756, Cream #F4F3EE
   Olive-Brown Foreground #3D3929, Accents & Semantic Colors
   Typography: 'Crimson Text' (headings), 'Inter' (body), 'JetBrains Mono'
   ============================================================ */

/* ---------- Google Fonts Import ---------- */
@import url('https://fonts.googleapis.com/css2?family=Crimson+Text:ital,wght@0,400;0,600;0,700;1,400;1,600&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* ---------- Design Tokens — Light Mode (Default) ---------- */
:root {
  /* --- Brand Color Palette --- */
  --brand-primary:          #DA7756;
  --brand-primary-hover:    #C15F3C;
  --brand-primary-fg:       #FFFFFF;
  --brand-primary-light:    rgba(218, 119, 86, 0.12);
  --brand-primary-border:   rgba(218, 119, 86, 0.35);

  --brand-accent:           #B87555;
  --brand-accent-hover:     #9E6042;
  --brand-accent-light:     rgba(184, 117, 85, 0.12);

  /* Semantic */
  --brand-success:          #FFD166;
  --brand-success-fg:       #3D3929;
  --brand-warning:          #FFD166;
  --brand-warning-fg:       #3D3929;
  --brand-destructive:      #CF222E;
  --brand-destructive-fg:   #FFFFFF;

  /* Chart Colors */
  --chart-1:                #DA7756;
  --chart-2:                #4CC9F0;
  --chart-3:                #FFD166;
  --chart-4:                #9D4EDD;
  --chart-5:                #F28482;

  /* --- Neutral / Surface --- */
  --color-bg:               #F4F3EE;
  --color-bg-alt:           #ECEAE2;
  --color-surface:          #FEFEFE;
  --color-surface-alt:      #F4F3EE;
  --color-surface-hover:    #EDE9E0;
  --color-muted:            #F4F3EE;
  --color-overlay:          rgba(61, 57, 41, 0.06);
  --color-overlay-heavy:    rgba(61, 57, 41, 0.7);

  /* --- Text --- */
  --color-text:             #3D3929;
  --color-text-secondary:   #6B654E;
  --color-text-muted:       #9C9476;
  --color-text-inverse:     #F4F3EE;
  --color-text-on-primary:  #FFFFFF;

  /* --- Borders --- */
  --color-border:           #3D3929;
  --color-border-light:     rgba(61, 57, 41, 0.2);
  --color-border-brand:     rgba(218, 119, 86, 0.4);
  --color-border-hover:     #DA7756;

  /* --- Shadows --- */
  --shadow-xs:    0 1px 2px rgba(61, 57, 41, 0.06);
  --shadow-sm:    0 1px 3px rgba(61, 57, 41, 0.08), 0 1px 2px rgba(61, 57, 41, 0.06);
  --shadow-md:    0 4px 6px -1px rgba(61, 57, 41, 0.08), 0 2px 4px -1px rgba(61, 57, 41, 0.05);
  --shadow-lg:    0 10px 15px -3px rgba(61, 57, 41, 0.08), 0 4px 6px -2px rgba(61, 57, 41, 0.05);
  --shadow-xl:    0 20px 25px -5px rgba(61, 57, 41, 0.08), 0 10px 10px -5px rgba(61, 57, 41, 0.04);
  --shadow-2xl:   0 25px 50px -12px rgba(61, 57, 41, 0.15);
  --shadow-card:  0 2px 8px rgba(61, 57, 41, 0.08);
  --shadow-brand: 0 4px 20px rgba(218, 119, 86, 0.25);
  --shadow-brand-lg: 0 8px 32px rgba(218, 119, 86, 0.30);

  /* --- Border Radius --- */
  --radius-xs:   0.25rem;    /* 4px  */
  --radius-sm:   0.375rem;   /* 6px  */
  --radius-md:   0.5rem;     /* 8px  */
  --radius-lg:   0.75rem;    /* 12px */
  --radius-xl:   1rem;       /* 16px */
  --radius-2xl:  1.25rem;    /* 20px */
  --radius-3xl:  1.5rem;     /* 24px */
  --radius-full: 9999px;

  /* --- Spacing (8px base unit) --- */
  --space-1:   0.25rem;  /* 4px  */
  --space-2:   0.5rem;   /* 8px  */
  --space-3:   0.75rem;  /* 12px */
  --space-4:   1rem;     /* 16px */
  --space-5:   1.25rem;  /* 20px */
  --space-6:   1.5rem;   /* 24px */
  --space-8:   2rem;     /* 32px */
  --space-10:  2.5rem;   /* 40px */
  --space-12:  3rem;     /* 48px */
  --space-16:  4rem;     /* 64px */
  --space-20:  5rem;     /* 80px */
  --space-24:  6rem;     /* 96px */

  /* --- Typography --- */
  --font-sans:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif:  'Crimson Text', Georgia, Cambria, 'Times New Roman', serif;
  --font-mono:   'JetBrains Mono', 'Fira Code', Consolas, monospace;

  /* Type Scale */
  --text-xs:    0.75rem;    /* 12px */
  --text-sm:    0.875rem;   /* 14px */
  --text-base:  1rem;       /* 16px */
  --text-lg:    1.125rem;   /* 18px */
  --text-xl:    1.25rem;    /* 20px */
  --text-2xl:   1.5rem;     /* 24px */
  --text-3xl:   1.875rem;   /* 30px */
  --text-4xl:   2.25rem;    /* 36px */
  --text-5xl:   3rem;       /* 48px */
  --text-6xl:   3.75rem;    /* 60px */

  /* Line Heights */
  --leading-tight:    1.25;
  --leading-snug:     1.375;
  --leading-normal:   1.5;
  --leading-relaxed:  1.625;
  --leading-loose:    1.8;

  /* --- Layout --- */
  --navbar-height:   72px;
  --max-width:       80rem;  /* 1280px */
  --max-width-prose: 65ch;

  /* --- Transitions --- */
  --transition-fast:   150ms ease;
  --transition-base:   200ms ease;
  --transition-slow:   300ms ease;
  --transition-bounce: 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---------- Dark Mode Tokens ---------- */
[data-theme="dark"] {
  --color-bg:               #0D0D0D;
  --color-bg-alt:           #111111;
  --color-surface:          #161B22;
  --color-surface-alt:      #1C2128;
  --color-surface-hover:    #21262D;
  --color-muted:            #21262D;
  --color-overlay:          rgba(0, 0, 0, 0.3);
  --color-overlay-heavy:    rgba(0, 0, 0, 0.85);

  --color-text:             #F0F6FC;
  --color-text-secondary:   #C9D1D9;
  --color-text-muted:       #8B949E;
  --color-text-inverse:     #0D0D0D;
  --color-text-on-primary:  #FFFFFF;

  --color-border:           #30363D;
  --color-border-light:     rgba(48, 54, 61, 0.6);
  --color-border-brand:     rgba(193, 95, 60, 0.4);
  --color-border-hover:     #C15F3C;

  --brand-primary:          #C15F3C;
  --brand-primary-hover:    #DA7756;
  --brand-primary-light:    rgba(193, 95, 60, 0.15);
  --brand-primary-border:   rgba(193, 95, 60, 0.35);

  --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.4);
  --shadow-lg:    0 10px 15px rgba(0, 0, 0, 0.5);
  --shadow-xl:    0 20px 25px rgba(0, 0, 0, 0.5);
  --shadow-2xl:   0 25px 50px rgba(0, 0, 0, 0.7);
  --shadow-card:  0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-brand: 0 4px 20px rgba(193, 95, 60, 0.2);
}

/* ---------- Global Reset & Base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, .font-serif {
  font-family: var(--font-serif);
  line-height: var(--leading-tight);
  color: var(--color-text);
  font-weight: 700;
}

h1 { font-size: var(--text-5xl); }
h2 { font-size: var(--text-4xl); font-weight: 600; }
h3 { font-size: var(--text-3xl); font-weight: 600; }
h4 { font-size: var(--text-2xl); font-weight: 600; }
h5 { font-size: var(--text-xl); font-weight: 600; font-family: var(--font-sans); }
h6 { font-size: var(--text-lg); font-weight: 600; font-family: var(--font-sans); }

p { line-height: var(--leading-relaxed); }

code, pre, .font-mono, kbd {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

pre {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-6);
  overflow-x: auto;
  line-height: 1.6;
}

a {
  color: var(--brand-primary);
  text-decoration: none;
  transition: color var(--transition-base);
}
a:hover { color: var(--brand-primary-hover); }

strong, b { font-weight: 600; }
em, i { font-style: italic; }

ul, ol { padding-left: var(--space-6); }
li { margin-bottom: var(--space-1); }

img, video, svg { display: block; max-width: 100%; }

hr {
  border: none;
  border-top: 1px solid var(--color-border-light);
  margin: var(--space-8) 0;
}

::selection {
  background: rgba(218, 119, 86, 0.2);
  color: var(--color-text);
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--color-bg); }
::-webkit-scrollbar-thumb {
  background: rgba(61, 57, 41, 0.25);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--brand-primary); }

[data-theme="dark"] ::-webkit-scrollbar-track { background: #0D0D0D; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(240, 246, 252, 0.15); }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: var(--brand-primary); }

/* ============================================================
   LAYOUT UTILITIES
   ============================================================ */

.container {
  width: 100%;
  max-width: var(--max-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

@media (min-width: 640px) {
  .container { padding-left: var(--space-6); padding-right: var(--space-6); }
}
@media (min-width: 1024px) {
  .container { padding-left: var(--space-8); padding-right: var(--space-8); }
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
@media (min-width: 640px) and (max-width: 1023px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

.w-full { width: 100%; }
.min-h-screen { min-height: 100vh; }
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }
.inset-0 { inset: 0; }
.overflow-hidden { overflow: hidden; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }
.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.z-40 { z-index: 40; }
.z-50 { z-index: 50; }

.hidden { display: none !important; }
.block { display: block; }
.inline { display: inline; }
.inline-flex { display: inline-flex; }

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

/* ============================================================
   NAVBAR
   ============================================================ */

.navbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(244, 243, 238, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--color-border-light);
  transition: box-shadow var(--transition-base), background var(--transition-base);
}

.navbar.scrolled {
  box-shadow: var(--shadow-md);
  background: rgba(244, 243, 238, 0.97);
}

[data-theme="dark"] .navbar {
  background: rgba(13, 13, 13, 0.92);
  border-bottom-color: rgba(48, 54, 61, 0.7);
}

[data-theme="dark"] .navbar.scrolled {
  background: rgba(13, 13, 13, 0.97);
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--navbar-height);
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-4);
}

@media (min-width: 640px) {
  .navbar-inner { padding: 0 var(--space-6); }
}
@media (min-width: 1024px) {
  .navbar-inner { padding: 0 var(--space-8); }
}

/* Brand Logo */
.navbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  transition: opacity var(--transition-base);
}
.navbar-brand:hover { opacity: 0.85; }

.navbar-brand-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 0;
  flex-shrink: 0;
}

.navbar-logo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border-radius: 10px;
  padding: 5px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  flex-shrink: 0;
}

.navbar-brand-name {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.navbar-brand-name em {
  color: var(--brand-primary);
  font-style: italic;
  font-weight: 400;
}

.navbar-brand-sub {
  display: none;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-text-muted);
  margin-top: 1px;
}

@media (min-width: 640px) { .navbar-brand-sub { display: block; } }

/* Desktop Nav */
.navbar-nav {
  display: none;
  align-items: center;
  gap: var(--space-1);
  list-style: none;
  padding: 0;
  margin: 0;
}

@media (min-width: 1024px) { .navbar-nav { display: flex; } }

.navbar-nav a {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-secondary);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: color var(--transition-base), background var(--transition-base);
}

.navbar-nav a:hover {
  color: var(--color-text);
  background: var(--color-overlay);
}

.navbar-nav a.active {
  color: var(--brand-primary);
  background: var(--brand-primary-light);
  border: 1px solid var(--brand-primary-border);
}

/* Navbar Right Actions */
.navbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Prevent visual flicker of action buttons when navbar background changes on scroll */
.navbar-actions,
#authLinks,
#mobileAuthLinks {
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transform: translateZ(0);
  will-change: opacity, transform;
}

/* Mobile Menu Button */
.mobile-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-base), color var(--transition-base);
}

.mobile-menu-btn:hover {
  background: var(--color-overlay);
  color: var(--color-text);
}

@media (min-width: 1024px) { .mobile-menu-btn { display: none; } }

/* Mobile Drawer */
.mobile-menu {
  display: none;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  border-top: 1px solid var(--color-border-light);
  background: var(--color-bg);
}

.mobile-menu.open { display: flex; }

.mobile-menu a {
  display: block;
  padding: 10px var(--space-3);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: color var(--transition-base), background var(--transition-base);
}

.mobile-menu a:hover {
  color: var(--color-text);
  background: var(--color-overlay);
}

.mobile-menu a.active {
  color: var(--brand-primary);
  background: var(--brand-primary-light);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 20px;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  /* Limit transitions to visual properties only to avoid layout repaint blink on scroll */
  transition: background var(--transition-base), color var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-base), transform var(--transition-base);
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}

.btn:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

/* Primary */
.btn-primary {
  background: var(--brand-primary);
  color: var(--brand-primary-fg);
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-brand);
}
.btn-primary:hover {
  background: var(--brand-primary-hover);
  border-color: var(--brand-primary-hover);
  color: var(--brand-primary-fg);
  box-shadow: var(--shadow-brand-lg);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

/* Secondary (outline) */
.btn-secondary {
  background: transparent;
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}
.btn-secondary:hover {
  background: var(--brand-primary-light);
  color: var(--brand-primary-hover);
  border-color: var(--brand-primary-hover);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: var(--color-border-light);
}
.btn-ghost:hover {
  background: var(--color-overlay);
  color: var(--color-text);
  border-color: var(--color-border);
}

/* Destructive */
.btn-destructive {
  background: var(--brand-destructive);
  color: var(--brand-destructive-fg);
  border-color: var(--brand-destructive);
}
.btn-destructive:hover {
  background: #B01E29;
  border-color: #B01E29;
  color: #FFFFFF;
}

/* Sizes */
.btn-xs { padding: 5px 12px; font-size: var(--text-xs); border-radius: var(--radius-xs); }
.btn-sm { padding: 7px 14px; font-size: var(--text-xs); }
.btn-lg { padding: 14px 28px; font-size: var(--text-base); }
.btn-xl { padding: 16px 32px; font-size: var(--text-lg); }

/* Icon Button */
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-base);
}
.btn-icon:hover {
  background: var(--color-overlay);
  color: var(--color-text);
}

/* Save to Library Active / Marked in Orange state */
.save-paper-btn.is-saved,
button.is-saved.save-paper-btn {
  color: var(--brand-primary) !important;
  background-color: var(--brand-primary-light) !important;
  border-color: var(--brand-primary-border) !important;
}
.save-paper-btn.is-saved svg,
.btn-icon.is-saved svg {
  fill: var(--brand-primary) !important;
  stroke: var(--brand-primary) !important;
}
.btn-icon.is-saved {
  color: var(--brand-primary) !important;
}

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

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition-base), border-color var(--transition-base), transform var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-hover:hover {
  border-color: var(--brand-primary-border);
  box-shadow: var(--shadow-brand);
  transform: translateY(-2px);
}

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

.card-title {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-text);
}

.card-body { /* content area */ }

/* ============================================================
   FORMS
   ============================================================ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.form-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--font-mono);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--color-text);
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--color-text-muted);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(218, 119, 86, 0.15);
}

.form-textarea {
  resize: vertical;
  min-height: 120px;
  line-height: var(--leading-relaxed);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--brand-destructive);
  margin-top: var(--space-1);
}

/* Checkbox & Radio */
.form-check {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  cursor: pointer;
}
.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--brand-primary);
  margin-top: 2px;
  cursor: pointer;
}

/* File Input */
.form-file {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-8) var(--space-6);
  border: 2px dashed var(--color-border-light);
  border-radius: var(--radius-lg);
  background: var(--color-muted);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition-base), background var(--transition-base);
}
.form-file:hover {
  border-color: var(--brand-primary);
  background: var(--brand-primary-light);
}

/* ============================================================
   BADGES & TAGS
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px 10px;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.badge-primary {
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  border: 1px solid var(--brand-primary-border);
}
.badge-accent {
  background: var(--brand-accent-light);
  color: var(--brand-accent);
  border: 1px solid rgba(184, 117, 85, 0.3);
}
.badge-success {
  background: rgba(255, 209, 102, 0.15);
  color: #8A6500;
  border: 1px solid rgba(255, 209, 102, 0.4);
}
.badge-destructive {
  background: rgba(207, 34, 46, 0.1);
  color: var(--brand-destructive);
  border: 1px solid rgba(207, 34, 46, 0.3);
}
.badge-neutral {
  background: var(--color-muted);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border-light);
}

[data-theme="dark"] .badge-success { color: var(--brand-success); }

/* ============================================================
   SECTION LABELS
   ============================================================ */

.section-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 14px;
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  border: 1px solid var(--brand-primary-border);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ============================================================
   DIVIDERS
   ============================================================ */

.divider {
  border: none;
  border-top: 1px solid var(--color-border-light);
  margin: var(--space-6) 0;
}

/* ============================================================
   TABS
   ============================================================ */

.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 2px solid var(--color-border-light);
  overflow-x: auto;
  padding-bottom: 2px;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  border: none;
  border-bottom: 3px solid transparent;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition-base), border-color var(--transition-base);
  margin-bottom: -2px;
  font-family: var(--font-sans);
}

.tab-btn:hover { color: var(--color-text); }

.tab-btn.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
}

/* ============================================================
   FOOTER
   ============================================================ */

.site-footer {
  background: var(--color-text);
  color: var(--color-text-inverse);
  padding: var(--space-16) 0 var(--space-8);
  margin-top: var(--space-16);
  border-top: 1px solid var(--color-border);
}

[data-theme="dark"] .site-footer {
  background: #0A0A0A;
  border-top: 1px solid var(--color-border);
}

.site-footer a {
  color: rgba(244, 243, 238, 0.65);
  text-decoration: none;
  font-size: var(--text-sm);
  transition: color var(--transition-base);
}
.site-footer a:hover { color: var(--brand-primary); }

.footer-grid {
  display: grid;
  grid-template-columns: 2.2fr 1fr 1fr 1fr;
  gap: var(--space-8);
  margin-bottom: var(--space-12);
}

@media (max-width: 860px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
  }
}

@media (max-width: 540px) {
  .footer-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
}

.footer-brand {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-weight: 700;
  color: #ffffff;
  margin-bottom: var(--space-2);
}

.footer-brand em {
  color: var(--brand-primary);
  font-style: italic;
  font-weight: 400;
}

.footer-tagline-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: rgba(218, 119, 86, 0.12);
  border: 1px solid rgba(218, 119, 86, 0.25);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-family: var(--font-mono);
  color: #f59e0b;
  margin-top: var(--space-1);
  margin-bottom: var(--space-3);
}

.footer-heading {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(244, 243, 238, 0.5);
  margin-bottom: var(--space-4);
}

.footer-links {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2.5);
}

.footer-bottom {
  border-top: 1px solid rgba(244, 243, 238, 0.1);
  margin-top: var(--space-12);
  padding-top: var(--space-6);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  font-size: var(--text-xs);
  color: rgba(244, 243, 238, 0.45);
}

/* ============================================================
   HERO SECTION
   ============================================================ */

.hero {
  position: relative;
  min-height: 88vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  background: var(--color-bg);
}

.hero-content {
  position: relative;
  z-index: 10;
  max-width: 56rem;
  margin: 0 auto;
  padding: var(--space-16) var(--space-4);
  text-align: center;
  width: 100%;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--brand-primary);
  background: var(--brand-primary-light);
  border: 1px solid var(--brand-primary-border);
  border-radius: var(--radius-full);
  padding: 5px 14px;
  margin-bottom: var(--space-6);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(2.5rem, 7vw, 4.5rem);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-6);
}

.hero-title em {
  color: var(--brand-primary);
  font-style: italic;
  font-weight: 400;
}

.hero-subtitle {
  font-size: var(--text-lg);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
  max-width: 42rem;
  margin: 0 auto var(--space-8);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  margin-top: var(--space-8);
}

/* ============================================================
   STATS BAR
   ============================================================ */

.stats-bar {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border-light);
  border-bottom: 1px solid var(--color-border-light);
  padding: var(--space-8) 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-6);
}

@media (min-width: 768px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

.stat-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
}

@media (min-width: 768px) {
  .stat-item {
    border-right: 1px solid var(--color-border-light);
    padding: var(--space-2) var(--space-6);
  }
  .stat-item:first-child { padding-left: 0; }
  .stat-item:last-child { border-right: none; }
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  background: var(--brand-primary-light);
  border: 1px solid var(--brand-primary-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-primary);
  flex-shrink: 0;
}

.stat-value {
  font-family: var(--font-serif);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.1;
}

.stat-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ============================================================
   MODALS
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--color-overlay-heavy);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-2xl);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-2xl);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-6);
  border-bottom: 1px solid var(--color-border-light);
  flex-shrink: 0;
}

.modal-title {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-text);
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* ============================================================
   SEARCH BAR
   ============================================================ */

.search-bar {
  display: flex;
  align-items: center;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-2);
  box-shadow: var(--shadow-md);
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.search-bar:focus-within {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(218, 119, 86, 0.15), var(--shadow-md);
}

.search-bar svg {
  width: 20px;
  height: 20px;
  color: var(--brand-primary);
  margin-left: var(--space-3);
  flex-shrink: 0;
}

.search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--color-text);
  outline: none;
}

.search-bar input::placeholder { color: var(--color-text-muted); }

/* ============================================================
   TABLE
   ============================================================ */

.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.data-table th {
  background: var(--color-muted);
  padding: 12px var(--space-4);
  text-align: left;
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border-light);
  white-space: nowrap;
}

.data-table td {
  padding: 14px var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
  color: var(--color-text);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr:hover { background: var(--color-overlay); }

/* ============================================================
   ALERTS / TOASTS
   ============================================================ */

.alert {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.alert-info {
  background: rgba(76, 201, 240, 0.08);
  border-color: rgba(76, 201, 240, 0.3);
  color: #0A6FA8;
}

.alert-success {
  background: rgba(255, 209, 102, 0.1);
  border-color: rgba(255, 209, 102, 0.4);
  color: #8A6500;
}

.alert-warning {
  background: rgba(255, 209, 102, 0.1);
  border-color: rgba(255, 209, 102, 0.4);
  color: #8A6500;
}

.alert-destructive {
  background: rgba(207, 34, 46, 0.08);
  border-color: rgba(207, 34, 46, 0.3);
  color: var(--brand-destructive);
}

[data-theme="dark"] .alert-info { color: #4CC9F0; }
[data-theme="dark"] .alert-success { color: var(--brand-success); }
[data-theme="dark"] .alert-warning { color: var(--brand-warning); }

/* Toast */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 12px var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(8px);
  pointer-events: auto;
  transform: translateY(8px);
  opacity: 0;
  transition: transform var(--transition-slow), opacity var(--transition-slow);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-success {
  background: rgba(244, 243, 238, 0.95);
  border-color: rgba(218, 119, 86, 0.3);
  color: var(--brand-primary);
}

.toast-error {
  background: rgba(244, 243, 238, 0.95);
  border-color: rgba(207, 34, 46, 0.3);
  color: var(--brand-destructive);
}

.toast-info {
  background: rgba(244, 243, 238, 0.95);
  border-color: var(--color-border-light);
  color: var(--color-text);
}

[data-theme="dark"] .toast-success {
  background: rgba(22, 27, 34, 0.95);
  color: var(--brand-primary);
}
[data-theme="dark"] .toast-error {
  background: rgba(22, 27, 34, 0.95);
}
[data-theme="dark"] .toast-info {
  background: rgba(22, 27, 34, 0.95);
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */

/* Text helpers */
.text-primary    { color: var(--brand-primary) !important; }
.text-muted      { color: var(--color-text-muted) !important; }
.text-secondary  { color: var(--color-text-secondary) !important; }
.text-xs  { font-size: var(--text-xs); }
.text-sm  { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg  { font-size: var(--text-lg); }
.text-xl  { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-3xl { font-size: var(--text-3xl); }
.text-4xl { font-size: var(--text-4xl); }
.text-5xl { font-size: var(--text-5xl); }

.font-sans   { font-family: var(--font-sans); }
.font-serif  { font-family: var(--font-serif); }
.font-mono   { font-family: var(--font-mono); }
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold   { font-weight: 700; }

/* Spacing */
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mt-12 { margin-top: var(--space-12); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.mb-12 { margin-bottom: var(--space-12); }
.mx-auto { margin-left: auto; margin-right: auto; }
.py-8 { padding-top: var(--space-8); padding-bottom: var(--space-8); }
.py-12 { padding-top: var(--space-12); padding-bottom: var(--space-12); }
.py-16 { padding-top: var(--space-16); padding-bottom: var(--space-16); }
.py-20 { padding-top: var(--space-20); padding-bottom: var(--space-20); }
.py-24 { padding-top: var(--space-24); padding-bottom: var(--space-24); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.px-6 { padding-left: var(--space-6); padding-right: var(--space-6); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }

/* Backgrounds */
.bg-surface  { background-color: var(--color-surface); }
.bg-muted    { background-color: var(--color-muted); }
.bg-brand    { background-color: var(--brand-primary); }

/* Borders */
.border      { border: 1px solid var(--color-border-light); }
.border-brand { border: 1px solid var(--brand-primary-border); }
.rounded     { border-radius: var(--radius-sm); }
.rounded-lg  { border-radius: var(--radius-lg); }
.rounded-xl  { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

/* Shadow */
.shadow-sm  { box-shadow: var(--shadow-sm); }
.shadow-md  { box-shadow: var(--shadow-md); }
.shadow-lg  { box-shadow: var(--shadow-lg); }

/* Responsive Helpers */
@media (max-width: 639px)  { .sm\:hidden { display: none; } }
@media (min-width: 640px)  { .sm\:show { display: flex; } }
@media (max-width: 1023px) { .lg\:hidden { display: none !important; } }
@media (min-width: 1024px) { .lg\:show { display: flex; } .lg\:grid-3 { grid-template-columns: repeat(3, 1fr); } }

/* ============================================================
   ADMIN SIDEBAR
   ============================================================ */

.admin-layout {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--color-text);
  color: var(--color-text-inverse);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 30;
  transition: transform var(--transition-slow);
}

.admin-main {
  flex: 1;
  margin-left: 260px;
  background: var(--color-bg);
  min-height: 100vh;
}

@media (max-width: 1023px) {
  .admin-sidebar { transform: translateX(-100%); }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
}

.sidebar-header {
  padding: var(--space-6);
  border-bottom: 1px solid rgba(244, 243, 238, 0.1);
  flex-shrink: 0;
}

.sidebar-brand {
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-surface);
  text-decoration: none;
}

.sidebar-brand em {
  color: var(--brand-primary);
  font-style: italic;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-4) var(--space-3);
  list-style: none;
}

.sidebar-nav-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(244, 243, 238, 0.35);
  padding: var(--space-4) var(--space-3) var(--space-2);
  font-family: var(--font-mono);
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 9px var(--space-3);
  font-size: var(--text-sm);
  font-weight: 500;
  color: rgba(244, 243, 238, 0.7);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all var(--transition-base);
  margin-bottom: 2px;
}

.sidebar-nav a:hover {
  color: var(--color-surface);
  background: rgba(244, 243, 238, 0.08);
}

.sidebar-nav a.active {
  color: var(--color-surface);
  background: rgba(218, 119, 86, 0.2);
  border-left: 3px solid var(--brand-primary);
  padding-left: calc(var(--space-3) - 3px);
}

/* ============================================================
   KEYFRAME ANIMATIONS
   ============================================================ */

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes brandPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(218, 119, 86, 0.3); }
  50%       { box-shadow: 0 0 0 12px rgba(218, 119, 86, 0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

.animate-fade-up    { animation: fadeInUp 0.5s ease forwards; }
.animate-fade-in    { animation: fadeIn 0.4s ease forwards; }
.animate-pulse      { animation: pulse 2s ease infinite; }
.animate-spin       { animation: spin 1s linear infinite; }
.animate-brand-pulse { animation: brandPulse 2.5s ease infinite; }

/* Staggered children */
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 80ms; }
.stagger > *:nth-child(3) { animation-delay: 160ms; }
.stagger > *:nth-child(4) { animation-delay: 240ms; }
.stagger > *:nth-child(5) { animation-delay: 320ms; }

/* ============================================================
   RANGE SLIDER (RRI Simulator)
   ============================================================ */

input[type="range"].brand-slider {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--color-border-light);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
  accent-color: var(--brand-primary);
}

input[type="range"].brand-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(218, 119, 86, 0.2);
  cursor: pointer;
  transition: box-shadow var(--transition-base);
}

input[type="range"].brand-slider::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 6px rgba(218, 119, 86, 0.25);
}

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

.progress {
  height: 6px;
  background: var(--color-border-light);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--brand-primary);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* ============================================================
   DARK MODE TOGGLE ICON
   ============================================================ */

.theme-toggle {
  position: relative;
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-border-light);
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  transition: all var(--transition-base);
}

.theme-toggle:hover {
  color: var(--brand-primary);
  border-color: var(--brand-primary-border);
  background: var(--brand-primary-light);
}

.theme-toggle .sun-icon { display: block; }
.theme-toggle .moon-icon { display: none; }
[data-theme="dark"] .theme-toggle .sun-icon { display: none; }
[data-theme="dark"] .theme-toggle .moon-icon { display: block; }

/* ============================================================
   AUTH FORMS
   ============================================================ */

.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
}

.auth-section {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-4);
  position: relative;
}

.auth-card {
  width: 100%;
  max-width: 420px;
}

.auth-header {
  text-align: center;
  margin-bottom: var(--space-8);
}

.auth-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  margin: 0 auto var(--space-4);
  border-radius: var(--radius-md);
}

.auth-title {
  font-family: var(--font-serif);
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.auth-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.auth-form-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-lg);
}

/* ============================================================
   DASHBOARD COMPONENTS
   ============================================================ */

.dashboard-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border-light);
  padding: var(--space-6) 0;
}

.dashboard-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.dashboard-title {
  font-family: var(--font-serif);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-text);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}

.metric-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.metric-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--brand-primary-light);
  border: 1px solid var(--brand-primary-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-primary);
  margin-bottom: var(--space-4);
}

.metric-value {
  font-family: var(--font-serif);
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.metric-label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ============================================================
   PAPER / ARTICLE CARDS
   ============================================================ */

.paper-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
  transition: all var(--transition-base);
  cursor: pointer;
  text-decoration: none;
  display: block;
  color: var(--color-text);
}

.paper-card:hover {
  border-color: var(--brand-primary-border);
  box-shadow: var(--shadow-brand);
  transform: translateY(-2px);
  color: var(--color-text);
}

.paper-card-title {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-2);
  line-height: var(--leading-snug);
}

.paper-card-authors {
  font-size: var(--text-sm);
  color: var(--brand-primary);
  margin-bottom: var(--space-3);
  font-weight: 500;
}

.paper-card-abstract {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.paper-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border-light);
  align-items: center;
}

/* ============================================================
   SECTION CONTAINERS
   ============================================================ */

.section {
  padding: var(--space-16) 0;
}

.section-lg {
  padding: var(--space-24) 0;
}

.section-header {
  text-align: center;
  max-width: 42rem;
  margin: 0 auto var(--space-12);
}

.section-title {
  font-family: var(--font-serif);
  font-size: clamp(1.75rem, 4vw, 3rem);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-4);
  line-height: 1.2;
}

.section-title em {
  color: var(--brand-primary);
  font-style: italic;
  font-weight: 400;
}

.section-subtitle {
  font-size: var(--text-lg);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
}

/* ============================================================
   TICKER / ANNOUNCEMENT BAR
   ============================================================ */

.ticker-bar {
  background: var(--brand-primary);
  color: var(--brand-primary-fg);
  padding: 10px 0;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  overflow: hidden;
}

.ticker-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-4);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

/* ============================================================
   DROPDOWN MENU
   ============================================================ */

.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 180px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: none;
  z-index: 50;
  animation: fadeInUp 0.15s ease;
}

.dropdown-menu.open { display: block; }

.dropdown-item {
  display: block;
  padding: 10px var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text);
  text-decoration: none;
  transition: background var(--transition-fast);
}

.dropdown-item:hover {
  background: var(--color-overlay);
  color: var(--brand-primary);
}

/* ============================================================
   WORKFLOW FEATURE CARDS
   ============================================================ */

.feature-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-slow);
}

.feature-card:hover {
  border-color: var(--brand-primary-border);
  box-shadow: var(--shadow-brand);
  transform: translateY(-3px);
}

.feature-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-lg);
  background: var(--brand-primary-light);
  border: 1px solid var(--brand-primary-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--brand-primary);
  flex-shrink: 0;
}

.feature-title {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
}

.feature-body {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
  flex: 1;
}

/* ============================================================
   STEP INDICATOR
   ============================================================ */

.step {
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
}

.step-number {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: var(--brand-primary-fg);
  font-weight: 700;
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: var(--font-mono);
  box-shadow: var(--shadow-brand);
}

.step-content { flex: 1; }

.step-title {
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.step-body {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
}

/* ============================================================
   ACCESSIBILITY
   ============================================================ */

:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

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

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   ECOSYSTEM ARCHITECTURE REDESIGN UX & STYLES
   ============================================================ */

.eco-tabs-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-2xl);
  padding: 8px;
  box-shadow: var(--shadow-sm);
}

.eco-tab-pill {
  flex: 1;
  min-width: 150px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-xl);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.eco-tab-pill:hover {
  color: var(--brand-primary);
  background: var(--brand-primary-light);
  border-color: var(--brand-primary-border);
  transform: translateY(-1px);
}

.eco-tab-pill.active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--brand-primary) 0%, #c05c3c 100%);
  border-color: var(--brand-primary);
  box-shadow: 0 4px 14px rgba(218, 119, 86, 0.35);
}

[data-theme="dark"] .eco-tab-pill.active {
  color: #111827;
  background: linear-gradient(135deg, #f59e0b 0%, var(--brand-primary) 100%);
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.3);
}

.eco-tab-pill .eco-step-num {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.08);
  font-family: var(--font-mono);
}

.eco-tab-pill.active .eco-step-num {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

[data-theme="dark"] .eco-tab-pill.active .eco-step-num {
  background: rgba(0, 0, 0, 0.2);
  color: #111827;
}

.eco-panel-wrapper {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.eco-tab-panel {
  animation: ecoFadeIn 0.35s ease-out forwards;
}

@keyframes ecoFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.eco-card-glass {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  padding: var(--space-4);
  background: var(--color-bg);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.eco-card-glass:hover {
  border-color: var(--brand-primary-border);
  box-shadow: 0 6px 18px rgba(218, 119, 86, 0.12);
  transform: translateY(-2px);
}

.eco-icon-badge {
  width: 34px;
  height: 34px;
  font-size: 1.05rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-2);
  transition: transform 0.25s ease;
}

.eco-card-glass:hover .eco-icon-badge {
  transform: scale(1.08) rotate(-3deg);
}

/* ============================================================
   WORKFLOW CANVAS LAYOUT (SPLIT STEPPER & LIVE STAGE)
   ============================================================ */

.eco-canvas-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: var(--space-5);
  align-items: start;
}

@media (max-width: 1023px) {
  .eco-canvas-layout {
    grid-template-columns: 1fr;
  }
}

.eco-timeline-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-xl);
  padding: 12px;
  box-shadow: var(--shadow-md);
}

.eco-timeline-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-align: left;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
}

.eco-timeline-item:hover {
  background: var(--brand-primary-light);
  border-color: var(--brand-primary-border);
  transform: translateX(4px);
}

.eco-timeline-item.active {
  background: linear-gradient(135deg, var(--brand-primary) 0%, #c05c3c 100%);
  border-color: var(--brand-primary);
  box-shadow: 0 4px 18px rgba(218, 119, 86, 0.35);
  color: #ffffff;
}

[data-theme="dark"] .eco-timeline-item.active {
  background: linear-gradient(135deg, #f59e0b 0%, var(--brand-primary) 100%);
  color: #111827;
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.3);
}

.eco-timeline-item .eco-step-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}

.eco-timeline-item.active .eco-step-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

[data-theme="dark"] .eco-timeline-item.active .eco-step-badge {
  background: rgba(0, 0, 0, 0.2);
  color: #111827;
}

.eco-timeline-item .eco-step-text {
  display: flex;
  flex-direction: column;
}

.eco-timeline-item .eco-step-title {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 700;
  line-height: 1.2;
}

.eco-timeline-item .eco-step-sub {
  font-size: 11px;
  opacity: 0.75;
  margin-top: 2px;
}

.eco-stage-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 320px;
  position: relative;
  overflow: hidden;
}

.eco-stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-border-light);
  padding-bottom: var(--space-2.5);
  margin-bottom: var(--space-4);
}

.eco-stage-title-group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.eco-stage-step-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  font-weight: 700;
}

.eco-stage-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--color-border-light);
  padding-top: var(--space-3);
  margin-top: var(--space-4);
}

.eco-step-dots {
  display: flex;
  align-items: center;
  gap: 6px;
}

.eco-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-border-light);
  transition: all 0.25s ease;
  cursor: pointer;
}

.eco-dot.active {
  width: 24px;
  border-radius: 4px;
  background: var(--brand-primary);
}

/* Redesigned Ecosystem Stage Cards System */
.eco-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 900px) {
  .eco-grid-3 {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

.eco-card-redesign {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.03);
}

.eco-card-redesign:hover {
  transform: translateY(-3px);
  border-color: rgba(218, 119, 86, 0.35);
  box-shadow: 0 12px 24px -6px rgba(0, 0, 0, 0.08);
}

.eco-icon-wrapper {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.eco-card-title {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 6px;
  line-height: 1.3;
}

.eco-card-desc {
  font-size: 12px;
  color: var(--color-text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
  flex-grow: 1;
}

.eco-btn-author {
  background: var(--brand-primary);
  color: #ffffff !important;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(218, 119, 86, 0.25);
}

.eco-btn-author:hover {
  background: #c86343;
  transform: translateY(-1px);
  color: #ffffff !important;
}

.eco-btn-reviewer {
  background: rgba(245, 158, 11, 0.08);
  color: #b87514 !important;
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.eco-btn-reviewer:hover {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.5);
  transform: translateY(-1px);
}

.eco-btn-member {
  background: rgba(67, 97, 238, 0.08);
  color: #3b52d4 !important;
  border: 1px solid rgba(67, 97, 238, 0.25);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.eco-btn-member:hover {
  background: rgba(67, 97, 238, 0.16);
  border-color: rgba(67, 97, 238, 0.45);
  transform: translateY(-1px);
}

/* ============================================================
   RESPONSIVE WEB DESIGN — MOBILE FIRST BREAKPOINTS
   Breakpoints:
     Mobile:  ≤ 639px
     Tablet:  640px – 1023px
     Desktop: ≥ 1024px
   ============================================================ */

/* ── Prevent any element from causing horizontal overflow ── */
*,
*::before,
*::after {
  max-width: 100%;
}

img,
video,
iframe,
table {
  max-width: 100%;
}

/* ── Navbar — Mobile Tightening ── */
@media (max-width: 639px) {
  /* Reduce brand name size on very small screens */
  .navbar-brand-name {
    font-size: var(--text-lg);
  }
  .navbar-brand-logo {
    width: 36px;
    height: 36px;
  }
  /* Tighten action buttons gap */
  .navbar-actions {
    gap: var(--space-1);
  }
  /* Hide Login/Register text on very narrow screens — keep just the hamburger */
  .navbar-actions .btn-xs {
    padding: 4px 8px;
    font-size: 11px;
  }
  /* Navbar inner padding */
  .navbar-inner {
    padding: 0 var(--space-3);
  }
}

/* ── Sections — Reduce vertical rhythm on mobile ── */
@media (max-width: 639px) {
  .section {
    padding: var(--space-10) 0;
  }
  .section-lg {
    padding: var(--space-16) 0;
  }
  .section-header {
    margin-bottom: var(--space-8);
  }
  .section-subtitle {
    font-size: var(--text-base);
  }
}

/* ── Container — Tighter side padding on mobile ── */
@media (max-width: 639px) {
  .container {
    padding-left: var(--space-3);
    padding-right: var(--space-3);
  }
}

/* ── Hero Section ── */
@media (max-width: 639px) {
  .hero-content {
    padding: var(--space-10) var(--space-3) var(--space-6);
  }
  .hero-title {
    font-size: clamp(1.75rem, 8vw, 2.5rem);
  }
  .hero-subtitle {
    font-size: var(--text-base);
  }
  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .hero-actions .btn {
    width: 100%;
    justify-content: center;
  }
  /* Search bar on mobile */
  .search-bar {
    flex-wrap: nowrap;
  }
  .search-bar input {
    min-width: 0;
    width: 100%;
  }
}

/* ── Filter Bar (researches page) — Mobile horizontal scroll ── */
@media (max-width: 767px) {
  .filters-bar {
    padding: var(--space-2) 0;
  }
  .filters-inner {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: var(--space-2);
    padding: 0 var(--space-3) var(--space-1);
    /* Smooth momentum scroll on iOS */
    -webkit-overflow-scrolling: touch;
    /* Hide scrollbar visually but keep functional */
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .filters-inner::-webkit-scrollbar {
    display: none;
  }
  /* Keep chips compact — no wrapping */
  .filter-chip {
    flex-shrink: 0;
    padding: 5px 10px;
    font-size: 11px;
  }
  /* Year select compact */
  .filters-inner select {
    flex-shrink: 0;
    min-width: 90px;
    max-width: 110px;
  }
  /* Results count + view toggle row — push to new line after scroll area */
  .filters-inner > div[style*="margin-left:auto"] {
    flex-shrink: 0;
    margin-left: 0 !important;
  }
}

/* ── Stats Grid — Responsive columns ── */
@media (max-width: 639px) {
  /* Override inline grid-template-columns on stats-grid */
  .stats-grid[style*="grid-template-columns:repeat(4"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .stats-grid[style*="grid-template-columns:repeat(3"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .stats-grid {
    gap: var(--space-3);
  }
  .stat-item {
    padding: var(--space-3);
    gap: var(--space-3);
  }
  .stat-icon {
    width: 38px;
    height: 38px;
  }
  .stat-value {
    font-size: var(--text-xl);
  }
}

/* ── Cards — Ensure no overflow ── */
@media (max-width: 639px) {
  .card {
    padding: var(--space-4);
  }
  .paper-card {
    padding: var(--space-4);
  }
  .paper-card-title {
    font-size: var(--text-lg);
  }
  .rri-panel {
    padding: var(--space-5);
  }
}

/* ── Buttons — Sensible sizes on mobile ── */
@media (max-width: 639px) {
  .btn-lg {
    padding: 12px 20px;
    font-size: var(--text-sm);
  }
  .btn-xl {
    padding: 13px 24px;
    font-size: var(--text-base);
  }
}

/* ── Modals — Full screen on mobile ── */
@media (max-width: 639px) {
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .modal {
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    max-height: 92vh;
    max-width: 100%;
  }
}

/* ── Tables — Horizontal scroll wrapper ── */
@media (max-width: 767px) {
  .table-wrapper {
    border-radius: var(--radius-md);
  }
  .data-table th,
  .data-table td {
    padding: 10px var(--space-3);
    font-size: var(--text-xs);
    white-space: nowrap;
  }
}

/* ── Footer — Stack on smallest screens ── */
@media (max-width: 400px) {
  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
    font-size: 11px;
  }
}

/* ── Admin Layout — Mobile sidebar as top nav ── */
@media (max-width: 767px) {
  .admin-layout {
    grid-template-columns: 1fr !important;
    gap: var(--space-4) !important;
  }
  /* Admin sidebar becomes a top horizontal nav strip */
  .admin-layout > aside {
    position: relative !important;
    width: 100% !important;
    order: -1;
  }
  .admin-layout > aside > div > div {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    gap: var(--space-1) !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 2px;
  }
  .admin-layout > aside > div > div::-webkit-scrollbar {
    display: none;
  }
  .admin-nav-item {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 7px 10px !important;
    font-size: 11px !important;
  }
}

/* ── Dashboard Header Actions — Stack on mobile ── */
@media (max-width: 639px) {
  .dashboard-topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .dashboard-topbar > div:last-child {
    width: 100%;
  }
  .dashboard-topbar .btn {
    flex: 1;
  }
}

/* ── Navbar — Mobile Proportions ── */
@media (max-width: 639px) {
  .navbar-brand {
    gap: var(--space-2);
  }
  .navbar-brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
  }
  .navbar-brand-name {
    font-size: 1.05rem;
    line-height: 1.2;
  }
  .navbar-actions {
    gap: var(--space-1.5);
  }
  .navbar-inner {
    padding: 0 var(--space-3.5);
  }
}

/* ── Ecosystem / How Digital Evolution Operates — Un-congested Mobile Layout ── */
@media (max-width: 1023px) {
  .eco-canvas-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  /* Tab Bar: Sleek horizontal scroll strip */
  .eco-timeline-sidebar {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    gap: 8px;
    padding: 8px;
    border-radius: var(--radius-xl);
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
  }
  .eco-timeline-sidebar::-webkit-scrollbar {
    display: none;
  }
  .eco-timeline-item {
    flex-shrink: 0;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 9px 15px;
    border-radius: 12px;
    width: auto;
    white-space: nowrap;
  }
  .eco-timeline-item .eco-step-badge {
    font-size: 10px;
    padding: 3px 6px;
    border-radius: 6px;
  }
  .eco-timeline-item .eco-step-title {
    font-size: 13px;
    font-weight: 600;
  }
  .eco-timeline-item .eco-step-sub {
    display: none; /* Hide dense subtext on mobile */
  }

  /* Stage Container & Cards: Spacious and airy */
  .eco-stage-container {
    padding: 20px 16px;
    min-height: auto;
    border-radius: 20px;
  }
  .eco-stage-header {
    padding-bottom: 12px;
    margin-bottom: 16px;
  }
  .eco-stage-header .badge {
    display: none; /* De-clutter badge on mobile */
  }
  .eco-stage-title-group {
    flex-wrap: wrap;
    gap: 8px;
  }
  .eco-stage-title-group h3 {
    font-size: 15px !important;
  }

  /* Hide redundant bottom stage pagination footer on mobile */
  .eco-stage-footer {
    display: none !important;
  }

  /* Un-congested Stage Cards Grid */
  .eco-grid-3 {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .eco-card-redesign {
    padding: 20px 18px;
    border-radius: 16px;
    background: var(--color-bg);
    border: 1px solid var(--color-border-light);
    box-shadow: none;
  }
  .eco-card-redesign:hover {
    transform: none;
  }
  .eco-icon-wrapper {
    width: 44px;
    height: 44px;
    font-size: 1.25rem;
    border-radius: 12px;
    margin-bottom: 12px;
  }
  .eco-card-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 6px;
  }
  .eco-card-desc {
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 16px;
  }
  .eco-btn-author,
  .eco-btn-reviewer,
  .eco-btn-member {
    padding: 10px 16px;
    font-size: 13px;
    border-radius: 10px;
  }
}

/* ── Page Headers (researches, archives, about etc.) ── */
@media (max-width: 639px) {
  /* Hero page header strip */
  section > div.container > div[style*="flex-wrap:wrap"][style*="justify-content:space-between"] {
    flex-direction: column !important;
    align-items: flex-start !important;
  }
  section > div.container > div[style*="flex-wrap:wrap"] .search-bar {
    max-width: 100% !important;
    width: 100%;
  }
  /* Reduce h1 on page banners */
  h1[style*="clamp"] {
    /* clamp already handles scaling, no override needed */
  }
}

/* ── RRI Simulator — Stack header on mobile ── */
@media (max-width: 639px) {
  .rri-panel > div:first-child {
    flex-direction: column !important;
    gap: var(--space-4) !important;
  }
  .rri-score-display {
    align-self: flex-start;
  }
}

/* ── Grid utilities — Tablet overrides ── */
@media (min-width: 640px) and (max-width: 1023px) {
  .stats-grid[style*="grid-template-columns:repeat(4"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ── Auth forms — Full-width card on mobile ── */
@media (max-width: 480px) {
  .auth-form-card {
    padding: var(--space-6) var(--space-4);
    border-radius: var(--radius-xl);
  }
  .auth-section {
    padding: var(--space-10) var(--space-3);
  }
}

/* ── Ticker bar — single line wrap ── */
@media (max-width: 639px) {
  .ticker-inner {
    justify-content: center;
    text-align: center;
    gap: var(--space-2);
    font-size: 11px;
  }
}

/* ── Toast container — bottom center on mobile ── */
@media (max-width: 639px) {
  .toast-container {
    right: var(--space-3);
    left: var(--space-3);
    bottom: var(--space-4);
  }
  .toast {
    width: 100%;
  }
}

/* ── Submission / Review form layouts ── */
@media (max-width: 639px) {
  /* Author row grid in submit form — single column */
  .author-grid {
    grid-template-columns: 1fr !important;
  }
  /* Submission card header actions */
  .submission-card > div:first-child {
    flex-direction: column;
    gap: var(--space-2);
  }
}

/* ── Paper detail sidebar — hidden from bottom ── */
@media (max-width: 639px) {
  .paper-detail-layout {
    gap: var(--space-5);
  }
}

/* ── Inline flex-wrap fixes for action rows ── */
@media (max-width: 639px) {
  /* Admin header action buttons */
  div[style*="display:flex;gap:var(--space-2)"] > button,
  div[style*="display:flex;gap:var(--space-3)"] > a {
    font-size: var(--text-xs);
  }
}

/* ── Prevent horizontal overflow on all pages ── */
html, body {
  overflow-x: hidden;
}

