/* =============================================
   FONTS & DESIGN TOKENS
   ============================================= */
@font-face {
  font-family: 'Vazirmatn';
  src: url('fonts/Vazirmatn.woff2') format('woff2'),
       url('/fonts/Vazirmatn.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-persian: 'Vazirmatn', Tahoma, -apple-system, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --text-xs: 0.72rem;
  --text-sm: 0.82rem;
  --text-base: 0.92rem;
  --text-md: 1rem;
  --text-lg: 1.15rem;
  --text-xl: 1.35rem;
  --text-2xl: 1.75rem;

  --space-1: 0.2rem;
  --space-2: 0.4rem;
  --space-3: 0.6rem;
  --space-4: 0.85rem;
  --space-5: 1.1rem;
  --space-6: 1.35rem;
  --space-8: 1.75rem;
  --space-10: 2.25rem;

  --radius-sm: 0.35rem;
  --radius-md: 0.55rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 999rem;

  --duration-fast: 0.12s;
  --duration-base: 0.18s;
  --max-width: 68rem;
}

/* Three Themes */
[data-theme="dark"] {
  color-scheme: dark;
  --bg-primary: #0c0f12;
  --bg-secondary: #141920;
  --bg-tertiary: #1a212b;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-dim: #64748b;
  --accent: #FFC107;
  --accent-hover: #FFD54F;
  --accent-rgb: 255, 193, 7;
  --accent-subtle: rgba(255, 193, 7, 0.10);
  --accent-glow: rgba(255, 193, 7, 0.20);
  --accent-ink: #0c0f12;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  --card-bg: rgba(20, 25, 32, 0.92);
  --card-hover: rgba(26, 33, 43, 0.98);
  --code-bg: #07090c;
  --code-border: rgba(255, 255, 255, 0.08);
  --input-bg: #0b0e12;
  --badge-bg: rgba(255, 255, 255, 0.05);
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.10);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.10);
}

[data-theme="black"] {
  color-scheme: dark;
  --bg-primary: #000000;
  --bg-secondary: #0a0b0d;
  --bg-tertiary: #131518;
  --text-primary: #ffffff;
  --text-secondary: #9aa0a6;
  --text-dim: #5f6368;
  --accent: #FFD54F;
  --accent-hover: #FFE082;
  --accent-rgb: 255, 213, 79;
  --accent-subtle: rgba(255, 213, 79, 0.12);
  --accent-glow: rgba(255, 213, 79, 0.25);
  --accent-ink: #000000;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --card-bg: #0b0d0f;
  --card-hover: #14171a;
  --code-bg: #040506;
  --code-border: #1e2126;
  --input-bg: #07080a;
  --badge-bg: rgba(255, 255, 255, 0.07);
  --success: #4ade80;
  --success-bg: rgba(74, 222, 128, 0.12);
  --error: #f87171;
  --error-bg: rgba(248, 113, 113, 0.12);
}

[data-theme="light"] {
  color-scheme: light;
  --bg-primary: #fdfbf7;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f4f1ea;
  --text-primary: #18181b;
  --text-secondary: #52525b;
  --text-dim: #71717a;
  --accent: #d97706;
  --accent-hover: #b45309;
  --accent-rgb: 217, 119, 6;
  --accent-subtle: rgba(217, 119, 6, 0.08);
  --accent-glow: rgba(217, 119, 6, 0.18);
  --accent-ink: #ffffff;
  --border: rgba(24, 24, 27, 0.08);
  --border-strong: rgba(24, 24, 27, 0.16);
  --card-bg: #ffffff;
  --card-hover: #faf9f6;
  --code-bg: #f4f2ee;
  --code-border: #e4e1d8;
  --input-bg: #ffffff;
  --badge-bg: rgba(24, 24, 27, 0.04);
  --success: #16a34a;
  --success-bg: rgba(22, 163, 74, 0.08);
  --error: #dc2626;
  --error-bg: rgba(220, 38, 38, 0.08);
}

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

html {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.5;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

html[lang="fa"] {
  font-family: var(--font-persian);
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--duration-fast);
}

button, input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

code, pre, .font-mono {
  font-family: var(--font-mono);
  direction: ltr !important;
  text-align: left !important;
}

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

.icon {
  width: 1.15rem;
  height: 1.15rem;
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
}

/* Header */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(12, 15, 18, 0.92);
  border-bottom: 0.0625rem solid var(--border);
  backdrop-filter: blur(0.625rem);
  -webkit-backdrop-filter: blur(0.625rem);
}
[data-theme="black"] .nav { background-color: rgba(0, 0, 0, 0.92); }
[data-theme="light"] .nav { background-color: rgba(253, 251, 247, 0.92); }

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

.nav-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
  cursor: pointer;
}

.brand-cube {
  width: 1.85rem;
  height: 1.85rem;
}

.brand-mark {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

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

.nav-center {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  transition: all var(--duration-fast);
  cursor: pointer;
}

.nav-link:hover {
  color: var(--text-primary);
  background-color: var(--badge-bg);
}

.nav-link.active {
  color: var(--accent);
  background-color: var(--accent-subtle);
  border: 0.0625rem solid rgba(var(--accent-rgb), 0.25);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Preferences Dropdown */
.custom-dropdown {
  position: relative;
}

.pref-compact-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  background-color: var(--badge-bg);
  border: 0.0625rem solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  transition: all var(--duration-fast);
}

.pref-compact-trigger:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.pref-pipe { opacity: 0.3; }

.pref-flag {
  width: 1rem;
  height: 0.75rem;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  width: 14rem;
  background-color: var(--bg-secondary);
  border: 0.0625rem solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  box-shadow: 0 10.125rem 20.5rem rgba(0, 0, 0, 0.35);
  display: none;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 120;
}

html[dir="rtl"] .dropdown-menu {
  right: auto;
  left: 0;
}

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

.form-hint {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin-bottom: var(--space-1);
  display: block;
}

.theme-grid, .lang-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.3rem;
}

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

.theme-btn, .lang-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.35rem 0.25rem;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 0.0625rem solid var(--border);
  background: var(--bg-primary);
  color: var(--text-secondary);
  transition: all var(--duration-fast);
}

.theme-btn.active, .lang-btn.active {
  background-color: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent);
}

/* =============================================
   PAGE VIEWS (SPA SWITCHING)
   ============================================= */
.page-view {
  display: none;
  animation: viewFadeIn 0.15s ease-out;
  padding: var(--space-6) 0 var(--space-8);
  flex: 1;
}

.page-view.active {
  display: block;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

@keyframes viewFadeIn {
  from { opacity: 0; transform: translateY(0.2rem); }
  to { opacity: 1; transform: translateY(0); }
}

/* Hero / Header in Pages */
.hero-header {
  margin-bottom: var(--space-4);
}

.hero-title-compact {
  font-size: clamp(1.4rem, 3.5vw, 1.9rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: var(--space-1);
}

.hero-title-compact .highlight {
  color: var(--accent);
}

.hero-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  max-width: 48rem;
  line-height: 1.5;
}

/* Credentials Box */
.creds-card {
  background: var(--card-bg);
  border: 0.0625rem solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: 0 0.625rem 1.875rem rgba(0, 0, 0, 0.25);
  margin-top: var(--space-4);
}

.creds-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 0.0625rem solid var(--border);
}

.creds-card-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.regenerate-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.9rem;
  background-color: var(--accent);
  color: var(--accent-ink);
  font-size: var(--text-xs);
  font-weight: 700;
  border-radius: var(--radius-full);
  box-shadow: 0 0.125rem 0.625rem var(--accent-glow);
  transition: all var(--duration-fast);
}

.regenerate-btn:hover {
  background-color: var(--accent-hover);
  transform: translateY(-0.0625rem);
}

.regenerate-btn:active {
  transform: translateY(0);
}

.regenerate-icon {
  width: 0.95rem;
  height: 0.95rem;
  transition: transform 0.3s ease;
}

.regenerate-btn:hover .regenerate-icon {
  transform: rotate(180deg);
}

.creds-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2);
}

@media (min-width: 42.5rem) {
  .creds-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.creds-item {
  background: var(--code-bg);
  border: 0.0625rem solid var(--code-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
}

.creds-item.full-width {
  grid-column: 1 / -1;
}

.creds-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-1);
}

.creds-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.creds-val-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.creds-val {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-primary);
  word-break: break-all;
}

.creds-val.accent { color: var(--accent); }
.creds-val.secret { color: var(--success); }

.copy-btn {
  padding: 0.25rem 0.45rem;
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  background: var(--badge-bg);
  border: 0.0625rem solid var(--border);
  font-size: var(--text-xs);
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
  transition: all var(--duration-fast);
}

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

/* Metadata pill row */
.creds-meta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 0.0625rem solid var(--border);
  font-size: var(--text-xs);
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-sm);
  background: var(--badge-bg);
  border: 0.0625rem solid var(--border);
  color: var(--text-secondary);
}

.meta-pill strong {
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.meta-pill.regex-pill {
  background: var(--success-bg);
  border-color: rgba(34, 197, 94, 0.25);
  color: var(--success);
  font-weight: 600;
}

/* Inline Inspector */
.inspector-strip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding: var(--space-2);
  background: var(--input-bg);
  border: 0.0625rem solid var(--border-strong);
  border-radius: var(--radius-md);
}

.inspector-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  outline: none;
  padding: 0.2rem 0.4rem;
}

.inspector-btn {
  padding: 0.35rem 0.75rem;
  background: var(--badge-bg);
  border: 0.0625rem solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  transition: all var(--duration-fast);
}

.inspector-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent);
}

/* =============================================
   SPECIFICATION SECTION (COMPACT)
   ============================================= */
.spec-grid-compact {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

@media (min-width: 42.5rem) {
  .spec-grid-compact {
    grid-template-columns: 1fr 1fr;
  }
}

.spec-card {
  background: var(--card-bg);
  border: 0.0625rem solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.spec-card h3 {
  font-size: var(--text-md);
  font-weight: 800;
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-primary);
}

.spec-card p, .spec-card li {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

.spec-card ul {
  margin-left: 1.25rem;
  margin-top: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.code-box-mini {
  background: var(--code-bg);
  border: 0.0625rem solid var(--code-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--accent);
  margin-top: var(--space-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.spec-card.full-width {
  grid-column: 1 / -1;
}

.spec-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
  gap: var(--space-2);
  flex-wrap: wrap;
}

.spec-card-head h3 {
  margin-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  font-size: var(--text-xs);
  font-weight: 700;
  border-radius: var(--radius-full);
  background: var(--accent-subtle);
  color: var(--accent);
  border: 0.0625rem solid rgba(var(--accent-rgb), 0.25);
  letter-spacing: 0.02em;
}

.decision-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

@media (min-width: 42.5rem) {
  .decision-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.decision-step {
  background: var(--bg-secondary);
  border: 0.0625rem solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
}

.decision-step .step-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 0.15rem;
}

.decision-step .step-date {
  font-size: var(--text-sm);
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.decision-step .step-date .dim {
  color: var(--text-dim);
  font-weight: 500;
}

.decision-step .step-desc {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

/* =============================================
   SPECIFICATION ENHANCEMENTS (DIAGRAM, TABLE, DDL)
   ============================================= */
.spec-badges-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: var(--space-3);
  justify-content: center;
}

.spec-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  border: 0.0625rem solid var(--border);
  color: var(--text-secondary);
}

.spec-badge-pill.accent {
  background: var(--accent-subtle);
  border-color: rgba(var(--accent-rgb), 0.3);
  color: var(--accent);
}

.anatomy-box {
  background: var(--code-bg);
  border: 0.0625rem solid var(--code-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-top: var(--space-3);
  margin-bottom: var(--space-3);
}

.anatomy-bar {
  display: flex;
  width: 100%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  height: 2.25rem;
  margin-top: 0.5rem;
  border: 0.0625rem solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  text-align: center;
  line-height: 2.25rem;
}

.anatomy-segment-sign {
  width: 8%;
  background: var(--bg-tertiary);
  color: var(--text-dim);
  border-right: 0.0625rem solid var(--border);
}

.anatomy-segment-time {
  width: 67%;
  background: var(--accent-subtle);
  color: var(--accent);
  border-right: 0.0625rem solid var(--border);
}

.anatomy-segment-rand {
  width: 25%;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
}

.anatomy-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: 0.6rem;
  font-size: var(--text-xs);
  color: var(--text-dim);
}

.anatomy-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.anatomy-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: var(--radius-full);
}
.anatomy-dot.sign { background: var(--text-dim); }
.anatomy-dot.time { background: var(--accent); }
.anatomy-dot.rand { background: #38bdf8; }

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: var(--space-3);
  border-radius: var(--radius-md);
  border: 0.0625rem solid var(--border);
}

.spec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-xs);
  text-align: left;
  min-width: 37.5rem;
}

[dir="rtl"] .spec-table {
  text-align: right;
}

.spec-table th {
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 700;
  padding: 0.65rem 0.85rem;
  border-bottom: 0.0625rem solid var(--border);
  white-space: nowrap;
}

.spec-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 0.0625rem solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

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

.spec-table tr.highlight-row {
  background: var(--accent-subtle);
}

.spec-table tr.highlight-row td {
  color: var(--text-primary);
  font-weight: 600;
}

.spec-table tr.highlight-row td:first-child {
  color: var(--accent);
  font-weight: 700;
}

.pill-sm {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 700;
}

.pill-sm.yes {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
  border: 0.0625rem solid rgba(34, 197, 94, 0.3);
}

.pill-sm.no {
  background: rgba(239, 68, 68, 0.12);
  color: var(--error);
  border: 0.0625rem solid rgba(239, 68, 68, 0.25);
}

.pill-sm.neutral {
  background: var(--bg-tertiary);
  color: var(--text-dim);
  border: 0.0625rem solid var(--border);
}

.ddl-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

@media (min-width: 42.5rem) {
  .ddl-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.ddl-item {
  background: var(--code-bg);
  border: 0.0625rem solid var(--code-border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
}

.ddl-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-primary);
}

.ddl-code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--text-secondary);
  background: transparent;
  padding: 0;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
}

/* =============================================
   CODE IMPLEMENTATIONS (COMPACT TABS)
   ============================================= */
.section-title-sm {
  font-size: var(--text-lg);
  font-weight: 800;
  margin-bottom: var(--space-3);
}

.lang-bar-compact {
  display: flex;
  gap: var(--space-1);
  overflow-x: auto;
  margin-bottom: var(--space-3);
  scrollbar-width: thin;
}

.lang-btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  border: 0.0625rem solid var(--border);
  color: var(--text-secondary);
  white-space: nowrap;
  transition: all var(--duration-fast);
}

.code-file-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.lang-btn-sm.active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 700;
}

.code-panel-sm {
  display: none;
  background: var(--code-bg);
  border: 0.0625rem solid var(--code-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.code-panel-sm.active {
  display: block;
}

.code-head-sm {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.8rem;
  background: var(--bg-secondary);
  border-bottom: 0.0625rem solid var(--border);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--text-dim);
}

.code-pre-sm {
  padding: var(--space-3) 0;
  overflow-x: auto;
  font-size: var(--text-xs);
  line-height: 1.55;
  color: #e2e8f0;
  max-height: 45rem;
}
[data-theme="light"] .code-pre-sm { color: #1e293b; }

.code-pre-sm code {
  display: block;
  min-width: max-content;
}

.code-line {
  display: flex;
  padding: 0 var(--space-3);
  min-height: 1.55em;
}

.code-line:hover {
  background-color: rgba(255, 255, 255, 0.04);
}
[data-theme="light"] .code-line:hover {
  background-color: rgba(0, 0, 0, 0.04);
}

.line-num {
  display: inline-block;
  width: 2.2rem;
  padding-right: var(--space-3);
  text-align: right;
  color: #64748b;
  user-select: none;
  -webkit-user-select: none;
  font-variant-numeric: tabular-nums;
  opacity: 0.65;
  flex-shrink: 0;
}
[data-theme="light"] .line-num {
  color: #94a3b8;
}

.line-content {
  flex: 1;
  white-space: pre;
}

/* =============================================
   SELF-CONTAINED SYNTAX HIGHLIGHTING TOKENS
   ============================================= */
.tok-keyword {
  color: #f59e0b;
  font-weight: 600;
}
.tok-string {
  color: #34d399;
}
.tok-comment {
  color: #64748b;
  font-style: italic;
}
.tok-number {
  color: #38bdf8;
}
.tok-type {
  color: #c084fc;
  font-weight: 600;
}

[data-theme="light"] .tok-keyword {
  color: #d97706;
  font-weight: 600;
}
[data-theme="light"] .tok-string {
  color: #059669;
}
[data-theme="light"] .tok-comment {
  color: #94a3b8;
  font-style: italic;
}
[data-theme="light"] .tok-number {
  color: #0284c7;
}
[data-theme="light"] .tok-type {
  color: #7c3aed;
  font-weight: 600;
}

/* Toast */
.toast-notice {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(5rem);
  background: var(--text-primary);
  color: var(--bg-primary);
  padding: 0.45rem 1rem;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
  z-index: 1000;
}

.toast-notice.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* =============================================
   UTILITY CLASSES (ZERO INLINE STYLES)
   ============================================= */
.svg-sprite {
  display: none;
}

.icon-sm {
  width: 0.9rem;
  height: 0.9rem;
}

.icon-base {
  width: 1rem;
  height: 1rem;
}

.icon-accent {
  color: var(--accent);
}

.icon-success {
  color: var(--success);
}

.token-val {
  color: var(--text-primary);
}

.mt-sm {
  margin-top: 0.5rem;
}

.nav-item-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.lang-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

/* Language Template Switching without JS HTML Injection */
html[lang="en"] [data-lang="fa"] {
  display: none !important;
}

html[lang="fa"] [data-lang="en"] {
  display: none !important;
}

/* Copy button icon states without JS HTML injection */
.copy-btn .icon-check {
  display: none;
}
.copy-btn.copied .icon-copy {
  display: none;
}
.copy-btn.copied .icon-check {
  display: inline-block;
  color: var(--success);
}

/* Regenerate button spinning state without JS style injection */
.regenerate-btn.spinning .regenerate-icon {
  transform: rotate(360deg);
}

/* =============================================
   BOTTOM NAVIGATION BAR (MOBILE)
   ============================================= */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3.75rem;
  background: var(--nav-bg);
  backdrop-filter: blur(0.625rem);
  -webkit-backdrop-filter: blur(0.625rem);
  border-top: 0.0625rem solid var(--border);
  z-index: 100;
  align-items: center;
  justify-content: space-around;
  padding: 0 0.5rem;
}

.bottom-nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.35rem 0.75rem;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast);
  cursor: pointer;
  flex: 1;
  max-width: 7rem;
}

.bottom-nav-icon {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}

.bottom-nav-link.active {
  color: var(--accent);
}

.bottom-nav-link.active .bottom-nav-icon {
  color: var(--accent);
}

@media (max-width: 42.5rem) {
  .nav-center {
    display: none;
  }
  .bottom-nav {
    display: flex;
  }
  body {
    padding-bottom: 4.5rem;
  }
  .toast-notice {
    bottom: 4.5rem;
  }
}
