/* ==========================================================================
   DeckDrop Pro — Design System (v2: Developer Premium)
   ========================================================================== */

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  border-radius: var(--radius-md);
}
table { border-spacing: 0; border-collapse: collapse; }
img { max-width: 100%; display: block; }

/* ==========================================================================
   1. Design Tokens
   ========================================================================== */

:root {
  /* --- Colors: Dark Theme (default) --- */
  --bg:            #09090b;
  --bg-raised:     #18181b;
  --bg-card:       #1c1c20;
  --bg-hover:      #27272a;
  --bg-selection:  rgba(163,230,53,0.06);
  --border:        #27272a;
  --border-hover:  #3f3f46;
  --text:          #e4e4e7;
  --text-bright:   #fafafa;
  --text-dim:      #a1a1aa;
  --text-muted:    #8a8a93;
  --accent:        #a3e635;
  --accent-hover:  #bef264;
  --accent-dim:    rgba(163,230,53,0.08);
  --accent-mid:    rgba(163,230,53,0.20);
  --green:         #4ade80;
  --red:           #f87171;
  --yellow:        #fbbf24;
  --blue:          #60a5fa;
  --cyan:          #22d3ee;
  --purple:        #a78bfa;
  --pink:          #f472b6;

  /* --- Typography --- */
  --font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:     'JetBrains Mono', 'Fira Code', 'SF Mono', Menlo, monospace;
  --text-xs:       11px;
  --text-sm:       13px;
  --text-base:     15px;
  --text-lg:       17px;
  --text-xl:       20px;
  --text-2xl:      26px;
  --text-3xl:      36px;

  /* --- Spacing (4px grid) --- */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* --- Radius --- */
  --radius-sm:   4px;
  --radius-md:   6px;
  --radius-lg:   8px;
  --radius-xl:   10px;
  --radius-full: 9999px;

  /* --- Shadows (dark: mostly border-based) --- */
  --shadow-sm:  none;
  --shadow-md:  0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg:  0 8px 24px rgba(0,0,0,0.4);

  /* --- Transitions --- */
  --transition-fast:  100ms ease-out;
  --transition-base:  150ms ease-out;
  --transition-slow:  250ms ease-out;

  /* --- Layout --- */
  --sidebar-width:     220px;
  --sidebar-collapsed: 56px;
  --content-max:       1200px;
  --nav-height:        56px;
}

/* --- Light Theme --- */
[data-theme="light"] {
  --bg:            #fafafa;
  --bg-raised:     #ffffff;
  --bg-card:       #ffffff;
  --bg-hover:      #f4f4f5;
  --bg-selection:  rgba(101,163,13,0.06);
  --border:        #e4e4e7;
  --border-hover:  #d4d4d8;
  --text:          #18181b;
  --text-bright:   #09090b;
  --text-dim:      #52525b;
  --text-muted:    #71717a;
  --accent:        #65a30d;
  --accent-hover:  #4d7c0f;
  --accent-dim:    rgba(101,163,13,0.06);
  --accent-mid:    rgba(101,163,13,0.15);
  --green:         #16a34a;
  --red:           #dc2626;
  --yellow:        #d97706;
  --blue:          #2563eb;
  --cyan:          #0891b2;
  --purple:        #7c3aed;
  --pink:          #db2777;
  --shadow-sm:     0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:     0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg:     0 8px 24px rgba(0,0,0,0.12);
}

/* --- Font Size Scaling --- */
[data-fontsize="small"] { font-size: 13px; }
[data-fontsize="large"]  { font-size: 17px; }

/* ==========================================================================
   2. Typography
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
  color: var(--text-bright);
  line-height: 1.3;
}
h1 { font-size: var(--text-3xl); font-weight: 800; letter-spacing: -0.03em; }
h2 { font-size: var(--text-2xl); font-weight: 700; letter-spacing: -0.02em; }
h3 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
h4 { font-size: var(--text-base); font-weight: 600; }

p { margin-bottom: var(--space-3); }
p:last-child { margin-bottom: 0; }

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

/* ==========================================================================
   3. App Shell — Navbar
   ========================================================================== */

.navbar {
  display: flex;
  align-items: center;
  height: var(--nav-height);
  padding: 0 var(--space-5);
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}
.navbar-brand {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--accent);
  text-decoration: none;
  margin-right: var(--space-8);
  letter-spacing: -0.02em;
}
.navbar-brand:hover { text-decoration: none; color: var(--accent-hover); }
.navbar-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  list-style: none;
}
.navbar-nav a {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 var(--space-3);
  color: var(--text-dim);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: color var(--transition-fast), background var(--transition-fast);
}
.navbar-nav a:hover {
  color: var(--text);
  background: var(--bg-hover);
  text-decoration: none;
}
.navbar-nav a.active {
  color: var(--accent);
  background: var(--accent-dim);
}
.navbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.navbar-right .user-name {
  font-size: var(--text-sm);
  color: var(--text-dim);
}

/* Hamburger (hidden on desktop) */
.navbar-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0;
}

/* Mobile menu overlay */
.mobile-menu-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 999;
  flex-direction: column;
  padding: var(--space-5);
}
.mobile-menu-overlay.open { display: flex; }
.mobile-menu-close {
  align-self: flex-end;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  width: 40px;
  height: 40px;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.mobile-menu-nav {
  display: flex;
  flex-direction: column;
  margin-top: var(--space-4);
  list-style: none;
}
.mobile-menu-nav a,
.mobile-menu-nav button {
  display: flex;
  align-items: center;
  height: 48px;
  padding: 0 var(--space-3);
  color: var(--text);
  text-decoration: none;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: var(--text-base);
  width: 100%;
  text-align: left;
  border-radius: 0;
}
.mobile-menu-nav a:hover { background: var(--bg-hover); text-decoration: none; }
.mobile-menu-nav a.active { color: var(--accent); }

/* ==========================================================================
   4. App Shell — Sidebar (Dashboard)
   ========================================================================== */

.sidebar {
  position: fixed;
  top: var(--nav-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 50;
  overflow-y: auto;
  transition: width var(--transition-slow);
}
.sidebar-nav {
  flex: 1;
  padding: var(--space-3) var(--space-3);
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  color: var(--text-dim);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: color var(--transition-fast), background var(--transition-fast);
}
.sidebar-nav a:hover {
  color: var(--text);
  background: var(--bg-hover);
  text-decoration: none;
}
.sidebar-nav a.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-left: 2px solid var(--accent);
}
.sidebar-nav .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}
.sidebar-nav a.active .nav-icon { opacity: 1; }
.sidebar-sep {
  height: 1px;
  background: var(--border);
  margin: var(--space-2) var(--space-3);
}
.sidebar-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.sidebar-usage {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.sidebar-meter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.sidebar-meter-bar {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.sidebar-meter-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

/* Main content area (when sidebar is present) */
.main-content {
  margin-left: var(--sidebar-width);
  padding: var(--space-6) var(--space-8);
  max-width: calc(var(--content-max) + var(--space-8) * 2);
  transition: margin-left var(--transition-slow);
  animation: content-enter 0.2s ease-out;
}
@keyframes content-enter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Page body (no sidebar — landing, auth pages) */
.page-body {
  padding: var(--space-6) var(--space-6) var(--space-12);
}

/* ==========================================================================
   5. Page Header (within content area)
   ========================================================================== */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
}
.page-header h1, .page-title {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-bright);
}
.page-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ==========================================================================
   6. Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition-base), border-color var(--transition-base), color var(--transition-base);
  min-height: 36px;
  line-height: 1;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #09090b;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary {
  background: transparent;
  border-color: var(--border-hover);
  color: var(--text);
}
.btn-secondary:hover {
  border-color: var(--text-muted);
  background: var(--bg-hover);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
}
.btn-ghost:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.btn-danger {
  background: transparent;
  border-color: rgba(248,113,113,0.3);
  color: var(--red);
}
.btn-danger:hover {
  border-color: var(--red);
  background: rgba(248,113,113,0.08);
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  min-height: 28px;
}
.btn-lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-base);
  min-height: 44px;
}

/* ==========================================================================
   7. Inputs
   ========================================================================== */

.field-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-bright);
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-base);
}
.field-input:focus {
  border-color: var(--accent-mid);
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-dim);
}
.field-input::placeholder { color: var(--text-muted); }

.field-label {
  display: block;
  color: var(--text-dim);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: var(--space-1);
}

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

/* ==========================================================================
   8. Cards
   ========================================================================== */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: border-color var(--transition-base);
}
.card:hover { border-color: var(--border-hover); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}

/* Deck-specific card */
.deck-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--transition-base), transform var(--transition-base);
}
.deck-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
}
.deck-card-thumb {
  aspect-ratio: 16/9;
  background: var(--bg-raised);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.deck-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.deck-card-thumb .deck-placeholder {
  color: var(--text-muted);
  font-size: var(--text-2xl);
  opacity: 0.3;
}
.deck-card-badge {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
}
.deck-card-body {
  padding: var(--space-3) var(--space-4);
}
.deck-card-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: var(--space-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.deck-card-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.deck-card-meta .sep { opacity: 0.4; }

/* ==========================================================================
   9. Badges
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  font-size: var(--text-xs);
  font-weight: 500;
  border: 1px solid;
  border-radius: var(--radius-sm);
  line-height: 1.5;
  white-space: nowrap;
}
.badge-public  { color: var(--green); border-color: rgba(74,222,128,0.3); background: rgba(74,222,128,0.06); }
.badge-private { color: var(--yellow); border-color: rgba(251,191,36,0.3); background: rgba(251,191,36,0.06); }
.badge-admin   { color: var(--purple); border-color: rgba(167,139,250,0.3); background: rgba(167,139,250,0.06); }
.badge-pro     { color: var(--accent); border-color: var(--accent-mid); background: var(--accent-dim); }
.badge-business { color: var(--cyan); border-color: rgba(34,211,238,0.3); background: rgba(34,211,238,0.06); }
.badge-starter { color: var(--text-muted); border-color: rgba(113,113,122,0.3); background: rgba(113,113,122,0.06); }
.badge-error   { color: var(--red); border-color: rgba(248,113,113,0.3); background: rgba(248,113,113,0.06); }
.badge-active  { color: var(--green); border-color: rgba(74,222,128,0.3); background: rgba(74,222,128,0.06); }

/* Plan badge (used in navbar/sidebar) */
.plan-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  font-size: var(--text-xs);
  font-weight: 500;
  border: 1px solid;
  border-radius: var(--radius-sm);
}
.plan-badge.starter  { color: var(--text-muted); border-color: rgba(113,113,122,0.3); }
.plan-badge.pro      { color: var(--accent); border-color: var(--accent-mid); background: var(--accent-dim); }
.plan-badge.business { color: var(--cyan); border-color: rgba(34,211,238,0.3); background: rgba(34,211,238,0.06); }
.plan-badge.admin    { color: var(--purple); border-color: rgba(167,139,250,0.3); background: rgba(167,139,250,0.06); }

/* ==========================================================================
   10. Section Label
   ========================================================================== */

.section-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--space-2);
}

/* ==========================================================================
   11. Tables
   ========================================================================== */

.data-table {
  width: 100%;
  font-size: var(--text-sm);
  border-collapse: collapse;
}
.data-table thead th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 500;
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: var(--space-2) var(--space-4) var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}
.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast);
}
.data-table tbody tr:hover {
  background: var(--bg-hover);
}
.data-table td {
  padding: var(--space-3) var(--space-4) var(--space-3) 0;
  vertical-align: middle;
}

/* ==========================================================================
   12. Code Blocks
   ========================================================================== */

.code-block {
  background: #111114;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.7;
  color: var(--text);
  overflow-x: auto;
  position: relative;
}
[data-theme="light"] .code-block { background: #f8f8fa; }

.code-block .comment { color: var(--text-muted); }
.code-block .string  { color: var(--green); }
.code-block .cmd     { color: var(--accent); }
.code-block .flag    { color: var(--cyan); }
.code-block .url     { color: var(--blue); }

/* ==========================================================================
   13. Copy Button
   ========================================================================== */

.copy-hint {
  position: absolute;
  top: var(--space-2);
  right: var(--space-3);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-family: var(--font);
  transition: border-color var(--transition-base), color var(--transition-base);
}
.copy-hint:hover {
  border-color: var(--accent-mid);
  color: var(--accent);
}

/* ==========================================================================
   14. Stats
   ========================================================================== */

.stats-row {
  display: flex;
  gap: var(--space-4);
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  flex: 1;
}
.stat-card .stat-value {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-bright);
}
.stat-card .stat-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

/* Legacy inline stats */
.stat-item .val { color: var(--accent); font-weight: 600; }
.stat-item .lbl { color: var(--text-dim); margin-left: var(--space-2); }

/* ==========================================================================
   15. Toast / Notifications
   ========================================================================== */

.toast {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text);
  z-index: 1000;
  max-width: 400px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--transition-base), transform var(--transition-base);
  box-shadow: var(--shadow-md);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { border-left: 3px solid var(--green); }
.toast-error   { border-left: 3px solid var(--red); }
.toast-info    { border-left: 3px solid var(--blue); }

/* ==========================================================================
   16. Modal / Dialog
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 500;
}
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  max-width: 480px;
  width: 90%;
  z-index: 501;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: var(--space-5) var(--space-5) var(--space-3);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-bright);
}
.modal-body { padding: var(--space-3) var(--space-5); }
.modal-footer {
  padding: var(--space-3) var(--space-5) var(--space-5);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* ==========================================================================
   17. Skeleton Loading
   ========================================================================== */

.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--bg-hover) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease infinite;
  border-radius: var(--radius-md);
}
.skeleton-text { height: 14px; margin-bottom: var(--space-2); }
.skeleton-heading { height: 20px; width: 60%; margin-bottom: var(--space-3); }
.skeleton-card {
  border-radius: var(--radius-lg);
  aspect-ratio: 16/9;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ==========================================================================
   18. Impersonation Banner
   ========================================================================== */

.impersonation-banner {
  background: var(--yellow);
  color: #09090b;
  text-align: center;
  padding: var(--space-1) var(--space-4);
  font-size: var(--text-xs);
  font-weight: 500;
}
.impersonation-banner a {
  color: #09090b;
  text-decoration: underline;
  margin-left: var(--space-2);
}

/* ==========================================================================
   19. Empty State
   ========================================================================== */

.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-6);
}
.empty-state-icon {
  font-size: 48px;
  color: var(--text-muted);
  margin-bottom: var(--space-4);
  opacity: 0.4;
}
.empty-state h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: var(--space-2);
}
.empty-state p {
  color: var(--text-dim);
  font-size: var(--text-sm);
  max-width: 400px;
  margin: 0 auto var(--space-5);
}
.empty-state-actions {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
}

/* ==========================================================================
   20. Meters / Progress
   ========================================================================== */

.meter {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.meter-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}
.meter-fill.warning { background: var(--yellow); }
.meter-fill.danger { background: var(--red); }
.meter-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 60px;
}

/* ==========================================================================
   21. Tabs
   ========================================================================== */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-5);
  overflow-x: auto;
}
.tab {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  font-family: var(--font);
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color var(--transition-fast);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab svg { flex-shrink: 0; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ==========================================================================
   22. Collapsible
   ========================================================================== */

.collapsible-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  font-size: var(--text-sm);
  padding: var(--space-2) 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  transition: color var(--transition-fast);
}
.collapsible-toggle:hover { color: var(--text); }
.collapsible-content { display: none; margin-top: var(--space-2); }
.collapsible-content.open { display: block; }

/* ==========================================================================
   23. Steps (Connect page)
   ========================================================================== */

.steps { display: flex; flex-direction: column; gap: var(--space-4); }
.step { display: flex; gap: var(--space-3); align-items: flex-start; }
.step-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 1px solid var(--accent-mid);
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 700;
  font-size: var(--text-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
}
.step-content { flex: 1; min-width: 0; }
.step-label {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: var(--space-1);
}
.step-desc {
  font-size: var(--text-sm);
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: var(--space-2);
}
.step-desc code {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  padding: 1px 5px;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   24. Theme & Font Toggle
   ========================================================================== */

.theme-toggle-btn,
.fontsize-toggle-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  transition: color var(--transition-fast), background var(--transition-fast);
  font-family: var(--font);
}
.theme-toggle-btn:hover,
.fontsize-toggle-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}

/* ==========================================================================
   25. Utility Classes
   ========================================================================== */

.text-accent  { color: var(--accent); }
.text-bright  { color: var(--text-bright); }
.text-dim     { color: var(--text-dim); }
.text-muted   { color: var(--text-muted); }
.text-green   { color: var(--green); }
.text-red     { color: var(--red); }
.text-yellow  { color: var(--yellow); }
.text-blue    { color: var(--blue); }
.text-cyan    { color: var(--cyan); }
.text-purple  { color: var(--purple); }
.mono         { font-family: var(--font-mono); }
.page-narrow  { max-width: 700px; margin: 0 auto; }
.page-mid     { max-width: 900px; margin: 0 auto; }
.page-wide    { max-width: var(--content-max); margin: 0 auto; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}

/* ==========================================================================
   26. Accessibility
   ========================================================================== */

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

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

/* ==========================================================================
   27. Responsive
   ========================================================================== */

@media (max-width: 1024px) {
  .sidebar { width: var(--sidebar-collapsed); overflow: hidden; }
  .sidebar-nav a { overflow: hidden; white-space: nowrap; justify-content: center; padding: var(--space-2); }
  .sidebar-nav a .nav-icon { flex-shrink: 0; }
  .sidebar-footer { display: none; }
  .sidebar-sep { margin: var(--space-2) var(--space-1); }
  .main-content { margin-left: var(--sidebar-collapsed); }
}

@media (max-width: 768px) {
  /* Navbar */
  .navbar-nav { display: none; }
  .navbar-right > *:not(.theme-toggle-btn):not(.menubar-hamburger):not(.navbar-hamburger) { display: none; }
  .navbar-hamburger, .menubar-hamburger { display: flex; }

  /* Sidebar — hidden, shown as overlay */
  .sidebar { display: none; }
  .sidebar.mobile-open {
    display: flex;
    width: 280px;
    z-index: 200;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.mobile-open ~ .sidebar-backdrop {
    display: block;
  }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 150;
  }

  /* Main content — full width */
  .main-content { margin-left: 0; padding: var(--space-4) var(--space-4); }

  /* Page body */
  .page-body { padding: var(--space-4) var(--space-4) var(--space-10); }

  /* Page header */
  .page-header { flex-direction: column; align-items: flex-start; }

  /* Buttons — larger touch targets */
  .btn { min-height: 44px; padding: var(--space-3) var(--space-4); }

  /* Stats */
  .stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
  }

  /* Card grid */
  .card-grid { grid-template-columns: 1fr; }

  /* Tables — card style */
  .data-table thead { display: none; }
  .data-table tbody tr { display: block; padding: var(--space-3) 0; }
  .data-table td { display: block; padding: var(--space-1) 0; }

  /* Tabs — smaller */
  .tab { padding: var(--space-2) var(--space-3); font-size: var(--text-xs); }

  /* Toast — full width */
  .toast { left: var(--space-4); right: var(--space-4); bottom: var(--space-4); max-width: none; }
}

@media (max-width: 420px) {
  .page-body { padding: var(--space-3) var(--space-3) var(--space-8); }
  .main-content { padding: var(--space-3); }
  .stats-row { grid-template-columns: 1fr; }
}

/* ==========================================================================
   28. Backward-compat aliases (remove after migration)
   ========================================================================== */

.menubar { display: flex; align-items: center; height: var(--nav-height); padding: 0 var(--space-5); background: var(--bg-raised); border-bottom: 1px solid var(--border); }
.menubar-brand { font-family: var(--font-mono); font-weight: 700; font-size: var(--text-lg); color: var(--accent); text-decoration: none; margin-right: var(--space-8); }
.menubar-brand:hover { text-decoration: none; }
.menubar-nav { display: flex; align-items: center; gap: var(--space-1); list-style: none; }
.menubar-nav a { display: inline-flex; align-items: center; height: 36px; padding: 0 var(--space-3); color: var(--text-dim); text-decoration: none; font-size: var(--text-sm); font-weight: 500; border-radius: var(--radius-md); transition: color var(--transition-fast), background var(--transition-fast); }
.menubar-nav a:hover { color: var(--text); background: var(--bg-hover); text-decoration: none; }
.menubar-nav a.active { color: var(--accent); background: var(--accent-dim); }
.menubar-right { margin-left: auto; display: flex; align-items: center; gap: var(--space-3); font-size: var(--text-sm); color: var(--text-dim); }
.menubar-hamburger { display: none; align-items: center; justify-content: center; width: 40px; height: 40px; margin-left: auto; background: none; border: 1px solid var(--border); border-radius: var(--radius-md); color: var(--text); cursor: pointer; font-size: 18px; padding: 0; }
.modeline { display: none; }

@media (max-width: 768px) {
  .menubar-nav { display: none; }
  .menubar-right > *:not(.theme-toggle-btn):not(.fontsize-toggle-btn) { display: none; }
  .navbar-right > .menubar-hamburger { display: flex; }
}

/* Token box (connect page) */
.token-box {
  background: var(--accent-dim);
  border: 1px solid var(--accent-mid);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.token-value {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent);
  word-break: break-all;
  flex: 1;
  min-width: 0;
}
.token-value.info {
  color: var(--text-dim);
  font-weight: normal;
  font-family: var(--font);
}
.token-note {
  font-size: var(--text-sm);
  color: var(--text-dim);
  margin-bottom: var(--space-5);
  line-height: 1.6;
}
.token-note a { color: var(--accent); }
.token-note a:hover { text-decoration: underline; }

/* Loading */
.loading {
  text-align: center;
  padding: var(--space-8);
  color: var(--text-dim);
  font-size: var(--text-base);
}

@media (max-width: 768px) {
  .token-box { flex-direction: column; align-items: stretch; }
}

/* Search trigger (Cmd+K hint) */
.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: var(--text-xs);
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast);
  height: 28px;
}
.search-trigger:hover { border-color: var(--border-hover); color: var(--text-dim); }
.search-trigger kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 4px;
  line-height: 1.4;
}

/* Command Palette (Cmd+K) */
.cmd-palette {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  align-items: flex-start;
  justify-content: center;
  padding-top: min(20vh, 160px);
}
.cmd-palette.open { display: flex; }
.cmd-dialog {
  width: 100%;
  max-width: 520px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 48px rgba(0,0,0,0.4);
  overflow: hidden;
}
.cmd-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.cmd-input-icon {
  color: var(--text-dim);
  font-size: 14px;
  flex-shrink: 0;
}
.cmd-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-bright);
  font-family: var(--font);
  font-size: var(--text-base);
}
.cmd-input::placeholder { color: var(--text-muted); }
.cmd-kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  flex-shrink: 0;
}
.cmd-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 8px;
}
.cmd-section {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 8px 8px 4px;
}
.cmd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background 0.1s;
}
.cmd-item:hover, .cmd-item.active {
  background: var(--bg-hover);
  color: var(--text-bright);
}
.cmd-icon {
  width: 20px;
  text-align: center;
  font-size: 14px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.cmd-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
}
@media (max-width: 520px) {
  .cmd-palette { padding-top: 12px; padding-left: 8px; padding-right: 8px; }
  .cmd-dialog { max-width: 100%; }
}
