/* ============================================================
   Study Vault V2 — Design System
   Theme: Deep Space / MTG Premium Dark
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

/* ================================================================
   CSS CUSTOM PROPERTIES
   ================================================================ */
:root {
  /* Backgrounds */
  --bg-base:      #070b12;
  --bg-surface:   #0c1220;
  --bg-card:      #101828;
  --bg-hover:     #152035;
  --bg-active:    #1a2d4a;

  /* Borders */
  --border:        #1a2840;
  --border-bright: #263d5a;

  /* Text */
  --text-1: #dce8f5;
  --text-2: #8aa8c6; /* was #7a9ab8 — promoted for WCAG AA on --bg-base */
  --text-3: #5a7798; /* was #3d5570 — promoted for WCAG AA on --bg-base */
  --text-muted: #5a7798; /* alias */

  /* Accent palette */
  --blue:   #4f8ef7;
  --gold:   #e8a84c;
  --green:  #34c76f;
  --purple: #a07af5;
  --red:    #e85454;
  --teal:   #2dd4bf;

  /* Accent scales (subset) — use for tints / badges / chart series */
  --blue-50:  #e9f1fe;
  --blue-100: #cfdffd;
  --blue-200: #a3c0fb;
  --blue-400: #6ea0f8;
  --blue-500: #4f8ef7;
  --blue-600: #3973de;
  --blue-700: #2858b3;
  --blue-900: #102744;

  --green-100: #cdf3dc;
  --green-500: #34c76f;
  --green-700: #1f8a4a;

  --red-100: #f8d4d4;
  --red-500: #e85454;
  --red-700: #b53636;

  --gold-100: #f7e3bd;
  --gold-500: #e8a84c;
  --gold-700: #b07a26;

  --purple-500: #a07af5;
  --teal-500:   #2dd4bf;

  /* MTG pip colors */
  --pip-w: #f4eedc;
  --pip-u: #1472c4;
  --pip-b: #2a1f2e;
  --pip-r: #d4200a;
  --pip-g: #1a7345;

  /* Glow effects */
  --glow-blue:   0 0 28px rgba(79,142,247,0.18);
  --glow-gold:   0 0 28px rgba(232,168,76,0.22);
  --glow-green:  0 0 28px rgba(52,199,111,0.18);
  --glow-purple: 0 0 28px rgba(160,122,245,0.18);

  /* Elevation — layered shadows */
  --shadow-1: 0 1px 2px rgba(0,0,0,0.25), 0 1px 1px rgba(0,0,0,0.18);
  --shadow-2: 0 4px 12px rgba(0,0,0,0.32), 0 2px 4px rgba(0,0,0,0.22);
  --shadow-3: 0 12px 32px rgba(0,0,0,0.42), 0 4px 12px rgba(0,0,0,0.28);
  --shadow-focus: 0 0 0 3px rgba(79,142,247,0.45);

  /* Spacing scale (4px base) */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Typography scale */
  --fs-xs:  0.72rem;   /* 11.5px */
  --fs-sm:  0.82rem;   /* 13px   */
  --fs-md:  0.94rem;   /* 15px   */
  --fs-lg:  1.08rem;   /* 17px   */
  --fs-xl:  1.35rem;   /* 22px   */
  --fs-2xl: 1.72rem;   /* 28px   */
  --fs-3xl: 2.15rem;   /* 35px   */

  --fw-regular: 400;
  --fw-medium:  500;
  --fw-semi:    600;
  --fw-bold:    700;

  --lh-tight: 1.25;
  --lh-base:  1.55;
  --lh-loose: 1.75;

  /* Layout */
  --sidebar-w:   240px;
  --topbar-h:    54px;
  --bottomnav-h: 62px;
  --radius:      12px;
  --radius-sm:   8px;
  --radius-xs:   6px;
  --radius-pill: 999px;

  /* Motion */
  --motion-fast: 0.12s ease;
  --motion-base: 0.18s ease;
  --motion-slow: 0.28s ease;
  --t: var(--motion-base); /* legacy alias */

  /* Focus ring */
  --focus-ring-color: var(--blue);
  --focus-ring-offset: 2px;
  --focus-ring-width: 2px;

  /* Z-index scale */
  --z-sidebar:  200;
  --z-topbar:   150;
  --z-overlay:  900;
  --z-tooltip:  1000;
  --z-toast:    1100;
}

/* ================================================================
   A11Y — focus, reduced motion, skip link, screen-reader helpers
   ================================================================ */

/* Hide outline only when interaction is via mouse, keep it for keyboard */
:where(a, button, input, select, textarea, summary, [tabindex]):focus { outline: none; }
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  border-radius: var(--radius-xs);
}

/* Skip-to-content link (visible only when focused) */
.skip-link {
  position: fixed;
  top: -100px;
  left: 12px;
  z-index: var(--z-toast);
  background: var(--blue);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: var(--fw-semi);
  text-decoration: none;
  box-shadow: var(--shadow-2);
  transition: top var(--motion-fast);
}
.skip-link:focus,
.skip-link:focus-visible {
  top: 12px;
  color: #fff;
}

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

/* Respect user motion preference */
@media (prefers-reduced-motion: reduce) {
  :root {
    --motion-fast: 0.001s linear;
    --motion-base: 0.001s linear;
    --motion-slow: 0.001s linear;
    --t:           0.001s linear;
  }
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
    scroll-behavior: auto !important;
  }
}

/* ================================================================
   RESET & BASE
   ================================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg-base);
  color: var(--text-1);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14.5px;
  line-height: 1.6;
  min-height: 100vh;        /* fallback */
  min-height: 100dvh;       /* dynamic viewport, fixes iOS Safari URL bar */
  overflow-x: hidden;
}

/* ================================================================
   SCROLLBAR
   ================================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ================================================================
   SIDEBAR
   ================================================================ */
.sv-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow: hidden;
  transition: transform var(--t), box-shadow var(--t);
}

/* Logo */
.sv-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 1.1rem 1rem 0.9rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text-1);
  flex-shrink: 0;
}
.sv-logo:hover { color: var(--text-1); }
.sv-logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--blue) 0%, var(--purple) 100%);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: var(--glow-blue);
  color: #fff;
}
.sv-logo-text {
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.2px;
  line-height: 1.2;
}
.sv-logo-sub {
  font-size: 0.63rem;
  color: var(--text-3);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

/* Nav body */
.sv-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0 0.75rem;
}
.sv-nav::-webkit-scrollbar { width: 0; }

.sv-section-label {
  font-size: 0.63rem;
  font-weight: 600;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0.65rem 1rem 0.2rem;
  margin-top: 0.25rem;
}

.sv-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0.42rem 1rem;
  color: var(--text-2);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 500;
  transition: background var(--t), color var(--t);
  position: relative;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.sv-nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-1);
}
.sv-nav-item.active {
  background: rgba(79, 142, 247, 0.1);
  color: var(--blue);
}
.sv-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--blue);
  border-radius: 0 2px 2px 0;
}
.sv-nav-icon {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
  opacity: 0.75;
}
.sv-nav-item.active .sv-nav-icon { opacity: 1; }
.sv-nav-label { flex: 1; }

/* Color pips in sidebar */
.sv-pip {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.15);
  flex-shrink: 0;
}
.sv-pip.w { background: var(--pip-w); }
.sv-pip.u { background: var(--pip-u); }
.sv-pip.b { background: var(--pip-b); border-color: rgba(255,255,255,0.35); }
.sv-pip.r { background: var(--pip-r); }
.sv-pip.g { background: var(--pip-g); }
.sv-pip.c { background: #888; }

.sv-pip-group {
  display: flex;
  align-items: center;
  gap: 2px;
  width: 20px;
  flex-shrink: 0;
}

/* Sidebar footer */
.sv-sidebar-footer {
  padding: 0.65rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.71rem;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.sv-version-badge {
  background: rgba(79,142,247,0.12);
  border: 1px solid rgba(79,142,247,0.25);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.67rem;
  color: var(--blue);
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* Mobile overlay */
.sv-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 199;
  backdrop-filter: blur(2px);
}
.sv-overlay.active { display: block; }

/* ================================================================
   MOBILE TOPBAR
   ================================================================ */
.sv-topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.6rem;
  position: sticky;
  top: 0;
  z-index: 150;
}
.sv-topbar-title {
  flex: 1;
  font-weight: 600;
  font-size: 0.9rem;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-1);
}
.sv-icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background var(--t), color var(--t);
  flex-shrink: 0;
}
.sv-icon-btn:hover { background: var(--bg-hover); color: var(--text-1); }

/* ================================================================
   MAIN CONTENT AREA
   ================================================================ */
.sv-main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;        /* fallback */
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.sv-content {
  flex: 1;
  padding: 1.75rem 2rem;
}
.sv-footer {
  padding: 0.9rem 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.73rem;
  color: var(--text-3);
}
.sv-footer a { color: var(--text-2); text-decoration: none; }
.sv-footer a:hover { color: var(--blue); text-decoration: underline; }

/* ================================================================
   BOTTOM NAV (mobile only)
   ================================================================ */
.sv-bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottomnav-h);
  background: rgba(12, 18, 32, 0.94);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 160;
  padding-bottom: env(safe-area-inset-bottom);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.sv-bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0.2rem 0.25rem;
  text-decoration: none;
  color: var(--text-3);
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.2px;
  cursor: pointer;
  border: none;
  background: none;
  transition: color var(--t);
}
.sv-bottom-nav-item:hover,
.sv-bottom-nav-item.active { color: var(--blue); }
.sv-bnav-icon {
  width: 34px; height: 26px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem;
  transition: background var(--t);
}
.sv-bottom-nav-item.active .sv-bnav-icon {
  background: rgba(79, 142, 247, 0.14);
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 991.98px) {
  .sv-sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
    box-shadow: none;
  }
  .sv-sidebar.open {
    transform: translateX(0);
    box-shadow: 6px 0 32px rgba(0,0,0,0.55);
  }
  .sv-main {
    margin-left: 0;
  }
  .sv-content {
    padding: 1rem;
    padding-bottom: calc(var(--bottomnav-h) + 1rem);
  }
  .sv-footer { display: none !important; }
}
@media (min-width: 992px) {
  .sv-topbar { display: none !important; }
  .sv-bottom-nav { display: none !important; }
}
@media (max-width: 575.98px) {
  .sv-content { padding: 0.7rem; padding-bottom: calc(var(--bottomnav-h) + 0.7rem); }
}

/* ================================================================
   BOOTSTRAP DARK BRIDGE
   ================================================================ */

/* Cards */
.card {
  background: var(--bg-card);
  border-color: var(--border);
  border-radius: var(--radius);
  color: var(--text-1);
}
.card-header {
  background: rgba(255,255,255,0.03);
  border-color: var(--border);
  font-weight: 600;
  font-size: 0.84rem;
  color: var(--text-1);
}
.card-footer {
  background: rgba(255,255,255,0.02);
  border-color: var(--border);
}

/* Tables */
.table {
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--border);
  --bs-table-striped-bg: rgba(255,255,255,0.02);
  --bs-table-hover-bg: var(--bg-hover);
  color: var(--text-1);
}
.table thead th {
  background: var(--bg-surface);
  color: var(--text-2);
  font-weight: 600;
  font-size: 0.73rem;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  border-color: var(--border);
  padding: 0.6rem 0.75rem;
  white-space: nowrap;
}
.table tbody td {
  border-color: var(--border);
  font-size: 0.86rem;
  vertical-align: middle;
  color: var(--text-1);
}
.table-hover tbody tr:hover td {
  background: var(--bg-hover) !important;
  color: var(--text-1);
}

/* Forms */
.form-control,
.form-select {
  background: var(--bg-card);
  border-color: var(--border-bright);
  color: var(--text-1);
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
}
.form-control:focus,
.form-select:focus {
  background: var(--bg-card);
  border-color: var(--blue);
  color: var(--text-1);
  box-shadow: 0 0 0 3px rgba(79,142,247,0.18);
}
.form-control::placeholder { color: var(--text-3); }
.form-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 0.35rem;
}
.input-group-text {
  background: var(--bg-card);
  border-color: var(--border-bright);
  color: var(--text-3);
}
.form-select option {
  background: var(--bg-card);
  color: var(--text-1);
}

/* Buttons */
.btn {
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.83rem;
  transition: all var(--t);
}
.btn-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.btn-primary:hover,
.btn-primary:focus {
  background: #3a7fe8;
  border-color: #3a7fe8;
  box-shadow: var(--glow-blue);
  color: #fff;
}
.btn-success {
  background: var(--green);
  border-color: var(--green);
  color: #03140a;
  font-weight: 600;
}
.btn-success:hover,
.btn-success:focus {
  background: #27b563;
  border-color: #27b563;
  box-shadow: var(--glow-green);
  color: #03140a;
}
.btn-danger {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}
.btn-warning {
  background: var(--gold);
  border-color: var(--gold);
  color: #1a0c00;
  font-weight: 600;
}
.btn-outline-primary {
  border-color: var(--blue);
  color: var(--blue);
}
.btn-outline-primary:hover {
  background: rgba(79,142,247,0.12);
  border-color: var(--blue);
  color: var(--blue);
}
.btn-outline-secondary {
  border-color: var(--border-bright);
  color: var(--text-2);
}
.btn-outline-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-bright);
  color: var(--text-1);
}
.btn-outline-light {
  border-color: var(--border-bright);
  color: var(--text-2);
}
.btn-outline-light:hover {
  background: var(--bg-hover);
  border-color: var(--border-bright);
  color: var(--text-1);
}
.btn-link { color: var(--blue); text-decoration: none; }
.btn-link:hover { color: var(--text-1); text-decoration: underline; }

/* Badges */
.badge {
  font-weight: 600;
  letter-spacing: 0.2px;
  border-radius: var(--radius-xs);
  font-size: 0.72rem;
}
.bg-primary { background-color: var(--blue) !important; }
.bg-success { background-color: var(--green) !important; }
.bg-danger  { background-color: var(--red) !important; }
.bg-warning { background-color: var(--gold) !important; color: #1a0c00 !important; }
.bg-info    { background-color: var(--teal) !important; color: #06110e !important; }
.bg-secondary { background-color: var(--border-bright) !important; }
.text-primary { color: var(--blue) !important; }
.text-success { color: var(--green) !important; }
.text-danger  { color: var(--red) !important; }
.text-warning { color: var(--gold) !important; }
.text-info    { color: var(--teal) !important; }
.text-muted   { color: var(--text-2) !important; }

/* Modals */
.modal-content {
  background: var(--bg-card);
  border-color: var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.7);
}
.modal-header, .modal-footer { border-color: var(--border); }
.modal-title { font-weight: 600; font-size: 0.95rem; color: var(--text-1); }
.btn-close { filter: invert(1) grayscale(1) opacity(0.7); }
.btn-close:hover { filter: invert(1) grayscale(0) opacity(1); }
.btn-close-white { filter: invert(1) grayscale(1); }

/* List groups */
.list-group-item {
  background: transparent;
  border-color: var(--border);
  color: var(--text-1);
  font-size: 0.86rem;
}
.list-group-item-action:hover,
.list-group-item-action:focus {
  background: var(--bg-hover) !important;
  color: var(--text-1) !important;
}

/* Pagination */
.pagination { gap: 2px; }
.page-link {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text-2);
  border-radius: var(--radius-sm) !important;
  font-size: 0.83rem;
}
.page-link:hover {
  background: var(--bg-hover);
  border-color: var(--blue);
  color: var(--blue);
}
.page-item.active .page-link {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.page-item.disabled .page-link {
  background: var(--bg-base);
  border-color: var(--border);
  color: var(--text-3);
}

/* Dropdowns */
.dropdown-menu {
  background: var(--bg-card);
  border-color: var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  padding: 0.3rem 0;
}
.dropdown-menu-dark { background: var(--bg-card); border-color: var(--border); }
.dropdown-item {
  color: var(--text-2);
  font-size: 0.84rem;
  padding: 0.42rem 0.9rem;
}
.dropdown-item:hover, .dropdown-item:focus {
  background: var(--bg-hover);
  color: var(--text-1);
}
.dropdown-item.active { background: rgba(79,142,247,0.12); color: var(--blue); }
.dropdown-divider { border-color: var(--border); margin: 0.25rem 0; }

/* Progress */
.progress {
  background: var(--bg-surface);
  border-radius: 4px;
  height: 8px;
}
.progress-bar { border-radius: 4px; }

/* Alerts */
.alert {
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  border-width: 1px;
}
.alert-primary   { background: rgba(79,142,247,0.1);  border-color: rgba(79,142,247,0.25);  color: var(--blue); }
.alert-success   { background: rgba(52,199,111,0.1);  border-color: rgba(52,199,111,0.25);  color: var(--green); }
.alert-warning   { background: rgba(232,168,76,0.1);  border-color: rgba(232,168,76,0.25);  color: var(--gold); }
.alert-danger    { background: rgba(232,84,84,0.1);   border-color: rgba(232,84,84,0.25);   color: var(--red); }
.alert-secondary { background: rgba(255,255,255,0.04); border-color: var(--border); color: var(--text-2); }

/* Nav tabs */
.nav-tabs {
  border-color: var(--border);
  gap: 2px;
}
.nav-tabs .nav-link {
  border-color: transparent;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  color: var(--text-2);
  font-size: 0.84rem;
  font-weight: 500;
  padding: 0.45rem 0.9rem;
  transition: color var(--t), background var(--t);
}
.nav-tabs .nav-link:hover { background: var(--bg-hover); color: var(--text-1); border-color: transparent; }
.nav-tabs .nav-link.active {
  background: var(--bg-card);
  border-color: var(--border) var(--border) var(--bg-card);
  color: var(--text-1);
}
.nav-pills .nav-link {
  color: var(--text-2);
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 500;
}
.nav-pills .nav-link:hover { background: var(--bg-hover); color: var(--text-1); }
.nav-pills .nav-link.active { background: rgba(79,142,247,0.15); color: var(--blue); }

/* Accordion */
.accordion-item { background: var(--bg-card); border-color: var(--border); }
.accordion-button {
  background: var(--bg-card);
  color: var(--text-1);
  font-weight: 600;
  font-size: 0.87rem;
}
.accordion-button:not(.collapsed) {
  background: rgba(79,142,247,0.07);
  color: var(--blue);
  box-shadow: none;
}
.accordion-button::after { filter: invert(1) brightness(0.6); }
.accordion-button:not(.collapsed)::after { filter: invert(1) brightness(0.8); }
.accordion-body { font-size: 0.86rem; color: var(--text-2); }

/* Tooltip */
.tooltip-inner {
  background: var(--bg-hover);
  color: var(--text-1);
  border: 1px solid var(--border-bright);
  font-size: 0.78rem;
  border-radius: var(--radius-xs);
}

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

/* --- Stat cards --- */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--glow-blue);
  border-color: rgba(79,142,247,0.3);
}
.stat-value {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text-1);
  line-height: 1.1;
  letter-spacing: -0.5px;
}
.stat-label {
  font-size: 0.7rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.9px;
  margin-top: 0.3rem;
  font-weight: 600;
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
}
.stat-icon.blue   { background: rgba(79,142,247,0.12); color: var(--blue); }
.stat-icon.green  { background: rgba(52,199,111,0.12); color: var(--green); }
.stat-icon.gold   { background: rgba(232,168,76,0.12); color: var(--gold); }
.stat-icon.purple { background: rgba(160,122,245,0.12); color: var(--purple); }

/* --- Deck cards --- */
.deck-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--t), box-shadow var(--t), transform var(--t);
}
.deck-card:hover {
  border-color: var(--border-bright);
  box-shadow: 0 6px 28px rgba(0,0,0,0.35);
  transform: translateY(-1px);
}
.deck-card:hover .commander-img {
  box-shadow: 0 0 18px rgba(232,168,76,0.22);
}

/* --- Quick links --- */
.quick-link-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--t);
  color: var(--text-1);
  display: block;
  text-decoration: none;
}
.quick-link-card:hover {
  background: var(--bg-hover);
  border-color: rgba(79,142,247,0.35);
  transform: translateY(-2px);
  box-shadow: var(--glow-blue);
  color: var(--text-1);
}

/* --- Hero section --- */
.hero-section { padding: 1.5rem 0 1.25rem; }
.hero-section h1 {
  background: linear-gradient(135deg, var(--blue) 0%, var(--purple) 55%, var(--gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 800;
  letter-spacing: -1px;
}

/* --- Section title --- */
.sv-section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.2px;
}
.sv-title-icon {
  width: 28px; height: 28px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.sv-title-icon.blue   { background: rgba(79,142,247,0.15);  color: var(--blue); }
.sv-title-icon.gold   { background: rgba(232,168,76,0.15);  color: var(--gold); }
.sv-title-icon.green  { background: rgba(52,199,111,0.15);  color: var(--green); }
.sv-title-icon.purple { background: rgba(160,122,245,0.15); color: var(--purple); }

/* --- Divider --- */
.sv-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-bright), transparent);
  margin: 1.5rem 0;
  border: none;
}

/* --- MTG Color pips (page-level) --- */
.color-pip {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.2);
  vertical-align: middle;
}
.pip-white  { background: var(--pip-w); }
.pip-blue   { background: var(--pip-u); }
.pip-black  { background: var(--pip-b); border-color: rgba(255,255,255,0.4); }
.pip-red    { background: var(--pip-r); }
.pip-green  { background: var(--pip-g); }
.color-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  vertical-align: middle;
}

/* --- Mana symbols --- */
.mana-symbol {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  font-size: 0.6rem;
  font-weight: 700;
  margin-right: 1px;
  vertical-align: middle;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.mana-inline {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  white-space: nowrap;
  min-width: 54px;
  width: 54px;
}
.mana-w { background: #f4eedc; color: #4a3820; }
.mana-u { background: #1472c4; color: #fff; }
.mana-b { background: #2a1f2e; color: #b0a0c0; border: 1px solid #555; }
.mana-r { background: #d4200a; color: #fff; }
.mana-g { background: #1a7345; color: #fff; }
.mana-c { background: #ccc2b6; color: #333; }
.mana-0,.mana-1,.mana-2,.mana-3,.mana-4,.mana-5,
.mana-6,.mana-7,.mana-8,.mana-9,.mana-10,.mana-11,.mana-12,
.mana-x { background: #8a7e72; color: #fff; }
.mana-gu,.mana-ug { background: linear-gradient(135deg, #1a7345 50%, #1472c4 50%); color: #fff; }
.mana-wb,.mana-bw { background: linear-gradient(135deg, #f4eedc 50%, #2a1f2e 50%); color: #333; }
.mana-up,.mana-bp,.mana-gp,.mana-rp,.mana-wp { background: #b33871; color: #fff; }

/* --- Commander frame --- */
.commander-frame {
  width: 120px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.65);
  border: 2px solid var(--border-bright);
  transition: box-shadow var(--t);
}
.commander-img { width: 100%; height: auto; display: block; }
@media (max-width: 576px) {
  .commander-frame { width: 80px; }
}

/* --- Deck header --- */
.deck-header {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-surface) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

/* --- Card list items --- */
.list-group-item.card-link {
  padding: 0.5rem 0.9rem;
  transition: background var(--t);
}
.list-group-item.card-link:hover {
  background: rgba(79, 142, 247, 0.07) !important;
}
.card-name-text { font-weight: 500; font-size: 0.86rem; }

/* --- Card grid images --- */
.card-grid-img {
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 2px 10px rgba(0,0,0,0.45);
  border-radius: 6px;
}
.card-grid-img:hover {
  transform: scale(1.07);
  box-shadow: 0 10px 36px rgba(79,142,247,0.28);
  z-index: 10;
  position: relative;
}
@media (max-width: 575.98px) {
  .card-grid-img:hover { transform: none; }
}

/* --- Card preview tooltip (hover) --- */
.card-preview {
  position: fixed;
  display: none;
  z-index: 9999;
  pointer-events: none;
  filter: drop-shadow(0 8px 28px rgba(0,0,0,0.75));
}
.card-preview img { width: 240px; border-radius: 10px; }
@media (max-width: 768px) { .card-preview { display: none !important; } }

/* --- Table sticky headers --- */
.table-header-sticky {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-surface);
}
.table-header-sticky th { background: var(--bg-surface); }
.collection-table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 767.98px) {
  .collection-table-wrapper { overflow-x: visible; }
}

/* --- Card rows in table --- */
.card-row {
  transition: background var(--t);
  cursor: pointer;
}
.card-row:hover td { background: rgba(79,142,247,0.05) !important; }

/* --- Price badges --- */
.price-badge {
  background: rgba(52,199,111,0.1);
  color: var(--green);
  border: 1px solid rgba(52,199,111,0.2);
  border-radius: var(--radius-xs);
  padding: 2px 8px;
  font-size: 0.78rem;
  font-weight: 600;
}
.price-positive { color: var(--green); font-weight: 600; }

/* --- Shopping priorities --- */
.shopping-priority-high   { color: var(--red); }
.shopping-priority-medium { color: var(--gold); }
.shopping-priority-low    { color: var(--text-3); }

/* --- Guide content --- */
.guide-content { font-size: 0.92rem; line-height: 1.78; color: var(--text-2); }
.guide-content h1 { font-size: 1.65rem; color: var(--blue); border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; margin-top: 2rem; font-weight: 700; }
.guide-content h2 { font-size: 1.3rem; color: var(--green); margin-top: 1.75rem; border-bottom: 1px solid rgba(52,199,111,0.15); padding-bottom: 0.3rem; font-weight: 600; }
.guide-content h3 { font-size: 1.1rem; color: var(--purple); margin-top: 1.4rem; font-weight: 600; }
.guide-content h4, .guide-content h5 { color: var(--text-1); margin-top: 1.2rem; }
.guide-content code { background: rgba(79,142,247,0.12); border-radius: 4px; padding: 0.15em 0.4em; font-size: 0.86em; color: #79c0ff; }
.guide-content pre { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; overflow-x: auto; }
.guide-content pre code { background: transparent; color: var(--text-1); padding: 0; }
.guide-content blockquote { border-left: 3px solid var(--blue); padding: 0.5rem 1rem; margin: 1rem 0; background: rgba(79,142,247,0.06); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text-2); }
.guide-content table { width: 100%; margin: 1rem 0; border-collapse: collapse; }
.guide-content table th, .guide-content table td { padding: 0.5rem 0.75rem; border: 1px solid var(--border); }
.guide-content table th { background: var(--bg-surface); font-weight: 600; color: var(--text-1); }
.guide-content table tr:nth-child(even) { background: rgba(22,27,34,0.4); }
.guide-content hr { border-color: var(--border); margin: 2rem 0; }
.guide-content a { color: var(--blue); }
.guide-content a:hover { color: var(--text-1); }
.guide-content ul, .guide-content ol { padding-left: 1.5rem; }
.guide-content li { margin-bottom: 0.3rem; }

/* ================================================================
   PAGE TRANSITIONS
   ================================================================ */
.sv-content, main {
  animation: svFadeIn 0.2s ease;
}
@keyframes svFadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ================================================================
   UTILITY CLASSES
   ================================================================ */
.bg-dark-subtle { background: var(--bg-surface) !important; }
.border-secondary { border-color: var(--border) !important; }
.border-subtle { border-color: var(--border) !important; }
.text-primary { color: var(--blue) !important; }
.bg-transparent { background: transparent !important; }

/* Sensitive values (toggleable) */
.sensitive-value { transition: filter var(--t); }
.sensitive-hidden { filter: blur(6px); user-select: none; }

/* Filter bar */
.filter-bar {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
}

/* Glowing divider */
hr.sv-glow {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-bright) 30%, var(--border-bright) 70%, transparent);
  opacity: 0.6;
}

/* ================================================================
   BOOTSTRAP BACKDROP
   ================================================================ */
.modal-backdrop { background: rgba(4,7,14,0.75); }
.modal-backdrop.show { opacity: 1; }

/* ================================================================
   L6 — RESPONSIVE MOBILE-FIRST POLISH
   Added after L1 base layer. Covers touch ergonomics, safe-area
   insets, mobile-friendly tables/modals/filters, iOS quirks.
   ================================================================ */

/* Safe-area insets for notched / gesture-bar devices */
@supports (padding: env(safe-area-inset-bottom)) {
  .sv-bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  }
  .sv-content {
    padding-left:  max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
}

/* iOS auto-zoom prevention: inputs must be >= 16px on mobile.
   Forms become 16px on touch viewports. */
@media (max-width: 767.98px) {
  .form-control,
  .form-select,
  textarea.form-control,
  input[type="text"],
  input[type="email"],
  input[type="number"],
  input[type="password"],
  input[type="search"],
  input[type="tel"],
  input[type="url"],
  input[type="date"] {
    font-size: 16px !important;
  }
}

/* Touch targets ≥ 44px (WCAG 2.5.5 — Target Size, AAA) */
@media (pointer: coarse) {
  .btn,
  .nav-link,
  .dropdown-item,
  .list-group-item-action,
  .sv-bottom-nav-item,
  .form-check-input,
  .btn-close {
    min-height: 44px;
  }
  .btn-sm {
    min-height: 38px;
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }
  /* Don't stretch icon-only buttons abnormally tall */
  .btn-icon,
  .btn-close { min-width: 44px; }
}

/* Modals — full-screen on mobile (better readability, less wasted chrome) */
@media (max-width: 575.98px) {
  .modal-dialog:not(.modal-dialog-centered):not(.modal-sm) {
    margin: 0;
    max-width: 100%;
    min-height: 100dvh;
    min-height: 100vh; /* fallback */
  }
  .modal-content {
    border-radius: 0;
    min-height: 100dvh;
    min-height: 100vh;
  }
  .modal-dialog-centered.modal-sm {
    margin: 1rem;
  }
}

/* Tables — better horizontal scroll on mobile + sticky first column hint */
@media (max-width: 767.98px) {
  .table-responsive,
  .collection-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .table-responsive::after,
  .collection-table-wrapper::after {
    /* subtle right-fade hint that more is scrollable */
    content: '';
    pointer-events: none;
  }
  /* Tables must allow horizontal overflow even if a parent has overflow-hidden */
  .table { min-width: 560px; }
}

/* Filter bars — sticky to top on mobile so search stays in reach */
@media (max-width: 767.98px) {
  .filter-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    margin-left: -0.7rem;
    margin-right: -0.7rem;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    backdrop-filter: blur(8px);
    background: rgba(12, 18, 32, 0.92);
  }
}

/* Long words / URLs / card names — never blow horizontal scroll on mobile */
.text-truncate-mobile,
.card-name-text,
.list-group-item.card-link .text-truncate {
  overflow-wrap: anywhere;
}
@media (max-width: 575.98px) {
  body, .sv-content {
    overflow-x: hidden;
  }
  /* allow word-break in long deck/title cells */
  h1, h2, h3, h4 { word-break: break-word; }
}

/* Stat cards — comfortable mobile spacing & full-bleed feel */
@media (max-width: 575.98px) {
  .stat-card .card-body { padding: 0.85rem 0.7rem; }
  .stat-value { font-size: 1.5rem; }
  .stat-label { font-size: 0.72rem; letter-spacing: 0.04em; }
}

/* Deck cards — pictures don't crush text on small screens */
@media (max-width: 575.98px) {
  .deck-header { padding: 1rem; }
  .commander-frame { width: 72px; }
}

/* Buttons in tight rows — wrap don't squish */
@media (max-width: 575.98px) {
  .btn-toolbar,
  .d-flex.gap-2.flex-wrap { row-gap: 0.5rem; }
  .btn-group .btn { flex: 1 1 auto; }
}

/* Better scrollbar styling everywhere (Firefox + Chromium) */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-bright) transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-bright);
  border-radius: 4px;
}
*::-webkit-scrollbar-thumb:hover { background: var(--blue-700); }

/* Chart containers — never overflow their card on mobile */
@media (max-width: 575.98px) {
  canvas { max-width: 100% !important; }
}

/* Mana cost inline rendering — keep symbols inline-block & not overflowing */
.mana-inline {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
}

/* Skeleton loader for slow-loading async content */
.sv-skeleton {
  background: linear-gradient(90deg, var(--bg-card) 0%, var(--bg-hover) 50%, var(--bg-card) 100%);
  background-size: 200% 100%;
  animation: svShimmer 1.4s infinite linear;
  border-radius: var(--radius-sm);
  min-height: 1em;
  display: inline-block;
  width: 100%;
}
@keyframes svShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .sv-skeleton { animation: none; }
}

/* Print — hide chrome, show content */
@media print {
  .sv-sidebar, .sv-topbar, .sv-bottom-nav, .sv-footer,
  .btn, .modal, .filter-bar { display: none !important; }
  .sv-main { margin-left: 0 !important; }
  .sv-content { padding: 0 !important; }
  body { background: #fff !important; color: #000 !important; }
  .card { border: 1px solid #ccc !important; background: #fff !important; color: #000 !important; box-shadow: none !important; }
}

/* ================================================================
   ADVISOR — Flexible chat height (remplace inline height:55vh)
   ================================================================ */
.advisor-chat-card {
  display: flex;
  flex-direction: column;
  height: calc(100svh - var(--topbar-h) - var(--bottomnav-h) - 11rem);
  min-height: 320px;
  max-height: 680px;
}
@media (min-width: 992px) {
  .advisor-chat-card {
    height: calc(100svh - 7rem);
    min-height: 400px;
    max-height: 820px;
  }
}
.advisor-messages {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 1rem;
}

/* ================================================================
   SHOPPING — colonnes Source/Pourquoi cachées sur mobile
   ================================================================ */
@media (max-width: 767.98px) {
  .tp-col-source,
  .tp-col-reason { display: none !important; }
}

/* ================================================================
   SHOPPING — boutons d'action de deck : wrapping sur mobile
   ================================================================ */
@media (max-width: 767.98px) {
  .shopping-deck-actions {
    display: flex !important;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    width: 100%;
  }
  .shopping-deck-actions .btn-group {
    flex: 0 0 auto;
  }
}

/* ================================================================
   BADGES — taille uniforme garantie partout (override Bootstrap em)
   ================================================================ */
.badge {
  font-size: 0.72rem;
  padding: 0.28em 0.6em;
  line-height: 1.4;
  font-weight: 600;
  letter-spacing: 0.2px;
  border-radius: var(--radius-xs);
  vertical-align: middle;
}

/* ================================================================
   OWNED RECOMMENDATIONS — séparateur titre / premier élément
   ================================================================ */
.owned-rec-title {
  font-weight: 600;
  padding-bottom: 0.5rem;
  margin-bottom: 0 !important;
  border-bottom: 1px solid var(--border-bright);
}
.list-group-flush .list-group-item:first-child {
  border-top: none;
}

/* ================================================================
   ADVISOR OFFCANVAS HISTORY — style drawer mobile
   ================================================================ */
.advisor-offcanvas {
  max-width: 85vw;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
}
.advisor-offcanvas .offcanvas-header {
  border-bottom: 1px solid var(--border);
}
.advisor-offcanvas .offcanvas-title {
  font-size: 0.86rem;
  color: var(--text-2);
}
.advisor-offcanvas .offcanvas-body {
  padding: 0.75rem;
  overflow-y: auto;
}

/* ================================================================
   BUILDER — panels fixes (remplace inline max-height:500px)
   ================================================================ */
.sv-scrollpanel {
  max-height: 420px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
@media (max-width: 991.98px) {
  .sv-scrollpanel {
    max-height: 260px;
  }
}

/* ================================================================
   FONT SIZE UTILITIES (mirror des --fs-* tokens)
   ================================================================ */
.fs-xs  { font-size: var(--fs-xs)  !important; }
.fs-sm  { font-size: var(--fs-sm)  !important; }
.fs-md  { font-size: var(--fs-md)  !important; }
.fs-lg  { font-size: var(--fs-lg)  !important; }
.fs-xl  { font-size: var(--fs-xl)  !important; }

/* ================================================================
   BG UTILITIES — remplace les inline style="background:#161b22"
   ================================================================ */
.bg-inset  { background: var(--bg-surface) !important; }
.bg-deeper { background: var(--bg-base)    !important; }
.border-panel { border: 1px solid var(--border) !important; }

/* ================================================================
   ACCORDION — override Bootstrap inline styles restants
   ================================================================ */
.accordion-item {
  background: transparent;
  border-color: var(--border);
}
.accordion-button {
  background: var(--bg-surface) !important;
  color: var(--text-1) !important;
  box-shadow: none !important;
}
.accordion-button:not(.collapsed) {
  background: var(--bg-hover) !important;
  color: var(--text-1) !important;
}
.accordion-button::after {
  filter: invert(0.7) sepia(0.3) hue-rotate(200deg);
}
.accordion-body {
  background: var(--bg-base) !important;
}

/* ================================================================
   SHOPPING PAGE — règles spécifiques (.shopping-view)
   (anciennement dans le {% block head %} de shopping.html)
   ================================================================ */

/* Fix #1 : checkbox carrée dans les tables (annule min-height:44px
   du @media coarse pour les inputs dans les lignes de liste d'achats) */
.shopping-view .form-check-input,
.shopping-row .form-check-input {
  min-height: 1em   !important;
  height:     1.15em !important;
  width:      1.15em !important;
  min-width:  1.15em !important;
}

/* Fix #2 : texte long (badges, noms de sets, etc.) wrap proprement */
.shopping-view table.table td,
.shopping-view table.table th {
  word-break: break-word;
  overflow-wrap: anywhere;
}
.shopping-view table.table .badge {
  white-space: normal;
  text-align: left;
}

/* Fix #3 : scroll horizontal si nécessaire (sans forcer de min-width) */
.shopping-view .table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ================================================================
   UTILITIES GLOBALES — remplacent les inline styles récurrents
   ================================================================ */

/* Dropdown autocomplete (recherche de carte dans formulaires) */
.suggestions-dropdown {
  z-index: 1060;
  max-height: 200px;
  overflow-y: auto;
  display: none;
}

/* Badge wrappant (texte long dans accordions, tableaux) */
.badge-wrap {
  white-space: normal !important;
  text-align: left;
}
