/* ============================================================
   Dricenta | ADC Agent — Design System
   ============================================================ */

:root {
  /* Neutrals */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fbfcfd;
  --surface-3: #f1f3f5;
  --border: #e5e8ec;
  --border-strong: #d5dae0;

  /* Text */
  --text: #10151c;
  --text-2: #4a5560;
  --text-3: #8a95a1;

  /* Brand — deep teal / clinical */
  --brand: #0e7c7b;
  --brand-600: #0a6867;
  --brand-050: #e7f3f3;
  --accent: #3b6ef5;
  --accent-050: #eaf0fe;

  /* Semantic */
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --violet: #7c3aed;

  /* Phase palette */
  --p1: #94a3b8;
  --p2: #38bdf8;
  --p3: #0e7c7b;
  --p-approved: #16a34a;
  --p-pre: #cbd5e1;

  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 21, 28, .04), 0 1px 3px rgba(16, 21, 28, .06);
  --shadow: 0 2px 6px rgba(16, 21, 28, .06), 0 6px 20px rgba(16, 21, 28, .07);
  --shadow-lg: 0 8px 30px rgba(16, 21, 28, .12);

  --sidebar-w: 264px;
  --sidebar-w-collapsed: 68px;
  --context-w: 340px;
  --header-h: 58px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, monospace;
}

[data-theme="dark"] {
  --bg: #0c0f14;
  --surface: #12161d;
  --surface-2: #151a22;
  --surface-3: #1b212b;
  --border: #232b36;
  --border-strong: #2f3947;
  --text: #eef2f6;
  --text-2: #a7b2be;
  --text-3: #6b7684;
  --brand-050: #0e2322;
  --accent-050: #131c30;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 4px 16px rgba(0, 0, 0, .4);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--brand-050); }

/* Scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 20px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: padding-box; }

/* ============================================================
   APP SHELL
   ============================================================ */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--context-w);
  grid-template-rows: var(--header-h) 1fr;
  grid-template-areas:
    "brand header header"
    "sidebar main context";
  height: 100vh;
  overflow: hidden;
}
.app.collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr var(--context-w); }
.app.no-context { grid-template-columns: var(--sidebar-w) 1fr 0; }
.app.collapsed.no-context { grid-template-columns: var(--sidebar-w-collapsed) 1fr 0; }

/* ---------- Brand cell (top-left) ---------- */
.brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}
.brand-logo {
  height: 32px; flex: none;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), #12a3a1);
  display: grid; place-items: center;
  padding: 0 11px;
  color: #fff; box-shadow: var(--shadow-sm);
}
.brand-logo img { height: 16px; width: auto; display: block; }
.brand-logo svg { width: 18px; height: 18px; }
/* Collapsed rail: swap the wide wordmark for a compact monogram tile. */
.app.collapsed .brand-logo { width: 34px; padding: 0; }
.app.collapsed .brand-logo img { display: none; }
.app.collapsed .brand-logo::after {
  content: attr(data-mono); font-size: 16px; font-weight: 800; letter-spacing: -.02em;
}
.brand-text { line-height: 1.15; overflow: hidden; }
.brand-text b { font-size: 14px; font-weight: 700; letter-spacing: -.01em; }
.brand-text span { display: block; font-size: 11px; color: var(--text-3); font-weight: 600; }
.app.collapsed .brand-text { display: none; }

/* ============================================================
   HEADER
   ============================================================ */

.header {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.workspace-select {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 13px; font-weight: 500;
  color: var(--text-2);
  transition: border-color .15s, background .15s;
}
.workspace-select:hover { border-color: var(--border-strong); background: var(--surface-3); }
.workspace-select .ws-label { color: var(--text-3); font-weight: 400; }
.workspace-select b { color: var(--text); font-weight: 600; }

.status-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--brand-050);
  color: var(--brand-600);
  font-size: 12px; font-weight: 600;
}
.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(22, 163, 74, .5);
  animation: pulse 2.4s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .45); }
  70% { box-shadow: 0 0 0 6px rgba(22, 163, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

.token-meter {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 11px; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-3); font-weight: 500;
}
.token-meter svg { opacity: .7; }
.token-meter .tk b { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.token-meter .tk { white-space: nowrap; }

.header-spacer { flex: 1; }

.header-search {
  display: flex; align-items: center; gap: 8px;
  width: 260px; max-width: 30vw;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-3);
}
.header-search input {
  border: none; background: none; outline: none;
  flex: 1; font-size: 13px; color: var(--text);
}
.header-search kbd {
  font-family: var(--mono); font-size: 10px;
  padding: 2px 5px; border-radius: 5px;
  background: var(--surface-3); border: 1px solid var(--border);
  color: var(--text-3);
}

.icon-btn {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: none; color: var(--text-2);
  transition: background .15s, color .15s, border-color .15s;
  position: relative;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .badge-dot {
  position: absolute; top: 7px; right: 8px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--red); border: 2px solid var(--surface);
}

.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #3b6ef5, #7c3aed);
  color: #fff; font-size: 12px; font-weight: 700;
  cursor: pointer; flex: none;
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 14px 12px 8px; }

.new-research {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  font-size: 13px; font-weight: 600;
  transition: transform .12s, box-shadow .15s, opacity .15s;
  box-shadow: var(--shadow-sm);
}
.new-research:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.new-research:active { transform: translateY(0); }
.new-research svg { width: 16px; height: 16px; flex: none; }
.app.collapsed .new-research { justify-content: center; padding: 10px; }
.app.collapsed .new-research .label { display: none; }

.nav-group { margin-top: 4px; }
.nav-group.collapsed { display: none; }
.nav-group-title {
  display: flex; align-items: center; gap: 6px; width: 100%;
  font-size: 10.5px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-3);
  padding: 14px 10px 6px; margin: 0;
  border: none; background: none; cursor: pointer; text-align: left;
  transition: color .13s;
}
.nav-group-title:hover { color: var(--text-2); }
.nav-group-title .grp-chev { margin-left: auto; opacity: .6; transition: transform .2s; display: grid; }
.nav-group-title.collapsed .grp-chev { transform: rotate(-90deg); }
.app.collapsed .nav-group-title { justify-content: center; font-size: 9px; padding: 12px 0 6px; opacity: .6; }
.app.collapsed .nav-group-title .grp-chev { display: none; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  width: 100%;
  padding: 8px 10px;
  border: none; border-radius: var(--radius-sm);
  background: none; color: var(--text-2);
  font-size: 13px; font-weight: 500;
  text-align: left;
  transition: background .13s, color .13s;
  position: relative;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--brand-050); color: var(--brand-600); font-weight: 600; }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--brand);
}
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.nav-item .count {
  margin-left: auto; font-size: 11px; color: var(--text-3);
  background: var(--surface-3); padding: 1px 7px; border-radius: 999px;
}
.nav-item.active .count { background: #fff; color: var(--brand-600); }
.app.collapsed .nav-item { justify-content: center; padding: 9px; }
.app.collapsed .nav-item .label,
.app.collapsed .nav-item .count { display: none; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 2px;
}

/* Tooltips for collapsed items */
.tip { position: relative; }
.app.collapsed .tip:hover::after {
  content: attr(data-tip);
  position: absolute; left: calc(100% + 10px); top: 50%;
  transform: translateY(-50%);
  background: var(--text); color: var(--surface);
  padding: 5px 9px; border-radius: 6px; font-size: 12px; font-weight: 500;
  white-space: nowrap; z-index: 100; box-shadow: var(--shadow);
}

/* ============================================================
   MAIN WORKSPACE
   ============================================================ */

.main {
  grid-area: main;
  background: var(--bg);
  overflow: hidden;
  display: flex; flex-direction: column;
  position: relative;
}
.main-scroll { flex: 1; overflow-y: auto; scroll-behavior: smooth; }

/* ---------- Landing ---------- */
.landing {
  max-width: 780px; margin: 0 auto;
  padding: 7vh 24px 40px;
}
.greeting { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 8px; }
.greeting .wave { display: inline-block; }
.sub { color: var(--text-2); font-size: 15px; margin: 0 0 28px; }

.suggest-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  margin-top: 22px;
}
.suggest-card {
  text-align: left;
  padding: 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface);
  transition: border-color .15s, transform .12s, box-shadow .15s;
  display: flex; flex-direction: column; gap: 10px;
}
.suggest-card:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: var(--shadow); }
.suggest-ic {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--brand-050); color: var(--brand);
}
.suggest-ic svg { width: 16px; height: 16px; }
.suggest-card .q { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.35; }
.suggest-card .tag { font-size: 11px; color: var(--text-3); }

.landing-hint { text-align: center; color: var(--text-3); font-size: 12px; margin-top: 26px; }

/* Home: sources & tools info */
.home-info { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 30px; }
.info-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 16px; }
.info-head { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.info-head .ih-ic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--brand-050); color: var(--brand); }
.info-head b { font-size: 13.5px; }
.info-head .ih-sub { font-size: 11.5px; color: var(--text-3); margin-left: auto; }
.info-item { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.info-item:first-of-type { border-top: none; }
.info-item .ii-ic { color: var(--brand); display: grid; place-items: center; margin-top: 1px; opacity: .9; }
.info-item .ii-name { font-size: 12.5px; font-weight: 600; }
.info-item .ii-desc { font-size: 11.5px; color: var(--text-3); line-height: 1.4; }
.info-item.clickable { cursor: pointer; border-radius: var(--radius-sm); margin: 0 -8px; padding: 8px; border-top: none; }
.info-item.clickable:hover { background: var(--surface-2); }
.info-badge { margin-left: auto; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-3); background: var(--surface-3); padding: 2px 6px; border-radius: 5px; align-self: center; }

/* Empty chat state (Research with no messages yet) */
.chat-empty { display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 12vh 24px; color: var(--text-3); }
.chat-empty .ce-ic { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), #12a3a1); color: #fff; margin-bottom: 16px; }
.chat-empty b { font-size: 17px; color: var(--text); margin-bottom: 6px; }
.chat-empty p { font-size: 13.5px; max-width: 420px; margin: 0 0 18px; }

/* ---------- Panel views ---------- */
.panel { max-width: 860px; margin: 0 auto; padding: 30px 24px 60px; animation: rise .3s ease; }
.panel-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 22px; }
.panel-ic {
  width: 42px; height: 42px; border-radius: 11px; flex: none;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--brand), #12a3a1);
}
.panel-title { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.panel-sub { color: var(--text-2); font-size: 14px; margin-top: 3px; }
.panel-head .spacer { flex: 1; }

.list-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 13px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); margin-bottom: 9px; text-align: left;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.list-row:hover { border-color: var(--brand); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.list-row .li-ic { width: 34px; height: 34px; border-radius: 9px; flex: none; display: grid; place-items: center;
  background: var(--brand-050); color: var(--brand); }
.list-row .li-main { flex: 1; min-width: 0; }
.list-row .li-title { font-size: 13.5px; font-weight: 600; }
.list-row .li-sub { font-size: 12px; color: var(--text-3); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .li-act { display: grid; place-items: center; color: var(--text-3); }

.cmp-builder { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 18px; }
.cmp-inputs { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.cmp-field {
  flex: 1; min-width: 170px; display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2);
}
.cmp-field input { border: none; outline: none; background: none; flex: 1; font-size: 14px; color: var(--text); font-family: inherit; }
.cmp-field .vs { font-size: 12px; font-weight: 700; color: var(--text-3); }

.settings-row {
  display: flex; align-items: center; gap: 12px; padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border: none; }
.settings-row .sr-main { flex: 1; }
.settings-row .sr-title { font-size: 13.5px; font-weight: 600; }
.settings-row .sr-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border); }
.seg button { padding: 5px 12px; border: none; border-radius: 999px; background: none; font-size: 12px; font-weight: 600; color: var(--text-3); transition: all .15s; }
.seg button.active { background: var(--surface); color: var(--brand-600); box-shadow: var(--shadow-sm); }

.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius-lg);
  background: var(--surface-2); padding: 40px 24px; text-align: center; color: var(--text-3);
  transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: var(--brand); background: var(--brand-050); }
.dropzone svg { width: 34px; height: 34px; margin-bottom: 10px; opacity: .7; }

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

.thread { max-width: 860px; margin: 0 auto; padding: 24px 24px 20px; }

.turn { margin-bottom: 26px; }

.msg-user {
  display: flex; justify-content: flex-end; margin-bottom: 18px;
}
.msg-user .bubble {
  background: var(--brand); color: #fff;
  padding: 11px 15px; border-radius: 14px 14px 4px 14px;
  font-size: 14px; max-width: 78%; box-shadow: var(--shadow-sm);
}

.agent { animation: rise .35s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.agent-head {
  display: flex; align-items: center; gap: 9px; margin-bottom: 12px;
}
.agent-badge {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(135deg, var(--brand), #12a3a1);
  display: grid; place-items: center; color: #fff; flex: none;
}
.agent-badge svg { width: 15px; height: 15px; }
.agent-name { font-weight: 700; font-size: 13.5px; }
.agent-name span { color: var(--text-3); font-weight: 500; }

/* Research activity */
.activity {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); margin-bottom: 16px; overflow: hidden;
}
.activity-head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; cursor: pointer; user-select: none;
}
.activity-head:hover { background: var(--surface-2); }
.activity-spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--brand-050); border-top-color: var(--brand);
  animation: spin .7s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.activity-check { color: var(--green); display: grid; place-items: center; }
.activity-check svg { width: 16px; height: 16px; }
.activity-title { font-size: 13px; font-weight: 600; }
.activity-summary { margin-left: auto; font-size: 12px; color: var(--text-3); }
.activity-chev { color: var(--text-3); transition: transform .2s; }
.activity.open .activity-chev { transform: rotate(180deg); }
.activity-body { padding: 0 14px; max-height: 0; overflow: hidden; transition: max-height .25s, padding .25s; }
.activity.open .activity-body { max-height: 320px; padding: 4px 14px 12px; }
.activity-step {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 0; font-size: 13px; color: var(--text-2);
}
.activity-step .s-ic { color: var(--green); display: grid; place-items: center; }
.activity-step .s-ic svg { width: 15px; height: 15px; }

/* Answer body */
.answer { font-size: 14px; color: var(--text); }
.answer p { margin: 0 0 12px; }
.answer h2, .answer h3 {
  font-size: 14px; font-weight: 700; letter-spacing: -.01em;
  margin: 20px 0 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.answer h3 { font-size: 13.5px; border: none; margin: 16px 0 6px; }
.answer ul { margin: 0 0 12px; padding-left: 18px; }
.answer li { margin: 4px 0; }
.answer a.wiki { color: var(--brand-600); border-bottom: 1px dashed var(--brand-050); font-weight: 500; }
.answer a.ext { color: var(--accent); }
.answer strong { font-weight: 650; }
.answer .md-table-wrap { overflow-x: auto; margin: 8px 0 16px; border: 1px solid var(--border); border-radius: var(--radius); }
.answer table.md-table { margin: 0; }
.answer table.md-table th { position: static; }

.cite {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px;
  font-size: 10.5px; font-weight: 700; vertical-align: super;
  border-radius: 4px; background: var(--accent-050); color: var(--accent);
  margin-left: 2px; cursor: pointer; line-height: 16px;
}
.cite:hover { background: var(--accent); color: #fff; }

/* KPI row */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 4px 0 18px; }
.kpi {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); padding: 14px 16px;
  position: relative; overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--brand);
}
.kpi .v { font-size: 26px; font-weight: 750; letter-spacing: -.03em; line-height: 1; }
.kpi .l { font-size: 12px; color: var(--text-3); margin-top: 6px; font-weight: 500; }

/* Card wrapper for chart/table */
.block {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); margin: 0 0 18px; overflow: hidden;
}
.block-head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.block-title { font-size: 13px; font-weight: 650; }
.block-title .sub { color: var(--text-3); font-weight: 500; margin-left: 6px; }
.block-actions { margin-left: auto; display: flex; gap: 4px; }
.mini-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 9px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-2);
  transition: background .13s, border-color .13s, color .13s;
}
.mini-btn:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.mini-btn svg { width: 14px; height: 14px; }

/* Chart */
.chart-wrap { padding: 16px; }
.bar-row { display: flex; align-items: center; gap: 12px; margin: 9px 0; }
.bar-label { width: 120px; font-size: 12.5px; color: var(--text-2); text-align: right; flex: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; height: 22px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.bar-fill {
  height: 100%; border-radius: 6px; width: 0;
  background: linear-gradient(90deg, var(--brand), #16b3b1);
  transition: width .8s cubic-bezier(.2,.8,.2,1);
}
.bar-val { width: 34px; font-size: 12.5px; font-weight: 650; color: var(--text); flex: none; }

/* Table */
.table-tools {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.table-search {
  display: flex; align-items: center; gap: 7px; flex: 1; max-width: 260px;
  padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text-3);
}
.table-search input { border: none; background: none; outline: none; flex: 1; font-size: 12.5px; color: var(--text); }
.table-scroll { overflow-x: auto; max-height: 420px; }
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; font-weight: 650; color: var(--text-2);
  padding: 9px 12px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap; cursor: pointer;
  user-select: none;
}
table.data th:hover { color: var(--text); }
table.data th .arrow { opacity: .4; margin-left: 4px; }
table.data th.sorted .arrow { opacity: 1; color: var(--brand); }
table.data td {
  padding: 9px 12px; border-bottom: 1px solid var(--border);
  color: var(--text); vertical-align: top; max-width: 320px;
}
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-2); }
td .link-entity { color: var(--brand-600); font-weight: 600; cursor: pointer; border-bottom: 1px dashed transparent; }
td .link-entity:hover { border-bottom-color: var(--brand); }
.cell-clip { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.table-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-3);
}

/* Answer action bar */
.answer-actions {
  display: flex; align-items: center; gap: 4px;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
}
.followups { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 4px; }
.followup {
  padding: 7px 12px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); font-size: 12.5px; font-weight: 500; color: var(--text-2);
  transition: border-color .15s, color .15s, background .15s;
}
.followup:hover { border-color: var(--brand); color: var(--brand-600); background: var(--brand-050); }

/* ============================================================
   PROMPT BOX
   ============================================================ */

.composer-wrap {
  border-top: 1px solid var(--border);
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  padding: 12px 24px 16px;
}
.composer {
  max-width: 860px; margin: 0 auto;
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
  /* NOTE: must stay visible so the Sources/Tools dropdowns can overflow upward */
  overflow: visible;
}
.composer textarea { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }

/* Attachment chips inside the composer */
.attach-chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 12px 14px 0; }
.attach-chips[hidden] { display: none; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 8px 5px 10px; border-radius: 999px;
  background: var(--brand-050); border: 1px solid var(--border);
  font-size: 12px; color: var(--text); font-weight: 500; max-width: 240px;
}
.attach-chip .ac-ic { color: var(--brand); display: grid; place-items: center; }
.attach-chip .ac-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip.loading { opacity: .7; }
.attach-chip .ac-x { display: grid; place-items: center; color: var(--text-3); cursor: pointer; border: none; background: none; padding: 2px; border-radius: 50%; }
.attach-chip .ac-x:hover { background: var(--surface); color: var(--red); }
.attach-chip .ac-spin { width: 12px; height: 12px; border: 2px solid var(--brand-050); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
.composer:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-050), var(--shadow); }
.composer.landing-mode { box-shadow: var(--shadow-lg); }
.composer textarea {
  width: 100%; border: none; outline: none; resize: none;
  background: none; color: var(--text);
  font-family: inherit; font-size: 15px; line-height: 1.5;
  padding: 15px 16px 6px; max-height: 200px;
}
.composer textarea::placeholder { color: var(--text-3); }
.composer-toolbar {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px 10px;
}
.tool-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: none;
  color: var(--text-2); font-size: 12.5px; font-weight: 500;
  transition: background .13s, color .13s;
}
.tool-btn:hover { background: var(--surface-3); color: var(--text); }
.tool-btn svg { width: 16px; height: 16px; }

.mode-toggle {
  display: inline-flex; padding: 3px; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--border);
}
.mode-toggle button {
  padding: 5px 12px; border: none; border-radius: 999px;
  background: none; font-size: 12px; font-weight: 600; color: var(--text-3);
  transition: all .15s;
}
.mode-toggle button.active { background: var(--surface); color: var(--brand-600); box-shadow: var(--shadow-sm); }

.composer-spacer { flex: 1; }

.model-select {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2);
  font-size: 12px; color: var(--text-2); font-weight: 500;
}

/* Tools single-select (left side) */
.tool-select { position: relative; }
.tool-select .src-menu { left: 0; right: auto; width: 230px; }
.tool-select .tool-btn[aria-expanded="true"] { background: var(--surface-3); color: var(--text); }
.tool-btn .tool-active { color: var(--brand-600); font-weight: 600; }
.src-item.selected { background: var(--brand-050); }
.src-item.selected .src-label { color: var(--brand-600); font-weight: 600; }
.src-item .src-radio {
  width: 16px; height: 16px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--border-strong); display: grid; place-items: center;
}
.src-item.selected .src-radio { border-color: var(--brand); }
.src-item.selected .src-radio::after {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--brand);
}

/* Sources multi-select (replaces model picker) */
.src-select { position: relative; }
.src-select .model-select { cursor: pointer; }
.src-select .src-count {
  font-weight: 700; color: var(--brand-600);
  background: var(--brand-050); padding: 1px 7px; border-radius: 999px; font-size: 11px;
}
.src-menu {
  position: absolute; bottom: calc(100% + 8px); right: 0;
  width: 260px; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); z-index: 30; overflow: hidden;
  animation: rise .16s ease;
}
/* On the Home/landing composer (near the top), drop the menus downward so
   they don't cover the greeting; the docked chat composer keeps them upward. */
.composer.landing-mode .src-menu,
.composer.landing-mode .tool-select .src-menu {
  top: calc(100% + 8px); bottom: auto;
}
.src-menu-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3);
}
.src-all { border: none; background: none; color: var(--brand-600); font-size: 11px; font-weight: 700;
  text-transform: none; letter-spacing: 0; cursor: pointer; }
.src-all:hover { text-decoration: underline; }
.src-items { padding: 6px; max-height: 300px; overflow-y: auto; }
.src-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 9px; border: none; background: none; border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text); text-align: left; cursor: pointer;
  transition: background .12s;
}
.src-item:hover { background: var(--surface-3); }
.src-item .src-ic { color: var(--brand); display: grid; place-items: center; opacity: .85; }
.src-item .src-label { flex: 1; font-weight: 500; }
.src-check {
  width: 18px; height: 18px; border-radius: 5px; flex: none;
  border: 1.5px solid var(--border-strong); display: grid; place-items: center;
  color: #fff; transition: background .12s, border-color .12s;
}
.src-item.on .src-check { background: var(--brand); border-color: var(--brand); }
.src-check svg { width: 12px; height: 12px; opacity: 0; }
.src-item.on .src-check svg { opacity: 1; }

.send-btn {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; border: none;
  background: var(--brand); color: #fff;
  transition: background .15s, transform .12s, opacity .15s;
}
.send-btn:hover { background: var(--brand-600); transform: translateY(-1px); }
.send-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.send-btn svg { width: 18px; height: 18px; }

.deep-hint {
  max-width: 860px; margin: 8px auto 0; font-size: 12px; color: var(--text-3);
  display: flex; align-items: center; gap: 7px;
}
.deep-hint svg { width: 14px; height: 14px; color: var(--violet); flex: none; }

/* ============================================================
   CONTEXT PANEL
   ============================================================ */

.context {
  grid-area: context;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.app.no-context .context { display: none; }
.context-tabs {
  display: flex; padding: 0 8px; border-bottom: 1px solid var(--border);
  gap: 2px;
}
.context-tab {
  padding: 13px 12px 11px; border: none; background: none;
  font-size: 12.5px; font-weight: 600; color: var(--text-3);
  border-bottom: 2px solid transparent; transition: color .15s;
}
.context-tab:hover { color: var(--text-2); }
.context-tab.active { color: var(--text); border-bottom-color: var(--brand); }
.context-tab .n {
  font-size: 10px; padding: 0 5px; margin-left: 4px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-2);
}
.context-body { flex: 1; overflow-y: auto; padding: 14px; }

.ctx-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; height: 100%; color: var(--text-3); padding: 30px 20px;
}
.ctx-empty svg { width: 34px; height: 34px; margin-bottom: 12px; opacity: .5; }
.ctx-empty b { color: var(--text-2); font-size: 13px; margin-bottom: 4px; }
.ctx-empty p { font-size: 12.5px; margin: 0; }

/* Source card */
.source-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; margin-bottom: 10px; background: var(--surface-2);
  transition: border-color .15s, box-shadow .15s;
}
.source-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.source-top { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.source-idx {
  width: 22px; height: 22px; border-radius: 6px; flex: none;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
  background: var(--brand); color: #fff;
}
.source-kind {
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--brand-600); background: var(--brand-050); padding: 2px 7px; border-radius: 5px;
}
.source-title { font-size: 12.5px; font-weight: 600; line-height: 1.35; margin-bottom: 5px; }
.source-title a { color: inherit; }
.source-title a:hover { color: var(--brand); text-decoration: underline; }
.source-meta { display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--text-3); margin-bottom: 8px; }
.source-meta svg { width: 11px; height: 11px; flex: none; opacity: .8; }
.source-open {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; color: var(--accent);
}
.source-open svg { width: 13px; height: 13px; }
/* Metadata info affordance */
.meta-info { display: inline-flex; align-items: center; color: var(--text-3);
  cursor: help; transition: color .15s; }
.meta-info:hover, .meta-info:focus { color: var(--brand); outline: none; }
.meta-info svg { width: 13px; height: 13px; }
/* Document snippet + search-term highlight (renders ES <em> markers) */
.doc-snippet { font-size: 12.5px; color: var(--text-2); margin: 4px 0 8px; line-height: 1.5; }
mark.hl { background: var(--brand-050); color: var(--brand-600);
  border-radius: 3px; padding: 0 2px; font-style: normal; font-weight: 600; }
[data-theme="dark"] mark.hl { color: var(--text); background: rgba(14, 124, 123, .28); }
/* Direct-answer highlight in generated answers — eye-catching amber marker. */
mark.ans-hl { background: #ffe9a8; color: #6b4e00;
  border-radius: 3px; padding: 0 4px; font-weight: 650; font-style: normal;
  box-decoration-break: clone; -webkit-box-decoration-break: clone; }
[data-theme="dark"] mark.ans-hl { background: rgba(245, 183, 49, .30); color: #ffe08a; }

/* Report builder */
.rep-actions { display: flex; gap: 8px; margin: 4px 0 2px; }
.rep-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 2px; }
.rep-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; padding: 6px 12px; border-radius: 20px;
  border: 1px solid var(--border-strong); background: var(--surface-2);
  color: var(--text-2); cursor: pointer; transition: all .12s;
}
.rep-chip svg { width: 13px; height: 13px; opacity: 0; }
.rep-chip.selected {
  border-color: var(--brand); background: var(--brand-050);
  color: var(--brand-600); font-weight: 600;
}
.rep-chip.selected svg { opacity: 1; }
.report-body h1 { font-size: 21px; margin: 2px 0 4px; letter-spacing: -.02em; }
.report-body h2 { font-size: 16px; margin-top: 20px; }

/* Clickable linker field + linker modal */
.field.field-link { cursor: pointer; border-radius: 8px; transition: background .12s; }
.field.field-link:hover { background: var(--brand-050); }
.field.field-link .v { color: var(--brand-600); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.field.field-link .field-go { display: inline-flex; color: var(--brand); }
.lk-overlay { position: fixed; inset: 0; z-index: 200; display: none; place-items: center;
  padding: 24px; background: rgba(10, 15, 20, .55); opacity: 0; transition: opacity .2s; }
.lk-overlay.show { display: grid; opacity: 1; }
.lk-modal { width: 100%; max-width: 720px; max-height: 88vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-lg); animation: authIn .28s ease both; }
.lk-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 18px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.lk-eyebrow { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; color: var(--text-3); }
.lk-title { font-size: 18px; font-weight: 750; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.lk-body { display: grid; grid-template-columns: 1.1fr 1fr; }
.lk-left { padding: 18px 20px; border-right: 1px solid var(--border); }
.lk-right { padding: 18px 20px; min-width: 0; }
.lk-section-t { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); margin-bottom: 9px; }
.lk-svg { width: 100%; height: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 6px; }
.lk-chem { margin: 2px 0 12px; padding-left: 18px; font-size: 12.5px; color: var(--text-2); line-height: 1.65; }
.lk-drugs { display: flex; flex-direction: column; gap: 8px; }
.lk-drug { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
  cursor: pointer; text-align: left; transition: border-color .12s, box-shadow .12s; }
.lk-drug:hover { border-color: var(--brand); box-shadow: var(--shadow-sm); }
.lk-drug-name { font-size: 13px; font-weight: 600; display: block; }
.lk-drug-sub { font-size: 11.5px; color: var(--text-3); }
.lk-loading { padding: 46px; text-align: center; color: var(--text-3);
  display: flex; flex-direction: column; align-items: center; gap: 10px; }
.lk-svg .lk-ab { fill: var(--brand-050); stroke: var(--brand); }
.lk-svg .lk-ab-t { fill: var(--brand-600); }
.lk-svg .lk-chain { stroke: var(--brand); stroke-width: 4; stroke-dasharray: 2 6; stroke-linecap: round; }
.lk-svg .lk-dot { fill: var(--brand); }
.lk-svg .lk-lbl { fill: var(--surface); stroke: var(--border-strong); }
.lk-svg .lk-lbl-t { fill: var(--text-2); }
.lk-svg .lk-pl { fill: rgba(217, 119, 6, .14); stroke: #d97706; }
.lk-svg .lk-pl-t, .lk-svg .lk-pl-s { fill: #b45309; }
.lk-svg .lk-t { font-weight: 700; }
[data-theme="dark"] .lk-svg .lk-pl-t, [data-theme="dark"] .lk-svg .lk-pl-s { fill: #f0b366; }
@media (max-width: 640px) { .lk-body { grid-template-columns: 1fr; } .lk-left { border-right: none; border-bottom: 1px solid var(--border); } }

/* Entity chip list */
.entity-group-title {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-3); margin: 14px 0 8px;
}
.entity-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); margin-bottom: 7px; text-align: left;
  transition: border-color .15s, background .15s;
}
.entity-item:hover { border-color: var(--brand); background: var(--brand-050); }
.entity-avatar {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff;
}
.entity-name { font-size: 12.5px; font-weight: 600; }
.entity-meta { font-size: 11px; color: var(--text-3); }
.entity-item .chev { margin-left: auto; color: var(--text-3); }

/* ============================================================
   DRAWER
   ============================================================ */

.scrim {
  position: fixed; inset: 0; background: rgba(16, 21, 28, .35);
  opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 40;
  backdrop-filter: blur(1px);
}
.scrim.show { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 440px; max-width: 92vw;
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg); z-index: 50;
  transform: translateX(100%); transition: transform .3s cubic-bezier(.3,.9,.3,1);
  display: flex; flex-direction: column;
}
.drawer.show { transform: none; }
.drawer-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 18px 18px 14px; border-bottom: 1px solid var(--border);
}
.drawer-avatar {
  width: 44px; height: 44px; border-radius: 11px; flex: none;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 16px;
  background: linear-gradient(135deg, var(--brand), #12a3a1);
}
.drawer-title { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.drawer-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.drawer-close { margin-left: auto; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px; }
.drawer-actions {
  display: flex; flex-wrap: wrap; gap: 7px;
  padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2);
}

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin-bottom: 4px; }
.field { border-bottom: 1px solid var(--border); padding-bottom: 9px; }
.field .k { font-size: 11px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.field .v { font-size: 13px; color: var(--text); margin-top: 3px; }
.drawer-section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-2); margin: 20px 0 10px;
}
.trial-chip {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 7px;
  background: var(--surface-2);
}
.trial-chip .nct { font-family: var(--mono); font-size: 12px; font-weight: 600; }

/* ============================================================
   BADGES / MISC
   ============================================================ */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600;
  background: var(--surface-3); color: var(--text-2);
}
.badge.approved { background: #eaf7ef; color: var(--green); }
.badge.p3 { background: var(--brand-050); color: var(--brand-600); }
.badge.p2 { background: #e6f6fe; color: #0284c7; }
.badge.p1 { background: #f1f3f5; color: var(--text-2); }
[data-theme="dark"] .badge.approved { background: #12251a; }

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: 6px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.skel-line { height: 12px; margin: 8px 0; }

/* Toast */
.toast-wrap {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 16px; border-radius: var(--radius);
  background: var(--text); color: var(--surface);
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg);
  animation: toastIn .3s ease;
}
.toast svg { width: 16px; height: 16px; color: #4ade80; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* Auth overlay */
.auth-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1000px 520px at 15% -10%, var(--brand-050), transparent 60%),
    radial-gradient(900px 500px at 100% 110%, var(--accent-050), transparent 55%),
    var(--bg);
}
/* A class-level `display` beats the UA [hidden] rule, so restore hiding explicitly. */
.auth-overlay[hidden] { display: none; }
.auth-card {
  width: 100%; max-width: 840px;
  display: grid; grid-template-columns: 1.02fr 1fr;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 22px; box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: authIn .45s cubic-bezier(.2, .7, .2, 1) both;
}
@keyframes authIn { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }

/* Fade the overlay out once auth resolves (no hard cut). */
.auth-overlay { transition: opacity .35s ease; }
.auth-overlay.hiding { opacity: 0; pointer-events: none; }

/* "Checking" splash: branded hero + spinner while auth resolves, form hidden —
   so neither the dashboard nor the login form flashes on reload. */
.auth-spinner { display: none; flex-direction: column; align-items: center;
  gap: 14px; padding: 46px 0; color: var(--text-3); }
.auth-overlay.checking .auth-panel > :not(.auth-spinner) { display: none; }
.auth-overlay.checking .auth-spinner { display: flex; }
.auth-spin { width: 30px; height: 30px; border: 3px solid var(--border);
  border-top-color: var(--brand); border-radius: 50%; animation: authSpin .8s linear infinite; }
.auth-spin-label { font-size: 12.5px; }
@keyframes authSpin { to { transform: rotate(360deg); } }

/* Minimal ambient motion + staggered form entrance. */
.auth-hero-orb--1 { animation: authOrb 8s ease-in-out infinite; }
.auth-hero-orb--2 { animation: authOrb 11s ease-in-out infinite reverse; }
@keyframes authOrb { 0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(12px, -14px) scale(1.08); } }
.auth-overlay:not(.checking) .auth-title,
.auth-overlay:not(.checking) .auth-sub,
.auth-overlay:not(.checking) #authStepEmail { animation: authRise .45s ease both; }
.auth-overlay:not(.checking) .auth-sub { animation-delay: .05s; }
.auth-overlay:not(.checking) #authStepEmail { animation-delay: .1s; }
@keyframes authRise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* --- Branded hero (white wordmark lives on the teal gradient) --- */
.auth-hero {
  position: relative; overflow: hidden;
  padding: 40px 36px; color: #fff;
  display: flex; flex-direction: column; gap: 26px;
  background: linear-gradient(155deg, #0f8a89 0%, var(--brand) 48%, #094f56 100%);
}
.auth-hero-orb { position: absolute; border-radius: 50%; filter: blur(2px); pointer-events: none; }
.auth-hero-orb--1 { width: 260px; height: 260px; top: -90px; right: -70px;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.28), transparent 62%); }
.auth-hero-orb--2 { width: 220px; height: 220px; bottom: -80px; left: -60px;
  background: radial-gradient(circle at 60% 40%, rgba(255,255,255,.16), transparent 60%); }
.auth-hero-logo { position: relative; width: 188px; max-width: 66%; height: auto; }
.auth-hero-copy { position: relative; }
.auth-hero-title { font-size: 18px; font-weight: 700; line-height: 1.35; letter-spacing: -.01em; margin: 0 0 18px; }
.auth-hero-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 13px; }
.auth-hero-list li { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.4; color: rgba(255,255,255,.94); }
.auth-hero-list svg { width: 15px; height: 15px; flex: none; margin-top: 2px;
  color: #fff; background: rgba(255,255,255,.18); border-radius: 50%; padding: 3px; box-sizing: content-box; }
.auth-hero-foot { position: relative; margin-top: auto; display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; font-weight: 500; color: rgba(255,255,255,.82); }
.auth-hero-foot svg { width: 14px; height: 14px; }

/* --- Form panel --- */
.auth-panel { padding: 42px 38px; display: flex; flex-direction: column; }
.auth-title { font-size: 22px; font-weight: 750; letter-spacing: -.02em; margin: 0 0 6px; }
.auth-sub { font-size: 13.5px; color: var(--text-2); margin: 0 0 24px; }
.auth-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
.auth-field { position: relative; margin-bottom: 16px; }
.auth-field-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--text-3); pointer-events: none; }
.auth-input {
  width: 100%; padding: 12px 14px 12px 40px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface-2); color: var(--text); font-size: 14px; font-family: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.auth-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-050); }
.auth-input:focus + .auth-field-icon, .auth-field:focus-within .auth-field-icon { color: var(--brand); }
.otp-boxes { display: flex; gap: 8px; margin-bottom: 18px; }
.otp-box {
  flex: 1; width: 0; height: 54px; text-align: center;
  border: 1px solid var(--border-strong); border-radius: 11px;
  background: var(--surface-2); color: var(--text);
  font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums;
  outline: none; transition: border-color .15s, box-shadow .15s, transform .1s;
}
.otp-box:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-050); transform: translateY(-1px); }
.otp-box.filled { border-color: var(--brand); background: var(--brand-050); }
.auth-btn {
  width: 100%; padding: 12px; border: none; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--brand); color: #fff; font-size: 14px; font-weight: 650;
  box-shadow: 0 6px 16px -6px rgba(14, 124, 123, .6);
  transition: background .15s, transform .1s, box-shadow .15s, opacity .15s;
}
.auth-btn svg { width: 16px; height: 16px; }
.auth-btn:hover { background: var(--brand-600); box-shadow: 0 8px 20px -6px rgba(14, 124, 123, .7); }
.auth-btn:active { transform: translateY(1px); }
.auth-btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.auth-link { width: 100%; margin-top: 12px; border: none; background: none; color: var(--text-3); font-size: 12.5px; cursor: pointer; transition: color .15s; }
.auth-link:hover { color: var(--brand); }
.auth-note {
  margin-top: 16px; padding: 11px 13px; border-radius: var(--radius);
  background: var(--brand-050); color: var(--brand-600); font-size: 12.5px; font-weight: 500;
}
.auth-note.err { background: #fdeeee; color: #b42318; }
[data-theme="dark"] .auth-note.err { background: #2a1414; color: #f6a6a6; }
.auth-foot { text-align: center; font-size: 11.5px; color: var(--text-3); margin: auto 0 0; padding-top: 20px; }

@media (max-width: 680px) {
  .auth-card { grid-template-columns: 1fr; max-width: 400px; }
  .auth-hero { padding: 26px 28px; gap: 16px; }
  .auth-hero-logo { width: 150px; }
  .auth-hero-title { font-size: 15px; margin-bottom: 0; }
  .auth-hero-list, .auth-hero-foot { display: none; }
  .auth-panel { padding: 28px 26px; }
}

.error-note {
  border: 1px solid #f3c6c6; background: #fdeeee; color: #b42318;
  padding: 12px 14px; border-radius: var(--radius); font-size: 13px;
}
[data-theme="dark"] .error-note { background: #2a1414; border-color: #4a1f1f; color: #f6a6a6; }

/* ============================================================
   RESPONSIVE
   ============================================================ */

.menu-toggle { display: none; }

@media (max-width: 1180px) {
  .app, .app.collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr 0; }
  .app .brand-text, .app .nav-item .label, .app .nav-item .count,
  .app .nav-group-title, .app .new-research .label { display: none; }
  .app .nav-item, .app .new-research { justify-content: center; }
  .context { display: none; }
}

@media (max-width: 760px) {
  .app, .app.collapsed {
    grid-template-columns: 1fr;
    grid-template-areas: "header" "main";
    grid-template-rows: var(--header-h) 1fr;
  }
  .brand, .sidebar, .context { display: none; }
  .menu-toggle { display: grid; }
  .suggest-grid { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .header-search { display: none; }
  .drawer { width: 100%; }
  .sidebar.mobile-open {
    display: flex; position: fixed; top: 0; left: 0; bottom: 0; width: 264px; z-index: 60;
    box-shadow: var(--shadow-lg);
  }
}
