/* ==========================================================================
   macOS Liquid Glass Theme System
   Dark Mode (Current preserved palette) & Light Mode (Light blue, almost white)
   ========================================================================== */

:root,
[data-theme="dark"] {
  /* Dark Theme Palette (Exact original colors preserved) */
  --bg-primary: #090d16;
  --bg-secondary: #0f172a;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --bg-glass: rgba(15, 23, 42, 0.68);
  --bg-glass-heavy: rgba(11, 17, 30, 0.84);
  --bg-glass-sidebar: rgba(11, 17, 30, 0.72);
  --bg-input: rgba(15, 23, 42, 0.82);
  --bg-input-focus: rgba(15, 23, 42, 0.96);

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glass: rgba(255, 255, 255, 0.12);
  --border-focus: rgba(56, 189, 248, 0.5);
  --border-accent: rgba(99, 102, 241, 0.3);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --text-inverse: #090d16;

  --accent-cyan: #38bdf8;
  --accent-blue: #3b82f6;
  --accent-indigo: #6366f1;
  --accent-purple: #a855f7;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;

  /* Liquid Glass Specular & Reflections */
  --glass-specular: rgba(255, 255, 255, 0.14);
  --glass-specular-bright: rgba(255, 255, 255, 0.25);
  --glass-inner-border: inset 0 1px 1px 0 rgba(255, 255, 255, 0.14), inset 0 -1px 1px 0 rgba(0, 0, 0, 0.25);
  --glass-highlight-linear: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.02) 60%, rgba(56, 189, 248, 0.05) 100%);

  /* Ambient Glass Glow Underlay */
  --ambient-mesh: 
    radial-gradient(circle at 10% 15%, rgba(56, 189, 248, 0.1) 0%, transparent 45%),
    radial-gradient(circle at 90% 85%, rgba(99, 102, 241, 0.1) 0%, transparent 45%),
    radial-gradient(circle at 50% 40%, rgba(16, 185, 129, 0.04) 0%, transparent 55%);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 16px 0 rgba(0, 0, 0, 0.42);
  --shadow-lg: 0 12px 30px -4px rgba(0, 0, 0, 0.55), 0 4px 8px -2px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 0 24px rgba(56, 189, 248, 0.18);
  --shadow-liquid: 0 12px 36px -6px rgba(0, 0, 0, 0.52), inset 0 1px 1px 0 rgba(255, 255, 255, 0.15);

  --code-badge-bg: rgba(56, 189, 248, 0.15);
  --code-badge-border: rgba(56, 189, 248, 0.3);
  --code-badge-color: #38bdf8;

  --tree-active-bg: rgba(56, 189, 248, 0.16);
  --tree-active-border: #38bdf8;
  --tree-hover-bg: rgba(255, 255, 255, 0.05);

  --stat-pill-bg: rgba(255, 255, 255, 0.05);
  --stat-pill-highlight-bg: rgba(56, 189, 248, 0.12);

  --card-metric-bg: rgba(15, 23, 42, 0.65);
  --semantic-preview-bg: rgba(15, 23, 42, 0.82);

  --ref-pill-bg: rgba(99, 102, 241, 0.15);
  --ref-pill-border: rgba(99, 102, 241, 0.3);
  --ref-pill-color: #c7d2fe;
  --ref-pill-hover-bg: rgba(99, 102, 241, 0.28);
  --ref-pill-hover-border: #818cf8;

  --search-dropdown-bg: rgba(15, 23, 42, 0.95);
  --search-item-hover: rgba(56, 189, 248, 0.14);

  --mac-control-bg: rgba(255, 255, 255, 0.06);
  --mac-control-border: rgba(255, 255, 255, 0.1);
  --mac-segment-active-bg: rgba(56, 189, 248, 0.25);
  --mac-segment-active-color: #f8fafc;
  --mac-segment-indicator-bg: rgba(255, 255, 255, 0.12);

  --scrollbar-thumb: rgba(255, 255, 255, 0.14);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.28);

  --window-frame-border: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] {
  /* Light Theme Palette: Light blue (almost white), icy macOS liquid glass */
  --bg-primary: #f0f5fc;           /* Crisp light icy blue, nearly white */
  --bg-secondary: #e3effa;         /* Soft frosted sky blue tint */
  --bg-card: rgba(255, 255, 255, 0.72); /* Translucent liquid white glass */
  --bg-card-hover: rgba(255, 255, 255, 0.92);
  --bg-glass: rgba(240, 246, 255, 0.78);
  --bg-glass-heavy: rgba(232, 242, 252, 0.9);
  --bg-glass-sidebar: rgba(235, 243, 252, 0.78);
  --bg-input: rgba(255, 255, 255, 0.88);
  --bg-input-focus: rgba(255, 255, 255, 0.98);

  --border-subtle: rgba(188, 212, 238, 0.65);
  --border-glass: rgba(255, 255, 255, 0.85);
  --border-focus: rgba(2, 132, 199, 0.55);
  --border-accent: rgba(59, 130, 246, 0.35);

  --text-main: #0c1d37;           /* Deep elegant dark navy for crystal-clear readability */
  --text-muted: #385170;          /* Refined slate-blue muted text */
  --text-dim: #647f9d;            /* Secondary label tone */
  --text-inverse: #ffffff;

  --accent-cyan: #0284c7;          /* Rich macOS sky blue */
  --accent-blue: #2563eb;          /* Native macOS royal blue */
  --accent-indigo: #4f46e5;
  --accent-purple: #7c3aed;
  --accent-emerald: #059669;
  --accent-rose: #e11d48;

  /* Liquid Glass Specular & Reflections */
  --glass-specular: rgba(255, 255, 255, 0.95);
  --glass-specular-bright: #ffffff;
  --glass-inner-border: inset 0 1px 1.5px 0 rgba(255, 255, 255, 0.95), inset 0 -1px 1px 0 rgba(180, 208, 238, 0.35);
  --glass-highlight-linear: linear-gradient(135deg, rgba(255, 255, 255, 0.75) 0%, rgba(255, 255, 255, 0.15) 60%, rgba(186, 230, 253, 0.3) 100%);

  /* Ambient Glass Glow Underlay */
  --ambient-mesh: 
    radial-gradient(circle at 10% 15%, rgba(186, 230, 253, 0.6) 0%, transparent 45%),
    radial-gradient(circle at 90% 85%, rgba(199, 210, 254, 0.45) 0%, transparent 50%),
    radial-gradient(circle at 50% 30%, rgba(224, 242, 254, 0.6) 0%, transparent 60%);

  --shadow-sm: 0 1px 2px 0 rgba(15, 45, 80, 0.05);
  --shadow-md: 0 4px 16px -1px rgba(15, 45, 80, 0.08), 0 2px 4px -1px rgba(15, 45, 80, 0.04);
  --shadow-lg: 0 12px 32px -4px rgba(15, 45, 80, 0.12), 0 4px 12px -2px rgba(15, 45, 80, 0.06);
  --shadow-glow: 0 0 22px rgba(2, 132, 199, 0.2);
  --shadow-liquid: 0 12px 32px -6px rgba(20, 60, 110, 0.12), inset 0 1px 1.5px 0 rgba(255, 255, 255, 0.95);

  --code-badge-bg: rgba(2, 132, 199, 0.12);
  --code-badge-border: rgba(2, 132, 199, 0.28);
  --code-badge-color: #0284c7;

  --tree-active-bg: rgba(2, 132, 199, 0.14);
  --tree-active-border: #0284c7;
  --tree-hover-bg: rgba(14, 165, 233, 0.08);

  --stat-pill-bg: rgba(255, 255, 255, 0.7);
  --stat-pill-highlight-bg: rgba(2, 132, 199, 0.12);

  --card-metric-bg: rgba(255, 255, 255, 0.65);
  --semantic-preview-bg: rgba(255, 255, 255, 0.72);

  --ref-pill-bg: rgba(79, 70, 229, 0.08);
  --ref-pill-border: rgba(79, 70, 229, 0.25);
  --ref-pill-color: #3730a3;
  --ref-pill-hover-bg: rgba(79, 70, 229, 0.16);
  --ref-pill-hover-border: #4f46e5;

  --search-dropdown-bg: rgba(255, 255, 255, 0.94);
  --search-item-hover: rgba(2, 132, 199, 0.1);

  --mac-control-bg: rgba(188, 212, 238, 0.4);
  --mac-control-border: rgba(188, 212, 238, 0.7);
  --mac-segment-active-bg: #ffffff;
  --mac-segment-active-color: #0c1d37;
  --mac-segment-indicator-bg: #ffffff;

  --scrollbar-thumb: rgba(15, 45, 80, 0.18);
  --scrollbar-thumb-hover: rgba(15, 45, 80, 0.35);

  --window-frame-border: rgba(188, 212, 238, 0.55);
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */

:root {
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', "SF Mono", Menlo, Consolas, monospace;

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  color-scheme: dark light;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

html[data-theme="light"] {
  color-scheme: light;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  overflow: hidden;
  background-image: var(--ambient-mesh);
  background-attachment: fixed;
  transition: background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1), color 0.3s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* App Layout - macOS Window Architecture */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  position: relative;
  border-top: 1px solid var(--window-frame-border);
}

/* ==========================================================================
   macOS Window Controls (Traffic Lights)
   ========================================================================== */
.mac-window-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 0 0;
  flex-shrink: 0;
  cursor: default;
  user-select: none;
}

.mac-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.4), 0 1px 2px rgba(0, 0, 0, 0.2);
}

.mac-dot-close {
  background: #ff5f56;
  border: 0.5px solid #e0443e;
}

.mac-dot-minimize {
  background: #ffbd2e;
  border: 0.5px solid #dea123;
}

.mac-dot-maximize {
  background: #27c93f;
  border: 0.5px solid #1aab29;
}

/* macOS traffic light icons appear on hover */
.mac-window-controls:hover .mac-dot-close::before {
  content: "";
  position: absolute;
  width: 6px;
  height: 1px;
  background: #4d0000;
  transform: rotate(45deg);
}
.mac-window-controls:hover .mac-dot-close::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 1px;
  background: #4d0000;
  transform: rotate(-45deg);
}

.mac-window-controls:hover .mac-dot-minimize::before {
  content: "";
  position: absolute;
  width: 6px;
  height: 1px;
  background: #5c3b00;
}

.mac-window-controls:hover .mac-dot-maximize::before {
  content: "";
  position: absolute;
  width: 4px;
  height: 4px;
  border-right: 1.5px solid #004d11;
  border-top: 1.5px solid #004d11;
  transform: rotate(45deg) translate(-0.5px, 0.5px);
}

.mac-dot:hover {
  filter: brightness(1.1);
}

.mac-dot:active {
  filter: brightness(0.9);
}

/* ==========================================================================
   Top Navigation Bar / macOS Unified Titlebar
   ========================================================================== */
.top-nav {
  height: 60px;
  background: var(--bg-glass);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 32px;
  z-index: 50;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), inset 0 1px 0 var(--glass-specular);
  transition: background-color 0.3s ease, border-color 0.3s ease;
  display: block;
}

.top-nav-inner {
  max-width: 1400px;
  width: 100%;
  height: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.logo-badge {
  width: 38px;
  height: 38px;
  background: transparent;
  border: none;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), filter 0.25s ease;
  cursor: pointer;
}

.logo-badge:hover {
  transform: scale(1.08);
  filter: drop-shadow(0 0 10px rgba(220, 185, 75, 0.65));
}

.logo-badge-img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.35));
}

[data-theme="light"] .logo-badge {
  background: transparent;
  border: none;
  box-shadow: none;
}

[data-theme="light"] .logo-badge:hover {
  filter: drop-shadow(0 0 12px rgba(184, 134, 11, 0.5));
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
}

/* ==========================================================================
   Search Bar (macOS Spotlight Style)
   ========================================================================== */
.search-box-container {
  flex: 1;
  max-width: 580px;
  position: relative;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-dim);
  pointer-events: none;
  transition: color 0.2s ease;
}

#global-search-input {
  width: 100%;
  height: 38px;
  background: var(--bg-input);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0 74px 0 42px;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-main);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08), inset 0 1px 0 var(--glass-specular);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

#global-search-input:hover {
  border-color: var(--border-focus);
}

#global-search-input:focus {
  outline: none;
  border-color: var(--accent-cyan);
  background: var(--bg-input-focus);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2), inset 0 1px 0 var(--glass-specular);
}

#global-search-input:focus ~ .search-icon {
  color: var(--accent-cyan);
}

.search-shortcut {
  position: absolute;
  right: 12px;
  padding: 2px 7px;
  background: var(--mac-control-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Search Dropdown / macOS Popover */
.search-dropdown {
  position: absolute;
  top: 46px;
  left: 0;
  right: 0;
  background: var(--search-dropdown-bg);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), inset 0 1px 1px var(--glass-specular);
  max-height: 420px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
  animation: macDropdownFade 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.search-dropdown.hidden {
  display: none;
}

.search-dropdown-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
}

.search-results-list {
  overflow-y: auto;
  padding: 6px;
}

.search-result-item {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: background 0.15s ease, transform 0.1s ease;
}

.search-result-item:hover,
.search-result-item.selected {
  background: var(--search-item-hover);
}

.result-top-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.result-code {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--code-badge-color);
  background: var(--code-badge-bg);
  border: 1px solid var(--code-badge-border);
  padding: 2px 7px;
  border-radius: 4px;
}

.result-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  flex: 1;
}

.result-count {
  font-size: 11px;
  color: var(--text-dim);
}

.result-path {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   Nav Right Cluster: Stats + macOS Theme Control
   ========================================================================== */
.nav-right-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  gap: 8px;
  align-items: center;
}

.nav-link-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--stat-pill-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  text-decoration: none;
  box-shadow: inset 0 1px 0 var(--glass-specular), var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.nav-link-pill:hover {
  background: var(--mac-control-bg-hover, rgba(255, 255, 255, 0.12));
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.15), inset 0 1px 0 var(--glass-specular-bright);
}

.nav-link-pill:active {
  transform: translateY(0);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

.nav-link-icon {
  display: inline-block;
  flex-shrink: 0;
  color: var(--text-dim);
  transition: transform 0.2s ease, color 0.2s ease;
}

.nav-link-pill:hover .nav-link-icon {
  color: var(--accent-cyan);
  transform: scale(1.1);
}

.nav-stats {
  display: flex;
  gap: 8px;
  align-items: center;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--stat-pill-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  box-shadow: inset 0 1px 0 var(--glass-specular), var(--shadow-sm);
  transition: all 0.2s ease;
}

.stat-pill.highlight {
  background: var(--stat-pill-highlight-bg);
  border-color: rgba(56, 189, 248, 0.35);
}

.stat-pill.highlight .stat-value {
  color: var(--accent-cyan);
}

.stat-label {
  color: var(--text-dim);
}

.stat-value {
  font-weight: 700;
  color: var(--text-main);
  font-family: var(--font-mono);
}

/* ==========================================================================
   macOS Segmented Theme Switch
   ========================================================================== */
.mac-theme-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 3px;
  background: var(--mac-control-bg);
  border: 1px solid var(--mac-control-border);
  border-radius: var(--radius-full);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), inset 0 1px 0 var(--glass-specular);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.theme-segment {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 28px;
  padding: 0;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  transition: color 0.2s ease, transform 0.1s ease;
}

.theme-segment:hover {
  color: var(--text-main);
}

.theme-segment.active {
  color: var(--mac-segment-active-color);
}

.theme-icon {
  display: inline-block;
  flex-shrink: 0;
  transition: transform 0.25s ease;
}

.theme-segment.active .theme-icon {
  transform: rotate(15deg) scale(1.08);
}

/* Sliding active pill indicator */
.theme-segment-indicator {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc(50% - 3px);
  background: var(--mac-segment-indicator-bg);
  border-radius: var(--radius-full);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15), inset 0 1px 0 var(--glass-specular-bright);
  z-index: 1;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.25s ease;
  pointer-events: none;
}

/* Light active: indicator is at left */
[data-theme="light"] .theme-segment-indicator {
  transform: translateX(0);
}

/* Dark active: indicator is at right */
[data-theme="dark"] .theme-segment-indicator,
:root:not([data-theme="light"]) .theme-segment-indicator {
  transform: translateX(100%);
}

/* ==========================================================================
   Main Layout
   ========================================================================== */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ==========================================================================
   Sidebar: macOS Finder Style Tree Navigation
   ========================================================================== */
.sidebar {
  width: 380px;
  background: var(--bg-glass-sidebar);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-shadow: inset -1px 0 0 var(--glass-specular-soft);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.sidebar-header {
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sidebar-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.tree-actions {
  display: flex;
  gap: 5px;
}

.icon-btn {
  background: var(--mac-control-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: inset 0 1px 0 var(--glass-specular), 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all 0.15s ease;
}

.icon-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--border-focus);
}

.tree-filter-wrapper input {
  width: 100%;
  height: 32px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0 12px;
  font-size: 12px;
  color: var(--text-main);
  outline: none;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05), inset 0 1px 0 var(--glass-specular);
  transition: all 0.2s ease;
}

.tree-filter-wrapper input:focus {
  border-color: var(--accent-cyan);
  background: var(--bg-input-focus);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.tree-container {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
}

/* Tree Nodes (macOS Finder Outline View) */
.tree-node-group {
  margin-bottom: 1px;
}

.tree-node-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.tree-node-row:hover {
  background: var(--tree-hover-bg);
}

.tree-node-row.active {
  background: var(--tree-active-bg);
  box-shadow: inset 2px 0 0 var(--tree-active-border), inset 0 1px 0 var(--glass-specular);
}

.tree-expander {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  cursor: pointer;
  transition: transform 0.2s ease, color 0.15s ease;
}

.tree-expander:hover {
  color: var(--accent-cyan);
}

.tree-expander.expanded {
  transform: rotate(90deg);
}

.tree-expander.empty {
  visibility: hidden;
}

.tree-code {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--stat-pill-bg);
  border: 1px solid var(--border-subtle);
  padding: 1px 5px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.tree-node-row.active .tree-code {
  color: var(--code-badge-color);
  background: var(--code-badge-bg);
  border-color: var(--code-badge-border);
}

.tree-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-main);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-node-row.active .tree-title {
  font-weight: 600;
}

.tree-badge {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  background: var(--stat-pill-bg);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
  transition: all 0.18s ease;
}

.tree-badge.zero {
  opacity: 0.45;
}

.tree-badge.has-matches {
  color: #0284c7;
  background: rgba(14, 165, 233, 0.12);
  border-color: rgba(14, 165, 233, 0.35);
  font-weight: 600;
  box-shadow: 0 0 6px rgba(14, 165, 233, 0.12);
}

[data-theme="dark"] .tree-badge.has-matches {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.2);
}

.tree-node-row:hover .tree-badge.has-matches {
  background: rgba(14, 165, 233, 0.22);
  border-color: rgba(14, 165, 233, 0.55);
}

[data-theme="dark"] .tree-node-row:hover .tree-badge.has-matches {
  background: rgba(56, 189, 248, 0.26);
  border-color: rgba(56, 189, 248, 0.6);
}

.subcat-count.has-matches,
.result-count.has-matches {
  color: #0284c7;
  font-weight: 600;
}

[data-theme="dark"] .subcat-count.has-matches,
[data-theme="dark"] .result-count.has-matches {
  color: #38bdf8;
}

.tree-children-container {
  padding-left: 14px;
  border-left: 1px dashed var(--border-subtle);
  margin-left: 8px;
}

.tree-children-container.collapsed {
  display: none;
}

/* ==========================================================================
   Center / Right Content Panel
   ========================================================================== */
.content-panel {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* Breadcrumbs (macOS Finder Path Bar) */
.breadcrumb-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 2px 0;
}

.breadcrumb-item {
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.breadcrumb-item:hover {
  color: var(--accent-cyan);
  background: var(--stat-pill-bg);
}

.breadcrumb-item.current {
  color: var(--text-main);
  font-weight: 700;
  cursor: default;
  background: transparent;
}

.breadcrumb-sep {
  color: var(--text-dim);
  user-select: none;
}

/* ==========================================================================
   Liquid Glass Hero Card (macOS Window Inspector Slab)
   ========================================================================== */
.category-hero-card {
  background: var(--bg-card);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 28px;
  box-shadow: var(--shadow-liquid);
  position: relative;
  overflow: hidden;
  transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Liquid specular top rim reflection */
.category-hero-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-indigo), var(--accent-cyan));
  background-size: 200% 100%;
}

.hero-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  width: 100%;
}

.code-badge-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.code-badge {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 800;
  background: var(--code-badge-bg);
  border: 1px solid var(--code-badge-border);
  color: var(--code-badge-color);
  padding: 4px 12px;
  border-radius: var(--radius-md);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.15), inset 0 1px 0 var(--glass-specular);
  flex-shrink: 0;
}

.level-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.35;
  word-break: break-word;
  overflow-wrap: break-word;
}

.hero-action-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-action-buttons .btn.hidden {
  display: none !important;
}

/* macOS Styled Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35), inset 0 1px 1px rgba(255, 255, 255, 0.35);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0369a1, #1d4ed8);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45), inset 0 1px 1px rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--stat-pill-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-color: var(--border-subtle);
  color: var(--text-main);
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--glass-specular);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  background: var(--stat-pill-bg);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  box-shadow: inset 0 1px 0 var(--glass-specular);
}

.btn-sm:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--border-focus);
}

.hero-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 22px;
  line-height: 1.3;
  color: var(--text-main);
}

.hero-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

/* Liquid Glass Metric Tiles */
.metric-card {
  background: var(--card-metric-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  box-shadow: inset 0 1px 0 var(--glass-specular), var(--shadow-sm);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.metric-card:hover {
  transform: translateY(-1px);
  border-color: var(--border-focus);
}

.metric-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.metric-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 2px;
  font-family: var(--font-mono);
}

.metric-subtext {
  font-size: 11px;
  color: var(--text-dim);
}

/* ==========================================================================
   Subcategories Section (Liquid Glass Grid)
   ========================================================================== */
.section-header {
  margin-bottom: 14px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}

.count-pill {
  font-size: 11px;
  font-weight: 700;
  background: var(--code-badge-bg);
  border: 1px solid var(--code-badge-border);
  color: var(--code-badge-color);
  padding: 1px 8px;
  border-radius: var(--radius-full);
}

.subcategories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

/* Liquid Glass Subcategory Cards */
.subcat-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 94px;
  box-shadow: inset 0 1px 0 var(--glass-specular), var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.subcat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--glass-highlight-linear);
}

.subcat-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow), var(--shadow-md), inset 0 1px 0 var(--glass-specular-bright);
}

.subcat-card:active {
  transform: translateY(0);
}

.subcat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.subcat-code {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--code-badge-color);
  background: var(--code-badge-bg);
  border: 1px solid var(--code-badge-border);
  padding: 2px 7px;
  border-radius: 5px;
}

.subcat-count {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.subcat-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-main);
}

/* ==========================================================================
   Direct Acts (Базове законодавство) Section
   ========================================================================== */
.direct-acts-section {
  margin-bottom: 24px;
}

.direct-acts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.direct-act-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: inset 0 1px 0 var(--glass-specular), var(--shadow-sm);
  position: relative;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
}

.direct-act-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, #3b82f6, #6366f1, #8b5cf6);
  opacity: 0.8;
}

.direct-act-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow), var(--shadow-md), inset 0 1px 0 var(--glass-specular-bright);
}

.direct-act-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.direct-act-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.25);
  padding: 2px 7px;
  border-radius: 5px;
  white-space: nowrap;
}

.direct-act-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.direct-act-card:hover .direct-act-icon-btn {
  background: #3b82f6;
  color: #ffffff;
  transform: scale(1.08);
}

.direct-act-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-main);
  margin-bottom: 6px;
}

.direct-act-number {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  font-family: var(--font-mono);
  margin-bottom: 8px;
}

.direct-act-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.45;
  margin-top: auto;
  border-top: 1px dashed var(--border-subtle);
  padding-top: 8px;
}

/* ==========================================================================
   Semantic Context & Cross-Relations Section
   ========================================================================== */
.semantic-cards-container {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 16px;
}

@media (max-width: 1024px) {
  .semantic-cards-container {
    grid-template-columns: 1fr;
  }
}

.semantic-card {
  background: var(--bg-card);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-liquid);
  display: flex;
  flex-direction: column;
}

.card-subtitle {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.cross-refs-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ref-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--ref-pill-bg);
  border: 1px solid var(--ref-pill-border);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--ref-pill-color);
  cursor: pointer;
  box-shadow: inset 0 1px 0 var(--glass-specular);
  transition: all 0.15s ease;
}

.ref-pill:hover {
  background: var(--ref-pill-hover-bg);
  border-color: var(--ref-pill-hover-border);
  transform: translateY(-1px);
}

.empty-text {
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
}

.semantic-text-preview {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-muted);
  background: var(--semantic-preview-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 12px;
  font-family: var(--font-sans);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05), inset 0 1px 0 var(--glass-specular);
}

.semantic-actions {
  display: flex;
  gap: 10px;
  margin-top: auto;
}

/* ==========================================================================
   Loading & Empty States
   ========================================================================== */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  gap: 12px;
  color: var(--text-dim);
  font-size: 13px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid rgba(56, 189, 248, 0.2);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: macSpin 0.75s linear infinite;
}

@keyframes macSpin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   macOS Smooth Scrollbars
   ========================================================================== */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* ==========================================================================
   macOS Liquid Glass Toast
   ========================================================================== */
.mac-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card-hover);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--border-focus);
  color: var(--text-main);
  padding: 10px 18px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg), inset 0 1px 0 var(--glass-specular-bright);
  z-index: 9999;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: macToastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.mac-toast-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
}

.mac-toast.fade-out {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

@keyframes macToastIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ==========================================================================
   Mobile Responsive System (Phones & Tablets)
   ========================================================================== */

/* Default Desktop Elements */
.mobile-sidebar-toggle {
  display: none;
}

.mobile-sidebar-close {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

.sidebar-mobile-stats {
  display: none;
}

/* Tablets and Mobile Screens (<= 900px) */
@media (max-width: 900px) {
  /* Hide macOS Window Dots on touch screens */
  .mac-window-controls {
    display: none !important;
  }

  /* App container adjustments */
  .app-container {
    height: 100vh;
    height: 100dvh;
    border-top: none;
  }

  /* Top Nav 2-tier clean mobile bar */
  .top-nav {
    height: auto;
    min-height: 56px;
    padding: 8px 12px 10px;
    display: block;
  }

  .top-nav-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 10px;
  }

  /* Mobile Toggle Button (Icon Only) */
  .mobile-sidebar-toggle {
    order: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 9px;
    min-width: 34px;
    height: 30px;
    background: var(--mac-control-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    color: var(--text-main);
    cursor: pointer;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: inset 0 1px 0 var(--glass-specular), 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: all 0.15s ease;
    user-select: none;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-toggle-text {
    display: none;
  }

  .mobile-sidebar-toggle:hover {
    border-color: var(--border-focus);
    background: var(--bg-card-hover);
  }

  .mobile-sidebar-toggle:active {
    transform: scale(0.96);
  }

  /* Brand Group */
  .brand-group {
    order: 2;
    flex: 1;
    min-width: 0;
    margin: 0 4px;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .logo-badge {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
  }

  .logo-badge-img {
    width: 34px;
    height: 34px;
  }

  .brand-title {
    font-size: 13.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .brand-subtitle {
    display: none;
  }

  /* Right Cluster / Nav Links & Theme Switcher (Icons Only) */
  .nav-right-cluster {
    order: 3;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    margin-left: auto;
  }

  .nav-links {
    gap: 6px;
  }

  .nav-link-pill {
    padding: 6px 9px;
    min-width: 34px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
  }

  .nav-link-pill span {
    display: none;
  }

  .nav-link-icon {
    width: 15px;
    height: 15px;
  }

  /* Hide Desktop Header Stats (moved into Drawer) */
  .nav-stats {
    display: none;
  }

  /* Compact Theme Switcher Icons on Mobile */
  .theme-segment {
    width: 30px;
    height: 26px;
  }

  .mac-theme-control {
    padding: 2px;
  }

  .theme-segment-indicator {
    width: calc(50% - 2px);
  }

  /* Search Container becomes full-width 2nd row */
  .search-box-container {
    order: 4;
    flex-basis: 100%;
    width: 100%;
    max-width: 100%;
    margin: 2px 0 0;
  }

  #global-search-input {
    height: 36px;
    font-size: 13px;
    padding-left: 36px;
    padding-right: 50px;
  }

  .search-icon {
    left: 12px;
    width: 15px;
    height: 15px;
  }

  .search-shortcut {
    font-size: 10px;
    padding: 2px 5px;
  }

  .search-dropdown {
    top: 42px;
    max-height: 320px;
  }

  /* Main Layout */
  .main-layout {
    flex: 1;
    flex-direction: column;
    height: calc(100vh - 108px);
    height: calc(100dvh - 108px);
    position: relative;
    overflow: hidden;
  }

  /* Mobile Backdrop Overlay */
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(3, 7, 18, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
  }

  /* Off-canvas Slide-over Sidebar Drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 86vw;
    max-width: 350px;
    height: 100vh;
    height: 100dvh;
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.32s ease;
    box-shadow: none;
    border-right: 1px solid var(--border-focus);
    background: var(--bg-glass-heavy);
    backdrop-filter: blur(36px) saturate(190%);
    -webkit-backdrop-filter: blur(36px) saturate(190%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.65), 0 0 25px rgba(56, 189, 248, 0.2);
  }

  .sidebar-header {
    padding: 16px 16px 12px;
  }

  .mobile-sidebar-close {
    display: flex !important;
  }

  /* Mobile Drawer Stats */
  .sidebar-mobile-stats {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
  }

  .sidebar-mobile-stats .stat-pill {
    padding: 4px 10px;
    font-size: 11px;
    flex: 1 1 auto;
    justify-content: center;
  }

  .tree-container {
    padding: 10px 8px 30px;
    -webkit-overflow-scrolling: touch;
  }

  .tree-node-row {
    padding: 9px 8px;
    min-height: 40px;
  }

  .tree-expander {
    width: 26px;
    height: 26px;
  }

  .tree-title {
    font-size: 13px;
  }

  /* Content Panel */
  .content-panel {
    padding: 14px 12px 36px;
    gap: 14px;
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .breadcrumb-bar {
    font-size: 11px;
    gap: 4px;
    line-height: 1.5;
    word-break: break-word;
  }

  /* Hero Card Mobile / Tablet Adaptation */
  .category-hero-card {
    padding: 16px 14px;
    border-radius: var(--radius-lg);
    width: 100%;
    box-sizing: border-box;
    overflow: visible; /* Prevents button / badge clipping */
  }

  .hero-top-row {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px;
    margin-bottom: 14px;
    width: 100%;
    box-sizing: border-box;
  }

  .code-badge-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 10px;
    width: 100%;
    min-width: 0;
  }

  .code-badge {
    font-size: 13px;
    padding: 4px 10px;
    flex-shrink: 0;
  }

  .level-badge {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    line-height: 1.4;
    word-break: break-word;
    overflow-wrap: break-word;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
  }

  /* Action Buttons / Tabs on Mobile */
  .hero-action-buttons {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: 8px;
    margin-top: 2px;
    box-sizing: border-box;
  }

  .hero-action-buttons .btn {
    width: 100% !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.35;
    text-align: center;
    border-radius: var(--radius-md);
    box-sizing: border-box;
    white-space: normal;
    word-break: break-word;
    box-shadow: var(--shadow-sm), inset 0 1px 0 var(--glass-specular);
  }

  .hero-action-buttons .btn.hidden {
    display: none !important;
  }

  .hero-title {
    font-size: 19px;
    line-height: 1.35;
    margin-bottom: 16px;
    word-break: break-word;
  }

  .hero-metrics-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .metric-card {
    padding: 12px 14px;
  }

  .metric-value {
    font-size: 20px;
  }

  /* Subcategories Grid */
  .subcategories-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .subcat-card {
    padding: 14px 14px;
    min-height: 76px;
  }

  /* Semantic Section */
  .semantic-cards-container {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .semantic-card {
    padding: 16px 14px;
    border-radius: var(--radius-lg);
  }

  .semantic-actions {
    flex-direction: column;
    width: 100%;
    gap: 8px;
  }

  .semantic-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

/* Small Mobile Phones (<= 480px, e.g. iPhone SE / mini) */
@media (max-width: 480px) {
  .top-nav {
    padding: 8px 10px 8px;
    min-height: 52px;
  }

  .mobile-toggle-text {
    display: none;
  }

  .mobile-sidebar-toggle {
    padding: 4px 7px;
    min-width: 30px;
    height: 26px;
  }

  .logo-badge {
    width: 30px;
    height: 30px;
  }

  .logo-badge svg {
    width: 18px;
    height: 18px;
  }

  /* Compact Theme Switcher & Nav Links on Small Screens */
  .nav-links {
    gap: 4px;
  }

  .nav-link-pill {
    padding: 4px 7px;
    min-width: 30px;
    height: 26px;
  }

  .nav-link-pill span {
    display: none;
  }

  .theme-segment {
    width: 28px;
    height: 24px;
    padding: 0;
  }

  .theme-segment-indicator {
    width: calc(50% - 2px);
  }

  .search-shortcut {
    display: none;
  }

  #global-search-input {
    padding-right: 14px;
    height: 36px;
    font-size: 13px;
  }

  .search-dropdown {
    max-height: 280px;
    top: 40px;
  }

  .content-panel {
    padding: 10px 8px 32px;
    gap: 12px;
  }

  .category-hero-card {
    padding: 14px 10px;
  }

  .code-badge {
    font-size: 12px;
    padding: 3px 8px;
  }

  .level-badge {
    font-size: 11px;
    letter-spacing: 0.01em;
    line-height: 1.3;
  }

  .hero-action-buttons {
    gap: 6px;
  }

  .hero-action-buttons .btn {
    padding: 9px 10px;
    font-size: 12px;
    gap: 6px;
  }

  .hero-title {
    font-size: 17px;
  }
}

/* ==========================================================================
   Judicial Practice Segments (Верховний Суд & PDF Journals)
   ========================================================================== */

.segments-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fadeIn 0.3s ease-out;
}

.segments-section.hidden {
  display: none !important;
}

.segments-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.segment-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  box-shadow: var(--shadow-md), var(--glass-inner-border);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  overflow: hidden;
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), 
              box-shadow 0.22s cubic-bezier(0.2, 0.8, 0.2, 1),
              border-color 0.22s ease;
}

.segment-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-cyan);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.segment-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-indigo), transparent);
  opacity: 0.85;
}

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

.segment-badges {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.segment-badge-case {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--accent-cyan);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  font-weight: 600;
}

.segment-badge-case-link {
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.segment-badge-case-link:hover {
  background: rgba(56, 189, 248, 0.24);
  border-color: rgba(56, 189, 248, 0.6);
  color: #38bdf8;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.25);
}

.external-icon-sm {
  margin-left: 2px;
  opacity: 0.75;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.segment-badge-case-link:hover .external-icon-sm {
  opacity: 1;
  transform: translate(1px, -1px);
}

.segment-badge-confidence {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 8px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: var(--accent-emerald);
  font-size: 12px;
  font-weight: 500;
}

.confidence-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

/* PDF Open Button */
.btn-pdf-view {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 9px;
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.16) 0%, rgba(225, 29, 72, 0.28) 100%);
  border: 1px solid rgba(244, 63, 94, 0.4);
  color: #fda4af;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(244, 63, 94, 0.18);
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

[data-theme="light"] .btn-pdf-view {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.1) 0%, rgba(225, 29, 72, 0.18) 100%);
  border-color: rgba(244, 63, 94, 0.35);
  color: #be123c;
  box-shadow: 0 2px 8px rgba(225, 29, 72, 0.12);
}

.btn-pdf-view:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.26) 0%, rgba(225, 29, 72, 0.42) 100%);
  border-color: #f43f5e;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(244, 63, 94, 0.35);
}

[data-theme="light"] .btn-pdf-view:hover {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.18) 0%, rgba(225, 29, 72, 0.3) 100%);
  border-color: #e11d48;
  color: #9f1239;
}

.btn-pdf-view .external-icon {
  opacity: 0.7;
  transition: transform 0.2s ease;
}

.btn-pdf-view:hover .external-icon {
  transform: translate(2px, -2px);
  opacity: 1;
}

.segment-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.segment-teza {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text-main);
  margin: 0;
}

.segment-summary {
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--bg-secondary);
  border-left: 3px solid var(--accent-cyan);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-muted);
}

.segment-summary p {
  margin: 0;
}

.segment-all-categories {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
}

.all-categories-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.all-categories-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--bg-surface, rgba(255, 255, 255, 0.04));
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  text-decoration: none;
  font-size: 12px;
  transition: all 0.2s ease;
}

.category-chip:hover {
  background: rgba(56, 189, 248, 0.12);
  border-color: var(--accent-cyan);
  color: #fff;
  transform: translateY(-1px);
}

.category-chip.active {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  font-weight: 600;
}

.chip-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 700;
  color: #c084fc;
}

.chip-name {
  color: var(--text-muted);
}

/* Segments Header Actions */
.segments-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

#btn-toggle-all-fulltext {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 8px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: var(--accent-cyan);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

#btn-toggle-all-fulltext:hover {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.5);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.2);
}

/* Full Text Section Inside Card */
.segment-fulltext-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.segment-fulltext-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.btn-toggle-fulltext {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 9px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.12) 0%, rgba(99, 102, 241, 0.16) 100%);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--accent-cyan);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

[data-theme="light"] .btn-toggle-fulltext {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.08) 0%, rgba(79, 70, 229, 0.12) 100%);
  border-color: rgba(2, 132, 199, 0.35);
  color: #0369a1;
}

.btn-toggle-fulltext:hover {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.22) 0%, rgba(99, 102, 241, 0.28) 100%);
  border-color: var(--accent-cyan);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.25);
}

[data-theme="light"] .btn-toggle-fulltext:hover {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.16) 0%, rgba(79, 70, 229, 0.22) 100%);
  border-color: #0284c7;
  color: #0c4a6e;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.15);
}

.btn-toggle-fulltext .chevron-icon {
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

.fulltext-badge {
  font-size: 11.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.03);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
}

.segment-fulltext-collapse {
  animation: fadeIn 0.25s ease-out;
}

.segment-fulltext-collapse.hidden {
  display: none !important;
}

.segment-fulltext-inner {
  padding: 18px 20px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(56, 189, 248, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 4px 20px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

[data-theme="light"] .segment-fulltext-inner {
  background: rgba(248, 250, 252, 0.9);
  border-color: rgba(2, 132, 199, 0.25);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 4px 16px rgba(0, 0, 0, 0.05);
}

.fulltext-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.fulltext-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-cyan);
}

.btn-copy-fulltext {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-copy-fulltext:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  transform: translateY(-1px);
}

.fulltext-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 14px;
  line-height: 1.68;
  color: var(--text-main);
}

.fulltext-intro-paragraph {
  margin: 0;
  color: var(--text-main);
  font-weight: 500;
}

.fulltext-section-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  border-left: 3px solid var(--accent-indigo);
}

[data-theme="light"] .fulltext-section-row {
  background: rgba(241, 245, 249, 0.7);
  border-left-color: #6366f1;
}

.fulltext-marker-badge {
  font-size: 12px;
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 0.02em;
}

[data-theme="light"] .fulltext-marker-badge {
  color: #0284c7;
}

.fulltext-marker-text {
  color: var(--text-main);
  line-height: 1.65;
}

.fulltext-regular-paragraph {
  margin: 0;
  line-height: 1.65;
}

.fulltext-citation-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(168, 85, 247, 0.08);
  border: 1px solid rgba(168, 85, 247, 0.25);
  font-size: 13px;
  line-height: 1.6;
}

[data-theme="light"] .fulltext-citation-box {
  background: rgba(168, 85, 247, 0.06);
  border-color: rgba(168, 85, 247, 0.22);
}

.citation-icon {
  font-size: 16px;
  line-height: 1;
}

.citation-content {
  flex: 1;
  color: var(--text-main);
}

.fulltext-reyestr-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 5px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: var(--accent-cyan);
  text-decoration: none;
  font-weight: 600;
  font-size: 12px;
  transition: all 0.2s ease;
}

.fulltext-reyestr-link:hover {
  background: rgba(56, 189, 248, 0.3);
  border-color: var(--accent-cyan);
  color: #ffffff;
}

.segment-details-collapse {
  margin-top: 6px;
  padding: 14px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: fadeIn 0.25s ease-out;
}

.segment-details-collapse.hidden {
  display: none !important;
}

[data-theme="light"] .segment-details-collapse {
  background: rgba(255, 255, 255, 0.65);
}

.detail-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-cyan);
}

.detail-text {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-main);
}

.detail-ai .detail-label {
  color: var(--accent-purple);
}

.detail-court-ref .detail-label {
  color: var(--accent-cyan);
}

.court-link-inline {
  color: var(--accent-cyan) !important;
}

.court-link-inline:hover {
  color: #38bdf8 !important;
}

.detail-pdf-ref .detail-label {
  color: var(--accent-rose);
}

.pdf-link-inline {
  color: var(--accent-rose);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s ease;
}

.pdf-link-inline:hover {
  color: #fb7185;
}

.segment-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-top: 4px;
}

.btn-toggle-details {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.btn-toggle-details:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

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

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

/* ==========================================================================
   Digest Registry Page & macOS Data Table
   ========================================================================== */
.page-digest {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.page-digest .app-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.digest-workspace {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-main);
  padding: 24px 32px 48px;
}

.digest-page-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header & Stat Cards */
.digest-header-section {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.digest-header-titles {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.digest-badge-pill {
  display: inline-flex;
  align-self: flex-start;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--accent-cyan);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.digest-main-heading {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
  margin: 0;
}

.digest-sub-heading {
  font-size: 13.5px;
  color: var(--text-muted);
  margin: 0;
}

.digest-stat-cards {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.digest-stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: inset 0 1px 0 var(--glass-specular), var(--shadow-sm);
  min-width: 190px;
}

.stat-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-card-icon.pdf-icon {
  background: rgba(244, 63, 94, 0.15);
  color: #f43f5e;
}

.stat-card-icon.md-icon {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
}

.stat-card-icon.seg-icon {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.stat-card-data {
  display: flex;
  flex-direction: column;
}

.stat-card-label {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
}

.stat-card-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  font-family: var(--font-mono);
}

.stat-card-value.highlight-cyan {
  color: var(--accent-cyan);
}

.stat-card-value.highlight-green {
  color: #10b981;
}

/* Filter Chips Bar */
.digest-filters-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.category-filter-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  padding: 6px 13px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background: var(--mac-control-bg);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.chip:hover {
  background: var(--mac-control-bg-hover);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

.chip.active {
  background: var(--accent-cyan);
  color: #030712;
  border-color: var(--accent-cyan);
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.35);
}

[data-theme="light"] .chip.active {
  background: var(--accent-cyan);
  color: #ffffff;
}

.results-counter-pill {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--mac-control-bg);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

/* Table Card Wrapper */
.digest-table-wrapper {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: inset 0 1px 0 var(--glass-specular), var(--shadow-lg);
  overflow: hidden;
}

.mac-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.mac-table th {
  background: var(--mac-control-bg);
  color: var(--text-dim);
  font-weight: 700;
  font-size: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  user-select: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.mac-table th:hover {
  background: var(--mac-control-bg-hover);
  color: var(--text-main);
}

.th-content {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sort-indicator {
  font-size: 10px;
  opacity: 0.5;
}

.mac-table th.sort-asc .sort-indicator,
.mac-table th.sort-desc .sort-indicator {
  opacity: 1;
  color: var(--accent-cyan);
}

.mac-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  vertical-align: middle;
}

.mac-table tbody tr {
  transition: background 0.15s ease;
}

.mac-table tbody tr:hover {
  background: rgba(56, 189, 248, 0.04);
}

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

/* Column Widths & Alignments */
.th-num, .td-num {
  width: 55px;
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-dim);
}

.th-file, .td-file {
  min-width: 320px;
}

.th-status, .td-status {
  width: 180px;
  text-align: center;
}

.th-status .th-content {
  justify-content: center;
}

.th-cat, .td-cat {
  width: 220px;
}

/* PDF File Link inside Table */
.pdf-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
  text-decoration: none;
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 13px;
  transition: all 0.2s ease;
  word-break: break-all;
}

.pdf-file-icon {
  color: #f43f5e;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.pdf-link:hover {
  color: var(--accent-cyan);
}

.pdf-link:hover .pdf-file-icon {
  transform: scale(1.15);
}

/* Badges for status and categories */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 700;
  user-select: none;
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-neutral {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
  border: 1px solid var(--border-subtle);
}

.badge-count {
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(16, 185, 129, 0.25);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.badge-interactive {
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.badge-interactive:hover {
  background: #10b981;
  border-color: #10b981;
  color: #ffffff;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.45);
  transform: translateY(-1px) scale(1.04);
}

.badge-interactive:hover .badge-count {
  background: rgba(0, 0, 0, 0.25);
  color: #ffffff;
}

.badge-interactive .icon-open-external {
  opacity: 0.7;
  transition: transform 0.2s ease, opacity 0.2s ease;
  margin-left: 1px;
}

.badge-interactive:hover .icon-open-external {
  opacity: 1;
  transform: translate(1px, -1px);
}

.badge-category {
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid transparent;
}

.cat-kks {
  background: rgba(244, 63, 94, 0.12);
  color: #f43f5e;
  border-color: rgba(244, 63, 94, 0.3);
}

.cat-kgs {
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent-cyan);
  border-color: rgba(56, 189, 248, 0.3);
}

.cat-kas {
  background: rgba(168, 85, 247, 0.12);
  color: #a855f7;
  border-color: rgba(168, 85, 247, 0.3);
}

.cat-kcs {
  background: rgba(234, 179, 8, 0.12);
  color: #eab308;
  border-color: rgba(234, 179, 8, 0.3);
}

.cat-vp {
  background: rgba(236, 72, 153, 0.12);
  color: #ec4899;
  border-color: rgba(236, 72, 153, 0.3);
}

.cat-espl {
  background: rgba(59, 130, 246, 0.12);
  color: #3b82f6;
  border-color: rgba(59, 130, 246, 0.3);
}

.cat-ses {
  background: rgba(20, 184, 166, 0.12);
  color: #14b8a6;
  border-color: rgba(20, 184, 166, 0.3);
}

.cat-general {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-muted);
  border-color: var(--border-subtle);
}

/* Empty and Error states inside table */
.empty-state-card, .table-error-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  color: var(--text-dim);
  text-align: center;
}

.table-error-msg {
  color: #f43f5e;
}

.error-icon {
  font-size: 28px;
}

.search-clear-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 8px;
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 4px;
}

.search-clear-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
}

.nav-link-pill.active {
  background: var(--accent-cyan);
  color: #030712;
  border-color: var(--accent-cyan);
  box-shadow: 0 2px 10px rgba(56, 189, 248, 0.35);
}

[data-theme="light"] .nav-link-pill.active {
  background: var(--accent-cyan);
  color: #ffffff;
}

.nav-link-pill.active .nav-link-icon {
  color: inherit;
}

/* Responsive Table Layout */
@media (max-width: 1024px) {
  .top-nav {
    padding: 0 16px;
  }

  .digest-workspace {
    padding: 16px;
  }

  .digest-table-wrapper {
    overflow-x: auto;
  }

  .mac-table {
    min-width: 750px;
  }
}

@media (max-width: 768px) {
  .digest-header-section {
    flex-direction: column;
    align-items: flex-start;
  }

  .digest-stat-cards {
    width: 100%;
  }

  .digest-stat-card {
    flex: 1;
    min-width: 140px;
    padding: 8px 12px;
  }

  .stat-card-value {
    font-size: 16px;
  }
}

/* ==========================================================================
   Minimalist Unified Footer
   ========================================================================== */
.app-footer {
  margin-top: 36px;
  padding: 22px 0 18px;
  border-top: 1px solid var(--border-subtle);
  width: 100%;
}

.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 12px;
  color: var(--text-dim);
  flex-wrap: wrap;
}

.footer-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.footer-copy {
  font-weight: 600;
  color: var(--text-main);
}

.footer-desc {
  color: var(--text-muted);
}

.footer-divider {
  color: var(--border-subtle);
  user-select: none;
}

.footer-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-dim);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease;
}

.footer-link:hover {
  color: var(--accent-cyan);
}

.footer-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  background: var(--stat-pill-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
  display: inline-block;
  animation: pulseStatus 2s infinite ease-in-out;
}

@keyframes pulseStatus {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

@media (max-width: 768px) {
  .app-footer {
    margin-top: 24px;
    padding: 18px 0 14px;
  }

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

  .footer-left, .footer-right {
    justify-content: center;
  }
}

/* ==========================================================================
   Direct Acts Modal Popup
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeInModal 0.2s ease-out;
}

.modal-backdrop.hidden,
.modal-backdrop[hidden],
.hidden {
  display: none !important;
}

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

.modal-dialog {
  width: 100%;
  max-width: 820px;
  max-height: 85vh;
  background: var(--bg-card);
  backdrop-filter: blur(30px) saturate(190%);
  -webkit-backdrop-filter: blur(30px) saturate(190%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), inset 0 1px 0 var(--glass-specular-bright);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: scaleInModal 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleInModal {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.modal-close-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s ease;
}

.modal-close-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-subtitle {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 16px;
  line-height: 1.5;
}

.modal-acts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-act-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-act-item:hover {
  background: var(--bg-card-hover);
  border-color: #3b82f6;
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.modal-act-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.modal-act-type {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: #3b82f6;
  letter-spacing: 0.04em;
}

.modal-act-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.35;
}

.modal-act-number {
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.modal-act-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 2px;
}

.modal-act-open-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 6px 12px;
  border-radius: 6px;
  white-space: nowrap;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.modal-act-item:hover .modal-act-open-btn {
  background: #3b82f6;
  color: #ffffff;
}

/* ==========================================================================
   ШІ-Асистент «Другий мозок» (Supreme Court AI Assistant & Audit System)
   ========================================================================== */

/* 1. Кнопка в навігаційному меню (Top Navigation) */
.nav-link-ai {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.18) 0%, rgba(168, 85, 247, 0.22) 100%) !important;
  border: 1px solid rgba(168, 85, 247, 0.38) !important;
  color: var(--text-main) !important;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.nav-link-ai:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.32) 0%, rgba(168, 85, 247, 0.38) 100%) !important;
  border-color: rgba(168, 85, 247, 0.6) !important;
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.35);
  transform: translateY(-1px);
}

.ai-sparkle-icon {
  color: #c084fc;
  animation: aiSparkleRotate 6s linear infinite;
}

@keyframes aiSparkleRotate {
  0% { transform: rotate(0deg); }
  50% { transform: rotate(180deg) scale(1.1); }
  100% { transform: rotate(360deg); }
}

.ai-badge-pulse {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1px 5px;
  border-radius: 10px;
  background: linear-gradient(135deg, #a855f7, #6366f1);
  color: #ffffff;
  box-shadow: 0 0 8px rgba(168, 85, 247, 0.6);
  animation: aiBadgeGlow 2.4s ease-in-out infinite alternate;
}

@keyframes aiBadgeGlow {
  0% { opacity: 0.85; transform: scale(0.96); }
  100% { opacity: 1; transform: scale(1.04); }
}

/* 2. Плаваюча кнопка виклику ШІ (Floating Action Button) */
.ai-floating-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1050;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 18px;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #9333ea 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.45), inset 0 1px 1px rgba(255, 255, 255, 0.3);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(8px);
}

.ai-floating-btn:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 12px 30px rgba(124, 58, 237, 0.65), 0 0 20px rgba(168, 85, 247, 0.5);
  border-color: rgba(255, 255, 255, 0.4);
}

.ai-floating-btn:active {
  transform: translateY(0) scale(0.98);
}

.ai-fab-glow {
  position: absolute;
  inset: -2px;
  border-radius: 999px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  z-index: -1;
  opacity: 0.4;
  filter: blur(6px);
  animation: aiFabPulse 3s ease-in-out infinite alternate;
}

@keyframes aiFabPulse {
  0% { opacity: 0.3; transform: scale(0.98); }
  100% { opacity: 0.7; transform: scale(1.05); }
}

/* 3. Модальне вікно ШІ-Асистента */
.ai-modal-dialog {
  max-width: 980px;
  width: 94vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid var(--border-glass);
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.65), var(--shadow-glow);
  border-radius: 20px;
  overflow: hidden;
  position: relative;
  animation: aiModalEnter 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes aiModalEnter {
  0% { opacity: 0; transform: scale(0.96) translateY(12px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.ai-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.4);
}

.ai-modal-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-header-badge {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(168, 85, 247, 0.3));
  border: 1px solid rgba(168, 85, 247, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c084fc;
}

.ai-header-titles h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-header-titles p {
  font-size: 12px;
  color: var(--text-muted);
  margin: 2px 0 0 0;
}

.ai-header-tag {
  font-size: 10px;
  font-weight: 600;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--accent-cyan);
  padding: 2px 7px;
  border-radius: 12px;
}

/* 4. Тіло вікна ШІ-Асистента */
.ai-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 5. Вкладки (Tabs) */
.ai-tabs-bar {
  display: flex;
  gap: 6px;
  background: var(--bg-input);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
}

.ai-tab-btn {
  flex: 1;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.ai-tab-btn.active {
  background: var(--bg-card);
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-glass);
}

/* 6. Поле вводу та контролери */
.ai-input-card {
  background: var(--bg-input);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ai-input-card:focus-within {
  border-color: rgba(168, 85, 247, 0.6);
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.2);
}

.ai-textarea {
  width: 100%;
  min-height: 110px;
  max-height: 240px;
  resize: vertical;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.5;
}

.ai-textarea::placeholder {
  color: var(--text-dim);
}

/* Швидкі чіпси / шаблони */
.ai-preset-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ai-preset-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.ai-preset-chip:hover {
  background: rgba(168, 85, 247, 0.15);
  border-color: rgba(168, 85, 247, 0.4);
  color: var(--text-main);
  transform: translateY(-1px);
}

.ai-preset-chip .chip-spark {
  color: #c084fc;
}

/* Рядок фільтрів та дій */
.ai-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 4px;
  border-top: 1px solid var(--border-subtle);
}

.ai-filters-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-select {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  outline: none;
  cursor: pointer;
}

.ai-actions-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-btn-primary {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.35);
}

.ai-btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.5);
  background: linear-gradient(135deg, #4338ca 0%, #6d28d9 100%);
}

.ai-btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.ai-btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ai-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

/* 7. Результати та картки */
.ai-results-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ai-empty-prompt {
  text-align: center;
  padding: 40px 20px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--border-glass);
  border-radius: 14px;
}

.ai-empty-icon {
  font-size: 38px;
  margin-bottom: 8px;
}

.ai-empty-prompt h4 {
  font-size: 16px;
  color: var(--text-main);
  margin: 0 0 6px 0;
}

.ai-empty-prompt p {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 540px;
  margin: 0 auto;
  line-height: 1.5;
}

/* Лоадер */
.ai-loading-box {
  text-align: center;
  padding: 40px 20px;
}

.ai-pulsing-rings {
  position: relative;
  width: 50px;
  height: 50px;
  margin: 0 auto 16px auto;
}

.ai-pulsing-rings .ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid #a855f7;
  animation: aiRingPulse 1.8s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

.ai-pulsing-rings .ring-2 { animation-delay: 0.4s; border-color: #6366f1; }
.ai-pulsing-rings .ring-3 { animation-delay: 0.8s; border-color: #38bdf8; }

@keyframes aiRingPulse {
  0% { transform: scale(0.3); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}

.ai-loading-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
}

.ai-loading-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto;
}

/* Верхній блок статистики результатів */
.ai-summary-header {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-stat-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
}

.ai-stat-pill .stat-num {
  font-weight: 700;
  color: var(--accent-cyan);
}

.ai-stat-pill.pill-vp {
  background: rgba(168, 85, 247, 0.15);
  border-color: rgba(168, 85, 247, 0.35);
}
.ai-stat-pill.pill-vp .stat-num { color: #c084fc; }

.ai-stat-pill.pill-op {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.35);
}
.ai-stat-pill.pill-op .stat-num { color: #60a5fa; }

.ai-articles-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
}

.articles-label {
  color: var(--text-muted);
  font-weight: 500;
}

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

.ai-art-tag {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--accent-cyan);
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 11.5px;
}

/* Банер відступу від практики */
.ai-overruling-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.18) 0%, rgba(249, 115, 22, 0.18) 100%);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 8px;
  padding: 10px 14px;
}

.ai-overruling-banner .banner-icon {
  font-size: 22px;
}

.ai-overruling-banner .banner-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12.5px;
}

.ai-overruling-banner strong {
  color: #f87171;
}

/* Юридичний бриф */
.ai-legal-brief {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(56, 189, 248, 0.06) 100%);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 12px;
  padding: 14px 18px;
}

.brief-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
}

.brief-body p {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0 0 6px 0;
}

.brief-bullets {
  margin: 0;
  padding-left: 18px;
  font-size: 12.5px;
  color: var(--text-main);
  line-height: 1.5;
}

.brief-bullets li {
  margin-bottom: 4px;
}

/* Картка постанови ВС */
.ai-decision-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.ai-decision-card:hover {
  border-color: rgba(168, 85, 247, 0.4);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  transform: translateY(-1px);
}

.ai-decision-card.card-overruling {
  border-color: rgba(239, 68, 68, 0.45);
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.06) 0%, var(--bg-card) 40%);
}

.card-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

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

.ai-comp-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.3px;
}

.ai-comp-badge.comp-vp {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.25), rgba(236, 72, 153, 0.25));
  border: 1px solid rgba(168, 85, 247, 0.5);
  color: #d8b4fe;
}

.ai-comp-badge.comp-op {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(99, 102, 241, 0.25));
  border: 1px solid rgba(59, 130, 246, 0.5);
  color: #93c5fd;
}

.ai-comp-badge.comp-palata {
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}

.ai-comp-badge.comp-kks {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.ai-ovr-badge {
  font-size: 10px;
  font-weight: 700;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fca5a5;
  padding: 2px 7px;
  border-radius: 6px;
}

.ai-match-badge {
  font-size: 10.5px;
  color: var(--text-dim);
}

.card-meta-line {
  font-size: 12.5px;
  color: var(--text-muted);
}

.card-overruling-notice {
  background: rgba(239, 68, 68, 0.12);
  border-left: 3px solid #ef4444;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  color: #fecaca;
}

.card-category-row {
  font-size: 11.5px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-category-row .cat-code {
  color: var(--accent-cyan);
  font-weight: 600;
}

/* Блок тези */
.card-teza-box {
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid #a855f7;
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
}

.teza-header {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #c084fc;
  margin-bottom: 4px;
}

.teza-content {
  font-size: 13.5px;
  color: var(--text-main);
  line-height: 1.55;
  font-weight: 500;
}

/* Акордеон деталей справи */
.card-details-accordion {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.details-summary {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.details-summary:hover {
  color: var(--text-main);
}

.details-summary .chevron {
  font-size: 9px;
  transition: transform 0.2s ease;
}

.card-details-accordion[open] .chevron {
  transform: rotate(180deg);
}

.details-body {
  padding: 10px 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

.detail-block strong {
  color: var(--text-main);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  display: block;
  margin-bottom: 2px;
}

.detail-block p {
  margin: 0;
}

/* Нижні кнопки дій картки */
.card-actions-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
}

.ai-card-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  border: 1px solid var(--border-glass);
}

.btn-copy-quote {
  background: rgba(168, 85, 247, 0.12);
  color: #d8b4fe;
  border-color: rgba(168, 85, 247, 0.35);
}

.btn-copy-quote:hover {
  background: #a855f7;
  color: #ffffff;
}

.btn-copy-quote.copied {
  background: #10b981 !important;
  color: #ffffff !important;
  border-color: #10b981 !important;
}

.btn-edrsr {
  background: rgba(56, 189, 248, 0.1);
  color: var(--accent-cyan);
  border-color: rgba(56, 189, 248, 0.3);
}

.btn-edrsr:hover {
  background: var(--accent-cyan);
  color: #090d16;
}

.btn-view-segment {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}

.btn-view-segment:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

/* 8. Блок уточнюючого діалогу (Follow-up chat) */
.ai-followup-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
}

.ai-chat-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-chat-bubble {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
}

.bubble-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #ffffff;
  border-bottom-right-radius: 2px;
}

.bubble-agent {
  align-self: flex-start;
  background: var(--bg-input);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  border-bottom-left-radius: 2px;
}

.bubble-header {
  font-size: 11px;
  font-weight: 700;
  color: #c084fc;
  margin-bottom: 4px;
}

.ai-generated-draft {
  margin: 8px 0 0 0;
  padding: 8px 12px;
  background: rgba(168, 85, 247, 0.08);
  border-left: 3px solid #a855f7;
  border-radius: 0 6px 6px 0;
  color: var(--text-main);
  font-style: italic;
  font-size: 13px;
}

.ai-followup-input-row {
  display: flex;
  gap: 8px;
}

.ai-followup-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text-main);
  font-size: 13px;
  outline: none;
}

.ai-followup-input:focus {
  border-color: rgba(168, 85, 247, 0.6);
}

/* Адаптивність мобілки */
@media (max-width: 768px) {
  .ai-floating-btn span.ai-fab-text {
    display: none;
  }
  .ai-floating-btn {
    padding: 12px;
    bottom: 16px;
    right: 16px;
  }
  .ai-modal-dialog {
    width: 98vw;
    max-height: 94vh;
  }
  .ai-controls-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .ai-actions-group {
    justify-content: flex-end;
  }
}

/* ==========================================================================
   Окрема сторінка ШІ-Асистента (assistant.html)
   ========================================================================== */
html:has(.page-assistant),
body.page-assistant,
.page-assistant {
  min-height: 100vh;
  height: auto !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  color: var(--text-main);
}

/* 10% brighter color system for Assistant page in Dark Theme */
:root:not([data-theme="light"]) body.page-assistant,
[data-theme="dark"] body.page-assistant {
  --bg-primary: #0e1526;               /* +10% lighter than #090d16 */
  --bg-secondary: #162238;             /* +10% lighter than #0f172a */
  --bg-card: rgba(25, 37, 60, 0.78);
  --bg-card-hover: rgba(42, 60, 92, 0.88);
  --bg-glass: rgba(22, 34, 58, 0.74);
  --bg-glass-heavy: rgba(16, 26, 46, 0.88);
  --bg-glass-sidebar: rgba(16, 26, 46, 0.76);
  --bg-input: rgba(22, 34, 58, 0.86);
  --bg-input-focus: rgba(28, 44, 72, 0.98);

  --border-subtle: rgba(255, 255, 255, 0.12);
  --border-glass: rgba(255, 255, 255, 0.16);
  --border-focus: rgba(82, 200, 250, 0.65);
  --border-accent: rgba(122, 125, 244, 0.42);

  --text-main: #ffffff;
  --text-muted: #a6b7ce;
  --text-dim: #798da6;

  --accent-cyan: #52c8fa;              /* +10% brighter from #38bdf8 */
  --accent-blue: #5b9bf8;              /* +10% brighter from #3b82f6 */
  --accent-indigo: #7a7df4;            /* +10% brighter from #6366f1 */
  --accent-purple: #b86cf9;            /* +10% brighter from #a855f7 */
  --accent-emerald: #22c55e;            /* +10% brighter from #10b981 */
  --accent-rose: #fb5173;              /* +10% brighter from #f43f5e */

  --shadow-glow: 0 0 28px rgba(82, 200, 250, 0.26);
}

/* ==========================================================================
   Скляно-прозорий хедер для сторінки ШІ-Асистента (assistant.html)
   з чіткою видимістю візерунка зміїної шкіри / рельєфу основного екрану
   ========================================================================== */
body.page-assistant .top-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(9, 16, 29, 0.12);
  backdrop-filter: blur(1.5px) saturate(125%);
  -webkit-backdrop-filter: blur(1.5px) saturate(125%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 4px 20px rgba(0, 0, 0, 0.15);
  transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

[data-theme="light"] body.page-assistant .top-nav {
  background: rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(1.5px) saturate(125%);
  -webkit-backdrop-filter: blur(1.5px) saturate(125%);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), 0 4px 16px rgba(0, 0, 0, 0.04);
}

/* Підкреслення та читабельність тексту та кнопок над прозорим візерунчастим склом */
body.page-assistant .top-nav .brand-title {
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

body.page-assistant .top-nav .brand-subtitle {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

[data-theme="light"] body.page-assistant .top-nav .brand-title,
[data-theme="light"] body.page-assistant .top-nav .brand-subtitle {
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

body.page-assistant .top-nav .nav-link-pill {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

[data-theme="light"] body.page-assistant .top-nav .nav-link-pill {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

body.page-assistant .top-nav .nav-link-pill:hover {
  background: rgba(255, 255, 255, 0.12);
}

[data-theme="light"] body.page-assistant .top-nav .nav-link-pill:hover {
  background: rgba(255, 255, 255, 0.85);
}

body.page-assistant .top-nav .mac-theme-control {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

[data-theme="light"] body.page-assistant .top-nav .mac-theme-control {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.assistant-page-main {
  flex: 1;
  padding: 24px 20px 40px;
}

.assistant-page-container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.assistant-hero-banner {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12) 0%, rgba(168, 85, 247, 0.12) 100%);
  border: 1px solid rgba(168, 85, 247, 0.25);
  border-radius: 16px;
  padding: 22px 28px;
  backdrop-filter: blur(16px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.hero-left {
  flex: 1;
  min-width: 280px;
}

.hero-right {
  display: flex;
  align-items: center;
}

/* Segmented Mode Switcher */
.assistant-mode-toggle {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-glass);
  border-radius: 30px;
  padding: 4px;
  gap: 4px;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.mode-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 24px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.mode-toggle-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.mode-toggle-btn.active {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #ffffff;
  box-shadow: 0 2px 12px rgba(168, 85, 247, 0.4);
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #c084fc;
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.35);
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 8px;
}

.hero-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
  margin: 0 0 6px 0;
  letter-spacing: -0.02em;
}

.hero-desc {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 820px;
  margin: 0;
  line-height: 1.5;
}

/* Двоколонкова робоча область */
.assistant-workspace-grid {
  display: grid;
  grid-template-columns: 460px 1fr;
  gap: 24px;
  align-items: start;
}

.assistant-input-panel {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 84px;
  align-self: start;
  z-index: 10;
}

.assistant-results-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.panel-card {
  background: var(--bg-card);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-md);
}

.panel-card.results-card {
  min-height: 520px;
}

.chips-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chips-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.textarea-wrap {
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  background: var(--bg-input);
  padding: 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.textarea-wrap:focus-within {
  border-color: rgba(168, 85, 247, 0.6);
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.2);
}

.assistant-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.controls-left,
.controls-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 1080px) {
  .assistant-workspace-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   ПРОСТИЙ РЕЖИМ (ChatGPT-style Autonomous AI Assistant)
   ========================================================================== */
.simple-mode-container {
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  min-height: 600px;
  position: relative;
}

.simple-chat-stream {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 20px 4px 60px 4px;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
}

/* Suggestions Wrapper (розміщується над стрічкою вводу) */
.simple-welcome-card {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  backdrop-filter: none;
  box-shadow: none;
  margin: 8px auto 0;
  max-width: 860px;
  width: 100%;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.simple-welcome-icon-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.simple-ai-orb {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #c084fc, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 0 28px rgba(168, 85, 247, 0.45);
  animation: orbPulse 3s infinite ease-in-out;
}

@keyframes orbPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 28px rgba(168, 85, 247, 0.45);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 42px rgba(168, 85, 247, 0.7);
  }
}

.simple-welcome-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
  margin: 0 0 10px 0;
  letter-spacing: -0.02em;
}

.simple-welcome-desc {
  font-size: 14.5px;
  color: var(--text-muted);
  max-width: 640px;
  margin: 0 auto 26px auto;
  line-height: 1.6;
}

.simple-prompt-suggestions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  text-align: left;
}

@media (max-width: 680px) {
  .simple-prompt-suggestions {
    grid-template-columns: 1fr;
  }
}

.simple-suggestion-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-hover);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.simple-suggestion-chip:hover {
  background: rgba(168, 85, 247, 0.12);
  border-color: rgba(168, 85, 247, 0.35);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(168, 85, 247, 0.15);
}

.chip-spark {
  font-size: 16px;
  flex-shrink: 0;
}

/* Chat Messages */
.simple-msg-row {
  display: flex;
  width: 100%;
  animation: fadeInMsg 0.3s ease;
}

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

.simple-msg-row.user-row {
  justify-content: flex-end;
}

.simple-msg-bubble-user {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25) 0%, rgba(168, 85, 247, 0.25) 100%);
  border: 1px solid rgba(168, 85, 247, 0.4);
  border-radius: 18px 18px 4px 18px;
  padding: 14px 20px;
  color: var(--text-main);
  font-size: 14.5px;
  max-width: 80%;
  line-height: 1.55;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  word-break: break-word;
}

.simple-msg-row.ai-row {
  justify-content: flex-start;
}

.simple-msg-bubble-ai {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  padding: 24px;
  width: 100%;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 18px;
  backdrop-filter: blur(16px);
}

.simple-ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-glass);
  padding-bottom: 12px;
}

.simple-ai-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #c084fc;
}

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

/* Executive summary box */
.simple-summary-box {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(168, 85, 247, 0.08) 100%);
  border-left: 4px solid #a855f7;
  border-radius: 0 12px 12px 0;
  padding: 14px 18px;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text-main);
}

.simple-summary-box strong {
  color: #c084fc;
}

/* Supreme Court holding cards */
.simple-holdings-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.simple-holding-card {
  background: var(--bg-hover);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.simple-holding-card:hover {
  border-color: rgba(168, 85, 247, 0.4);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.simple-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.court-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.court-badge.badge-op {
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.5);
  color: #fbbf24;
}

.court-badge.badge-vp {
  background: rgba(168, 85, 247, 0.2);
  border: 1px solid rgba(168, 85, 247, 0.5);
  color: #d8b4fe;
}

.court-badge.badge-palata {
  background: rgba(14, 165, 233, 0.18);
  border: 1px solid rgba(14, 165, 233, 0.45);
  color: #38bdf8;
}

.court-badge.badge-kks {
  background: rgba(100, 116, 139, 0.2);
  border: 1px solid rgba(100, 116, 139, 0.4);
  color: #cbd5e1;
}

.simple-case-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
}

.simple-holding-text {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-main);
}

.simple-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
  border-top: 1px dashed var(--border-glass);
}

.simple-rubric-label {
  font-size: 11.5px;
  color: var(--text-muted);
}

.simple-edrsr-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #a855f7;
  text-decoration: none;
  background: rgba(168, 85, 247, 0.1);
  border: 1px solid rgba(168, 85, 247, 0.3);
  padding: 4px 10px;
  border-radius: 8px;
  transition: all 0.2s;
}

.simple-edrsr-btn:hover {
  background: rgba(168, 85, 247, 0.25);
  color: #d8b4fe;
}

/* Input Bar (розташовується під кнопками-підказками або під відповідями) */
.simple-input-bar-container {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  z-index: 40;
}

.simple-input-bar-card {
  background: var(--bg-card);
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-radius: 20px;
  padding: 8px 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(24px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.simple-input-bar-card:focus-within {
  border-color: rgba(168, 85, 247, 0.7);
  box-shadow: 0 12px 48px rgba(168, 85, 247, 0.25);
}

.simple-input-bar-inner {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 4px 6px 4px 10px;
}

.simple-input-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.5;
  resize: none;
  max-height: 150px;
  min-height: 24px;
  padding: 4px 0;
}

.simple-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 10px rgba(168, 85, 247, 0.4);
}

.simple-send-btn:hover:not(:disabled) {
  transform: scale(1.08);
  box-shadow: 0 4px 16px rgba(168, 85, 247, 0.6);
}

.simple-send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.simple-input-footer-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding-bottom: 2px;
}

.simple-input-footer-hint code {
  color: #c084fc;
}

/* Typing Indicator */
.simple-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #a855f7;
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* ==========================================================================
   ЗМІЇНА ШКІРА ТА ВОДЯНА РЯБЬ (ФОН ДЛЯ ПРОСТОГО РЕЖИМУ: ТЕМНА ТА СВІТЛА ТЕМА)
   ========================================================================== */

/* --- ТЕМНА ТЕМА (ТЕМНИЙ ПІТОН) --- */
.scale-crevice,
[data-theme="dark"] .scale-crevice,
:root:not([data-theme="light"]) .scale-crevice {
  fill: #010408;
  stroke: #000000;
  stroke-width: 1.2;
}

.scale-base,
[data-theme="dark"] .scale-base,
:root:not([data-theme="light"]) .scale-base {
  fill: url(#scale-highlight-dark);
  stroke: rgba(0, 0, 0, 0.95);
  stroke-width: 1.1;
  stroke-linejoin: round;
}

.scale-ridge,
[data-theme="dark"] .scale-ridge,
:root:not([data-theme="light"]) .scale-ridge {
  fill: none;
  stroke: rgba(148, 163, 184, 0.4);
  stroke-width: 0.8;
  stroke-linecap: round;
}

.scale-bevel-left,
[data-theme="dark"] .scale-bevel-left,
:root:not([data-theme="light"]) .scale-bevel-left {
  fill: rgba(148, 163, 184, 0.12);
}

.scale-granule,
[data-theme="dark"] .scale-granule,
:root:not([data-theme="light"]) .scale-granule {
  fill: rgba(203, 213, 225, 0.4);
}

.scale-micro,
[data-theme="dark"] .scale-micro,
:root:not([data-theme="light"]) .scale-micro {
  fill: url(#scale-highlight-dark);
  stroke: rgba(0, 0, 0, 0.95);
  stroke-width: 0.8;
}

/* --- СВІТЛА ТЕМА (ШКІРА БІЛОЇ ЗМІЇ: ПЕРЛАМУТРОВА БІЛА ЛУСКА) --- */
[data-theme="light"] .scale-crevice {
  display: none;
  fill: transparent;
  stroke: none;
}

[data-theme="light"] .scale-base {
  fill: url(#scale-highlight-light);
  stroke: none;
}

[data-theme="light"] .scale-ridge {
  fill: none;
  stroke: rgba(148, 163, 184, 0.45);
  stroke-width: 0.85;
  stroke-linecap: round;
}

[data-theme="light"] .scale-bevel-left {
  fill: rgba(255, 255, 255, 0.7);
}

[data-theme="light"] .scale-granule {
  fill: #ffffff;
  filter: drop-shadow(0 0.8px 1px rgba(0, 0, 0, 0.18));
}

[data-theme="light"] .scale-micro {
  fill: url(#scale-highlight-light);
  stroke: none;
}

/* Контейнер підкладки зміїної шкіри на весь екран */
.snakeskin-backdrop {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.6s, background-color 0.4s ease;
  overflow: hidden;
  background: #09101d;
}

body.page-assistant.mode-simple-active {
  background: #09101d;
}

/* Світла тема: фон білої змії */
[data-theme="light"] .snakeskin-backdrop,
[data-theme="light"] body.page-assistant.mode-simple-active {
  background: #f1f5f9;
}

body.mode-simple-active .snakeskin-backdrop {
  opacity: 1;
  visibility: visible;
}

/* 1. Шар 3D-луски зміїної шкіри (базовий шар рельєфу) */
.snakeskin-scales-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  opacity: 1;
  transform: translateZ(0);
  will-change: transform, filter;
}

.snakeskin-scales-svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* 2. Іридесцентний шар: перелив кольорів (ТЕМНА ТЕМА: +10% яскравіше та виразніше) */
.snakeskin-iridescent-layer {
  position: absolute;
  inset: -20%;
  width: 140%;
  height: 140%;
  z-index: 2;
  mix-blend-mode: color;
  background: linear-gradient(
    135deg,
    #175d58 0%,
    #244672 16%,
    #3a3799 33%,
    #462364 50%,
    #25334a 67%,
    #124856 83%,
    #175d58 100%
  );
  background-size: 350% 350%;
  animation: iridescentFlow 16s ease-in-out infinite alternate;
  opacity: 0.55;
  transition: opacity 0.4s ease, mix-blend-mode 0.4s ease;
}

@keyframes iridescentFlow {
  0% {
    background-position: 0% 0%;
    filter: hue-rotate(0deg) saturate(0.75) brightness(0.95);
  }
  50% {
    background-position: 100% 100%;
    filter: hue-rotate(180deg) saturate(0.88) brightness(1.02);
  }
  100% {
    background-position: 0% 100%;
    filter: hue-rotate(360deg) saturate(0.75) brightness(0.95);
  }
}

/* Світла тема: Варіант 4 — Pure Titanium & Silver (нейтральна гра світла й тіні білої змії) */
[data-theme="light"] .snakeskin-iridescent-layer {
  mix-blend-mode: soft-light;
  opacity: 0.55;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.45) 0%,
    rgba(226, 232, 240, 0.35) 25%,
    rgba(203, 213, 225, 0.30) 50%,
    rgba(148, 163, 184, 0.20) 75%,
    rgba(255, 255, 255, 0.45) 100%
  );
  background-size: 200% 200%;
  animation: titaniumShimmerLight 22s ease-in-out infinite alternate;
}

@keyframes titaniumShimmerLight {
  0% {
    background-position: 0% 0%;
    opacity: 0.45;
  }
  50% {
    background-position: 100% 100%;
    opacity: 0.60;
  }
  100% {
    background-position: 0% 100%;
    opacity: 0.45;
  }
}

/* 3. Шар водяної рябі під дією вітру (активується під час обдумування ШІ) */
.snakeskin-water-ripples {
  position: absolute;
  inset: -60px;
  z-index: 3;
  background: radial-gradient(
    ellipse at 50% 50%,
    rgba(255, 255, 255, 0.25) 0%,
    rgba(255, 255, 255, 0.12) 18%,
    transparent 50%
  ),
  repeating-radial-gradient(
    circle at 50% 50%,
    rgba(255, 255, 255, 0.2) 0,
    rgba(255, 255, 255, 0.09) 5px,
    transparent 11px,
    rgba(255, 255, 255, 0.15) 18px
  );
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: overlay;
  transition: opacity 0.3s ease;
  transform: translateZ(0);
}

[data-theme="light"] .snakeskin-water-ripples {
  background: radial-gradient(
    ellipse at 50% 50%,
    rgba(255, 255, 255, 0.35) 0%,
    rgba(226, 232, 240, 0.18) 20%,
    transparent 55%
  ),
  repeating-radial-gradient(
    circle at 50% 50%,
    rgba(255, 255, 255, 0.25) 0,
    rgba(203, 213, 225, 0.12) 5px,
    transparent 11px,
    rgba(255, 255, 255, 0.18) 18px
  );
  mix-blend-mode: overlay;
}

/* 4. М'яка віньєтка по краях для фокусування та читабельності тексту */
.snakeskin-vignette {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: radial-gradient(
    ellipse at 50% 45%,
    rgba(9, 16, 29, 0.05) 0%,
    rgba(9, 16, 29, 0.28) 55%,
    rgba(5, 10, 20, 0.65) 100%
  );
  pointer-events: none;
}

[data-theme="light"] .snakeskin-vignette {
  background: radial-gradient(
    ellipse at 50% 45%,
    rgba(255, 255, 255, 0.05) 0%,
    rgba(241, 245, 249, 0.35) 55%,
    rgba(203, 213, 225, 0.7) 100%
  );
}

/* Фон залишається абсолютно стабільним і спокійним під час роботи ШІ */

/* ========================================================
   РОЗТАШУВАННЯ ТА ЦЕНТРУВАННЯ ПРОСТОГО РЕЖИМУ ШІ
   ======================================================== */

/* 1. ПОЧАТКОВИЙ СТАН: ПЕРЕМИКАЧ + 4 КНОПКИ + РЯДОК ВВОДУ СТРОГО ПО ЦЕНТРУ ЕКРАНУ */
body.mode-simple-active:not(.simple-dialogue-active) {
  min-height: 100vh;
}

body.mode-simple-active:not(.simple-dialogue-active) .assistant-page-main {
  min-height: calc(100vh - 65px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px 20px 48px;
  box-sizing: border-box;
}

body.mode-simple-active:not(.simple-dialogue-active) .assistant-page-container {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

body.mode-simple-active:not(.simple-dialogue-active) .simple-mode-container {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  min-height: auto;
}

body.mode-simple-active:not(.simple-dialogue-active) .simple-welcome-card {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
}

body.mode-simple-active:not(.simple-dialogue-active) .simple-chat-stream {
  display: none !important;
}

body.mode-simple-active:not(.simple-dialogue-active) .simple-input-bar-container {
  position: relative;
  top: auto;
  bottom: auto;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
}

/* 2. АКТИВНИЙ ДІАЛОГ: ВІДПОВІДІ ЗВЕРХУ, РЯДОК ВВОДУ ЗАВЖДИ ПІД НИМИ */
body.mode-simple-active.simple-dialogue-active .assistant-page-main {
  display: block;
  min-height: auto;
  padding: 16px 20px 60px;
}

body.mode-simple-active.simple-dialogue-active .assistant-page-container {
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

body.mode-simple-active.simple-dialogue-active .assistant-hero-banner {
  padding: 4px 0 10px 0;
  margin: 0 auto;
}

body.mode-simple-active.simple-dialogue-active .simple-welcome-card {
  display: none !important;
}

body.mode-simple-active.simple-dialogue-active .simple-mode-container {
  display: flex;
  flex-direction: column;
  min-height: auto;
  gap: 16px;
}

body.mode-simple-active.simple-dialogue-active .simple-chat-stream {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 8px 0 16px 0;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
}

body.mode-simple-active.simple-dialogue-active .simple-input-bar-container {
  position: sticky;
  bottom: 20px;
  top: auto;
  width: 100%;
  max-width: 860px;
  margin: 12px auto 20px;
  z-index: 50;
}

/* Стилізація компонентів простого режиму: лаконічний заголовок по центру сторінки (ТЕМНА ТЕМА) */
body.mode-simple-active .assistant-hero-banner {
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  padding: 10px 0 6px 0;
  margin: 0 auto;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 860px;
}

body.mode-simple-active .hero-left {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
}

body.mode-simple-active .hero-left .hero-badge {
  margin-bottom: 8px;
}

body.mode-simple-active .hero-left .hero-title {
  font-size: 1.6rem;
  margin-bottom: 6px;
}

body.mode-simple-active .hero-left .hero-desc {
  font-size: 0.88rem;
  max-width: 640px;
  margin: 0 auto;
  opacity: 0.85;
}

body.mode-simple-active .assistant-mode-toggle {
  margin: 0 auto;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(20px) saturate(160%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  padding: 5px;
}

body.mode-simple-active .simple-welcome-card {
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  padding: 0;
  margin: 0 auto;
  max-width: 860px;
  width: 100%;
}

body.mode-simple-active .simple-suggestion-chip {
  background: rgba(15, 23, 42, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(18px);
  color: #f1f5f9;
  border-radius: 14px;
  padding: 12px 16px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

body.mode-simple-active .simple-suggestion-chip:hover {
  background: rgba(30, 41, 59, 0.92);
  border-color: rgba(168, 85, 247, 0.55);
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(168, 85, 247, 0.28);
}

body.mode-simple-active .simple-msg-bubble-ai {
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(24px) saturate(160%);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

body.mode-simple-active .simple-holding-card {
  background: rgba(30, 41, 59, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
}

body.mode-simple-active .simple-input-bar-container {
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
}

body.mode-simple-active .simple-input-bar-card {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 24px;
  backdrop-filter: blur(28px) saturate(180%);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.65), 0 0 25px rgba(99, 102, 241, 0.22);
}

body.mode-simple-active .simple-input-bar-card textarea {
  color: #ffffff;
}

/* --- СТИЛІЗАЦІЯ КОМПОНЕНТІВ ПРОСТОГО РЕЖИМУ (СВІТЛА ТЕМА: БІЛА ЗМІЯ) --- */
[data-theme="light"] body.mode-simple-active .assistant-hero-banner {
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  padding: 6px 0 10px 0;
}

[data-theme="light"] body.mode-simple-active .assistant-mode-toggle {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(203, 213, 225, 0.9);
  backdrop-filter: blur(20px) saturate(160%);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] body.mode-simple-active .simple-welcome-card {
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  padding: 0;
  margin: 0 auto;
  max-width: 860px;
  width: 100%;
}

[data-theme="light"] body.mode-simple-active .simple-suggestion-chip {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(203, 213, 225, 0.88);
  color: #1e293b;
  backdrop-filter: blur(16px);
  border-radius: 14px;
  padding: 12px 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] body.mode-simple-active .simple-suggestion-chip:hover {
  background: rgba(248, 250, 252, 0.98);
  border-color: #818cf8;
  color: #1e1b4b;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.16);
}

[data-theme="light"] body.mode-simple-active .simple-msg-bubble-ai {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(226, 232, 240, 0.9);
  color: #0f172a;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.07);
}

[data-theme="light"] body.mode-simple-active .simple-ai-meta {
  color: #64748b;
}

[data-theme="light"] body.mode-simple-active .simple-holding-card {
  background: rgba(248, 250, 252, 0.92);
  border: 1px solid rgba(226, 232, 240, 0.95);
  color: #1e293b;
}

[data-theme="light"] body.mode-simple-active .simple-holding-thesis {
  color: #1e293b;
}

[data-theme="light"] body.mode-simple-active .simple-input-bar-container {
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
}

[data-theme="light"] body.mode-simple-active .simple-input-bar-card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(203, 213, 225, 0.95);
  border-radius: 24px;
  backdrop-filter: blur(24px) saturate(160%);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.08), 0 0 24px rgba(203, 213, 225, 0.45);
}

[data-theme="light"] body.mode-simple-active .simple-input-bar-card textarea {
  color: #0f172a;
}

[data-theme="light"] body.mode-simple-active .simple-input-bar-card textarea::placeholder {
  color: #94a3b8;
}

/* ==========================================================================
   Article Official Text Section (Liquid Glass Style)
   ========================================================================== */
.article-text-section {
  margin-bottom: 24px;
  animation: fadeIn 0.25s ease-out;
}

.article-text-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(20px);
  overflow: hidden;
  position: relative;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.article-text-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #38bdf8, #6366f1, #a855f7);
  opacity: 0.85;
}

.article-text-header {
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
}

.article-text-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.article-icon-badge {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.15), rgba(99, 102, 241, 0.15));
  border: 1px solid rgba(99, 102, 241, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #38bdf8;
  flex-shrink: 0;
}

[data-theme="light"] .article-icon-badge {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.12), rgba(79, 70, 229, 0.12));
  border-color: rgba(79, 70, 229, 0.25);
  color: #0284c7;
}

.article-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.article-law-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.16);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

[data-theme="light"] .article-law-badge {
  background: rgba(79, 70, 229, 0.1);
  color: #4338ca;
  border-color: rgba(79, 70, 229, 0.25);
}

.article-code-pill {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.article-text-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.35;
  margin: 0;
}

.article-text-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.article-text-body {
  padding: 24px;
  font-size: 0.96rem;
  line-height: 1.7;
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .article-text-body {
  background: rgba(248, 250, 252, 0.7);
  color: #1e293b;
}

.article-text-part {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.article-text-part:last-child {
  margin-bottom: 0;
}

.part-number {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 2px 8px;
  border-radius: 6px;
  flex-shrink: 0;
  margin-top: 1px;
}

[data-theme="light"] .part-number {
  color: #0284c7;
  background: rgba(2, 132, 199, 0.08);
  border-color: rgba(2, 132, 199, 0.22);
}

.part-content {
  flex: 1;
  min-width: 0;
  line-height: 1.7;
}

.article-text-subitem {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-left: 28px;
  margin-bottom: 10px;
}

.subitem-number {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.9rem;
  color: #a5b4fc;
  background: rgba(99, 102, 241, 0.1);
  padding: 1px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

[data-theme="light"] .subitem-number {
  color: #4f46e5;
  background: rgba(79, 70, 229, 0.08);
}

.subitem-content {
  flex: 1;
  min-width: 0;
  line-height: 1.65;
}

.article-text-p {
  margin-bottom: 14px;
  line-height: 1.7;
}

.article-text-p:last-child {
  margin-bottom: 0;
}

.article-text-note {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid rgba(99, 102, 241, 0.4);
  padding: 8px 14px;
  border-radius: 0 6px 6px 0;
  margin: 12px 0;
  font-style: italic;
}

[data-theme="light"] .article-text-note {
  background: rgba(241, 245, 249, 0.9);
  border-left-color: rgba(79, 70, 229, 0.5);
  color: #64748b;
}

@media (max-width: 768px) {
  .article-text-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .article-text-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .article-text-subitem {
    margin-left: 14px;
  }
}

/* Article text placeholder for laws without stored offline full text */
.article-text-placeholder {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 20px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-md);
}

[data-theme="light"] .article-text-placeholder {
  background: rgba(241, 245, 249, 0.6);
  border-color: rgba(203, 213, 225, 0.9);
}

.article-placeholder-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #818cf8;
  flex-shrink: 0;
}

[data-theme="light"] .article-placeholder-icon {
  background: rgba(79, 70, 229, 0.1);
  color: #4f46e5;
}

.article-placeholder-content {
  flex: 1;
  min-width: 0;
}

.article-placeholder-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 4px;
}

.article-placeholder-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 12px;
}

.article-placeholder-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  color: #ffffff !important;
  background: linear-gradient(135deg, #0284c7, #4f46e5);
  padding: 8px 16px;
  border-radius: 8px;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.article-placeholder-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
  opacity: 0.95;
}

/* Панель дій (Очистити діалог) одразу над рядком введення тексту */
.simple-chat-actions-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  width: 100%;
  max-width: 860px;
  margin: 0 auto 8px auto;
  padding: 0 4px;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.simple-chat-actions-bar.hidden {
  display: none !important;
}

body.mode-simple-active:not(.simple-dialogue-active) .simple-chat-actions-bar {
  display: none !important;
}

.simple-clear-chat-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted, #94a3b8);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.simple-clear-chat-btn svg {
  color: inherit;
  transition: transform 0.2s ease;
}

.simple-clear-chat-btn:hover {
  color: #f87171;
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.18);
}

.simple-clear-chat-btn:hover svg {
  transform: scale(1.1);
}

.simple-clear-chat-btn:active {
  transform: translateY(0);
}

[data-theme="light"] .simple-clear-chat-btn {
  color: #475569;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(203, 213, 225, 0.9);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .simple-clear-chat-btn:hover {
  color: #ef4444;
  background: #fef2f2;
  border-color: rgba(239, 68, 68, 0.4);
}

/* ==========================================================================
   МОБІЛЬНА ВЕРСІЯ: ПРИХОВУВАННЯ ПОСИЛАНЬ НА ІНШІ СТОРІНКИ В ХЕДЕРІ
   ========================================================================== */
@media (max-width: 900px) {
  .top-nav .nav-links a[href*="index.html"],
  .top-nav .nav-links a[href*="digest.html"],
  .top-nav .nav-links a[href*="decisions.html"],
  .top-nav .nav-links a[href*="viewer.html"] {
    display: none !important;
  }

  body.page-assistant .top-nav .nav-links {
    display: none !important;
  }
}

html.is-mobile-device .top-nav .nav-links a[href*="index.html"],
html.is-mobile-device .top-nav .nav-links a[href*="digest.html"],
html.is-mobile-device .top-nav .nav-links a[href*="decisions.html"],
html.is-mobile-device .top-nav .nav-links a[href*="viewer.html"],
html.is-mobile-device body.page-assistant .top-nav .nav-links {
  display: none !important;
}

/* ==========================================================================
   МОБІЛЬНА ВЕРСІЯ: ВЕРТИКАЛЬНЕ ЦЕНТРУВАННЯ ХЕДЕРА (ЛОГОТИП, НАЗВА, ПЕРЕМИКАЧ ТЕМ)
   ========================================================================== */
@media (max-width: 900px) {
  body.page-assistant .top-nav {
    height: 56px !important;
    min-height: 56px !important;
    padding: 0 16px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  body.page-assistant .top-nav-inner {
    height: 100% !important;
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: nowrap !important;
    gap: 12px !important;
  }

  body.page-assistant .brand-group {
    display: flex !important;
    align-items: center !important;
    height: 100% !important;
    margin: 0 !important;
    gap: 10px !important;
    flex: 1 !important;
    min-width: 0 !important;
  }

  body.page-assistant .logo-badge-link {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 100% !important;
    flex-shrink: 0 !important;
  }

  body.page-assistant .logo-badge {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 34px !important;
    height: 34px !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
  }

  body.page-assistant .logo-badge-img {
    width: 34px !important;
    height: 34px !important;
    display: block !important;
    object-fit: contain !important;
  }

  body.page-assistant .brand-text {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    min-width: 0 !important;
    margin: 0 !important;
  }

  body.page-assistant .brand-title {
    font-size: 14.5px !important;
    line-height: 1.25 !important;
    margin: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  body.page-assistant .brand-subtitle {
    display: none !important;
  }

  body.page-assistant .nav-right-cluster {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    height: 100% !important;
    margin: 0 0 0 auto !important;
    flex-shrink: 0 !important;
  }

  body.page-assistant .mac-theme-control {
    display: inline-flex !important;
    align-items: center !important;
    margin: 0 !important;
  }
}

@media (max-width: 480px) {
  body.page-assistant .top-nav {
    height: 52px !important;
    min-height: 52px !important;
    padding: 0 12px !important;
  }

  body.page-assistant .logo-badge,
  body.page-assistant .logo-badge-img {
    width: 30px !important;
    height: 30px !important;
  }

  body.page-assistant .brand-title {
    font-size: 13.5px !important;
  }
}

html.is-mobile-device body.page-assistant .top-nav {
  height: 56px !important;
  min-height: 56px !important;
  padding: 0 16px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

html.is-mobile-device body.page-assistant .top-nav-inner {
  height: 100% !important;
  width: 100% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  flex-wrap: nowrap !important;
  gap: 12px !important;
}

html.is-mobile-device body.page-assistant .brand-group {
  display: flex !important;
  align-items: center !important;
  height: 100% !important;
  margin: 0 !important;
  gap: 10px !important;
  flex: 1 !important;
  min-width: 0 !important;
}

html.is-mobile-device body.page-assistant .logo-badge-link {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 100% !important;
  flex-shrink: 0 !important;
}

html.is-mobile-device body.page-assistant .logo-badge {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 34px !important;
  height: 34px !important;
  margin: 0 !important;
  flex-shrink: 0 !important;
}

html.is-mobile-device body.page-assistant .logo-badge-img {
  width: 34px !important;
  height: 34px !important;
  display: block !important;
  object-fit: contain !important;
}

html.is-mobile-device body.page-assistant .brand-text {
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  min-width: 0 !important;
  margin: 0 !important;
}

html.is-mobile-device body.page-assistant .nav-right-cluster {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  height: 100% !important;
  margin: 0 0 0 auto !important;
  flex-shrink: 0 !important;
}

html.is-mobile-device body.page-assistant .mac-theme-control {
  display: inline-flex !important;
  align-items: center !important;
  margin: 0 !important;
}





