:root {
  color-scheme: dark;
  --bg: #080c10;
  --surface: #0f1a1f;
  --surface-hover: #152328;
  --surface-soft: rgba(15, 26, 31, 0.78);
  --primary: #4ecdc4;
  --primary-dim: rgba(78, 205, 196, 0.15);
  --secondary: #a8e6cf;
  --gold: #ffd93d;
  --gold-dim: rgba(255, 217, 61, 0.15);
  --case: #a8e6cf;
  --case-dim: rgba(168, 230, 207, 0.13);
  --text: #e8f4f0;
  --text-muted: #6b8f8a;
  --line: rgba(78, 205, 196, 0.12);
  --line-strong: rgba(78, 205, 196, 0.28);
  --danger: #ff6b6b;
  --radius: 20px;
  --radius-sm: 12px;
  --radius-pill: 50px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  --transition: cubic-bezier(0.45, 0.05, 0.55, 0.95);
}

/* Production AI workspace redesign
   Shared by LEXPrevoyance and Reglement RAG. Keeps the existing Django/JS
   structure, but shifts the product from the former MindFlow-style glass UI
   to a professional AI-chat shell with a black history rail and pale-blue work
   canvas. */
:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eaf6fb;
  --canvas: #eaf6fb;
  --canvas-deep: #d7edf7;
  --rail: #05070a;
  --rail-soft: #0a1016;
  --rail-hover: #101923;
  --surface: #f9fdff;
  --surface-hover: #eef9fd;
  --surface-soft: rgba(249, 253, 255, 0.92);
  --primary: #0a7d89;
  --primary-strong: #075f6f;
  --primary-soft: rgba(10, 125, 137, 0.1);
  --secondary: #2fb7e5;
  --gold: #9b6d0a;
  --gold-dim: rgba(155, 109, 10, 0.1);
  --case: #2457c5;
  --case-dim: rgba(36, 87, 197, 0.09);
  --text: #0e171c;
  --text-muted: #5c7079;
  --rail-text: #f7fbfc;
  --rail-muted: #899aa5;
  --line: rgba(15, 55, 66, 0.13);
  --line-strong: rgba(10, 125, 137, 0.28);
  --danger: #b93b4b;
  --radius: 8px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --shadow: 0 18px 48px rgba(20, 75, 91, 0.11);
}

html,
body {
  background: var(--canvas);
  color: var(--text);
  font-family: Inter, "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::after,
.rag-mesh {
  display: none;
}

.rag-app {
  min-height: 100vh;
  background: linear-gradient(180deg, #f7fdff 0, var(--canvas) 36%, var(--canvas-deep) 100%);
}

.rag-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  margin-left: 300px;
  width: calc(100% - 300px);
  min-height: 68px;
  padding: 12px 28px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  background: rgba(242, 251, 255, 0.86);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(22, 79, 96, 0.08);
  backdrop-filter: blur(22px);
}

.rag-back {
  display: none;
}

.history-toggle {
  width: 38px;
  min-width: 38px;
  height: 38px;
  padding: 0;
  color: var(--primary-strong);
  background: var(--surface);
  border-color: var(--line);
  box-shadow: 0 8px 18px rgba(20, 75, 91, 0.08);
}

.history-toggle-label {
  display: none;
}

.rag-brand {
  gap: 1px;
}

.rag-brand span {
  color: var(--text);
  background: none;
  font-family: Inter, "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 780;
  letter-spacing: 0;
}

.rag-brand small {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.rag-topnote {
  gap: 8px;
  color: var(--text-muted);
  font-family: Inter, "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 0.78rem;
}

.model-toggle,
.quota-pill,
.quota-request-link,
.rag-theme-toggle {
  min-height: 34px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(20, 75, 91, 0.06);
}

.model-toggle {
  grid-template-columns: repeat(2, minmax(70px, 1fr));
  padding: 3px;
}

.model-toggle-option {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 720;
}

.model-toggle-option.active {
  color: #f5fdff;
  background: #071018;
  box-shadow: none;
}

.quota-pill {
  color: var(--primary-strong);
  background: #e7f8fc;
  font-size: 0.78rem;
  font-weight: 760;
}

.quota-request-link,
.rag-theme-toggle {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 720;
}

.quota-request-link:hover,
.rag-theme-toggle:hover,
.rag-theme-toggle.active {
  color: var(--primary-strong);
  border-color: var(--line-strong);
  background: #eefbff;
}

.rag-account-name {
  max-width: 160px;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.rag-workspace {
  max-width: none;
  min-height: calc(100vh - 68px);
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) minmax(310px, 370px);
  gap: 0;
  align-items: stretch;
}

.rag-app.history-collapsed .rag-workspace {
  grid-template-columns: minmax(0, 1fr) minmax(310px, 370px);
  max-width: none;
}

.rag-app.history-collapsed .rag-topbar {
  margin-left: 0;
  width: 100%;
}

.rag-history-sidebar,
.rag-source-sidebar {
  position: sticky;
  top: 68px;
  max-height: calc(100vh - 68px);
}

.rag-history-sidebar {
  top: 0;
  max-height: 100vh;
  min-height: 100vh;
  padding: 16px;
  background: var(--rail);
  border-right: 1px solid rgba(116, 214, 255, 0.14);
}

.history-panel {
  height: calc(100vh - 32px);
  padding: 0;
  background: var(--rail) !important;
  border: 0 !important;
  border-radius: 0;
  box-shadow: none !important;
  backdrop-filter: none !important;
}

.history-panel .source-panel-heading {
  min-height: 78px;
  margin: 0 0 16px;
  padding: 6px 2px 14px;
  border-bottom: 1px solid rgba(116, 214, 255, 0.13);
}

.history-panel .rag-kicker {
  color: #74d6ff;
  font-size: 0.64rem;
  letter-spacing: 0.13em;
}

.history-panel h2 {
  color: var(--rail-text);
  font-size: 1.08rem;
  font-weight: 760;
}

.history-panel-actions {
  gap: 6px;
}

.history-panel .ghost-button {
  min-height: 30px;
  padding: 5px 10px;
  color: var(--rail-muted);
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(116, 214, 255, 0.13);
}

.history-new-button {
  min-height: 42px;
  margin-bottom: 14px;
  color: #eafdff;
  background: linear-gradient(135deg, #076b76, #0d98a6);
  border: 1px solid rgba(116, 214, 255, 0.22);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.26);
}

.history-list {
  max-height: calc(100vh - 156px);
  gap: 6px;
  padding-right: 0;
}

.history-empty {
  color: var(--rail-muted);
  border-color: rgba(116, 214, 255, 0.14);
  background: rgba(255, 255, 255, 0.03);
}

.history-item {
  min-height: 84px;
  padding: 11px 12px;
  color: var(--rail-text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
}

.history-item:hover {
  background: var(--rail-hover);
  border-color: rgba(116, 214, 255, 0.11);
  transform: none;
}

.history-item.active {
  background: #101923;
  border-color: rgba(116, 214, 255, 0.18);
  box-shadow: inset 3px 0 0 #74d6ff;
}

.history-question {
  color: var(--rail-text);
  font-size: 0.88rem;
  font-weight: 650;
}

.history-meta {
  color: var(--rail-muted);
  font-size: 0.62rem;
}

.history-meta span {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(116, 214, 255, 0.1);
}

.rag-main {
  min-height: calc(100vh - 68px);
  padding: 30px clamp(24px, 4vw, 54px) 34px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0) 28%),
    var(--canvas);
}

.rag-answer {
  order: 1;
  flex: 1 1 auto;
  min-height: 420px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
}

#answer-card {
  width: min(850px, 100%);
  margin: 0 auto;
  padding: 26px 30px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(15, 55, 66, 0.12);
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(20, 75, 91, 0.11);
}

.rag-empty {
  width: min(760px, 100%);
  min-height: 390px;
  margin: 0 auto;
  padding: 42px 24px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  text-align: center;
}

.rag-empty h2 {
  color: var(--text);
  font-family: Inter, "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 2.6rem;
  line-height: 1.08;
  letter-spacing: -0.02em;
  font-weight: 760;
}

.rag-empty .rag-kicker,
.rag-panel-heading .rag-kicker,
.source-panel-heading .rag-kicker {
  color: var(--primary-strong);
}

.rag-form-panel {
  order: 2;
  position: sticky;
  bottom: 18px;
  width: min(850px, 100%);
  margin: 0 auto;
  padding: 13px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(15, 55, 66, 0.14);
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(20, 75, 91, 0.2);
  backdrop-filter: blur(18px);
}

.rag-panel-heading {
  display: none;
}

.rag-form {
  margin: 0;
}

.rag-form label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

textarea {
  min-height: 82px;
  max-height: 240px;
  padding: 15px 17px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 8px;
  line-height: 1.48;
  box-shadow: none;
}

textarea::placeholder {
  color: #81949d;
  font-style: normal;
}

textarea:focus {
  background: transparent;
  box-shadow: none;
}

textarea[readonly],
textarea[readonly]:focus {
  background: #eef8fc;
  border: 0;
}

.rag-actions {
  margin-top: 8px;
  padding: 0 4px 2px;
  justify-content: flex-end;
  gap: 10px;
}

.rag-hint {
  margin-right: auto;
  color: var(--text-muted);
  font-size: 0.78rem;
}

#ask-button,
.quota-dialog button[type="submit"] {
  min-height: 40px;
  padding: 9px 22px;
  color: #f6fdff;
  background: #071018;
  border-radius: 8px;
}

#ask-button:hover,
.quota-dialog button[type="submit"]:hover {
  background: #0d7f8c;
}

.button-secondary,
.ghost-button {
  min-height: 38px;
  color: var(--text-muted);
  background: #f6fcff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.84rem;
}

.button-secondary:hover,
.ghost-button:hover {
  color: var(--primary-strong);
  border-color: var(--line-strong);
  background: #ebf8fc;
}

.answer-toolbar {
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.answer-meta {
  color: var(--text-muted);
  font-family: Inter, "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 0.76rem;
}

.citation-chip,
.citation-link {
  min-height: 24px;
  color: var(--primary-strong);
  background: #e5f7fc;
  border-color: rgba(10, 125, 137, 0.18);
  border-radius: 7px;
  font-size: 0.76rem;
}

.journal-rendered {
  color: var(--text);
  font-size: 1rem;
  line-height: 1.76;
}

.journal-rendered h1,
.journal-rendered h2,
.journal-rendered h3 {
  color: var(--text);
  font-family: Inter, "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  letter-spacing: -0.015em;
}

.journal-rendered h1 {
  font-size: 1.55rem;
}

.journal-rendered h2 {
  font-size: 1.28rem;
}

.journal-rendered h3 {
  font-size: 1.08rem;
}

.journal-rendered blockquote {
  color: var(--text-muted);
  font-family: Inter, "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 1rem;
  border-left-color: var(--primary);
}

.journal-rendered pre,
.journal-raw-pre {
  background: #071018;
  border: 1px solid rgba(116, 214, 255, 0.16);
  border-radius: 8px;
}

.source-panel {
  max-height: calc(100vh - 92px);
  padding: 18px;
  background: rgba(245, 252, 255, 0.72);
  border-left: 1px solid rgba(15, 55, 66, 0.1);
  border-radius: 0;
  box-shadow: none;
}

.rag-source-sidebar {
  padding: 24px 22px 24px 0;
  background: var(--canvas);
}

.source-panel-heading {
  margin-bottom: 12px;
}

.source-panel h2 {
  color: var(--text);
  font-size: 1rem;
}

.source-count,
.rag-status {
  min-height: 28px;
  color: var(--primary-strong);
  background: #e5f7fc;
  border-color: rgba(10, 125, 137, 0.18);
}

.source-list {
  gap: 9px;
}

.source-card {
  padding: 13px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(15, 55, 66, 0.1);
  border-radius: 8px;
  box-shadow: none;
}

.source-card:hover {
  background: #ffffff;
  border-color: rgba(10, 125, 137, 0.22);
  transform: none;
}

.source-code {
  color: #f5fdff;
  background: var(--primary-strong);
  border-radius: 6px;
}

.source-card.case .source-code {
  background: var(--case);
}

.source-title {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 720;
}

.source-subtitle,
.source-reason,
.source-excerpt,
.source-path {
  color: var(--text-muted);
  font-size: 0.79rem;
}

.source-reason {
  color: #4d666f;
}

.source-link {
  min-height: 30px;
  color: var(--primary-strong);
  background: #e8f8fd;
  border-color: rgba(10, 125, 137, 0.18);
  border-radius: 8px;
}

.example-btn {
  color: var(--text);
  background: #f6fcff;
  border-color: var(--line);
  border-radius: 8px;
}

.example-btn span {
  color: var(--primary-strong);
}

.quota-dialog,
.access-card,
.owner-header,
.owner-section {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line);
  border-radius: 8px;
}

.quota-dialog input,
.owner-limit-form input,
.owner-status-form input,
.owner-inline-form input,
.owner-status-form select {
  color: var(--text);
  background: #f6fcff;
}

.reglement-app .source-panel {
  background: rgba(245, 252, 255, 0.74);
}

.reglement-app .fund-catalog-panel summary {
  color: var(--primary-strong);
  font-family: Inter, "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 0.72rem;
}

.reglement-app .fund-catalog-table th {
  color: var(--text-muted);
  background: #f7fdff;
}

@media (max-width: 1180px) {
  .rag-topbar {
    margin-left: 270px;
    width: calc(100% - 270px);
  }

  .rag-workspace {
    grid-template-columns: 270px minmax(0, 1fr);
  }

  .rag-source-sidebar {
    display: none;
  }

  .rag-app.history-collapsed .rag-workspace {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 820px) {
  .rag-topbar {
    margin-left: 0;
    width: 100%;
    min-height: auto;
    padding: 10px 14px;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .rag-topnote {
    grid-column: 1 / -1;
    justify-content: flex-start;
    white-space: normal;
  }

  .rag-workspace,
  .rag-app.history-collapsed .rag-workspace {
    grid-template-columns: minmax(0, 1fr);
    min-height: auto;
  }

  .rag-history-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 45;
    width: min(320px, 88vw);
    transform: translateX(0);
    transition: transform 0.22s ease;
  }

  .rag-app.history-collapsed .rag-history-sidebar {
    display: block;
    transform: translateX(-100%);
  }

  .history-backdrop {
    position: fixed;
    inset: 0;
    z-index: 44;
    display: block;
    background: rgba(3, 7, 10, 0.42);
    border: 0;
  }

  .rag-app.history-collapsed .history-backdrop {
    display: none;
  }

  .history-close-mobile {
    display: inline-flex;
  }

  .rag-main {
    min-height: calc(100vh - 116px);
    padding: 22px 14px 24px;
  }

  .rag-form-panel,
  #answer-card,
  .rag-empty {
    width: 100%;
  }

  .rag-empty h2 {
    font-size: 2rem;
  }

  #answer-card {
    padding: 20px 16px;
  }

  .rag-form-panel {
    bottom: 10px;
  }
}

/* v30 final AI-shell polish. This sits at the very end so it wins over
   older experimental rules in the file. */
:root,
:root[data-theme="dark"],
:root[data-theme="light"] {
  color-scheme: light;
  --app-bg: #eaf8ff;
  --app-bg-deep: #d9f0fb;
  --rail-bg: #05080d;
  --rail-row: #111922;
  --rail-border: rgba(125, 219, 255, 0.16);
  --rail-text: #f4fbff;
  --rail-muted: #91a7b4;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-solid: #fbfeff;
  --panel-hover: #f2fbff;
  --ink: #0b1720;
  --ink-soft: #526b79;
  --blue: #0c7f91;
  --blue-strong: #075d71;
  --blue-bright: #64cdf5;
  --blue-soft: #e6f8ff;
  --border-blue: rgba(20, 118, 145, 0.18);
  --card-shadow: 0 18px 54px rgba(22, 86, 112, 0.12);
  --composer-shadow: 0 18px 50px rgba(9, 67, 92, 0.18);
  --radius: 10px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --text: var(--ink);
  --text-muted: var(--ink-soft);
  --primary: var(--blue);
  --primary-strong: var(--blue-strong);
  --secondary: var(--blue-bright);
  --surface: var(--panel-solid);
  --surface-soft: var(--panel);
  --surface-hover: var(--panel-hover);
  --line: var(--border-blue);
  --line-strong: rgba(20, 118, 145, 0.34);
  --bg: var(--app-bg);
  --shadow: var(--card-shadow);
}

html,
body {
  background: var(--app-bg) !important;
  color: var(--ink) !important;
  font-family: Inter, "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
}

body::after,
.rag-mesh {
  display: none !important;
}

.rag-app {
  min-height: 100vh !important;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.72), transparent 8%, transparent 92%, rgba(255, 255, 255, 0.72)),
    linear-gradient(180deg, #f8fdff 0, var(--app-bg) 34%, var(--app-bg-deep) 100%) !important;
  overflow-x: hidden !important;
}

.rag-topbar {
  position: sticky !important;
  top: 0 !important;
  z-index: 35 !important;
  min-height: 74px !important;
  margin-left: 330px !important;
  width: calc(100% - 330px) !important;
  padding: 12px clamp(20px, 3vw, 38px) !important;
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr) auto !important;
  gap: 14px !important;
  align-items: center !important;
  background: rgba(239, 250, 255, 0.88) !important;
  border-bottom: 1px solid rgba(20, 118, 145, 0.16) !important;
  box-shadow: 0 10px 28px rgba(19, 83, 110, 0.08) !important;
  backdrop-filter: blur(20px) !important;
}

.rag-back,
.rag-brand {
  display: none !important;
}

.history-toggle {
  width: 42px !important;
  min-width: 42px !important;
  height: 42px !important;
  padding: 0 !important;
  border-radius: 12px !important;
  color: var(--blue-strong) !important;
  background: rgba(255, 255, 255, 0.84) !important;
  border: 1px solid var(--border-blue) !important;
  box-shadow: 0 8px 20px rgba(16, 86, 112, 0.08) !important;
}

.history-toggle-label {
  display: none !important;
}

.rag-topnote {
  gap: 12px !important;
  justify-content: flex-end !important;
  color: var(--ink-soft) !important;
  font-family: Inter, "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif !important;
  font-size: 0.82rem !important;
  white-space: normal !important;
}

.model-toggle,
.quota-pill,
.quota-request-link,
.rag-theme-toggle {
  min-height: 42px !important;
  border-radius: 12px !important;
  border: 1px solid var(--border-blue) !important;
  background: rgba(255, 255, 255, 0.84) !important;
  box-shadow: 0 8px 20px rgba(16, 86, 112, 0.07) !important;
}

.model-toggle {
  display: inline-grid !important;
  grid-template-columns: repeat(2, minmax(82px, 1fr)) !important;
  padding: 4px !important;
}

.model-toggle-option {
  min-height: 32px !important;
  border-radius: 10px !important;
  color: var(--ink-soft) !important;
  font-weight: 760 !important;
  font-size: 0.82rem !important;
}

.model-toggle-option.active {
  color: #f6fdff !important;
  background: linear-gradient(180deg, #168ba1, #0b6d82) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24), 0 8px 18px rgba(13, 114, 137, 0.18) !important;
}

.quota-pill {
  position: relative !important;
  min-width: 210px !important;
  padding: 8px 14px 8px 44px !important;
  color: var(--blue-strong) !important;
  background: rgba(255, 255, 255, 0.86) !important;
  font-weight: 760 !important;
}

.quota-pill::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  border-radius: 5px;
  background: linear-gradient(180deg, #6ecff2, #148ba3);
  box-shadow: 0 0 0 4px rgba(100, 205, 245, 0.14);
}

.quota-request-link,
.rag-theme-toggle {
  color: var(--ink) !important;
  font-weight: 760 !important;
  text-decoration: none !important;
}

.rag-account-name {
  max-width: 160px !important;
  color: var(--ink-soft) !important;
  font-size: 0.82rem !important;
  font-weight: 650 !important;
}

.rag-workspace,
.rag-app.history-collapsed .rag-workspace {
  width: 100% !important;
  max-width: none !important;
  min-height: calc(100vh - 74px) !important;
  margin: 0 !important;
  padding: 0 !important;
  display: grid !important;
  grid-template-columns: 330px minmax(0, 1fr) minmax(320px, 370px) !important;
  gap: 0 !important;
  align-items: stretch !important;
}

.rag-app.history-collapsed .rag-workspace {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 370px) !important;
}

.rag-app.history-collapsed .rag-topbar {
  margin-left: 0 !important;
  width: 100% !important;
}

.rag-app.history-collapsed .rag-history-sidebar {
  display: none !important;
}

.rag-history-sidebar {
  position: fixed !important;
  inset: 0 auto 0 0 !important;
  z-index: 45 !important;
  width: 330px !important;
  min-width: 330px !important;
  height: 100vh !important;
  max-height: 100vh !important;
  padding: 18px 14px !important;
  display: block !important;
  background: var(--rail-bg) !important;
  border-right: 1px solid var(--rail-border) !important;
}

.history-panel {
  position: relative !important;
  height: 100% !important;
  max-height: none !important;
  padding: 0 !important;
  display: grid !important;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto !important;
  overflow: hidden !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}

.history-panel::before {
  content: "⚖  LEXPrevoyance";
  min-height: 42px;
  margin: 2px 0 18px;
  display: flex;
  align-items: center;
  color: var(--rail-text);
  font-size: 1.04rem;
  font-weight: 820;
  letter-spacing: -0.01em;
}

.reglement-app .history-panel::before {
  content: "▦  Reglement RAG";
}

.history-panel .source-panel-heading {
  margin: 0 0 14px !important;
  padding: 0 0 14px !important;
  min-height: auto !important;
  border-bottom: 1px solid rgba(125, 219, 255, 0.12) !important;
}

.history-panel .rag-kicker {
  margin-bottom: 6px !important;
  color: var(--blue-bright) !important;
  font-size: 0.66rem !important;
  letter-spacing: 0.16em !important;
}

.history-panel h2 {
  color: var(--rail-text) !important;
  font-size: 1.12rem !important;
  line-height: 1.2 !important;
  font-weight: 780 !important;
}

.history-panel .ghost-button {
  min-height: 32px !important;
  padding: 6px 10px !important;
  color: var(--rail-muted) !important;
  background: rgba(255, 255, 255, 0.045) !important;
  border: 1px solid rgba(125, 219, 255, 0.13) !important;
  border-radius: 9px !important;
  box-shadow: none !important;
}

.history-new-button {
  min-height: 48px !important;
  margin: 0 0 14px !important;
  padding: 0 16px !important;
  border: 1px solid rgba(125, 219, 255, 0.18) !important;
  border-radius: 9px !important;
  color: #f6fdff !important;
  background: linear-gradient(180deg, #168ba1, #0b6d82) !important;
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.26) !important;
  font-size: 0.94rem !important;
  font-weight: 780 !important;
}

.history-new-button::before {
  content: "+";
  margin-right: 10px;
  font-size: 1.35rem;
  line-height: 0;
  font-weight: 400;
}

.history-list {
  max-height: none !important;
  min-height: 0 !important;
  display: grid !important;
  gap: 6px !important;
  overflow: auto !important;
  padding: 0 2px 14px 0 !important;
}

.history-empty {
  color: var(--rail-muted) !important;
  background: rgba(255, 255, 255, 0.035) !important;
  border: 1px dashed rgba(125, 219, 255, 0.14) !important;
}

.history-item {
  min-height: 76px !important;
  padding: 12px 13px !important;
  display: grid !important;
  gap: 7px !important;
  color: var(--rail-text) !important;
  background: transparent !important;
  border: 1px solid transparent !important;
  border-radius: 9px !important;
  box-shadow: none !important;
  transform: none !important;
}

.history-item:hover {
  background: var(--rail-row) !important;
  border-color: rgba(125, 219, 255, 0.12) !important;
}

.history-item.active {
  background: linear-gradient(90deg, rgba(100, 205, 245, 0.13), rgba(255, 255, 255, 0.035)) !important;
  border-color: rgba(125, 219, 255, 0.2) !important;
  box-shadow: inset 3px 0 0 var(--blue-bright) !important;
}

.history-question {
  color: var(--rail-text) !important;
  font-size: 0.86rem !important;
  line-height: 1.32 !important;
  font-weight: 660 !important;
  -webkit-line-clamp: 2 !important;
}

.history-preview {
  display: none !important;
}

.history-meta {
  gap: 7px !important;
  color: var(--rail-muted) !important;
  font-family: Inter, "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif !important;
  font-size: 0.74rem !important;
}

.history-meta span {
  min-height: auto !important;
  max-width: none !important;
  padding: 0 !important;
  color: var(--rail-muted) !important;
  background: transparent !important;
  border: 0 !important;
}

.history-meta span + span::before {
  content: "·";
  margin-right: 7px;
  color: rgba(145, 167, 180, 0.62);
}

.rag-main {
  min-width: 0 !important;
  min-height: calc(100vh - 74px) !important;
  padding: 28px clamp(24px, 4vw, 56px) 24px !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 16px !important;
  background: transparent !important;
}

.rag-answer {
  order: 1 !important;
  flex: 1 1 auto !important;
  min-height: 410px !important;
  padding: 0 !important;
  display: flex !important;
  justify-content: center !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}

#answer-card {
  width: min(870px, 100%) !important;
  align-self: flex-start !important;
  margin: 0 auto !important;
  padding: 26px 30px !important;
  background: rgba(255, 255, 255, 0.88) !important;
  border: 1px solid var(--border-blue) !important;
  border-radius: 11px !important;
  box-shadow: var(--card-shadow) !important;
}

.rag-empty {
  width: min(820px, 100%) !important;
  min-height: 390px !important;
  margin: 0 auto !important;
  padding: 42px 24px !important;
  display: grid !important;
  place-items: center !important;
  color: var(--ink-soft) !important;
  text-align: center !important;
}

.rag-empty .rag-kicker {
  color: var(--blue-strong) !important;
}

.rag-empty h2 {
  max-width: 620px !important;
  margin: 0 auto 12px !important;
  color: var(--ink) !important;
  font-family: Inter, "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif !important;
  font-size: clamp(2.1rem, 5vw, 3.7rem) !important;
  line-height: 1.03 !important;
  font-weight: 780 !important;
  letter-spacing: -0.02em !important;
}

.rag-empty p:last-child {
  max-width: 560px !important;
  margin-inline: auto !important;
  line-height: 1.65 !important;
}

.rag-form-panel {
  order: 2 !important;
  position: sticky !important;
  bottom: 16px !important;
  z-index: 20 !important;
  width: min(870px, 100%) !important;
  margin: auto auto 0 !important;
  padding: 10px !important;
  background: rgba(255, 255, 255, 0.92) !important;
  border: 1px solid rgba(20, 118, 145, 0.24) !important;
  border-radius: 12px !important;
  box-shadow: var(--composer-shadow) !important;
  backdrop-filter: blur(18px) !important;
}

.rag-panel-heading {
  display: none !important;
}

.rag-form {
  width: 100% !important;
  margin: 0 !important;
  display: grid !important;
  gap: 8px !important;
}

.rag-form label {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
}

textarea,
#question {
  width: 100% !important;
  min-height: 56px !important;
  max-height: 170px !important;
  padding: 14px 16px !important;
  color: var(--ink) !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 9px !important;
  box-shadow: none !important;
  resize: vertical !important;
  line-height: 1.45 !important;
  font-size: 0.96rem !important;
  caret-color: var(--blue) !important;
}

textarea::placeholder,
#question::placeholder {
  color: #728794 !important;
  font-style: normal !important;
}

textarea:focus,
#question:focus {
  background: #fafdff !important;
  outline: none !important;
  box-shadow: inset 0 0 0 1px rgba(20, 118, 145, 0.14) !important;
}

.rag-actions {
  width: 100% !important;
  margin: 0 !important;
  padding: 0 4px 2px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 9px !important;
}

.rag-hint {
  margin-right: auto !important;
  color: var(--ink-soft) !important;
  font-size: 0.82rem !important;
  line-height: 1.25 !important;
}

#ask-button,
.quota-dialog button[type="submit"] {
  min-height: 40px !important;
  padding: 9px 20px !important;
  color: #f6fdff !important;
  background: linear-gradient(180deg, #168ba1, #0b6d82) !important;
  border: 0 !important;
  border-radius: 9px !important;
  box-shadow: 0 10px 18px rgba(13, 114, 137, 0.18) !important;
  font-size: 0.92rem !important;
  font-weight: 780 !important;
}

#ask-button::before {
  content: "↗";
  margin-right: 8px;
  font-weight: 700;
}

#ask-button:disabled {
  color: #dbe8ed !important;
  background: #8d969d !important;
  box-shadow: none !important;
}

.button-secondary,
.ghost-button {
  min-height: 40px !important;
  padding: 9px 15px !important;
  color: var(--ink-soft) !important;
  background: #f7fcff !important;
  border: 1px solid var(--border-blue) !important;
  border-radius: 9px !important;
  box-shadow: none !important;
  font-size: 0.88rem !important;
  font-weight: 720 !important;
}

.answer-toolbar {
  margin-bottom: 20px !important;
  padding-bottom: 14px !important;
  border-bottom: 1px solid var(--border-blue) !important;
}

.answer-meta {
  color: var(--ink-soft) !important;
  font-family: Inter, "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif !important;
  font-size: 0.78rem !important;
}

.journal-rendered {
  color: var(--ink) !important;
  font-size: 1rem !important;
  line-height: 1.74 !important;
}

.journal-rendered h1,
.journal-rendered h2,
.journal-rendered h3 {
  color: var(--ink) !important;
  font-family: Inter, "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif !important;
  letter-spacing: -0.015em !important;
  font-weight: 760 !important;
}

.journal-rendered h1 {
  font-size: 1.55rem !important;
}

.journal-rendered h2 {
  font-size: 1.28rem !important;
}

.journal-rendered h3 {
  font-size: 1.08rem !important;
}

.citation-chip,
.citation-link {
  min-height: 24px !important;
  color: var(--blue-strong) !important;
  background: var(--blue-soft) !important;
  border: 1px solid rgba(20, 118, 145, 0.16) !important;
  border-radius: 7px !important;
  font-size: 0.76rem !important;
}

.rag-source-sidebar {
  position: sticky !important;
  top: 74px !important;
  max-height: calc(100vh - 74px) !important;
  padding: 24px 16px 24px 0 !important;
  display: grid !important;
  background: transparent !important;
}

.source-panel {
  max-height: calc(100vh - 104px) !important;
  padding: 18px !important;
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) auto !important;
  background: rgba(255, 255, 255, 0.58) !important;
  border: 1px solid rgba(20, 118, 145, 0.14) !important;
  border-radius: 12px !important;
  box-shadow: none !important;
  backdrop-filter: blur(14px) !important;
}

.source-panel .rag-kicker {
  color: var(--blue-strong) !important;
}

.source-panel h2 {
  color: var(--ink) !important;
  font-size: 1rem !important;
  font-weight: 780 !important;
}

.source-count,
.rag-status {
  color: var(--blue-strong) !important;
  background: var(--blue-soft) !important;
  border: 1px solid rgba(20, 118, 145, 0.16) !important;
  border-radius: 8px !important;
}

.source-card {
  padding: 13px !important;
  color: var(--ink) !important;
  background: rgba(255, 255, 255, 0.76) !important;
  border: 1px solid rgba(20, 118, 145, 0.13) !important;
  border-radius: 9px !important;
  box-shadow: none !important;
  transform: none !important;
}

.source-card:hover {
  background: #ffffff !important;
  border-color: rgba(20, 118, 145, 0.28) !important;
  transform: none !important;
}

.source-code {
  color: #f6fdff !important;
  background: #197fb6 !important;
  border-radius: 6px !important;
}

.source-card.case .source-code {
  background: #2457c5 !important;
}

.source-title {
  color: var(--ink) !important;
  font-size: 0.9rem !important;
  font-weight: 740 !important;
}

.source-subtitle,
.source-reason,
.source-excerpt,
.source-path {
  color: var(--ink-soft) !important;
  font-size: 0.79rem !important;
}

.source-link {
  min-height: 30px !important;
  color: var(--blue-strong) !important;
  background: var(--blue-soft) !important;
  border: 1px solid rgba(20, 118, 145, 0.18) !important;
  border-radius: 8px !important;
}

@media (max-width: 1180px) {
  .rag-topbar {
    margin-left: 300px !important;
    width: calc(100% - 300px) !important;
  }

  .rag-workspace,
  .rag-app.history-collapsed .rag-workspace {
    grid-template-columns: 300px minmax(0, 1fr) !important;
  }

  .rag-history-sidebar {
    width: 300px !important;
    min-width: 300px !important;
  }

  .rag-source-sidebar {
    display: none !important;
  }
}

@media (max-width: 820px) {
  .rag-topbar {
    margin-left: 0 !important;
    width: 100% !important;
    min-height: auto !important;
    padding: 10px 12px !important;
    grid-template-columns: auto minmax(0, 1fr) !important;
  }

  .rag-topnote {
    grid-column: 1 / -1 !important;
    justify-content: flex-start !important;
  }

  .rag-workspace,
  .rag-app.history-collapsed .rag-workspace {
    grid-template-columns: minmax(0, 1fr) !important;
    min-height: auto !important;
  }

  .rag-history-sidebar {
    width: min(320px, 88vw) !important;
    min-width: 0 !important;
    transform: translateX(0);
    transition: transform 0.22s ease;
  }

  .rag-app.history-collapsed .rag-history-sidebar {
    display: block !important;
    transform: translateX(-100%);
  }

  .history-backdrop {
    position: fixed !important;
    inset: 0 !important;
    z-index: 44 !important;
    display: block !important;
    background: rgba(3, 7, 10, 0.42) !important;
    border: 0 !important;
  }

  .rag-app.history-collapsed .history-backdrop {
    display: none !important;
  }

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

  .rag-main {
    width: 100% !important;
    min-height: calc(100vh - 116px) !important;
    padding: 18px 12px 18px !important;
  }

  .rag-empty,
  #answer-card,
  .rag-form-panel {
    width: 100% !important;
    max-width: 100% !important;
  }

  .rag-empty {
    min-height: 300px !important;
    padding: 30px 12px !important;
  }

  .rag-empty h2 {
    font-size: clamp(1.75rem, 9vw, 2.35rem) !important;
  }

  #answer-card {
    padding: 20px 16px !important;
  }

  .rag-form-panel {
    bottom: 10px !important;
  }

  .rag-actions {
    flex-wrap: wrap !important;
  }

  .rag-hint {
    flex-basis: 100% !important;
    order: 3 !important;
  }

  #ask-button,
  .button-secondary {
    flex: 1 1 130px !important;
  }
}

/* Final mobile viewport guard. This must stay at the end of the stylesheet
   because older responsive blocks above still contain wider shell defaults. */
@media (max-width: 820px) {
  html,
  body {
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  .rag-app,
  .rag-workspace,
  .rag-main,
  .rag-answer,
  .rag-form-panel,
  #answer-card,
  .rag-empty {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .rag-app,
  .rag-workspace {
    width: 100vw !important;
    max-width: 100vw !important;
    margin-inline: 0 !important;
    overflow-x: hidden !important;
  }

  .rag-main {
    width: 100vw !important;
    max-width: 100vw !important;
    padding: 22px 14px 24px !important;
    overflow-x: hidden !important;
  }

  .rag-answer {
    width: 100% !important;
  }

  .rag-topbar,
  .rag-topnote,
  .rag-form,
  .rag-empty > div {
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .rag-topnote {
    white-space: normal !important;
    justify-content: flex-start !important;
  }

  .rag-empty {
    width: calc(100vw - 28px) !important;
    max-width: calc(100vw - 28px) !important;
    padding: 34px 12px !important;
  }

  .rag-empty > div {
    width: calc(100vw - 52px) !important;
    max-width: calc(100vw - 52px) !important;
  }

  .rag-empty h2 {
    width: auto !important;
    max-width: min(300px, calc(100vw - 52px)) !important;
    margin-inline: auto !important;
    font-size: clamp(1.55rem, 7.5vw, 1.85rem) !important;
    letter-spacing: 0 !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: normal !important;
  }

  .rag-empty p {
    width: auto !important;
    max-width: min(310px, calc(100vw - 52px)) !important;
    margin-inline: auto !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }

  .rag-form-panel {
    width: calc(100vw - 28px) !important;
    max-width: calc(100vw - 28px) !important;
    overflow: hidden !important;
  }

  .rag-form {
    width: calc(100vw - 54px) !important;
    max-width: calc(100vw - 54px) !important;
  }

  textarea,
  #question,
  #quota-reason {
    display: block !important;
    width: calc(100vw - 58px) !important;
    min-width: 0 !important;
    max-width: calc(100vw - 58px) !important;
    box-sizing: border-box !important;
  }

  .rag-actions {
    width: calc(100vw - 58px) !important;
    max-width: calc(100vw - 58px) !important;
    flex-wrap: wrap !important;
  }

  #ask-button,
  .button-secondary {
    flex: 1 1 120px !important;
    min-width: 0 !important;
  }

  .rag-hint {
    flex-basis: 100% !important;
    order: 3 !important;
  }
}

@media (max-width: 820px) {
  .rag-app,
  .rag-workspace,
  .rag-main,
  .rag-answer,
  .rag-form-panel,
  #answer-card,
  .rag-empty {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  .rag-main {
    width: 100%;
    overflow-x: hidden;
  }

  .rag-answer {
    width: 100%;
  }

  .rag-empty {
    padding: 34px 12px;
  }

  .rag-empty h2 {
    max-width: 100%;
    font-size: clamp(1.85rem, 9vw, 2.12rem);
    letter-spacing: 0;
    overflow-wrap: anywhere;
  }

  .rag-empty p {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .rag-form-panel {
    width: calc(100vw - 28px);
    max-width: calc(100vw - 28px);
  }

  textarea {
    width: 100%;
    min-width: 0;
  }

  .rag-actions {
    flex-wrap: wrap;
  }

  .rag-hint {
    flex-basis: 100%;
    order: 3;
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f3ec;
  --surface: #fffaf1;
  --surface-hover: #f0ebe1;
  --surface-soft: rgba(255, 250, 241, 0.82);
  --primary: #087e78;
  --primary-dim: rgba(8, 126, 120, 0.12);
  --secondary: #427d5d;
  --gold: #9c7200;
  --gold-dim: rgba(156, 114, 0, 0.12);
  --case: #5b55b8;
  --case-dim: rgba(91, 85, 184, 0.11);
  --text: #17211f;
  --text-muted: #687972;
  --line: rgba(8, 126, 120, 0.16);
  --line-strong: rgba(8, 126, 120, 0.32);
  --danger: #b23a48;
  --shadow: 0 18px 42px rgba(56, 42, 20, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
  opacity: 0.42;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
}

:root[data-theme="light"] body::after {
  opacity: 0.18;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
p {
  margin-top: 0;
}

.rag-app {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  background: var(--bg);
  overflow-x: clip;
}

.rag-mesh {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 15% 80%, rgba(78, 205, 196, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 20%, rgba(168, 230, 207, 0.06) 0%, transparent 40%),
    radial-gradient(ellipse at 50% 50%, rgba(90, 100, 140, 0.05) 0%, transparent 60%),
    var(--bg);
}

:root[data-theme="light"] .rag-mesh,
:root[data-theme="light"] .rag-access-shell,
:root[data-theme="light"] .rag-owner-shell {
  background:
    radial-gradient(ellipse at 14% 78%, rgba(8, 126, 120, 0.14) 0%, transparent 48%),
    radial-gradient(ellipse at 88% 18%, rgba(255, 205, 100, 0.18) 0%, transparent 42%),
    radial-gradient(ellipse at 48% 45%, rgba(91, 85, 184, 0.08) 0%, transparent 58%),
    var(--bg);
}

.rag-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  margin: 0 auto;
  padding: 14px clamp(16px, 4vw, 34px) 12px;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  background: rgba(8, 12, 16, 0.84);
  border-bottom: 1px solid rgba(78, 205, 196, 0.08);
  backdrop-filter: blur(20px);
}

:root[data-theme="light"] .rag-topbar {
  background: rgba(255, 250, 241, 0.88);
  border-bottom-color: rgba(8, 126, 120, 0.14);
  box-shadow: 0 12px 34px rgba(56, 42, 20, 0.08);
}

.rag-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  padding: 8px 0;
  transition: color 0.25s;
}

.rag-back::before {
  content: "<";
  color: var(--primary);
  font-weight: 800;
}

.rag-back:hover {
  color: var(--primary);
}

.history-toggle {
  width: auto;
  min-width: 42px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.045);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  transition: color 0.25s, border-color 0.25s, background 0.25s, transform 0.25s;
}

.history-toggle-label {
  display: inline;
  font-size: 0.76rem;
  font-weight: 850;
}

.history-toggle:hover {
  color: var(--text);
  border-color: var(--line-strong);
  background: var(--surface-hover);
  transform: translateY(-1px);
}

.history-toggle-icon {
  width: 17px;
  height: 16px;
  display: grid;
  grid-template-columns: 6px 1fr;
  gap: 4px;
}

.history-toggle-icon span {
  min-width: 0;
  border: 1.5px solid currentColor;
  border-radius: 3px;
}

.history-toggle-icon span:first-child {
  background: currentColor;
  opacity: 0.82;
}

.rag-brand {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.rag-brand span {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(1.85rem, 3vw, 2.45rem);
  line-height: 1.08;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.rag-brand small,
.rag-topnote,
.rag-hint,
.muted {
  color: var(--text-muted);
}

.rag-brand small,
.rag-topnote {
  font-size: 0.82rem;
}

.rag-topnote {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  flex-wrap: wrap;
}

.model-toggle {
  display: inline-grid;
  min-height: 30px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.045);
}

.model-toggle {
  grid-template-columns: repeat(2, minmax(74px, 1fr));
}

.model-toggle-option {
  min-height: 24px;
  border: 0;
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  color: var(--text-muted);
  background: transparent;
  font: inherit;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  transition: color 0.2s, background 0.2s, box-shadow 0.2s;
}

.model-toggle-option:hover {
  color: var(--text);
}

.model-toggle-option.active {
  color: var(--bg);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: 0 0 0 1px rgba(168, 230, 207, 0.18);
}

.quota-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  padding: 5px 11px;
  color: var(--primary);
  background: var(--primary-dim);
  font-weight: 800;
}

.quota-pill.quota-empty {
  color: var(--danger);
  border-color: rgba(255, 138, 122, 0.38);
  background: rgba(255, 138, 122, 0.08);
}

.quota-request-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 5px 11px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.045);
  text-decoration: none;
  font: inherit;
  font-weight: 800;
  transition: color 0.25s, border-color 0.25s, background 0.25s;
}

.quota-request-link:hover {
  color: var(--text);
  border-color: var(--line-strong);
  background: var(--surface-hover);
}

.rag-theme-toggle {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 5px 11px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.045);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s, background 0.25s, transform 0.25s;
}

.rag-theme-toggle:hover,
.rag-theme-toggle.active {
  color: var(--primary);
  border-color: var(--line-strong);
  background: var(--primary-dim);
}

.rag-theme-toggle.system {
  border-style: dashed;
}

.rag-theme-toggle:hover {
  transform: translateY(-1px);
}

:root[data-theme="light"] .rag-theme-toggle,
:root[data-theme="light"] .quota-request-link,
:root[data-theme="light"] .model-toggle,
:root[data-theme="light"] .history-toggle,
:root[data-theme="light"] .button-secondary,
:root[data-theme="light"] .ghost-button {
  background: rgba(255, 255, 255, 0.56);
}

.owner-link {
  color: var(--gold);
  border-color: rgba(255, 217, 61, 0.24);
}

.rag-account-name {
  display: inline-block;
  max-width: min(210px, 28vw);
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

.rag-logout-form,
.access-logout-form {
  margin: 0;
}

.rag-logout-button {
  color: var(--danger);
  border-color: rgba(255, 138, 122, 0.26);
}

.rag-logout-button:hover {
  color: var(--text);
  border-color: rgba(255, 138, 122, 0.48);
  background: rgba(255, 138, 122, 0.1);
}

.guest-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.guest-card {
  width: min(620px, calc(100vw - 32px));
}

.guest-card h1 {
  margin: 8px 0 12px;
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.guest-name-form {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

.guest-name-form label {
  color: var(--text-muted);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
}

.guest-name-form input {
  width: 100%;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  font: inherit;
  font-size: 1rem;
}

.guest-name-form input:focus {
  outline: none;
  border-color: var(--line-strong);
  box-shadow: 0 0 0 4px rgba(54, 130, 116, 0.14);
}

.guest-note {
  margin-top: 18px;
  font-size: 0.9rem;
}

.rag-workspace {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 30px 24px 72px;
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr) minmax(310px, 390px);
  gap: 22px;
  align-items: start;
}

.rag-app.history-collapsed .rag-workspace {
  grid-template-columns: minmax(0, 1fr) minmax(310px, 390px);
  max-width: 1080px;
}

.rag-app.history-collapsed .rag-history-sidebar {
  display: none;
}

.rag-app.history-collapsed .history-toggle-icon {
  grid-template-columns: 1fr 6px;
}

.rag-app.history-collapsed .history-toggle-icon span:first-child {
  order: 2;
  opacity: 0.45;
}

.history-backdrop {
  display: none;
}

.rag-main {
  min-width: 0;
  display: grid;
  gap: 18px;
}

.rag-form-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  background: var(--surface-soft);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.rag-panel-heading,
.source-panel-heading,
.answer-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.rag-panel-heading.compact {
  margin-bottom: 14px;
}

.rag-kicker {
  margin: 0 0 7px;
  color: var(--gold);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
}

h1 {
  margin-bottom: 8px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(1.85rem, 3.7vw, 2.25rem);
  line-height: 1.08;
  font-weight: 700;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.35;
  font-weight: 750;
}

.rag-status,
.source-count,
.answer-meta {
  color: var(--text-muted);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
}

.rag-status,
.source-count {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  padding: 5px 11px;
  background: var(--primary-dim);
  color: var(--primary);
  white-space: nowrap;
}

.rag-form {
  margin-top: 16px;
}

.rag-form label {
  display: block;
  margin-bottom: 10px;
  color: var(--text-muted);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 126px;
  max-height: 360px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  color: var(--text);
  background: rgba(8, 12, 16, 0.44);
  line-height: 1.65;
  caret-color: var(--primary);
  box-shadow: none;
  outline: none;
  transition: border-color 0.25s, background 0.25s, box-shadow 0.25s;
}

textarea::placeholder {
  color: rgba(168, 230, 207, 0.28);
  font-style: italic;
}

textarea:focus {
  border-color: var(--line-strong);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.08);
}

textarea[readonly] {
  cursor: default;
  color: var(--text-muted);
  border-color: rgba(255, 217, 61, 0.24);
  background: rgba(15, 26, 31, 0.52);
  box-shadow: none;
}

textarea[readonly]:focus {
  border-color: rgba(255, 217, 61, 0.28);
  background: rgba(15, 26, 31, 0.52);
  box-shadow: none;
}

.rag-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.quota-dialog button[type="submit"],
#ask-button {
  border: 0;
  border-radius: var(--radius-pill);
  min-height: 46px;
  padding: 12px 30px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--bg);
  font-weight: 800;
  transition: transform 0.25s, opacity 0.25s;
}

.quota-dialog button[type="submit"]:hover,
#ask-button:hover {
  transform: translateY(-1px);
  opacity: 0.94;
}

.quota-dialog button[type="submit"]:disabled,
#ask-button:disabled,
.button-secondary:disabled,
.ghost-button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  transform: none;
}

.quota-dialog button[type="submit"]:active,
#ask-button:active {
  transform: translateY(0);
}

.rag-hint {
  font-size: 0.88rem;
}

.button-secondary,
.ghost-button {
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  background: rgba(15, 26, 31, 0.58);
  font-weight: 750;
  transition: color 0.25s, border-color 0.25s, background 0.25s, transform 0.25s;
}

.button-secondary {
  min-height: 46px;
  padding: 11px 20px;
}

.ghost-button {
  min-height: 32px;
  padding: 6px 13px;
  font-size: 0.78rem;
}

.button-secondary:hover,
.ghost-button:hover {
  color: var(--text);
  border-color: var(--line-strong);
  background: var(--surface-hover);
  transform: translateY(-1px);
}

.rag-answer {
  min-height: 260px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 30px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.quota-dialog {
  width: min(560px, calc(100% - 32px));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.48);
}

.quota-dialog::backdrop {
  background: rgba(2, 5, 7, 0.72);
  backdrop-filter: blur(4px);
}

.quota-dialog form {
  padding: 24px;
}

.quota-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.quota-dialog label {
  display: block;
  margin: 16px 0 8px;
  color: var(--text-muted);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.quota-dialog input,
.owner-limit-form input,
.owner-status-form input,
.owner-inline-form input,
.owner-status-form select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--text);
  background: rgba(8, 12, 16, 0.64);
  outline: none;
}

.quota-dialog input:focus,
.owner-limit-form input:focus,
.owner-status-form input:focus,
.owner-inline-form input:focus,
.owner-status-form select:focus {
  border-color: var(--line-strong);
}

.rag-empty {
  min-height: 190px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--text-muted);
}

.rag-empty h2 {
  color: var(--text);
  margin-bottom: 8px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.7rem;
  font-weight: 700;
}

.rag-empty p:last-child {
  margin-bottom: 0;
}

.answer-toolbar {
  align-items: center;
  margin-bottom: 22px;
}

.answer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  flex-wrap: wrap;
}

.answer-meta {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
}

.citation-strip {
  display: flex;
  gap: 7px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.citation-chip,
.citation-link {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: var(--radius-pill);
  padding: 2px 8px;
  color: var(--primary);
  background: var(--primary-dim);
  border: 1px solid rgba(78, 205, 196, 0.22);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
  vertical-align: 0.08em;
}

.citation-link {
  margin: 0 2px;
}

.citation-link:hover,
.citation-chip:hover {
  border-color: var(--primary);
  color: var(--secondary);
}

.answer-text .error-block {
  border-left: 3px solid var(--danger);
  background: rgba(255, 138, 122, 0.08);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
}

.loading-block {
  min-height: 150px;
  display: grid;
  place-items: center;
  grid-template-columns: repeat(3, auto);
  justify-content: center;
  gap: 8px;
  text-align: center;
  color: var(--text-muted);
}

.loading-block p {
  grid-column: 1 / -1;
  margin: 8px 0 0;
  font-size: 0.95rem;
}

.loading-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  animation: pulseDot 1s ease-in-out infinite;
}

.loading-dot:nth-child(2) {
  animation-delay: 0.12s;
}

.loading-dot:nth-child(3) {
  animation-delay: 0.24s;
}

@keyframes pulseDot {
  0%,
  100% {
    opacity: 0.28;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .loading-dot {
    animation: none;
  }
}

.rag-history-sidebar,
.rag-source-sidebar {
  min-width: 0;
  display: grid;
  align-content: start;
  position: sticky;
  top: 96px;
  max-height: calc(100vh - 116px);
}

.history-panel,
.source-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: var(--surface-soft);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.history-panel {
  display: grid;
  min-height: 0;
  overflow: hidden;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.history-panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

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

.history-new-button {
  width: 100%;
  min-height: 38px;
  margin: 0 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  color: var(--bg);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  font: inherit;
  font-weight: 850;
  transition: transform 0.25s, opacity 0.25s;
}

.history-new-button:hover {
  transform: translateY(-1px);
  opacity: 0.94;
}

.history-list {
  min-height: 0;
  max-height: calc(100vh - 236px);
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 8px;
  padding-right: 3px;
}

.history-list[aria-busy="true"] {
  opacity: 0.7;
}

.history-empty {
  margin: 0;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}

.history-item {
  width: 100%;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  background: rgba(15, 26, 31, 0.62);
  text-align: left;
  display: grid;
  grid-template-rows: auto auto;
  gap: 8px;
  overflow: hidden;
  transition: border-color 0.25s, background 0.25s, transform 0.25s var(--transition);
}

.history-item:hover,
.history-item.active {
  border-color: var(--line-strong);
  background: var(--surface-hover);
  transform: translateY(-1px);
}

.history-item.active {
  box-shadow: inset 3px 0 0 var(--primary);
}

.rag-app.history-viewing #ask-button {
  background: var(--primary-dim);
  color: var(--primary);
  border: 1px solid var(--line-strong);
}

.rag-app.history-viewing .button-secondary {
  color: var(--gold);
  border-color: rgba(255, 217, 61, 0.26);
  background: var(--gold-dim);
}

.history-question,
.history-preview,
.history-meta {
  min-width: 0;
  overflow-wrap: anywhere;
}

.history-question {
  color: var(--text);
  font-weight: 800;
  line-height: 1.28;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-preview {
  display: none;
}

.history-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  overflow: hidden;
  color: var(--text-muted);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.64rem;
}

.history-meta span {
  display: inline-flex;
  min-width: 0;
  max-width: 42%;
  min-height: 22px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 2px 7px;
  background: rgba(8, 12, 16, 0.32);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-meta span:first-child {
  flex: 0 0 auto;
}

.history-meta span:last-child {
  max-width: 50%;
}

.source-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: calc(100vh - 116px);
}

.source-panel-heading {
  margin-bottom: 14px;
}

.source-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 12px;
  padding-right: 3px;
}

.source-empty {
  margin: 0;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.source-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 15px;
  background: var(--surface-soft);
  transition: border-color 0.25s, background 0.25s, transform 0.25s var(--transition);
}

.source-card:hover {
  border-color: rgba(78, 205, 196, 0.24);
  background: var(--surface-hover);
  transform: translateY(-1px);
}

.source-card.case:hover {
  border-color: rgba(200, 165, 255, 0.28);
}

.source-head {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 8px;
}

.source-code {
  flex: 0 0 auto;
  color: var(--bg);
  background: var(--primary);
  border-radius: 7px;
  padding: 2px 7px;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  font-weight: 800;
}

.source-card.case .source-code {
  background: var(--case);
}

.source-title {
  min-width: 0;
  color: var(--text);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.source-title-link {
  text-decoration: none;
}

.source-title-link:hover {
  color: var(--primary);
}

.source-card.case .source-title-link:hover {
  color: var(--case);
}

.source-subtitle,
.source-reason,
.source-excerpt,
.source-path {
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

.source-subtitle {
  margin: -2px 0 8px;
}

.source-reason {
  margin-bottom: 8px;
  color: #a8c5bf;
}

.source-excerpt {
  margin: 0 0 12px;
}

.source-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.source-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  color: var(--primary);
  background: var(--primary-dim);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 800;
}

.source-card.case .source-link {
  color: var(--case);
  background: var(--case-dim);
  border-color: rgba(200, 165, 255, 0.24);
}

.source-link:hover {
  border-color: currentColor;
}

.source-path {
  overflow-wrap: anywhere;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
}

.example-grid {
  display: grid;
  gap: 10px;
}

.example-btn {
  width: 100%;
  min-height: 66px;
  text-align: left;
  background: rgba(15, 26, 31, 0.62);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  line-height: 1.42;
  font-weight: 650;
  transition: border-color 0.25s, background 0.25s, transform 0.25s var(--transition);
}

.example-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
  border-color: rgba(255, 217, 61, 0.28);
  transform: translateY(-1px);
}

.example-btn span {
  display: block;
  margin-bottom: 6px;
  color: var(--gold);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.journal-rendered {
  font-size: 1.08rem;
  line-height: 1.85;
  color: var(--text);
  word-wrap: break-word;
}

.journal-rendered > *:first-child {
  margin-top: 0;
}

.journal-rendered > *:last-child {
  margin-bottom: 0;
}

.journal-rendered p {
  margin: 0 0 1.05em;
}

.journal-rendered h1,
.journal-rendered h2,
.journal-rendered h3 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 700;
  color: var(--text);
  margin: 1.6em 0 0.55em;
  line-height: 1.2;
}

.journal-rendered h1 {
  font-size: 2.1rem;
}

.journal-rendered h2 {
  font-size: 1.65rem;
}

.journal-rendered h3 {
  font-size: 1.3rem;
}

.journal-rendered h4,
.journal-rendered h5,
.journal-rendered h6 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 1.4em 0 0.4em;
}

.journal-rendered ul,
.journal-rendered ol {
  margin: 0 0 1.05em 1.6em;
  padding: 0;
}

.journal-rendered li {
  margin-bottom: 0.35em;
}

.journal-rendered blockquote {
  margin: 1.1em 0;
  padding: 6px 0 6px 18px;
  border-left: 3px solid var(--primary);
  color: var(--text-muted);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-size: 1.12rem;
}

.journal-rendered a {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-color: rgba(78, 205, 196, 0.4);
  text-underline-offset: 3px;
}

.journal-rendered a:hover {
  text-decoration-color: var(--primary);
}

.journal-rendered code {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
  background: rgba(78, 205, 196, 0.08);
  border: 1px solid rgba(78, 205, 196, 0.12);
  padding: 1px 6px;
  border-radius: 6px;
}

.journal-rendered pre,
.journal-raw-pre {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 1.1em 0;
  white-space: pre-wrap;
}

.journal-rendered pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text);
}

.journal-rendered hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin: 1.8em 0;
}

.journal-rendered img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin: 0.6em 0;
  display: block;
}

.journal-rendered strong,
.journal-rendered em {
  color: var(--text);
}

.rag-access-shell {
  min-height: 100vh;
  width: min(760px, calc(100% - 36px));
  margin: 0 auto;
  padding: 28px 0 72px;
  display: grid;
  align-content: center;
  gap: 24px;
}

.access-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: clamp(28px, 6vw, 52px);
}

.access-card h1 {
  max-width: 680px;
  margin-bottom: 16px;
}

.access-card p {
  max-width: 640px;
  color: var(--text-muted);
  font-size: 1.02rem;
  line-height: 1.7;
}

.access-details {
  display: grid;
  gap: 12px;
  margin: 28px 0;
}

.access-details div {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.access-details dt {
  color: var(--text-muted);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.access-details dd {
  margin: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

.access-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.access-logout-form .source-link {
  border: 0;
  cursor: pointer;
}

.rag-owner-shell {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 28px 0 80px;
  display: grid;
  gap: 24px;
}

.rag-owner-shell.narrow {
  width: min(900px, calc(100% - 36px));
}

.owner-header,
.owner-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(15, 26, 31, 0.82);
  box-shadow: var(--shadow);
}

.owner-header {
  padding: clamp(24px, 5vw, 38px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 28px;
  align-items: end;
}

.owner-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.owner-section {
  padding: 24px;
}

.owner-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.owner-stat-grid div {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: rgba(8, 12, 16, 0.42);
}

.owner-stat-grid strong {
  display: block;
  font-size: 1.45rem;
  color: var(--primary);
}

.owner-stat-grid span {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.owner-section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.owner-list {
  display: grid;
  gap: 12px;
}

.owner-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
  background: rgba(8, 12, 16, 0.34);
  display: grid;
  gap: 12px;
}

.owner-card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.owner-card p:last-child {
  margin-bottom: 0;
}

.owner-inline-form,
.owner-limit-form,
.owner-status-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.owner-table-wrap {
  overflow-x: auto;
}

.owner-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

.owner-table th,
.owner-table td {
  padding: 13px 10px;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.owner-table th {
  color: var(--text-muted);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.owner-table td strong,
.owner-table td span {
  display: block;
}

.owner-table td span {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 2px;
}

.owner-status {
  display: inline-flex;
  border-radius: var(--radius-pill);
  padding: 4px 9px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.owner-status-approved {
  color: var(--primary);
  background: var(--primary-dim);
}

.owner-status-denied {
  color: var(--danger);
  background: rgba(255, 138, 122, 0.08);
}

.owner-status-pending {
  color: var(--gold);
  background: var(--gold-dim);
}

.owner-query-card {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.owner-error,
.owner-warning {
  border-left: 3px solid var(--danger);
  border-radius: 0 8px 8px 0;
  padding: 10px 12px;
  background: rgba(255, 138, 122, 0.08);
  color: var(--text);
}

.owner-warning {
  border-left-color: var(--gold);
  background: var(--gold-dim);
}

.owner-empty {
  margin: 0;
  padding: 12px 0;
}

.owner-pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(8, 12, 16, 0.42);
  padding: 16px;
  color: var(--text);
  line-height: 1.65;
}

:root[data-theme="light"] textarea,
:root[data-theme="light"] .history-item,
:root[data-theme="light"] .example-btn,
:root[data-theme="light"] .quota-dialog input,
:root[data-theme="light"] .guest-name-form input,
:root[data-theme="light"] .owner-limit-form input,
:root[data-theme="light"] .owner-status-form input,
:root[data-theme="light"] .owner-inline-form input,
:root[data-theme="light"] .owner-status-form select,
:root[data-theme="light"] .journal-rendered pre,
:root[data-theme="light"] .journal-raw-pre,
:root[data-theme="light"] .owner-pre {
  background: rgba(255, 255, 255, 0.66);
  border-color: var(--line);
}

:root[data-theme="light"] textarea::placeholder {
  color: rgba(101, 117, 110, 0.58);
}

:root[data-theme="light"] .rag-answer,
:root[data-theme="light"] .rag-form-panel,
:root[data-theme="light"] .history-panel,
:root[data-theme="light"] .source-panel,
:root[data-theme="light"] .quota-dialog,
:root[data-theme="light"] .access-card,
:root[data-theme="light"] .owner-header,
:root[data-theme="light"] .owner-section {
  border-color: var(--line);
  background: rgba(255, 250, 241, 0.88);
  box-shadow: var(--shadow);
}

:root[data-theme="light"] .source-card,
:root[data-theme="light"] .owner-card,
:root[data-theme="light"] .owner-stat-grid div {
  background: rgba(255, 255, 255, 0.74);
  border-color: var(--line);
}

:root[data-theme="light"] .source-reason {
  color: #506a63;
}

:root[data-theme="light"] .history-meta span {
  background: rgba(255, 255, 255, 0.72);
}

:root[data-theme="light"] .model-toggle-option.active,
:root[data-theme="light"] .quota-dialog button[type="submit"],
:root[data-theme="light"] #ask-button,
:root[data-theme="light"] .history-new-button {
  color: #fffaf0;
}

:root[data-theme="light"] .source-code {
  color: #fffaf0;
}

@media (max-width: 1180px) {
  .rag-workspace {
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
    max-width: 980px;
  }

  .rag-app.history-collapsed .rag-workspace {
    grid-template-columns: 1fr;
    max-width: 780px;
  }

  .rag-history-sidebar,
  .rag-source-sidebar {
    position: static;
    max-height: none;
  }

  .rag-source-sidebar {
    grid-column: 2;
  }

  .rag-app.history-collapsed .rag-source-sidebar {
    grid-column: auto;
  }

  .source-panel {
    max-height: none;
  }

  .history-list {
    max-height: none;
  }

  .owner-header {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .rag-workspace {
    grid-template-columns: 1fr;
    max-width: 780px;
  }

  .rag-source-sidebar {
    grid-column: auto;
  }
}

@media (max-width: 680px) {
  .rag-topbar {
    position: sticky;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 9px 12px;
    padding: max(12px, env(safe-area-inset-top)) 16px 10px;
  }

  .rag-back {
    grid-column: 1;
    min-height: 34px;
    padding: 0;
  }

  .history-toggle {
    grid-column: 2;
    justify-self: end;
    width: auto;
    min-width: 0;
    padding: 0 12px;
    border-radius: var(--radius-pill);
  }

  .history-toggle-label {
    display: inline;
  }

  .rag-brand {
    grid-column: 1 / -1;
  }

  .rag-brand span {
    font-size: 1.82rem;
  }

  .rag-brand small {
    font-size: 0.78rem;
  }

  .model-toggle {
    grid-template-columns: repeat(2, minmax(68px, 1fr));
  }

  .rag-topnote {
    grid-column: 1 / -1;
    min-width: 0;
    white-space: normal;
    justify-content: flex-start;
    flex-wrap: wrap;
    overflow: visible;
    padding: 2px 0 4px;
  }

  .rag-topnote > * {
    flex: 0 0 auto;
  }

  .rag-account-name {
    max-width: 100%;
  }

  .rag-workspace {
    padding: 18px 16px 52px;
    gap: 22px;
  }

  .history-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 34;
    border: 0;
    padding: 0;
    opacity: 0;
    pointer-events: none;
    background: rgba(3, 9, 12, 0.46);
    backdrop-filter: blur(3px);
    transition: opacity 0.22s ease;
  }

  .rag-app:not(.history-collapsed) .history-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .rag-history-sidebar {
    position: fixed;
    z-index: 40;
    top: max(10px, env(safe-area-inset-top));
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    width: min(360px, calc(100vw - 20px));
    max-height: none;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    transform: translateX(0);
    transition: transform 0.24s var(--transition);
  }

  .rag-app.history-collapsed .rag-history-sidebar {
    display: grid;
    transform: translateX(calc(-100% - 24px));
  }

  .history-panel {
    height: 100%;
  }

  .history-close-mobile {
    display: inline-flex;
  }

  .history-list {
    max-height: none;
    padding-right: 2px;
  }

  .history-item {
    height: 112px;
    min-height: 112px;
  }

  .history-question {
    -webkit-line-clamp: 2;
  }

  .history-preview {
    -webkit-line-clamp: 2;
  }

  .rag-panel-heading,
  .source-panel-heading,
  .answer-toolbar {
    display: grid;
  }

  .citation-strip {
    justify-content: flex-start;
  }

  textarea {
    min-height: 190px;
    padding: 16px;
  }

  .rag-answer {
    min-height: 250px;
    padding: 26px 20px;
  }

  .rag-actions {
    align-items: stretch;
  }

  #ask-button,
  .button-secondary {
    flex: 1 1 150px;
  }

  .journal-rendered {
    font-size: 1rem;
    line-height: 1.78;
  }

  .journal-rendered h1 {
    font-size: 1.7rem;
  }

  .journal-rendered h2 {
    font-size: 1.35rem;
  }

  .access-details div {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}

/* Final production shell cascade. This intentionally sits after the legacy
   responsive rules so the AI-workspace layout wins in the browser. */
:root,
:root[data-theme="light"],
:root[data-theme="dark"] {
  color-scheme: light;
  --bg: #eaf6fb;
  --canvas: #eaf6fb;
  --canvas-deep: #d7edf7;
  --rail: #05070a;
  --rail-hover: #101923;
  --surface: #f9fdff;
  --surface-hover: #eef9fd;
  --surface-soft: rgba(249, 253, 255, 0.92);
  --primary: #0a7d89;
  --primary-strong: #075f6f;
  --primary-dim: rgba(10, 125, 137, 0.1);
  --secondary: #2fb7e5;
  --gold: #9b6d0a;
  --gold-dim: rgba(155, 109, 10, 0.1);
  --case: #2457c5;
  --case-dim: rgba(36, 87, 197, 0.09);
  --text: #0e171c;
  --text-muted: #5c7079;
  --rail-text: #f7fbfc;
  --rail-muted: #899aa5;
  --line: rgba(15, 55, 66, 0.13);
  --line-strong: rgba(10, 125, 137, 0.28);
  --danger: #b93b4b;
  --radius: 8px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --shadow: 0 18px 48px rgba(20, 75, 91, 0.11);
}

html,
body {
  background: var(--canvas);
  color: var(--text);
  font-family: Inter, "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::after,
.rag-mesh {
  display: none;
}

.rag-app {
  background: linear-gradient(180deg, #f7fdff 0, var(--canvas) 36%, var(--canvas-deep) 100%);
}

.rag-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  margin-left: 300px;
  width: calc(100% - 300px);
  min-height: 68px;
  padding: 12px 28px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  background: rgba(242, 251, 255, 0.88);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(22, 79, 96, 0.08);
  backdrop-filter: blur(22px);
}

.rag-back {
  display: none;
}

.history-toggle {
  width: 38px;
  min-width: 38px;
  height: 38px;
  padding: 0;
  color: var(--primary-strong);
  background: var(--surface);
  border-color: var(--line);
}

.history-toggle-label {
  display: none;
}

.rag-brand span {
  color: var(--text);
  background: none;
  font-family: Inter, "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 780;
}

.rag-brand small {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.rag-topnote,
.answer-meta {
  color: var(--text-muted);
  font-family: Inter, "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 0.78rem;
}

.model-toggle,
.quota-pill,
.quota-request-link,
.rag-theme-toggle {
  min-height: 34px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(20, 75, 91, 0.06);
}

.model-toggle-option {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 720;
}

.model-toggle-option.active {
  color: #f5fdff;
  background: #071018;
  box-shadow: none;
}

.quota-pill,
.quota-request-link:hover,
.rag-theme-toggle:hover,
.rag-theme-toggle.active {
  color: var(--primary-strong);
  background: #e7f8fc;
}

.rag-account-name,
.quota-request-link,
.rag-theme-toggle {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.rag-workspace {
  max-width: none;
  min-height: calc(100vh - 68px);
  margin: 0;
  padding: 0;
  grid-template-columns: 300px minmax(0, 1fr) minmax(310px, 370px);
  gap: 0;
  align-items: stretch;
}

.rag-app.history-collapsed .rag-workspace {
  max-width: none;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 370px);
}

.rag-app.history-collapsed .rag-topbar {
  margin-left: 0;
  width: 100%;
}

.rag-history-sidebar {
  position: sticky;
  top: 0;
  max-height: 100vh;
  min-height: 100vh;
  padding: 16px;
  background: var(--rail);
  border-right: 1px solid rgba(116, 214, 255, 0.14);
}

.history-panel {
  height: calc(100vh - 32px);
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.history-panel .source-panel-heading {
  min-height: 78px;
  margin: 0 0 16px;
  padding: 6px 2px 14px;
  border-bottom: 1px solid rgba(116, 214, 255, 0.13);
}

.history-panel .rag-kicker {
  color: #74d6ff;
}

.history-panel h2,
.history-question {
  color: var(--rail-text);
}

.history-panel .ghost-button,
.history-meta,
.history-empty {
  color: var(--rail-muted);
}

.history-new-button {
  min-height: 42px;
  margin-bottom: 14px;
  color: #eafdff;
  background: linear-gradient(135deg, #076b76, #0d98a6);
  border: 1px solid rgba(116, 214, 255, 0.22);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.26);
}

.history-list {
  max-height: calc(100vh - 156px);
  gap: 6px;
  padding-right: 0;
}

.history-item {
  min-height: 84px;
  height: auto;
  padding: 11px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
}

.history-item:hover,
.history-item.active {
  background: var(--rail-hover);
  border-color: rgba(116, 214, 255, 0.14);
  transform: none;
}

.history-item.active {
  box-shadow: inset 3px 0 0 #74d6ff;
}

.history-meta span,
.history-empty {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(116, 214, 255, 0.1);
}

.rag-main {
  min-height: calc(100vh - 68px);
  padding: 30px clamp(24px, 4vw, 54px) 34px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0) 28%),
    var(--canvas);
}

.rag-answer {
  order: 1;
  flex: 1 1 auto;
  min-height: 420px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
}

#answer-card {
  width: min(850px, 100%);
  margin: 0 auto;
  padding: 26px 30px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(15, 55, 66, 0.12);
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(20, 75, 91, 0.11);
}

.rag-empty {
  width: min(760px, 100%);
  min-height: 390px;
  margin: 0 auto;
  padding: 42px 24px;
  color: var(--text-muted);
}

.rag-empty h2 {
  color: var(--text);
  font-family: Inter, "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 2.6rem;
  line-height: 1.08;
  letter-spacing: -0.02em;
  font-weight: 760;
}

.rag-form-panel {
  order: 2;
  position: sticky;
  bottom: 18px;
  width: min(850px, 100%);
  margin: 0 auto;
  padding: 13px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(15, 55, 66, 0.14);
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(20, 75, 91, 0.2);
  backdrop-filter: blur(18px);
}

.rag-panel-heading {
  display: none;
}

.rag-form {
  margin: 0;
}

.rag-form label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

textarea {
  min-height: 82px;
  max-height: 240px;
  padding: 15px 17px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 8px;
  line-height: 1.48;
  box-shadow: none;
}

textarea::placeholder {
  color: #81949d;
  font-style: normal;
}

textarea:focus,
textarea[readonly],
textarea[readonly]:focus {
  background: transparent;
  border: 0;
  box-shadow: none;
}

.rag-actions {
  margin-top: 8px;
  padding: 0 4px 2px;
  justify-content: flex-end;
  gap: 10px;
}

.rag-hint {
  margin-right: auto;
  color: var(--text-muted);
  font-size: 0.78rem;
}

#ask-button,
.quota-dialog button[type="submit"] {
  min-height: 40px;
  padding: 9px 22px;
  color: #f6fdff;
  background: #071018;
  border-radius: 8px;
}

#ask-button:hover,
.quota-dialog button[type="submit"]:hover {
  background: #0d7f8c;
}

.button-secondary,
.ghost-button {
  min-height: 38px;
  color: var(--text-muted);
  background: #f6fcff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.84rem;
}

.answer-toolbar {
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.citation-chip,
.citation-link,
.source-link {
  color: var(--primary-strong);
  background: #e5f7fc;
  border-color: rgba(10, 125, 137, 0.18);
  border-radius: 7px;
}

.journal-rendered {
  color: var(--text);
  font-size: 1rem;
  line-height: 1.76;
}

.journal-rendered h1,
.journal-rendered h2,
.journal-rendered h3 {
  color: var(--text);
  font-family: Inter, "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  letter-spacing: -0.015em;
}

.journal-rendered h1 {
  font-size: 1.55rem;
}

.journal-rendered h2 {
  font-size: 1.28rem;
}

.journal-rendered h3 {
  font-size: 1.08rem;
}

.source-panel {
  max-height: calc(100vh - 92px);
  padding: 18px;
  background: rgba(245, 252, 255, 0.72);
  border-left: 1px solid rgba(15, 55, 66, 0.1);
  border-radius: 0;
  box-shadow: none;
}

.rag-source-sidebar {
  position: sticky;
  top: 68px;
  max-height: calc(100vh - 68px);
  padding: 24px 22px 24px 0;
  background: var(--canvas);
}

.source-count,
.rag-status {
  min-height: 28px;
  color: var(--primary-strong);
  background: #e5f7fc;
  border-color: rgba(10, 125, 137, 0.18);
}

.source-card {
  padding: 13px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(15, 55, 66, 0.1);
  border-radius: 8px;
  box-shadow: none;
}

.source-card:hover {
  background: #ffffff;
  border-color: rgba(10, 125, 137, 0.22);
  transform: none;
}

.source-code {
  color: #f5fdff;
  background: var(--primary-strong);
  border-radius: 6px;
}

.source-card.case .source-code {
  background: var(--case);
}

.source-title {
  color: var(--text);
}

.source-subtitle,
.source-reason,
.source-excerpt,
.source-path {
  color: var(--text-muted);
}

.example-btn {
  color: var(--text);
  background: #f6fcff;
  border-color: var(--line);
  border-radius: 8px;
}

.example-btn span,
.reglement-app .fund-catalog-panel summary {
  color: var(--primary-strong);
}

.quota-dialog,
.access-card,
.owner-header,
.owner-section {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line);
  border-radius: 8px;
}

.reglement-app .source-panel {
  background: rgba(245, 252, 255, 0.74);
}

@media (max-width: 1180px) {
  .rag-topbar {
    margin-left: 270px;
    width: calc(100% - 270px);
  }

  .rag-workspace {
    grid-template-columns: 270px minmax(0, 1fr);
  }

  .rag-source-sidebar {
    display: none;
  }

  .rag-app.history-collapsed .rag-workspace {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 820px) {
  .rag-topbar {
    margin-left: 0;
    width: 100%;
    min-height: auto;
    padding: 10px 14px;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .rag-topnote {
    grid-column: 1 / -1;
    justify-content: flex-start;
    white-space: normal;
  }

  .rag-workspace,
  .rag-app.history-collapsed .rag-workspace {
    grid-template-columns: minmax(0, 1fr);
    min-height: auto;
  }

  .rag-history-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 45;
    width: min(320px, 88vw);
    transform: translateX(0);
    transition: transform 0.22s ease;
  }

  .rag-app.history-collapsed .rag-history-sidebar {
    display: block;
    transform: translateX(-100%);
  }

  .history-backdrop {
    position: fixed;
    inset: 0;
    z-index: 44;
    display: block;
    background: rgba(3, 7, 10, 0.42);
    border: 0;
  }

  .rag-app.history-collapsed .history-backdrop {
    display: none;
  }

  .history-close-mobile {
    display: inline-flex;
  }

  .rag-main {
    min-height: calc(100vh - 116px);
    padding: 22px 14px 24px;
  }

  .rag-form-panel,
  #answer-card,
  .rag-empty {
    width: 100%;
  }

  .rag-empty h2 {
    font-size: 2rem;
  }

  #answer-card {
    padding: 20px 16px;
  }

  .rag-form-panel {
    bottom: 10px;
  }
}
