/* Product Analytics — design system.
   Light is the default; dark follows the system unless the viewer picks a
   theme (html[data-theme]). Token names are shared with feature styles. */

:root {
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --surface-3: #e9ecf1;
  --border: #e3e6eb;
  --border-strong: #cfd4dc;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --faint: #9ca3af;
  --accent: #2f5fd0;
  --accent-hover: #264fb0;
  --accent-soft: #eef3fe;
  --accent-text: #ffffff;
  --focus: rgba(47, 95, 208, 0.35);
  --success: #15803d;
  --success-soft: #ecfdf3;
  --warn-soft: #fff7e6;
  --warn-text: #92400e;
  --danger: #c0262d;
  --danger-soft: #fdeeee;
  --code-bg: #f5f6f8;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-pop: 0 8px 24px rgba(16, 24, 40, 0.12), 0 2px 6px rgba(16, 24, 40, 0.06);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --header-h: 56px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117;
    --surface: #151a22;
    --surface-2: #1b212b;
    --surface-3: #232b37;
    --border: #262e3a;
    --border-strong: #354050;
    --text: #e8ebf0;
    --text-2: #c5cbd5;
    --muted: #8b95a5;
    --faint: #677285;
    --accent: #7b9ef0;
    --accent-hover: #93b0f4;
    --accent-soft: #1a2540;
    --accent-text: #0b1220;
    --focus: rgba(123, 158, 240, 0.4);
    --success: #4ade80;
    --success-soft: #0f2a1a;
    --warn-soft: #2d2410;
    --warn-text: #f4c56a;
    --danger: #f08b8f;
    --danger-soft: #2e1517;
    --code-bg: #10151c;
    --shadow: none;
    --shadow-pop: 0 10px 30px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --surface: #151a22; --surface-2: #1b212b; --surface-3: #232b37;
  --border: #262e3a; --border-strong: #354050; --text: #e8ebf0; --text-2: #c5cbd5; --muted: #8b95a5; --faint: #677285;
  --accent: #7b9ef0; --accent-hover: #93b0f4; --accent-soft: #1a2540; --accent-text: #0b1220; --focus: rgba(123, 158, 240, 0.4);
  --success: #4ade80; --success-soft: #0f2a1a; --warn-soft: #2d2410; --warn-text: #f4c56a; --danger: #f08b8f; --danger-soft: #2e1517;
  --code-bg: #10151c; --shadow: none; --shadow-pop: 0 10px 30px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

/* -- Base ---------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { color: var(--text); letter-spacing: -0.01em; line-height: 1.25; }
h1 { font-size: 24px; font-weight: 650; margin: 0 0 6px; }
h2 { font-size: 17px; font-weight: 620; margin: 28px 0 10px; }
h3 { font-size: 14px; font-weight: 620; margin: 0 0 8px; }
p { margin: 0 0 10px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
code, pre, kbd { font-family: var(--mono); font-size: 12.5px; }
pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; overflow: auto; max-height: 360px; margin: 8px 0 0; white-space: pre-wrap; word-break: break-word; color: var(--text-2); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.note { color: var(--muted); font-size: 12.5px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.06em; font-size: 11px; font-weight: 600; color: var(--muted); margin: 0 0 6px; }
.error { color: var(--danger); margin: 0; }
.danger { color: var(--danger) !important; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.icon { display: inline-block; vertical-align: -3px; flex: none; }
.lead { font-size: 15px; color: var(--muted); max-width: 720px; }

/* -- Buttons and inputs -------------------------------------------------- */

button { cursor: pointer; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font-weight: 520; font-size: 13px; white-space: nowrap; box-shadow: var(--shadow);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
button:hover:not(:disabled) { background: var(--surface-2); }
button.primary, .button-link {
  background: var(--accent) !important; border-color: var(--accent) !important; color: var(--accent-text) !important;
}
button.primary:hover:not(:disabled), .button-link:hover { background: var(--accent-hover) !important; border-color: var(--accent-hover) !important; text-decoration: none; }
.button-link { display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border-radius: var(--radius-sm); font-weight: 560; font-size: 13px; border: 1px solid; }
button.link {
  height: auto; box-shadow: none; border: 0; background: none; padding: 4px 6px; margin: 0 -2px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 12.5px; font-weight: 520; display: inline-flex; align-items: center; gap: 5px;
}
button.link:hover { background: var(--surface-2); color: var(--text); }
.icon-btn {
  box-shadow: none; padding: 0;
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: none; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

input[type=text], input[type=password], input[type=search], input[type=number], input[type=date], input[type=email], select, textarea {
  width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 13.5px; transition: border-color 0.12s, box-shadow 0.12s;
}
textarea { height: auto; padding: 8px 10px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
select {
  appearance: none; padding-right: 28px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
input[type=date] { color-scheme: inherit; }

/* -- App shell ----------------------------------------------------------- */

.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1280px; height: var(--header-h); margin: 0 auto; padding: 0 20px; display: flex; gap: 20px; align-items: center; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: 8px; white-space: nowrap; }
.brand strong { font-size: 14.5px; font-weight: 650; letter-spacing: -0.01em; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; background: var(--accent); color: var(--accent-text); }
.pill { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 560; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
nav.tabs { display: flex; gap: 2px; height: 100%; align-items: stretch; margin-right: auto; }
nav.tabs button, nav.tabs a {
  box-shadow: none; position: relative; display: inline-flex; align-items: center; height: 100%; padding: 0 12px; border: 0; background: none;
  color: var(--muted); font-size: 13.5px; font-weight: 540; border-radius: 0; text-decoration: none; box-shadow: none;
}
nav.tabs button:hover { color: var(--text); }
nav.tabs button[aria-selected="true"] { color: var(--text); }
nav.tabs button[aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-actions form { margin: 0; }

.segmented { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.segmented .seg { box-shadow: none; padding: 0; display: grid; place-items: center; width: 28px; height: 24px; border: 0; border-radius: 6px; background: none; color: var(--muted); }
.segmented .seg:hover { color: var(--text); }
.segmented .seg[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }

main.view { max-width: 1280px; margin: 0 auto; padding: 28px 20px 140px; }
.page-header { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 20px; }
.page-header > div:first-child { flex: 1; min-width: 260px; }
.page-title { font-size: 22px; font-weight: 650; margin: 0 0 4px; letter-spacing: -0.015em; }
.banner { background: var(--warn-soft); color: var(--warn-text); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 13px; margin-bottom: 16px; }

/* -- Cards, tables, lists ----------------------------------------------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card h2, .card h3 { margin-top: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); gap: 16px; }
.table-scroll { max-height: 360px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.data-table th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-weight: 560; font-size: 12px; text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); color: var(--text-2); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: var(--surface-2); }
.data-table td.num, .data-table th.num { text-align: right; }
.list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.list li { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.members { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 4px 16px; font-size: 13px; margin: 0; }
.members dt { font-weight: 560; color: var(--text); }
.members dd { margin: 0 0 8px; color: var(--muted); }
details summary { cursor: pointer; color: var(--text-2); font-weight: 540; font-size: 13px; margin: 12px 0 8px; list-style: none; display: inline-flex; align-items: center; gap: 6px; }
details summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform 0.15s; }
details[open] summary::before { transform: rotate(45deg); }
details summary::-webkit-details-marker { display: none; }

/* -- Ask ----------------------------------------------------------------- */

#view-ask { max-width: 900px; }
.empty { text-align: center; padding: 72px 0 8px; }
.empty h2 { font-size: 26px; font-weight: 650; margin: 0 0 8px; letter-spacing: -0.02em; }
.empty > p { color: var(--muted); max-width: 520px; margin: 0 auto; }
.suggestions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 28px auto 0; max-width: 720px; text-align: left; }
.suggestions button {
  height: auto; padding: 12px 14px; border-radius: var(--radius); white-space: normal;
  text-align: left; justify-content: flex-start; font-weight: 500; color: var(--text-2); line-height: 1.4;
}
.suggestions button:hover:not(:disabled) { border-color: var(--accent); color: var(--text); background: var(--surface); }
.sample-line { margin-top: 22px; font-size: 13px; color: var(--muted); }
.sample-banner { background: var(--accent-soft); color: var(--accent); border-radius: var(--radius-sm); padding: 9px 12px; font-size: 13px; }

.thread { display: grid; gap: 22px; }
.thread-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; margin-bottom: 16px; }
.msg-user { justify-self: end; max-width: 78%; background: var(--surface-3); color: var(--text); padding: 10px 14px; border-radius: 14px 14px 4px 14px; font-size: 14px; }
.msg-assistant { padding: 2px 0 0 40px; position: relative; }
.msg-assistant::before {
  content: ""; position: absolute; left: 0; top: 2px; width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 19V9M10 19V5M16 19v-7M22 19H2'/%3E%3C/svg%3E") center / 15px no-repeat;
}
.steps { list-style: none; margin: 0 0 10px; padding: 0; color: var(--muted); font-size: 12.5px; display: grid; gap: 3px; }
.steps li { display: flex; align-items: center; gap: 8px; }
.steps li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); flex: none; }
.steps li.running::before { width: 10px; height: 10px; background: none; border: 1.5px solid var(--accent); border-top-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.answer { color: var(--text-2); font-size: 14px; }
.answer > :first-child { margin-top: 0; }
.answer > :last-child { margin-bottom: 0; }
.answer strong { color: var(--text); font-weight: 600; }
.answer ul, .answer ol { padding-left: 20px; margin: 8px 0; }
.answer li { margin: 3px 0; }
.answer table { border-collapse: collapse; margin: 10px 0; font-size: 13px; font-variant-numeric: tabular-nums; display: block; overflow-x: auto; }
.answer th, .answer td { border-bottom: 1px solid var(--border); padding: 6px 12px 6px 0; text-align: left; }
.answer th { color: var(--muted); font-weight: 560; font-size: 12px; }

.composer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; padding: 16px 20px 18px; background: linear-gradient(to bottom, transparent, var(--bg) 35%); }
.composer form { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); padding: 8px; box-shadow: var(--shadow-pop); }
.composer form:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus), var(--shadow-pop); }
.composer-row { display: flex; gap: 6px; align-items: flex-end; }
.composer textarea { border: 0 !important; box-shadow: none !important; background: none; resize: none; min-height: 40px; max-height: 160px; padding: 9px 6px; font-size: 14.5px; }
.attach { box-shadow: none; padding: 0; display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 9px; background: none; color: var(--muted); flex: none; }
.attach:hover { background: var(--surface-2); color: var(--text); }
#send { height: 36px; border-radius: 9px; padding: 0 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 2px 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 6px; padding: 0 4px 0 8px; font-size: 12.5px; max-width: 100%; }
.chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; font-weight: 520; }
.chip .kind { color: var(--muted); }
.chip.error { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
.chip button { border: 0; background: none; padding: 0 4px; height: auto; color: var(--muted); box-shadow: none; }
.msg-user .chips { padding: 0 0 6px; justify-content: flex-end; }
.msg-user .chip { background: var(--surface); }
.drop-overlay { position: fixed; inset: 0; z-index: 40; background: color-mix(in srgb, var(--accent) 10%, transparent); display: grid; place-items: center; pointer-events: none; }
.drop-overlay p { background: var(--surface); border: 1.5px dashed var(--accent); border-radius: var(--radius-lg); padding: 22px 30px; font-weight: 600; box-shadow: var(--shadow-pop); }

/* -- Charts -------------------------------------------------------------- */

.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 10px; margin: 12px 0; box-shadow: var(--shadow); min-width: 0; }
.grid > .chart-card { margin: 0; }
.chart-card h3 { font-size: 13.5px; font-weight: 600; margin: 0 0 10px; color: var(--text); }
.chart-box { position: relative; height: 290px; }
.chart-actions { display: flex; flex-wrap: wrap; gap: 2px 4px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); align-items: center; }
.number { font-size: 34px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; padding: 8px 0 4px; }
.save-form, .share-box { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.save-form input { width: 240px; }
.share-url { width: min(340px, 70vw) !important; font-family: var(--mono); font-size: 12px !important; }

/* Chart editor */
.editor { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 14px; display: grid; gap: 10px; }
.editor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); gap: 10px 12px; }
.field { display: grid; gap: 5px; font-size: 12px; font-weight: 540; color: var(--muted); }
.field.wide { grid-column: 1 / -1; }
.field input, .field select { color: var(--text); font-weight: 400; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); font-weight: 450; }
.filters { display: grid; gap: 6px; }
.filter-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr) minmax(0, 2fr) auto; gap: 6px; align-items: center; }
.words { display: grid; gap: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.words .row { flex-wrap: nowrap; }
.words .row input { flex: 1; }

/* -- Dashboards ---------------------------------------------------------- */

.dash-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 14px; margin-top: 4px; }
.dash-card { display: grid; gap: 6px; align-content: start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; color: inherit; min-height: 128px; box-shadow: var(--shadow); transition: border-color 0.12s, transform 0.12s; }
.dash-card:hover { border-color: var(--border-strong); text-decoration: none; transform: translateY(-1px); }
.dash-card strong { font-size: 14.5px; font-weight: 620; color: var(--text); }
.dash-desc { font-size: 13px; color: var(--muted); }
.dash-card .note { margin-top: auto; }
.create-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0 0 16px; }
.create-form input { flex: 1 1 220px; width: auto; }
.back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.back:hover { color: var(--text); text-decoration: none; }
.dash-heading { min-width: 0; }
.dash-heading p { margin: 0; }

/* -- Measures and How it works ------------------------------------------ */

.how { max-width: 1000px; margin: 0 auto; }
.how h1 { font-size: 26px; }
.how h2 { font-size: 17px; margin: 40px 0 12px; }
.measures-list { display: grid; gap: 16px; margin-top: 16px; }
.defs td { vertical-align: top; }
.defs code { font-size: 12px; color: var(--text-2); background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }
#measures input[type=search] { max-width: 420px; }
.diagram-wrap { margin: 24px 0 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; overflow-x: auto; }
.diagram { width: 100%; min-width: 760px; height: auto; display: block; font-family: var(--font); }
.d-node rect { fill: var(--surface-2); stroke: var(--border-strong); stroke-width: 1.25; }
.d-node.accent rect { fill: var(--accent-soft); stroke: var(--accent); }
.d-node.strong rect { fill: var(--accent); stroke: var(--accent); }
.d-node.strong text { fill: var(--accent-text); }
.d-node.dashed rect { fill: none; stroke-dasharray: 5 4; stroke: var(--faint); }
.d-title { fill: var(--text); font-size: 15px; font-weight: 620; text-anchor: middle; }
.d-sub { fill: var(--muted); font-size: 12.5px; text-anchor: middle; }
.d-node.strong .d-sub { fill: var(--accent-text); opacity: 0.85; }
.d-lane { fill: var(--muted); font-size: 11px; letter-spacing: 0.08em; font-weight: 600; }
.d-label { fill: var(--muted); font-size: 12px; }
.d-edge { fill: none; stroke: var(--faint); stroke-width: 1.5; }
.d-edge.dashed { stroke-dasharray: 5 4; }
.d-arrowhead { fill: var(--faint); }
.steps-list { padding-left: 22px; display: grid; gap: 10px; max-width: 820px; color: var(--text-2); }
.steps-list strong { color: var(--text); }
.how-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 14px; }
.how-grid .card h3 { margin-bottom: 6px; font-size: 14.5px; }
.how-grid .card p { margin: 0 0 8px; color: var(--text-2); }
ul.plain { padding-left: 20px; display: grid; gap: 8px; max-width: 820px; color: var(--text-2); }

/* -- Login and share page ----------------------------------------------- */

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px; max-width: 420px; width: 100%; box-shadow: var(--shadow-pop); }
.login-card h1 { font-size: 22px; margin: 14px 0 8px; }
.login-card form { display: grid; gap: 8px; margin-top: 22px; }
.login-card label { font-weight: 560; font-size: 13px; }
.login-card button { height: 38px; margin-top: 6px; }
.share-view { max-width: 1100px; padding-bottom: 48px; }

/* -- Tooltips and menus (shared) ---------------------------------------- */

[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); font-size: 11.5px; font-weight: 520; padding: 4px 8px; border-radius: 5px;
  white-space: nowrap; pointer-events: none; z-index: 50;
}
.menu { position: absolute; z-index: 60; min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-pop); padding: 4px; }
.menu button { width: 100%; justify-content: flex-start; border: 0; box-shadow: none; background: none; height: 32px; padding: 0 10px; font-weight: 450; color: var(--text-2); }
.menu button:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

@media (max-width: 760px) {
  .topbar-inner { gap: 10px; padding: 0 14px; }
  .brand .pill { display: none; }
  nav.tabs button { padding: 0 8px; font-size: 13px; }
  main.view { padding: 20px 14px 140px; }
  .suggestions { grid-template-columns: 1fr; }
  .msg-user { max-width: 92%; }
  .msg-assistant { padding-left: 0; }
  .msg-assistant::before { display: none; }
  .chart-box { height: 240px; }
  .filter-row { grid-template-columns: 1fr 1fr; }
  .composer { padding: 10px 10px 12px; }
}
@media (max-width: 520px) {
  .brand strong { display: none; }
}

/* Dashboard filters, layout, history, export */
.dash-toolbar { align-items: flex-start; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin: 8px 0 6px; }
.filter-dates { display: flex; gap: 8px; align-items: flex-end; }
.filter-dates select, .filter-dates input { width: auto; }
.filter-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.filter-summary { margin: 4px 0 12px; }
details.ms { position: relative; }
details.ms > summary { list-style: none; cursor: pointer; display: grid; gap: 2px; border: 1px solid var(--border); border-radius: 8px; padding: 5px 10px; min-width: 140px; background: var(--surface); margin: 0; color: var(--text); }
details.ms > summary::-webkit-details-marker { display: none; }
details.ms[open] > summary { border-color: var(--accent); }
.ms-label { font-size: 12px; color: var(--muted); }
.ms-value { font-size: 14px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-pop { position: absolute; z-index: 10; top: calc(100% + 4px); left: 0; width: 280px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px; box-shadow: var(--shadow-pop); display: grid; gap: 8px; }
.ms-list { max-height: 240px; overflow: auto; display: grid; gap: 2px; }
.ms-option { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.ms-only { font-size: 12px; padding: 0 4px; visibility: hidden; }
.ms-option:hover .ms-only, .ms-only:focus-visible { visibility: visible; }
@media (hover: none) { .ms-only { visibility: visible; } }
.dash-grid > .w-full { grid-column: 1 / -1; }
.size-small .chart-box { height: 200px; }
.size-large .chart-box { height: 460px; }
.size-small .table-scroll { max-height: 200px; }
.size-large .table-scroll { max-height: 560px; }
.note-card .answer { font-size: 15px; }
.note-card.size-small { min-height: 0; }
.layout-tile { cursor: grab; border-style: dashed; }
.layout-tile.dragging { opacity: .5; }
.layout-tile.drop-target { border-color: var(--accent); }
.layout-tile textarea { width: 100%; }
.layout-head { gap: 8px; margin-bottom: 6px; }
.drag-hint { font-size: 12px; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; }
.layout-placeholder { display: grid; place-items: center; background: var(--surface-2); border-radius: 8px; min-height: 90px; padding: 10px; text-align: center; }
.size-large .layout-placeholder { min-height: 220px; }
.size-small .layout-placeholder { min-height: 50px; }
.layout-controls { gap: 10px; margin-top: 8px; font-size: 13px; }
.layout-controls select { width: auto; padding: 3px 6px; }
label.inline { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); }
.layout-bar .row { gap: 10px; }
.history .list li { align-items: flex-start; }
.badge { display: inline-block; margin-left: 8px; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); vertical-align: middle; }
pre.diff .add { color: var(--accent); }
pre.diff .del { color: var(--danger); }
.export-only { display: none; }
.dash-export.exporting { padding: 16px; }
.dash-export.exporting .export-only { display: block; }
@media (max-width: 640px) { .filter-actions { margin-left: 0; } .ms-pop { width: min(280px, 80vw); } }

/* Measures, drill-down, hover */
.def-line { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: -4px 0 6px; }
.def-chip { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 0; font-size: 12px; color: var(--muted); cursor: help; }
.def-chip:hover, .def-chip:focus-visible { color: var(--accent); }
.def-tip { position: fixed; z-index: 30; max-width: 340px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; box-shadow: var(--shadow-pop); font-size: 13px; pointer-events: none; }
.def-tip p { margin: 4px 0 6px; }
.def-tip code { display: block; font-size: 12px; background: var(--code-bg); border-radius: 6px; padding: 4px 6px; word-break: break-word; }
th[data-def] { cursor: help; }
.check[data-def] { cursor: help; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
.drill-menu { position: fixed; z-index: 25; min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px; box-shadow: var(--shadow-pop); display: grid; gap: 2px; }
.drill-menu .eyebrow { margin: 2px 6px 6px; }
.drill-menu button { text-align: left; border: 0; background: none; padding: 7px 8px; border-radius: 6px; }
.drill-menu button:hover, .drill-menu button:focus-visible { background: var(--accent-soft); color: var(--accent); }
.chart-card.drilled { border-left: 3px solid var(--accent); grid-column: 1 / -1; }
.drill-bar { display: flex; justify-content: space-between; align-items: center; margin: -4px 0 4px; }
.propose { margin-top: 14px; display: grid; gap: 10px; }
.propose h2 { margin: 0; }
.propose textarea { resize: vertical; }
.examples { gap: 6px; }
.chip-button { border-radius: 999px; font-size: 13px; padding: 4px 10px; }
.proposal { border-top: 1px solid var(--border); padding-top: 12px; display: grid; gap: 8px; }
.proposal h3 { margin: 0; }
.proposal-facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; font-size: 14px; }
.proposal-facts dt { color: var(--muted); }
.proposal-facts dd { margin: 0; }
pre.diff .add { color: var(--accent); }
pre.diff .ctx { color: var(--muted); }
.flash { background: var(--accent-soft); color: var(--accent); border-radius: 8px; padding: 8px 12px; }

/* Chat history and usage */
.ask-bar { display: flex; justify-content: flex-end; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.ask-bar .thread-tools { margin-bottom: 0; }
.ask-bar button { display: inline-flex; align-items: center; gap: 6px; }
.history-panel { margin-bottom: 14px; display: grid; gap: 10px; }
.history-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 360px; overflow: auto; }
.history-list li { display: flex; align-items: center; gap: 8px; border-radius: 8px; }
.history-list li.current { background: var(--accent-soft); }
.history-open { flex: 1; min-width: 0; display: grid; gap: 2px; text-align: left; border: 0; background: none; padding: 8px 10px; }
.history-open:hover { background: var(--surface-2); }
.history-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.usage-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); gap: 12px; margin: 16px 0; }
.usage-tile .number { font-size: 28px; }
.usage-tile p { margin: 0; }
.top-questions { padding-left: 20px; display: grid; gap: 4px; margin: 0; }

/* Feature buttons that aren't standard buttons */
.history-open, .ms-only, .def-chip, .drill-menu button, .chip-button { height: auto; box-shadow: none; }
.history-open { justify-content: flex-start; white-space: normal; }
.drill-menu button { justify-content: flex-start; height: 32px; padding: 0 10px; font-weight: 450; color: var(--text-2); }
.chip-button { height: 28px; padding: 0 10px; border-radius: 999px; font-weight: 450; color: var(--text-2); }
.filter-bar { box-shadow: var(--shadow); }
details.ms > summary { border-color: var(--border-strong); border-radius: var(--radius-sm); }
details.ms > summary::before { display: none; }
.badge { font-weight: 560; }
pre.diff .add { color: var(--success); }
.chart-card.drilled { border-left: 2px solid var(--accent); }
.flash { border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }

/* Chart card header, collapsed steps */
.chart-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 6px; }
.chart-head h3 { flex: 1; margin: 4px 0 0; }
.chart-head .chart-actions { margin: 0; padding: 0; border: 0; gap: 2px; flex-wrap: nowrap; }
.chart-card .def-line { margin: 0 0 8px; }
.chart-card > span:empty { display: none; }
.chart-card .save-form, .chart-card .share-box { margin-top: 10px; }
details.steps-wrap { margin: 0 0 10px; }
details.steps-wrap > summary { margin: 0 0 6px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
details.steps-wrap .steps { margin: 4px 0 0 14px; }

.ask-bar { min-height: 32px; }
.empty { padding-top: 48px; }
.sample-line { max-width: 720px; margin-left: auto; margin-right: auto; }
button.link.inline { color: var(--accent); padding: 0; margin: 0; font-size: inherit; }
button.link.inline:hover { background: none; text-decoration: underline; text-underline-offset: 2px; }
.dash-toolbar { flex-wrap: nowrap; align-items: flex-start; }
.dash-toolbar .dash-heading { flex: 1; }
.dash-toolbar .spacer { display: none; }
@media (max-width: 760px) { .dash-toolbar { flex-wrap: wrap; } }

/* Narrow screens: brand and actions on one row, tabs scroll on the next */
@media (max-width: 760px) {
  .topbar-inner { flex-wrap: wrap; height: auto; padding-top: 8px; gap: 6px 10px; }
  .header-actions { margin-left: auto; }
  nav.tabs { order: 3; width: 100%; height: 40px; margin: 0 -6px; overflow-x: auto; scrollbar-width: none; }
  nav.tabs::-webkit-scrollbar { display: none; }
  nav.tabs button { flex: none; }
  .page-header, .dash-toolbar { gap: 10px; }
}
@media (max-width: 760px) {
  .dash-toolbar .dash-heading { flex: 1 1 100%; }
  #measures .row code { overflow-wrap: anywhere; white-space: normal; }
  #measures .card { padding: 14px; }
  .proposal-facts { grid-template-columns: 1fr; }
  .filter-bar > * { flex: 1 1 140px; }
}
.measures-list > *, .grid > *, .how-grid > *, .dash-cards > * { min-width: 0; }
