/* ============================================================================
   QUIDORIS — custom.css
   Brand overrides on top of USWDS v3. Loaded AFTER USWDS in layout.templ.
   ============================================================================ */

:root {
  /* ─── Ink (cool USWDS grays) ─── */
  --q-ink-900:#1b1b1b; --q-ink-800:#2e2e2e; --q-ink-700:#454545;
  --q-ink-600:#565c65; --q-ink-500:#71767a; --q-ink-400:#919191;
  --q-ink-300:#a9aeb1; --q-ink-200:#c9c9c9; --q-ink-100:#dfe1e2; --q-ink-50:#f0f0f0;

  /* ─── Surface ─── */
  --q-white:#ffffff; --q-paper:#ffffff; --q-paper-2:#f0f0f0;
  --q-paper-3:#eff6fb; --q-tint-blue:#d9e8f6;

  /* ─── Navy (USWDS blue-warm) ─── */
  --q-navy-900:#112f4e; --q-navy-800:#14365d; --q-navy-700:#1a4480;
  --q-navy-600:#005ea2; --q-navy-500:#2378c3; --q-navy-400:#4f97d1;
  --q-navy-300:#73b3e7; --q-navy-200:#aacdec; --q-navy-100:#d9e8f6; --q-navy-50:#eff6fb;

  /* ─── Semantic (Bloomberg palette) ─── */
  --q-success-700:#004d2a; --q-success-600:#006b3c; --q-success-100:#e6f2e6;
  --q-warn-700:#5c4d00;    --q-warn-600:#b08800;    --q-warn-100:#faf3d1;
  --q-danger-700:#7a142a;  --q-danger-600:#a51c30;  --q-danger-100:#f8e1e1;
  --q-info-600:#1a3a6b;    --q-info-100:#eef3fa;

  /* ─── Type ─── */
  --q-font-sans:'Public Sans',system-ui,-apple-system,'Segoe UI',Helvetica,Arial,sans-serif;
  --q-font-serif:'Newsreader','Charter','Iowan Old Style',Georgia,serif;
  --q-font-mono:'JetBrains Mono','IBM Plex Mono',ui-monospace,'SF Mono',Menlo,Consolas,monospace;

  /* ─── Spacing (8pt + half) ─── */
  --q-space-0_5:4px; --q-space-1:8px; --q-space-1_5:12px; --q-space-2:16px;
  --q-space-3:24px; --q-space-4:32px; --q-space-5:40px; --q-space-6:48px;
  --q-space-8:64px; --q-space-10:80px; --q-space-12:96px; --q-space-16:128px;

  /* ─── Radii (institutional) ─── */
  --q-r-0:0; --q-r-sm:2px; --q-r-md:4px; --q-r-lg:8px;

  /* ─── Motion ─── */
  --q-ease:cubic-bezier(.2,0,0,1);
  --q-ease-emph:cubic-bezier(.2,0,0,.9);

  /* ─── Layout ─── */
  --q-content-max:1200px;
  --q-prose-max:68ch;

  /* ─── Aliases ─── */
  --q-bg:var(--q-paper); --q-bg-subtle:var(--q-paper-2); --q-bg-tertiary:var(--q-paper-3);
  --q-bg-inverse:var(--q-navy-900);
  --q-fg:var(--q-ink-700); --q-fg-strong:var(--q-ink-900); --q-fg-muted:var(--q-ink-500);
  --q-fg-disabled:var(--q-ink-300); --q-fg-inverse:var(--q-paper);
  --q-fg-accent:var(--q-navy-700); --q-fg-link:var(--q-navy-600); --q-fg-link-hover:var(--q-navy-700);
  --q-border:var(--q-ink-100); --q-border-rule:var(--q-ink-300);
  --q-action:var(--q-navy-600); --q-action-hover:var(--q-navy-700); --q-action-press:var(--q-navy-900);
  --q-action-on:var(--q-white);
  --q-shadow-focus:0 0 0 3px rgba(0,94,162,.30);
  --q-shadow-card:0 1px 0 rgba(27,27,27,.04),0 1px 3px rgba(27,27,27,.05);
  --q-shadow-elevated:0 2px 4px rgba(27,27,27,.04),0 8px 24px rgba(27,27,27,.08);
}

/* ============================================================================
   BASE
   ============================================================================ */

html { font-size: 16px; }
body {
  font-family: var(--q-font-sans);
  font-size: 16px; line-height: 1.6;
  color: var(--q-fg);
  background: var(--q-bg);
  font-feature-settings: "ss01","ss02","kern";
  -webkit-font-smoothing: antialiased;
  margin: 0;
  display: flex; flex-direction: column; min-height: 100vh;
}
/* #main fills the space between header and footer (sticky-footer pattern).
   On authenticated app pages it becomes a flex column so .q-app-shell can
   fill the remaining viewport height instead of a fixed 100vh that would push
   the chat composer below the fold (it sits under the banner+header). */
#main { flex: 1 0 auto; }
#main:has(.q-app-shell) { display: flex; flex-direction: column; min-height: 0; }

h1, h2, h3, h4 { font-family: var(--q-font-serif); color: var(--q-fg-strong); font-weight: 500; letter-spacing: -0.005em; margin: 0; }
h1 { font-size: 36px; line-height: 1.2; }
h2 { font-size: 28px; line-height: 1.25; }
h3 { font-size: 22px; line-height: 1.3; }
h4 { font-size: 18px; line-height: 1.4; }

p { margin: 0 0 16px; max-width: var(--q-prose-max); }
.q-lead { font-size: 18px; line-height: 1.6; color: var(--q-ink-600); max-width: 56ch; }
.q-muted { color: var(--q-fg-muted); }
.q-micro { font-size: 12px; line-height: 1.4; }
.q-num { text-align: right; font-variant-numeric: tabular-nums; }
.q-mono { font-family: var(--q-font-mono); font-size: 0.92em; }

.q-eyebrow {
  font-family: var(--q-font-mono); font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--q-fg-accent); font-weight: 500;
  display: inline-block;
}
.q-field-label {
  font-family: var(--q-font-mono); font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--q-fg-muted); font-weight: 500;
}

a { color: var(--q-fg-link); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--q-fg-link-hover); text-decoration-thickness: 2px; }
a:focus-visible { outline: none; box-shadow: var(--q-shadow-focus); border-radius: 2px; }
::selection { background: var(--q-navy-100); color: var(--q-navy-900); }

.q-container { max-width: var(--q-content-max); margin: 0 auto; padding: 0 24px; }
.q-section { padding: 80px 0; }
.q-section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 24px; gap: 24px; }
.q-hr { height: 1px; background: var(--q-border); border: none; margin: 32px 0; }
.q-rule-thick { height: 2px; background: var(--q-ink-900); border: none; margin: 0; }
.q-rule-accent { height: 3px; width: 64px; background: var(--q-navy-600); border: none; margin: 0 0 16px; }
.q-empty { color: var(--q-fg-muted); padding: 40px; text-align: center; }

/* ============================================================================
   BANNER + HEADER (with spinning 3D Q + fly-in mega-nav)
   ============================================================================ */

.q-banner { background: var(--q-ink-900); color: var(--q-paper); padding: 8px 0; }
.q-banner-inner { max-width: var(--q-content-max); margin: 0 auto; padding: 0 24px; display: flex; align-items: center; justify-content: center; gap: 12px; }
.q-tagline { font-family: var(--q-font-serif); font-style: italic; font-size: 13px; color: var(--q-paper); }

.q-header { background: var(--q-white); border-bottom: 1px solid var(--q-border); position: relative; z-index: 10; }
.q-header-inner { max-width: var(--q-content-max); margin: 0 auto; padding: 16px 24px; display: flex; align-items: center; gap: 32px; }
.q-header-logo { display: flex; align-items: center; gap: 14px; text-decoration: none; }
.q-wm { display: flex; flex-direction: column; line-height: 1; }
.q-wm-name { font-family: var(--q-font-sans); font-weight: 800; font-size: 26px; color: var(--q-fg-strong); letter-spacing: -0.005em; }
.q-wm-sub  { font-family: var(--q-font-sans); font-weight: 500; font-size: 11px; color: var(--q-ink-600); margin-top: 4px; }

/* The spinning Q */
.q-spin-wrap { perspective: 800px; display: inline-block; width: 56px; height: 56px; }
.q-spin-wrap--sm { width: 40px; height: 40px; }
.q-spin { width: 100%; height: 100%; display: block; transform-style: preserve-3d;
          animation: qspinY 6s linear infinite; transform-origin: 50% 50%; }
.q-header-logo:hover .q-spin { animation-play-state: paused; }
@keyframes qspinY { from { transform: rotateY(0deg); } to { transform: rotateY(360deg); } }
@media (prefers-reduced-motion: reduce) { .q-spin { animation: none; } }

/* Mega-nav */
.q-mega-nav { display: flex; gap: 4px; margin-left: auto; }
.q-mega-item { position: relative; }
.q-mega-item > a { display: block; padding: 18px 14px; color: var(--q-fg-strong); text-decoration: none; font-size: 14px; font-weight: 500; transition: color 120ms var(--q-ease); }
.q-mega-item > a::after { content: ""; display: inline-block; margin-left: 6px; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 4px solid var(--q-ink-400); transform: translateY(-1px); transition: transform 200ms var(--q-ease); }
.q-mega-item:hover > a, .q-mega-item.is-active > a { color: var(--q-navy-700); box-shadow: inset 0 -2px 0 var(--q-navy-600); }
.q-mega-item:hover > a::after { transform: rotate(180deg) translateY(2px); border-top-color: var(--q-navy-700); }

.q-mega-panel {
  position: absolute; top: calc(100% + 4px); left: 0; min-width: 260px;
  background: var(--q-white); border: 1px solid var(--q-border);
  box-shadow: var(--q-shadow-elevated);
  padding: 12px 0;
  opacity: 0; visibility: hidden; transform: translateY(-8px);
  transition: opacity 180ms var(--q-ease), transform 220ms var(--q-ease-emph), visibility 0ms linear 220ms;
  z-index: 50;
}
.q-mega-panel::before { content: ""; position: absolute; top: -8px; left: 0; right: 0; height: 8px; }
.q-mega-item:hover .q-mega-panel, .q-mega-item:focus-within .q-mega-panel {
  opacity: 1; visibility: visible; transform: translateY(0);
  transition: opacity 180ms var(--q-ease), transform 220ms var(--q-ease-emph), visibility 0ms linear 0ms;
}
.q-mega-section { font-family: var(--q-font-mono); font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.12em; color: var(--q-fg-muted); padding: 4px 18px 8px; }
.q-mega-panel a { display: flex; align-items: baseline; gap: 10px; padding: 8px 18px; color: var(--q-fg-strong); text-decoration: none; font-size: 14px; font-weight: 500; }
.q-mega-panel a:hover { background: var(--q-navy-50); color: var(--q-navy-700); }
.q-mega-desc { color: var(--q-fg-muted); font-size: 12px; font-weight: 400; }

/* ============================================================================
   HERO + PAGE HEADER
   ============================================================================ */

.q-hero { background: var(--q-paper-3); border-bottom: 1px solid var(--q-border); }
.q-hero-inner { padding: 80px 24px; max-width: var(--q-content-max); margin: 0 auto; }
.q-hero-h { font-family: var(--q-font-serif); font-size: 56px; line-height: 1.05; font-weight: 400; letter-spacing: -0.01em; margin: 12px 0 20px; max-width: 18ch; color: var(--q-ink-900); }
.q-hero .q-lead { font-size: 19px; }
.q-hero-actions { display: flex; gap: 12px; margin-top: 28px; }

.q-page-header { background: var(--q-paper); border-bottom: 1px solid var(--q-border); padding: 56px 0 40px; }
.q-page-h { font-size: 44px; line-height: 1.1; margin: 0 0 16px; max-width: 18ch; }

/* ============================================================================
   BUTTONS + TAGS + STATUS + FORMS
   ============================================================================ */

.q-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-family: var(--q-font-sans); font-size: 15px; font-weight: 600; padding: 10px 18px; border-radius: var(--q-r-md); border: 1px solid transparent; cursor: pointer; text-decoration: none; transition: background 120ms var(--q-ease), color 120ms var(--q-ease), border-color 120ms var(--q-ease); }
.q-btn:focus-visible { outline: none; box-shadow: var(--q-shadow-focus); }
.q-btn--primary { background: var(--q-action); color: var(--q-action-on); }
.q-btn--primary:hover { background: var(--q-action-hover); color: var(--q-action-on); }
.q-btn--secondary { background: var(--q-white); color: var(--q-fg-strong); border-color: var(--q-ink-300); }
.q-btn--secondary:hover { background: var(--q-paper-2); border-color: var(--q-ink-500); }
.q-btn--ghost { background: transparent; color: var(--q-fg-link); }
.q-btn--ghost:hover { background: var(--q-navy-50); color: var(--q-navy-700); }
.q-btn--danger { background: var(--q-danger-600); color: var(--q-white); }
.q-btn--sm { padding: 6px 12px; font-size: 13px; }
.q-btn--lg { padding: 13px 22px; font-size: 16px; }
.q-btn--block { width: 100%; }
.q-btn[disabled] { opacity: .45; cursor: not-allowed; }
.q-inline-form { display: inline-flex; margin: 0; }

.q-tag { display: inline-flex; align-items: center; padding: 2px 8px; background: var(--q-ink-900); color: var(--q-white); border-radius: var(--q-r-sm); font-family: var(--q-font-sans); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; line-height: 1.4; }

.q-status { display: inline-flex; align-items: center; gap: 8px; font-family: var(--q-font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--q-ink-700); }
.q-status::before { content: ""; width: 8px; height: 8px; border-radius: 999px; background: var(--q-ink-300); }
.q-status--live::before     { background: var(--q-success-600); }
.q-status--draft::before    { background: var(--q-warn-600); }
.q-status--archived::before { background: var(--q-ink-400); }
.q-status--error::before    { background: var(--q-danger-600); }

.q-field { display: flex; flex-direction: column; gap: 6px; }
.q-field > label { font-family: var(--q-font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--q-fg-muted); font-weight: 500; }
.q-input, .q-textarea, .q-select { font-family: var(--q-font-sans); font-size: 15px; background: var(--q-white); color: var(--q-fg-strong); border: 1px solid var(--q-ink-300); border-radius: var(--q-r-sm); padding: 10px 12px; width: 100%; box-sizing: border-box; }
.q-input:focus, .q-textarea:focus, .q-select:focus { outline: none; border-color: var(--q-navy-600); box-shadow: var(--q-shadow-focus); }
.q-textarea { resize: vertical; min-height: 64px; }

.q-search { display: flex; align-items: stretch; border: 1px solid var(--q-ink-300); background: var(--q-white); border-radius: var(--q-r-sm); }
.q-search input { border: none; padding: 10px 12px; background: transparent; font-family: var(--q-font-sans); font-size: 15px; flex: 1; outline: none; }
.q-search button { border: none; background: var(--q-navy-600); color: var(--q-white); padding: 0 16px; cursor: pointer; font-family: var(--q-font-sans); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.q-search button:hover { background: var(--q-navy-700); }

/* ============================================================================
   CARDS + FEATURE GRID
   ============================================================================ */

.q-card { background: var(--q-white); border: 1px solid var(--q-border); padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.q-card--accent { border-top: 3px solid var(--q-navy-600); }
.q-card-meta { display: flex; gap: 12px; align-items: center; font-family: var(--q-font-mono); font-size: 11px; color: var(--q-fg-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.q-card-title { font-family: var(--q-font-serif); font-size: 22px; line-height: 1.25; color: var(--q-fg-strong); font-weight: 500; margin: 0; }
.q-card-body { font-size: 15px; line-height: 1.55; color: var(--q-fg); margin: 0; }
.q-card-cta { margin-top: auto; padding-top: 8px; }
.q-feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
@media (max-width: 900px) { .q-feature-grid { grid-template-columns: 1fr; } }

/* ============================================================================
   PUBLICATIONS LIST + TABLE
   ============================================================================ */

.q-pub-list { list-style: none; padding: 0; margin: 0; }
.q-pub-row { border-bottom: 1px solid var(--q-border); padding: 20px 0; display: grid; grid-template-columns: 130px 1fr auto; gap: 24px; align-items: baseline; }
.q-pub-doi { color: var(--q-fg-muted); font-size: 13px; }
.q-pub-title { font-size: 20px; margin: 0 0 4px; line-height: 1.3; font-family: var(--q-font-serif); }
.q-pub-title a, .q-pub-title-link { color: var(--q-fg-strong); text-decoration: none; font-weight: 500; }
.q-pub-title a:hover, .q-pub-title-link:hover { color: var(--q-navy-700); text-decoration: underline; }
.q-pub-meta { margin: 0; color: var(--q-fg-muted); font-size: 14px; }
.q-pub-venue { font-size: 12px; color: var(--q-fg-muted); margin-top: 2px; }
.q-pub-right { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.q-pub-year { font-size: 12px; color: var(--q-fg-muted); }

.q-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.q-table thead th { text-align: left; padding: 10px 12px; font-family: var(--q-font-mono); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; color: var(--q-fg-muted); border-bottom: 2px solid var(--q-ink-300); }
.q-table tbody td { padding: 12px; border-bottom: 1px solid var(--q-border); vertical-align: top; }
.q-table tbody tr:hover td { background: var(--q-paper-2); }
.q-col-doi { width: 130px; }
.q-col-authors { width: 170px; }
.q-col-year { width: 70px; }
.q-col-status { width: 130px; }

.q-pub-filters { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin-bottom: 20px; }
.q-pub-filters .q-search { flex: 1 1 320px; max-width: 480px; }
.q-tabs--filter { display: flex; gap: 0; border-bottom: none; }
.q-tab-radio { padding: 12px 18px; font-size: 14px; font-weight: 500; color: var(--q-fg-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.q-tab-radio.is-active { color: var(--q-fg-strong); border-bottom-color: var(--q-navy-600); }
.q-tab-radio input { display: none; }

/* ============================================================================
   ABOUT
   ============================================================================ */

.q-about-split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 64px; }
@media (max-width: 900px) { .q-about-split { grid-template-columns: 1fr; } }
.q-about-photo { aspect-ratio: 4 / 3; background: var(--q-paper-2); display: flex; align-items: center; justify-content: center; font-family: var(--q-font-mono); font-size: 11px; color: var(--q-fg-muted); text-transform: uppercase; letter-spacing: 0.1em; }
.q-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin: 24px 0 0; padding: 0; }
.q-stats > div { display: flex; flex-direction: column; }
.q-stats dt { font-family: var(--q-font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--q-fg-muted); }
.q-stats dd { margin: 4px 0 0; font-family: var(--q-font-serif); font-size: 28px; color: var(--q-fg-strong); }
.q-team-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; margin-top: 24px; }
@media (max-width: 900px) { .q-team-grid { grid-template-columns: repeat(2, 1fr); } }
.q-team-portrait { aspect-ratio: 1 / 1; background: var(--q-ink-100); margin-bottom: 12px; display: flex; align-items: center; justify-content: center; font-family: var(--q-font-mono); font-size: 11px; color: var(--q-fg-muted); letter-spacing: 0.1em; text-transform: uppercase; }
.q-team-portrait.is-placeholder { background: var(--q-paper-2); border: 1px dashed var(--q-ink-300); }
.q-team-name { margin: 4px 0 6px; font-size: 18px; }
.q-team-bio { margin: 0; font-size: 13px; color: var(--q-fg-muted); line-height: 1.55; }

/* ============================================================================
   FOOTER (dark)
   ============================================================================ */

.q-footer { background: var(--q-ink-900); color: var(--q-paper); padding: 56px 0 28px; margin-top: 80px; }
.q-footer a { color: var(--q-paper); }
.q-footer-inner { max-width: var(--q-content-max); margin: 0 auto; padding: 0 24px; display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 48px; }
@media (max-width: 900px) { .q-footer-inner { grid-template-columns: 1fr 1fr; } }
.q-footer h4 { font-family: var(--q-font-mono); font-size: 11px; font-weight: 500; color: var(--q-navy-300); text-transform: uppercase; letter-spacing: 0.12em; margin: 0 0 14px; }
.q-footer ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.q-footer ul a { font-size: 14px; text-decoration: none; color: var(--q-ink-200, #c9c9c9); }
.q-footer ul a:hover { color: var(--q-paper); text-decoration: underline; }
.q-footer-tagline { margin-top: 14px; font-family: var(--q-font-serif); font-style: italic; font-size: 15px; color: var(--q-paper); max-width: 32ch; }
.q-footer-bottom { max-width: var(--q-content-max); margin: 48px auto 0; padding: 20px 24px 0; border-top: 1px solid var(--q-ink-700); display: flex; justify-content: space-between; align-items: center; font-family: var(--q-font-mono); font-size: 11px; color: var(--q-ink-300); letter-spacing: 0.08em; text-transform: uppercase; }
.q-footer-social { display: flex; gap: 12px; }
.q-footer-social a { width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; color: var(--q-ink-300); }
.q-footer-social a:hover { color: var(--q-navy-300); }
.q-footer-social svg { width: 18px; height: 18px; }

/* ============================================================================
   SIGN IN
   ============================================================================ */

.q-signin { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--q-paper); }
@media (max-width: 900px) { .q-signin { grid-template-columns: 1fr; } }
.q-signin-rail { background: var(--q-ink-900); color: var(--q-paper); padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.q-signin-rail .q-header-logo { gap: 16px; }
.q-signin-h { font-family: var(--q-font-serif); font-size: 44px; line-height: 1.1; font-weight: 400; color: var(--q-paper); margin: 18px 0 0; max-width: 14ch; }
.q-signin-lead { color: var(--q-navy-200); font-size: 16px; line-height: 1.55; margin-top: 24px; max-width: 44ch; }
.q-signin-form { padding: 48px 56px; max-width: 520px; display: flex; flex-direction: column; gap: 16px; }
.q-stack-3 > * + * { margin-top: 16px; }
.q-or-divider { display: flex; align-items: center; gap: 12px; margin: 24px 0; max-width: 380px; }
.q-or-divider::before, .q-or-divider::after { content: ""; flex: 1; height: 1px; background: var(--q-border); }
.q-or-divider span { color: var(--q-fg-muted); text-transform: uppercase; letter-spacing: 0.12em; }
.q-xaman-mark { display: inline-block; width: 18px; height: 18px; background: var(--q-ink-900); color: var(--q-paper); font-family: var(--q-font-mono); font-weight: 700; font-size: 11px; line-height: 18px; text-align: center; border-radius: 2px; }
.q-xaman-mount { margin-top: 16px; max-width: 380px; }
.q-xaman-mount img { max-width: 180px; border: 1px solid var(--q-border); display: block; }

/* ============================================================================
   AUTHENTICATED APP SHELL (Dashboard + Chat)
   ============================================================================ */

.q-app-shell { flex: 1; min-height: 0; display: grid; grid-template-columns: 260px 1fr; background: var(--q-paper); }
.q-app-side { background: var(--q-paper-2); border-right: 1px solid var(--q-border); display: flex; flex-direction: column; padding: 0; }
.q-app-side-logo { display: flex; align-items: center; gap: 12px; padding: 20px 16px; text-decoration: none; border-bottom: 1px solid var(--q-border); }
.q-app-side-logo .q-wm-name { font-size: 18px; }
.q-app-side-logo .q-wm-sub  { font-size: 10px; }
.q-app-main { display: flex; flex-direction: column; min-width: 0; }
.q-app-topbar { display: flex; align-items: center; gap: 16px; padding: 0 32px; height: 56px; border-bottom: 1px solid var(--q-border); }
.q-crumbs { color: var(--q-fg-muted); text-transform: uppercase; letter-spacing: 0.12em; }
.q-crumbs span { color: var(--q-fg-strong); }
.q-app-body { padding: 32px 32px 64px; }

.q-sidenav { display: flex; flex-direction: column; padding: 8px 0; }
.q-sidenav a, .q-sidenav-btn { padding: 10px 16px; font-size: 14px; font-weight: 500; color: var(--q-fg); text-decoration: none; border-left: 3px solid transparent; display: block; background: none; border-top: none; border-right: none; border-bottom: none; text-align: left; cursor: pointer; font-family: inherit; width: 100%; }
.q-sidenav a:hover, .q-sidenav-btn:hover { background: var(--q-paper); color: var(--q-fg-strong); }
.q-sidenav a.is-active { color: var(--q-navy-700); border-left-color: var(--q-navy-600); background: var(--q-navy-50); font-weight: 600; }
.q-sidenav-section { font-family: var(--q-font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--q-fg-muted); padding: 16px 16px 6px; }

.q-dash-head { display: flex; justify-content: space-between; align-items: baseline; }
.q-dash-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 32px; margin-top: 24px; }
@media (max-width: 1000px) { .q-dash-grid { grid-template-columns: 1fr; } }
.q-convo-list { list-style: none; padding: 0; margin: 0; }
.q-convo-list li { border-bottom: 1px solid var(--q-border); }
.q-convo-list a { display: flex; justify-content: space-between; padding: 12px 0; text-decoration: none; }
.q-convo-title { font-size: 14px; font-weight: 500; color: var(--q-fg-strong); }
.q-convo-list .q-mono { color: var(--q-fg-muted); }

/* ============================================================================
   CHAT
   ============================================================================ */

.q-chat-main { padding: 0 !important; display: grid; grid-template-columns: 260px 1fr; min-height: 0; }
.q-chat-rail { border-right: 1px solid var(--q-border); display: flex; flex-direction: column; }
.q-chat-rail-head { padding: 20px 16px; border-bottom: 1px solid var(--q-border); display: flex; flex-direction: column; gap: 12px; }
.q-chat-rail-list { list-style: none; margin: 0; padding: 8px 0; overflow: auto; }
.q-chat-rail-list a { display: block; padding: 10px 16px; text-decoration: none; border-left: 3px solid transparent; }
.q-chat-rail-list a:hover { background: var(--q-paper-2); }
.q-chat-rail-list a.is-active { background: var(--q-navy-50); border-left-color: var(--q-navy-600); }
.q-chat-rail-list .q-convo-title { display: block; }
.q-chat-thread-wrap { display: flex; flex-direction: column; min-width: 0; }
.q-chat-thread-head { display: flex; gap: 16px; align-items: center; padding: 16px 32px; border-bottom: 1px solid var(--q-border); }
.q-chat-meta { margin-left: auto; color: var(--q-fg-muted); text-transform: uppercase; letter-spacing: 0.12em; }
.q-chat-thread { flex: 1; overflow: auto; padding: 0 32px; }
.q-chat-empty { padding: 80px 0; text-align: center; }
.q-chat-msg { display: grid; grid-template-columns: 80px 1fr; gap: 18px; padding: 20px 0; border-bottom: 1px solid var(--q-border); }
.q-chat-role { color: var(--q-fg-muted); text-transform: uppercase; letter-spacing: 0.12em; padding-top: 4px; }
.qrg-md { font-size: 15px; line-height: 1.6; color: var(--q-fg-strong); white-space: pre-wrap; overflow-wrap: anywhere; }
.qrg-md--error { color: var(--q-danger-600); }
.q-streaming-dot { display: inline-block; width: 8px; height: 8px; border-radius: 999px; background: var(--q-navy-600); animation: qpulse 1s infinite; vertical-align: middle; }
@keyframes qpulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
/* Composer zone: friendly greeting + a roomy, stylish input card. */
.q-composer-zone { padding: 14px 32px 18px; border-top: 1px solid var(--q-border); background: linear-gradient(180deg, transparent, var(--q-paper-2)); }
.q-chat-greeting { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.q-chat-greeting-hi { font-family: var(--q-font-serif); font-size: 22px; font-weight: 600; color: var(--q-navy-700); line-height: 1.2; }
.q-chat-greeting-sub { font-size: 13px; color: var(--q-fg-muted); }
.q-chat-composer { display: flex; flex-direction: column; border: 1px solid var(--q-ink-300); border-radius: 18px; background: var(--q-white); box-shadow: var(--q-shadow-card); overflow: hidden; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.q-chat-composer:focus-within { border-color: var(--q-navy-600); box-shadow: 0 0 0 3px var(--q-navy-50), var(--q-shadow-elevated); }
.q-composer-input.q-textarea { border: none; border-radius: 0; background: transparent; min-height: 128px; resize: none; font-size: 16px; line-height: 1.55; padding: 16px 18px; }
.q-composer-input.q-textarea:focus { outline: none; border: none; box-shadow: none; }
.q-composer-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px 8px 18px; border-top: 1px solid var(--q-border); background: var(--q-paper-2); }
.q-composer-hint { color: var(--q-fg-muted); text-transform: uppercase; letter-spacing: 0.12em; }
.q-chat-foot { padding: 10px 4px 0; color: var(--q-fg-muted); text-transform: uppercase; letter-spacing: 0.1em; }

/* Reclaim width for the chat thread on narrower viewports (e.g. the Studio
   preview pane). Without this, the app sidebar + conversation rail (260px each)
   squeeze assistant replies into a ~25-char column. */
@media (max-width: 1024px) {
  .q-chat-main { grid-template-columns: 1fr; }   /* drop the conversation rail */
  .q-chat-rail { display: none; }
}
@media (max-width: 720px) {
  .q-app-shell { grid-template-columns: 1fr; }    /* drop the app sidebar */
  .q-app-side { display: none; }
  .q-chat-thread { padding: 0 16px; }
  .q-chat-msg { grid-template-columns: 1fr; gap: 6px; }  /* role label above text */
  .q-chat-role { padding-top: 0; }
}

/* ============================================================================
   ERROR PAGES
   ============================================================================ */

.q-error-page { padding: 120px 0; text-align: center; }
.q-error-page h1 { font-size: 48px; margin: 16px 0; }
