/* ==========================================================================
   TYPOVAULT FOUNDRY STUDIO — DESIGN SYSTEM & STYLESHEET
   Aesthetic: Contemporary High-End Editorial Typography Studio
   100% Original Brand Identity (Non-Infringing, High Contrast, Accessible)
   ========================================================================== */

:root {
  /* Brand Identity Palette */
  --brand-primary: #4f46e5;         /* Electric Indigo */
  --brand-primary-hover: #4338ca;
  --brand-accent: #f97316;          /* Warm Ember / Coral */
  --brand-glow: rgba(79, 70, 229, 0.2);

  /* Light Theme Palette (Default) */
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-input: #ffffff;
  
  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-focus: #4f46e5;

  --text-primary: #0f172a;          /* Rich Charcoal / Black */
  --text-secondary: #475569;
  --text-muted: #64748b;

  /* Specimen Text: Pure Crisp Black in Light Mode */
  --specimen-bg: #ffffff;
  --specimen-text: #0f172a;

  --btn-primary-bg: #4f46e5;
  --btn-primary-text: #ffffff;
  --btn-secondary-bg: #f1f5f9;
  --btn-secondary-text: #1e293b;
  --btn-secondary-border: #cbd5e1;

  --badge-bg: #ede9fe;
  --badge-text: #4f46e5;

  --card-radius: 12px;
  --pill-radius: 9999px;

  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 28px -6px rgba(15, 23, 42, 0.12);
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
  --brand-primary: #6366f1;
  --brand-primary-hover: #818cf8;
  --brand-accent: #fb923c;
  --brand-glow: rgba(99, 102, 241, 0.3);

  --bg-page: #0b0f19;
  --bg-surface: #131826;
  --bg-surface-elevated: #1a2234;
  --bg-input: #111522;

  --border-subtle: #242c40;
  --border-strong: #333e5a;
  --border-focus: #6366f1;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* Specimen Text: Crisp Pure White on Dark */
  --specimen-bg: #111522;
  --specimen-text: #ffffff;

  --btn-primary-bg: #6366f1;
  --btn-primary-text: #ffffff;
  --btn-secondary-bg: #1e2638;
  --btn-secondary-text: #e2e8f0;
  --btn-secondary-border: #333e5a;

  --badge-bg: rgba(99, 102, 241, 0.18);
  --badge-text: #a5b4fc;

  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.6);
}

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

body {
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Ambient Backdrops */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(140px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.12;
}

.glow-1 {
  width: 500px;
  height: 500px;
  background: var(--brand-primary);
  top: -80px;
  right: -60px;
}

.glow-2 {
  width: 650px;
  height: 650px;
  background: var(--brand-accent);
  bottom: -120px;
  left: -80px;
}

/* Main Layout Wrapper */
.app-layout {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 20px 80px 20px;
  position: relative;
  z-index: 10;
}

/* 1. TOP NAVIGATION BAR */
.top-nav-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(248, 250, 252, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 14px 0;
  margin-bottom: 14px;
  transition: background 0.25s ease;
}

[data-theme="dark"] .top-nav-bar {
  background: rgba(11, 15, 25, 0.95);
}

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

/* Brand Identity */
.brand-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
  transition: var(--transition);
}

.brand-logo:hover {
  transform: translateY(-1px);
}

.logo-mark {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--brand-primary), #818cf8);
  color: #ffffff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px var(--brand-glow);
}

.logo-mark.small {
  width: 28px;
  height: 28px;
  border-radius: 7px;
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text-primary);
  line-height: 1;
}

.logo-accent {
  color: var(--brand-primary);
}

.logo-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 2px;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 5px 12px;
  border-radius: var(--pill-radius);
  font-size: 12px;
}

.stat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.stat-count {
  font-weight: 700;
  color: var(--brand-primary);
  font-family: var(--font-mono);
}

.stat-lbl {
  color: var(--text-muted);
}

/* Universal Search Container */
.search-container {
  flex: 1;
  max-width: 580px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-input-wrap {
  position: relative;
  flex: 1;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input-wrap input {
  width: 100%;
  height: 40px;
  padding: 0 34px 0 38px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.search-input-wrap input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--brand-glow);
}

.search-clear-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  display: none;
  padding: 2px;
}

.search-submit-btn {
  height: 40px;
  padding: 0 16px;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px var(--brand-glow);
  transition: var(--transition);
}

.search-submit-btn:hover {
  background: var(--brand-primary-hover);
  transform: translateY(-1px);
}

/* Navigation Actions (Favorites, Compare, Theme) */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.action-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0 12px;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.action-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.action-btn svg {
  color: var(--text-muted);
}

.action-badge {
  background: var(--badge-bg);
  color: var(--badge-text);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--pill-radius);
  font-family: var(--font-mono);
}

.action-btn.editor-btn-accent {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff !important;
  box-shadow: 0 2px 10px rgba(124, 58, 237, 0.35);
  text-decoration: none;
}

.action-btn.editor-btn-accent:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.55);
  color: #ffffff !important;
}

.action-btn.editor-btn-accent svg {
  color: #ffffff !important;
}

.action-badge-gold {
  background: #fbbf24 !important;
  color: #1e1b4b !important;
  font-weight: 800 !important;
}

.theme-toggle {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0 12px;
  height: 40px;
  display: flex;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.theme-toggle:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

[data-theme="light"] .dark-text { display: none; }
[data-theme="dark"] .light-text { display: none; }

/* 2. ALPHABETICAL FILTER RIBBON (A-Z) */
.alpha-ribbon {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 6px 12px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  scrollbar-width: none;
}

.alpha-ribbon::-webkit-scrollbar {
  display: none;
}

.alpha-container {
  display: flex;
  align-items: center;
  gap: 4px;
}

.alpha-chip {
  background: none;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-display);
  transition: var(--transition);
}

.alpha-chip:hover {
  background: var(--bg-surface-elevated);
  color: var(--brand-primary);
}

.alpha-chip.active {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
  box-shadow: 0 2px 8px var(--brand-glow);
}

/* 3. CATEGORY HUB (MODERN DIRECTORY) */
.category-hub {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--card-radius);
  padding: 20px 24px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}

.hub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.hub-title-group {
  display: flex;
  flex-direction: column;
}

.hub-kicker {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand-primary);
}

.hub-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.hub-toggle-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.hub-toggle-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.chevron-icon {
  transition: transform 0.2s ease;
}

.hub-toggle-btn.open .chevron-icon {
  transform: rotate(180deg);
}

/* Category Main Pills */
.main-cat-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.main-cat-tabs::-webkit-scrollbar {
  display: none;
}

.main-cat-tab {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: var(--pill-radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: var(--transition);
}

.main-cat-tab:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.main-cat-tab.active {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
  box-shadow: 0 4px 12px var(--brand-glow);
}

.tab-pill-badge {
  background: rgba(0, 0, 0, 0.08);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--pill-radius);
  font-family: var(--font-mono);
}

.main-cat-tab.active .tab-pill-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

/* Subcategory Ribbon */
.subcat-ribbon {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  overflow-x: auto;
}

.subcat-ribbon-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.subcat-chips-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.subcat-chips-wrap::-webkit-scrollbar {
  display: none;
}

.subcat-chip {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.subcat-chip:hover {
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}

.subcat-chip.active {
  background: var(--brand-accent);
  color: #ffffff;
  border-color: var(--brand-accent);
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.25);
}

/* Mega Directory Grid */
.mega-directory {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
  animation: fadeIn 0.2s ease;
}

.mega-directory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.mega-cat-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: var(--transition);
}

.mega-cat-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.mega-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 8px;
}

.mega-card-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
}

.mega-card-title:hover {
  color: var(--brand-primary);
}

.mega-card-count {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.mega-sub-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mega-sub-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 11px;
  color: var(--text-secondary);
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
}

.mega-sub-item:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.mega-sub-item.active {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
}

/* 4. TESTING STUDIO (TOOLBAR) */
.testing-studio {
  margin-bottom: 22px;
}

.studio-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--card-radius);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
}

.studio-row.primary-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.preview-input-group {
  flex: 1;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.studio-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.preview-field-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.preview-field-wrap input {
  flex: 1;
  height: 40px;
  padding: 0 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
}

.preview-field-wrap input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--brand-glow);
}

.pangram-select {
  height: 40px;
  padding: 0 10px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  outline: none;
  max-width: 170px;
}

.studio-quick-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.control-unit {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.studio-select {
  height: 40px;
  padding: 0 10px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.studio-filter-btn {
  height: 40px;
  margin-top: 19px;
  padding: 0 14px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.studio-filter-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.layout-toggle-group {
  display: flex;
  margin-top: 19px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
}

.layout-toggle-btn {
  height: 38px;
  padding: 0 10px;
  background: var(--bg-surface);
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.layout-toggle-btn:hover {
  color: var(--text-primary);
}

.layout-toggle-btn.active {
  background: var(--brand-primary);
  color: #ffffff;
}

/* Fine-Tuning Drawer */
.studio-fine-tune-drawer {
  display: none;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  animation: fadeIn 0.15s ease;
}

.studio-fine-tune-drawer.open {
  display: block;
}

.fine-tune-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  align-items: center;
}

.slider-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slider-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slider-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.slider-val {
  font-size: 12px;
  font-weight: 700;
  color: var(--brand-primary);
  font-family: var(--font-mono);
}

.range-slider {
  width: 100%;
  accent-color: var(--brand-primary);
  cursor: pointer;
}

.align-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.align-group {
  display: flex;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
}

.align-chip {
  flex: 1;
  height: 34px;
  background: var(--bg-surface-elevated);
  border: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.align-chip.active {
  background: var(--brand-primary);
  color: #ffffff;
}

.color-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.color-picker-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-input {
  width: 44px;
  height: 34px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: none;
  cursor: pointer;
}

.reset-color-btn {
  height: 34px;
  padding: 0 12px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

.reset-color-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

/* 5. RESULTS BAR & BREADCRUMBS */
.results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.results-breadcrumbs {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.current-directory-heading {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.results-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 2px 8px;
  border-radius: var(--pill-radius);
}

/* Pagination Buttons */
.pagination-bar {
  display: flex;
  align-items: center;
  gap: 4px;
}

.page-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.page-btn:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.page-btn.active {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
  box-shadow: 0 2px 8px var(--brand-glow);
}

.page-ellipsis {
  color: var(--text-muted);
  font-size: 12px;
  padding: 0 4px;
}

/* 6. MAIN CATALOG SHOWCASE (SHOWCASE ROWS & GRID CARDS) */
.font-showcase-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Individual Showcase Card */
.typeface-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--card-radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.typeface-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* Card Header */
.card-header-bar {
  padding: 12px 20px;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.typeface-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
}

.typeface-title:hover {
  color: var(--brand-primary);
}

.cat-breadcrumb-pill {
  font-size: 11px;
  font-weight: 600;
  color: var(--brand-primary);
  background: var(--badge-bg);
  padding: 3px 10px;
  border-radius: var(--pill-radius);
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
}

.cat-breadcrumb-pill:hover {
  opacity: 0.85;
}

.author-pill {
  font-size: 11px;
  color: var(--text-muted);
}

.card-meta-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.downloads-stat {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-tool-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: var(--transition);
}

.card-tool-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.card-fav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 16px;
  line-height: 1;
  transition: var(--transition);
}

.card-fav-btn:hover, .card-fav-btn.active {
  color: #ef4444;
  transform: scale(1.2);
}

/* Primary Download Button */
.btn-download-package {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border: none;
  border-radius: 7px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 8px var(--brand-glow);
  transition: var(--transition);
}

.btn-download-package:hover {
  background: var(--brand-primary-hover);
  transform: translateY(-1px);
}

/* Specimen Body (High Contrast Jet Black Text on Light Mode) */
.card-specimen-body {
  padding: 24px;
  background: var(--specimen-bg);
  min-height: 100px;
  display: flex;
  align-items: center;
  overflow-x: auto;
  cursor: text;
}

/* CRITICAL CONTRAST FIX: Pure Jet Black in Light Mode (#0f172a), Pure White in Dark Mode */
.specimen-display-text {
  color: var(--specimen-text) !important;
  width: 100%;
  line-height: 1.25;
  white-space: pre-wrap;
  word-break: break-word;
  outline: none;
  font-family: sans-serif; /* Replaced dynamically via @font-face */
  letter-spacing: 0px;
  transition: font-size 0.15s ease, letter-spacing 0.15s ease;
}

/* Studio Grid View (2-column layout alternative) */
.font-showcase-container.view-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 20px;
}

.font-showcase-container.view-cards .typeface-card {
  display: flex;
  flex-direction: column;
}

.font-showcase-container.view-cards .card-specimen-body {
  flex: 1;
  min-height: 130px;
}

/* Bottom Results Bar */
.bottom-results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 12px;
}

.pagination-summary {
  font-size: 12px;
  color: var(--text-muted);
}

/* Skeleton Loader */
.skeleton-showcase {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.skeleton-item {
  height: 120px;
  background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-surface-elevated) 50%, var(--bg-surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--card-radius);
  border: 1px solid var(--border-subtle);
}

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

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 7. SPECIMEN MODAL */
.specimen-modal {
  border: none;
  border-radius: 16px;
  background: var(--bg-surface);
  color: var(--text-primary);
  max-width: 940px;
  width: 94vw;
  max-height: 90vh;
  box-shadow: var(--shadow-lg);
  padding: 0;
  margin: auto;
}

.specimen-modal::backdrop {
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
}

.modal-dialog-content {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.modal-header {
  padding: 20px 28px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.modal-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.modal-font-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--brand-primary);
}

.modal-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-btn-download {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 8px var(--brand-glow);
  transition: var(--transition);
}

.modal-btn-download:hover {
  background: var(--brand-primary-hover);
  transform: translateY(-1px);
}

.modal-btn-secondary {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.modal-btn-secondary:hover {
  border-color: var(--border-focus);
  color: var(--brand-primary);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 28px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
  transition: var(--transition);
}

.modal-close-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 28px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.modal-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 6px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.section-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.waterfall-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--specimen-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 20px;
}

.waterfall-row {
  display: flex;
  align-items: baseline;
  gap: 18px;
}

.waterfall-size {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  width: 45px;
}

.waterfall-sample {
  color: var(--specimen-text) !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.glyph-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  padding: 10px;
  background: var(--specimen-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
}

.glyph-tile {
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--specimen-text);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
}

.glyph-tile:hover {
  border-color: var(--brand-primary);
  background: var(--badge-bg);
  color: var(--brand-primary);
  transform: scale(1.08);
}

.code-box {
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px 18px;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.code-box pre {
  overflow-x: auto;
}

.btn-copy-code {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
}

.btn-copy-code:hover {
  background: var(--brand-primary);
  color: #ffffff;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.meta-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  padding: 14px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.meta-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

/* 8. COMPARISON DRAWER */
.comparator-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 340px;
  background: var(--bg-surface);
  border-top: 2px solid var(--brand-primary);
  box-shadow: 0 -12px 36px rgba(0, 0, 0, 0.25);
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 60;
  display: flex;
  flex-direction: column;
}

.comparator-drawer.open {
  transform: translateY(0);
}

.drawer-header {
  padding: 14px 24px;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-title-group {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.drawer-header h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--brand-primary);
}

.drawer-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.drawer-close-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-muted);
}

.drawer-body {
  padding: 20px 24px;
  overflow-x: auto;
  display: flex;
  gap: 20px;
  flex: 1;
}

.compare-card {
  min-width: 300px;
  max-width: 360px;
  background: var(--specimen-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.compare-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 8px;
}

.btn-remove-compare {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 11px;
  cursor: pointer;
  font-weight: 600;
}

/* 9. FOOTER */
.app-footer {
  margin-top: 60px;
  padding-top: 30px;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
}

.footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.footer-logo-text {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.footer-badge {
  font-size: 11px;
  color: var(--text-muted);
}

.footer-text {
  font-size: 12px;
  color: var(--text-muted);
}

/* Toast Container */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}

.toast {
  background: #0f172a;
  color: #ffffff;
  border-left: 4px solid var(--brand-primary);
  padding: 12px 18px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==========================================================================
   Responsive Breakpoints & Mobile Optimization for Typography Studio
   ========================================================================== */

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

@media (max-width: 960px) {
  .nav-container {
    flex-wrap: wrap;
    gap: 12px;
    padding: 10px 16px;
  }
  .search-container {
    order: 3;
    max-width: 100%;
    width: 100%;
  }
  .main-cat-tabs {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
  }
  .alpha-container {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
  }
}

@media (max-width: 640px) {
  .app-header {
    position: sticky;
    top: 0;
    z-index: 80;
  }
  .brand-group {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .stat-chip {
    display: none;
  }
  .nav-actions {
    gap: 6px;
  }
  .action-btn span {
    display: none;
  }
  .action-btn {
    padding: 6px 10px;
    min-height: 40px;
  }
  .action-badge {
    margin-left: 2px;
  }
  .editor-btn-accent span:not(.action-badge) {
    display: inline;
    font-size: 11px;
  }
  .studio-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 12px;
  }
  .toolbar-left, .toolbar-right {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }
  .toolbar-left input[type="text"] {
    width: 100% !important;
    min-width: 100% !important;
  }
  .fine-tune-grid {
    grid-template-columns: 1fr;
  }
  .meta-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .font-showcase-container.view-cards {
    grid-template-columns: 1fr;
  }
  .card-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .card-actions-wrap {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .card-actions-wrap button, .card-actions-wrap a {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  /* Specimen Inspection Modal on Mobile */
  .specimen-modal-dialog {
    width: 96% !important;
    max-height: 92vh !important;
    padding: 16px !important;
    margin: 4vh auto !important;
  }
  .modal-specimen-waterfall {
    gap: 12px;
  }
  .waterfall-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .waterfall-label {
    min-width: unset;
  }
  /* Comparator Drawer on Mobile */
  .comparator-drawer {
    height: 380px;
  }
  .drawer-body {
    padding: 12px;
    gap: 12px;
  }
  .compare-card {
    min-width: 260px;
  }
}

/* ==========================================================================
   Smart Search Autocomplete Dropdown (Studio & Discovery)
   ========================================================================== */
.studio-search-autocomplete {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16), 0 4px 12px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 1000;
  overflow: hidden;
  animation: autocompleteFadeIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 480px;
  display: flex;
  flex-direction: column;
}

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

.studio-autocomplete-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.02);
}

.studio-autocomplete-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  overflow-y: auto;
  max-height: 360px;
}

.studio-autocomplete-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
  border-left: 3px solid transparent;
  gap: 12px;
}

.studio-autocomplete-item:hover,
.studio-autocomplete-item.active {
  background: rgba(99, 102, 241, 0.08);
  border-left-color: var(--brand-primary);
}

.studio-autocomplete-item-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.studio-autocomplete-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.studio-autocomplete-name mark {
  background: rgba(99, 102, 241, 0.22);
  color: var(--brand-primary);
  font-weight: 700;
  padding: 1px 3px;
  border-radius: 3px;
}

.studio-autocomplete-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.studio-autocomplete-cat {
  background: rgba(99, 102, 241, 0.1);
  color: var(--brand-primary);
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 600;
}

.studio-autocomplete-item-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.studio-autocomplete-downloads {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.studio-autocomplete-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--border-subtle);
  color: var(--text-secondary);
}

.studio-autocomplete-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.02);
  border-top: 1px solid var(--border-subtle);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s ease;
}

.studio-autocomplete-footer:hover {
  background: rgba(99, 102, 241, 0.06);
  color: var(--brand-primary);
}

.studio-autocomplete-kbd {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  padding: 2px 6px;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

