:root {
  font-family: "Segoe UI", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  color: #20203a;
  background: #f8f8fc;
  color-scheme: light;
  --ink: #20203a;
  --muted: #676880;
  --border: #e7e6ef;
  --accent: #593dc8;
  --accent-dark: #472caf;
  --tint: #f1edff;
  --mono: "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; }
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible, textarea:focus-visible {
  outline: 2px solid #9379ed;
  outline-offset: 3px;
}
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.shell { min-height: 100dvh; display: grid; grid-template-columns: 238px minmax(0, 1fr); }
.sidebar {
  background: #1a182a;
  color: #f1eefb;
  padding: 28px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow: auto;
}
.sidebar > :not(.side-history) { flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 7px; }
.brand-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 1px solid #74618e;
  border-radius: 50%;
  object-fit: cover;
}
.brand strong { display: block; font-size: 17px; letter-spacing: .025em; }
.brand div span { display: block; color: #b2acc9; font-size: 12px; margin-top: 3px; }
.sidebar-actions {
  display: grid;
  gap: 4px;
  padding-bottom: 8px;
  margin-bottom: -8px;
  border-bottom: 1px solid #312a42;
}
.new-run {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 41px;
  padding: 8px 12px;
  border: 1px solid #68538e;
  border-radius: 8px;
  background: #3b2c57;
  color: #f4edff;
  font-size: 14px;
  font-weight: 650;
}
.new-run:hover:not(:disabled) { background: #49376a; }
.new-run span { color: #d1bdfc; font-size: 17px; line-height: 1; }
.demo-link {
  display: flex;
  align-items: center;
  justify-self: start;
  min-height: 34px;
  padding: 4px 12px;
  border-radius: 7px;
  color: #c9bddf;
  font-size: 13px;
  font-weight: 550;
  text-decoration: none;
}
.demo-link:hover { background: #2c263e; color: #fff; }
.side-section { min-width: 0; }
.side-label { margin: 0 9px 9px; color: #a8a1bf; font-size: 11px; letter-spacing: .1em; font-weight: 650; }
.mode-list, .history { display: grid; gap: 4px; }
.mode-button, .history button {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #d2cde4;
  font-size: 13px;
  text-align: left;
  padding: 11px 12px;
}
.mode-button { display: flex; align-items: center; gap: 10px; }
.mode-button:hover, .history button:hover { background: #2c263e; color: #fff; }
.history button.active { background: #3d2e5e; color: #fff; }
.mode-button.active { background: #302743; box-shadow: inset 2px 0 #bda9f1; color: #fff; font-weight: 650; }
.mode-icon { color: #b8a9e7; position: relative; flex: 0 0 14px; width: 14px; height: 14px; }
.icon-rag { border: 1.5px solid currentColor; border-radius: 3px; }
.icon-rag::after { content: ""; position: absolute; left: 3px; top: 4px; width: 5px; height: 2px; border-block: 1px solid currentColor; }
.icon-agent { background: currentColor; clip-path: polygon(50% 0, 62% 37%, 100% 50%, 62% 63%, 50% 100%, 37% 63%, 0 50%, 37% 37%); }
.icon-search::before { content: ""; position: absolute; width: 8px; height: 8px; border: 1.5px solid currentColor; border-radius: 50%; }
.icon-search::after { content: ""; position: absolute; width: 6px; height: 1.5px; background: currentColor; top: 10px; left: 8px; transform: rotate(45deg); }
.icon-library { border: 1.5px solid currentColor; border-radius: 3px; height: 11px; }
.icon-library::before { content: ""; position: absolute; left: 0; right: 4px; top: -4px; height: 3px; border-top: 1.5px solid currentColor; border-radius: 2px; }
.icon-orders { border: 1.5px solid currentColor; border-radius: 2px; width: 12px; }
.icon-orders::before { content: ""; position: absolute; inset: 3px 2px; border-block: 1.5px solid currentColor; }
.icon-models {
  background: linear-gradient(currentColor, currentColor) left 4px / 100% 1.5px no-repeat,
              linear-gradient(currentColor, currentColor) left 10px / 100% 1.5px no-repeat;
}
.icon-models::before, .icon-models::after { content: ""; position: absolute; width: 4px; height: 4px; border-radius: 1px; background: currentColor; }
.icon-models::before { top: 3px; left: 3px; }
.icon-models::after { top: 9px; right: 3px; }
.icon-usage {
  border-bottom: 1.5px solid currentColor;
  background: linear-gradient(currentColor, currentColor) 2px bottom / 2px 5px no-repeat,
              linear-gradient(currentColor, currentColor) 6px bottom / 2px 10px no-repeat,
              linear-gradient(currentColor, currentColor) 10px bottom / 2px 7px no-repeat;
}
.side-history { display: flex; flex: 1; flex-direction: column; min-height: 105px; }
.sidebar, .history { scrollbar-width: thin; scrollbar-color: #66577e transparent; }
.history-heading { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 6px; min-height: 28px; margin-bottom: 6px; }
.history-heading .side-label { margin-block: 0; }
.history { grid-template-columns: minmax(0, 1fr); grid-auto-rows: max-content; align-content: start; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; scrollbar-gutter: stable; }
.no-history { margin: 2px 10px 0; font-size: 12px; color: #a8a1bf; }
.history button { min-width: 0; min-height: 36px; overflow: hidden; white-space: nowrap; padding-block: 7px; line-height: 1.4; }
.history-title { display: block; overflow: hidden; text-overflow: ellipsis; }
.history-meta { display: block; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; color: #b9afcf; font-size: 11px; }
.history-status:not(:empty) { margin: 6px 9px; color: #d2cde4; font-size: 12px; }
.history-status:empty { margin: 0; }
.history-more { flex-shrink: 0; padding: 5px 8px; border: 0; border-radius: 6px; color: #cfbafb; background: transparent; font-size: 12px; white-space: nowrap; }
.history-retry { align-self: flex-start; margin-left: 1px; }
.history-more:hover:not(:disabled), .history-more.active { background: #2c263e; }
.history button:focus-visible { outline-offset: -2px; }

.workspace { min-width: 0; }
.topbar { height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 30px; border-bottom: 1px solid var(--border); background: #fff; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 11px; font-size: 13px; color: var(--muted); }
.breadcrumb strong { color: var(--ink); font-weight: 650; }
.slash { color: #a19bb3; }
.model-settings-button { border: 1px solid var(--border); border-radius: 8px; padding: 6px 11px; color: var(--accent-dark); background: #fff; font-size: 13px; font-weight: 650; white-space: nowrap; }
.model-settings-button:hover:not(:disabled) { background: var(--tint); border-color: #bcaaed; }
.provider-page { max-width: 1250px; margin-inline: auto; padding: clamp(28px, 5vw, 58px) clamp(16px, 4vw, 54px) 48px; }
.provider-page-header { margin-bottom: 24px; }
.provider-page-header h1 { margin: 0 0 8px; font-size: clamp(27px, 4vw, 39px); line-height: 1.15; }
.provider-page-header p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.65; }
.provider-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 16px; margin: 0 0 13px; }
.provider-filter { display: flex; flex: 0 1 410px; align-items: center; min-width: 0; gap: 10px; }
.provider-filter input { flex: 1; width: 100%; min-width: 0; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--ink); font-size: 13px; }
.provider-default { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 8px; min-width: 0; max-width: 100%; font-size: 12px; }
.provider-default > span { white-space: nowrap; color: var(--muted); }
.provider-default strong { min-width: 0; overflow-wrap: anywhere; }
.provider-default button { padding: 5px 8px; font-size: 12px; }
.provider-count { white-space: nowrap; font-size: 12px; color: var(--muted); }
.provider-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(245px, 100%), 1fr)); gap: 13px; }
.provider-card { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.provider-card[data-active="true"] { border-color: #ab94e8; box-shadow: 0 0 0 1px #ad96e62c; }
.provider-card-body { flex: 1; min-width: 0; padding: 17px 16px 14px; }
.provider-card-head { display: flex; justify-content: space-between; gap: 6px; align-items: flex-start; margin-bottom: 12px; }
.provider-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: #f0e9ff; color: #542da8; font: 700 13px var(--mono); }
.provider-card[data-provider="deepseek"] .provider-mark { background: #e8efff; color: #2e4b99; }
.provider-card[data-provider="openai"] .provider-mark { background: #e4f3ed; color: #215c49; }
.provider-card[data-provider="gemini"] .provider-mark { background: #f4e9f9; color: #7a3988; }
.provider-card[data-provider="xai"] .provider-mark { background: #ededf3; color: #333347; }
.provider-badge { border-radius: 20px; background: #f2f1f7; color: var(--muted); font-size: 11px; font-weight: 650; padding: 4px 8px; white-space: nowrap; }
.provider-badge[data-state="configured"] { background: #e7f6ed; color: #215a41; }
.provider-badge[data-state="active"] { background: #eee7fe; color: var(--accent-dark); }
.provider-card h2 { margin: 0 0 5px; font-size: 17px; }
.provider-card-endpoint { margin: 5px 0 0; overflow-wrap: anywhere; font: 11px/1.5 var(--mono); color: var(--muted); }
.provider-card-actions { display: flex; flex-wrap: wrap; gap: 7px; padding: 11px 16px; border-top: 1px solid var(--border); }
.provider-card-actions .run-button { font-size: 12px; }
.provider-models { list-style: none; margin: 0 16px 12px; padding: 0; }
.provider-model { display: flex; flex-wrap: wrap; gap: 6px 9px; align-items: flex-start; padding: 9px; background: #f8f7fc; border-radius: 8px; }
.provider-model + .provider-model { margin-top: 7px; }
.provider-model-name { display: grid; flex: 1; min-width: 0; gap: 3px; font-size: 13px; overflow-wrap: anywhere; }
.provider-model-name span { color: var(--muted); font-size: 11px; }
.provider-model-actions { display: flex; flex-wrap: wrap; flex-basis: 100%; gap: 6px; }
.provider-model-actions button { padding: 4px 7px; font-size: 11px; }
.provider-empty { margin: 6px 0; color: var(--muted); font-size: 13px; }
.provider-page > .model-status:not(:empty) { margin: 0 0 12px; }
.usage-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 14px; }
.usage-filters label { max-width: 100%; }
.usage-filters select { width: min(100%, 280px); min-width: 150px; }
.usage-filters .run-button { min-height: 35px; }
.usage-status { margin: 14px 0; color: var(--muted); font-size: 13px; }
.usage-status.error { color: #a22c48; }
.usage-page { padding-top: clamp(24px, 3.2vw, 40px); }
.usage-page .provider-page-header { margin-bottom: 18px; }
.usage-section-title { margin: 0 0 14px; font-size: 17px; }
.guest-budget, .usage-report {
  min-width: 0;
  padding: clamp(14px, 1.7vw, 20px);
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #fff;
}
.guest-budget { margin-bottom: 16px; }
.guest-budget-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 18px; }
.guest-budget h2 { margin: 0; font-size: 17px; }
.guest-budget-header time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.guest-budget-layout { display: grid; grid-template-columns: minmax(230px, .92fr) minmax(0, 1.8fr); gap: 14px; align-items: start; margin-top: 12px; }
.guest-budget-overview { min-width: 0; padding: 12px 14px; border: 1px solid #eee9f8; border-radius: 9px; background: #faf8ff; }
.guest-budget-total { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; margin: 0; color: var(--muted); font-size: 13px; }
.guest-budget-total strong { color: var(--accent-dark); font-size: clamp(20px, 2.1vw, 26px); font-weight: 700; font-variant-numeric: tabular-nums; }
.guest-budget-meter { appearance: none; display: block; width: 100%; height: 6px; margin: 9px 0 6px; overflow: hidden; border: 0; border-radius: 8px; background: #ede8f7; color: var(--accent); }
.guest-budget-meter::-webkit-progress-bar { border-radius: 8px; background: #ede8f7; }
.guest-budget-meter::-webkit-progress-value { border-radius: 8px; background: var(--accent); }
.guest-budget-meter::-moz-progress-bar { border-radius: 8px; background: var(--accent); }
.guest-budget-balance { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 8px; color: var(--muted); font-size: 12px; }
.guest-budget-balance strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.guest-budget-breakdown { margin: 0; border: 1px solid var(--border); border-radius: 8px; }
.guest-budget-breakdown > div {
  display: grid;
  grid-template-columns: minmax(78px, .8fr) minmax(84px, .85fr) minmax(0, 2.5fr);
  align-items: baseline;
  gap: 4px 10px;
  padding: 8px 11px;
  font-size: 13px;
}
.guest-budget-breakdown > div + div { border-top: 1px solid var(--border); }
.guest-budget-breakdown dt { font-weight: 650; }
.guest-budget-breakdown dd { min-width: 0; margin: 0; }
.guest-budget-amount { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.guest-budget-explanation { color: var(--muted); line-height: 1.5; }
.guest-budget-legacy { border-radius: 0 0 7px 7px; background: #f7f3ff; }
.guest-budget-legacy .guest-budget-amount { color: var(--accent-dark); }
.guest-budget-comparison { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 8px; margin-top: 9px; padding-top: 8px; border-top: 1px solid #eee9f8; color: var(--muted); font-size: 12px; }
.guest-budget-comparison strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.guest-budget-holds { margin-top: 16px; }
.guest-budget-holds h3 { margin: 0 0 7px; font-size: 13px; }
.guest-budget-table { max-height: 280px; }
.guest-budget-table th { position: sticky; top: 0; }
.usage-report .usage-filters { display: grid; grid-template-columns: repeat(2, minmax(114px, 1fr)) minmax(150px, 1.4fr) minmax(112px, 1fr) auto; }
.usage-report .usage-filters label, .usage-report .usage-filters select { width: 100%; min-width: 0; }
.usage-report .usage-filters input, .usage-report .usage-filters select, .usage-report .usage-filters .run-button { min-height: 38px; }
.usage-report .usage-status:empty { display: none; }
.usage-report .usage-table tbody tr:nth-child(even) { background: #fbfaff; }
.run-history-filters label:first-child { flex: 1 1 210px; }
.run-history-results { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.run-history-row {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) auto minmax(104px, auto);
  align-items: baseline;
  gap: 6px 20px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}
.run-history-row:hover { border-color: #bcaaed; background: #fcfaff; }
.run-history-row strong { font-size: 14px; overflow-wrap: anywhere; }
.run-history-row time, .run-history-state { color: var(--muted); font-size: 12px; }
.run-history-state[data-status="failed"], .run-history-state[data-status="completed_with_errors"] { color: #a22c48; }
.run-history-pagination { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 16px; color: var(--muted); font-size: 13px; }
.run-history-pagination button:disabled { opacity: .5; cursor: default; }
.usage-totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.65fr); margin: 13px 0; border: 1px solid #eee9f8; border-radius: 9px; background: #faf8ff; }
.usage-totals div { min-width: 0; padding: 10px 13px; }
.usage-totals div + div { border-inline-start: 1px solid #eae5f5; }
.usage-totals dt { color: var(--muted); font-size: 12px; }
.usage-totals dd { margin: 4px 0 0; color: var(--accent-dark); font-size: clamp(17px, 2.1vw, 23px); font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
#token-cost-total { font-size: clamp(14px, 1.5vw, 19px); }
.usage-note { margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.usage-note a { color: var(--accent-dark); }
.usage-table { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.usage-table table { width: 100%; border-collapse: collapse; white-space: nowrap; font-size: 13px; }
.usage-table th, .usage-table td { padding: 12px 14px; text-align: right; font-variant-numeric: tabular-nums; }
.usage-table th:nth-child(-n+3), .usage-table td:nth-child(-n+3) { text-align: left; }
.usage-table th { background: var(--tint); }
.usage-table td { border-top: 1px solid var(--border); }
.usage-table:focus-visible { outline: 2px solid #9379ed; outline-offset: 3px; }
.usage-call-link { font-variant-numeric: tabular-nums; text-decoration: underline; text-underline-offset: 3px; }
.model-dialog.usage-runs-dialog { width: min(850px, calc(100% - 32px)); }
.usage-runs-group { margin: 0 0 12px; color: var(--muted); font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
#usage-runs-status:empty { display: none; }
.usage-runs-table th:nth-child(n+2), .usage-runs-table td:nth-child(n+2) { text-align: right; }
.usage-runs-table td:first-child { min-width: 170px; max-width: 280px; white-space: normal; overflow-wrap: anywhere; }
.usage-runs-table .usage-run-link { padding: 0; text-align: left; overflow-wrap: anywhere; }
.usage-run-meta { display: flex; flex-wrap: wrap; gap: 3px 8px; margin-top: 4px; color: var(--muted); font-size: 11px; }
.usage-run-count { display: block; }
.usage-run-missing { color: var(--muted); font-size: 11px; }
.model-dialog { width: min(448px, calc(100% - 32px)); max-height: calc(100% - 32px); border: 1px solid var(--border); border-radius: 14px; padding: 20px; color: var(--ink); box-shadow: 0 20px 70px #1a123646; }
.model-dialog::backdrop { background: #1a182a70; }
.model-dialog-header, .model-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.model-dialog-header { margin-bottom: 16px; }
.model-dialog-header h2 { margin: 0; font-size: 19px; }
.model-close { border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 21px; line-height: 1; padding: 5px 8px; }
.model-close:hover { background: var(--tint); }
.model-field { display: grid; gap: 6px; margin: 0; font-size: 13px; font-weight: 650; }
.model-field input, .model-field select { min-width: 0; width: 100%; border: 1px solid #d8d4e4; border-radius: 7px; padding: 8px; color: var(--ink); background: #fff; font-weight: 400; }
.model-fields { display: grid; gap: 12px; min-width: 0; border: 0; margin: 12px 0 0; padding: 0; }
.model-help, .model-status { margin: 0; color: var(--muted); font-size: 12px; }
.model-actions { justify-content: flex-end; margin-top: 16px; }
.model-status:not(:empty) { margin-top: 10px; }
.model-status.error { color: #a22c48; }
.orders-page { max-width: none; padding-inline: clamp(16px, 3vw, 32px); }
.orders-filters label { flex: 0 1 280px; min-width: 0; }
.orders-filters label input { min-height: 35px; }
.orders-filters > button { min-height: 35px; }
.orders-table table { white-space: normal; }
.orders-table th, .orders-table td { text-align: left; }
.orders-table th:nth-child(5), .orders-table td:nth-child(5) { text-align: right; white-space: nowrap; }
.orders-table tr:nth-child(even) { background: #fbfaff; }
.orders-table tbody tr:hover { background: #f8f5ff; }
.orders-table .library-link { padding: 0; font-family: var(--mono); overflow-wrap: anywhere; text-align: left; }
.order-status { display: inline-block; border-radius: 6px; padding: 3px 7px; color: #51416e; background: var(--tint); white-space: nowrap; font-size: 12px; }
.order-status[data-status="已到账"] { color: #276851; background: #e3f4ea; }
.order-status[data-status="已拒绝"], .order-status[data-status="供应商取消"] { color: #94344e; background: #fae9ee; }
.order-dialog { width: min(610px, calc(100% - 32px)); }
.order-dialog h2, .order-product, .order-facts dd, .order-refund { overflow-wrap: anywhere; }
.order-product { margin: 0 0 14px; font-size: 14px; font-weight: 650; }
.order-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 120px), 1fr)); gap: 12px; margin: 0; padding: 12px; border-radius: 9px; background: #f8f7fc; }
.order-facts dt { margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.order-facts dd { margin: 0; font-size: 13px; }
.order-refunds-title { margin: 18px 0 8px; font-size: 15px; }
.order-refunds { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.order-refund { display: grid; gap: 4px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.order-refund-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; }
.order-refund p { margin: 0; color: var(--muted); }
.columns { display: grid; grid-template-columns: minmax(0, 1fr) 330px; min-height: calc(100dvh - 62px); }
.experiment { display: flex; flex-direction: column; min-width: 0; }
.content { flex: 1; padding: clamp(30px, 6vh, 75px) clamp(23px, 5vw, 72px) 28px; }
.welcome, .result { max-width: 790px; margin-inline: auto; }
.welcome-mark {
  height: 52px;
  width: 52px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: #ece7ff;
  border: 1px solid #e4dafa;
  color: var(--accent);
  font-size: 24px;
}
.welcome h1 { font-size: clamp(29px, 4vw, 47px); font-weight: 760; line-height: 1.14; letter-spacing: -.03em; margin: 17px 0 9px; }
.welcome p { margin: 0 0 25px; font-size: 14px; color: var(--muted); line-height: 1.75; max-width: 46ch; }
.examples-heading { margin: 0 0 10px; font-size: 12px; font-weight: 700; color: var(--muted); }
.examples { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.example { min-width: 0; border: 1px solid var(--border); background: #fff; border-radius: 12px; padding: 13px 15px; color: var(--ink); text-align: left; }
.example:hover { border-color: #b4a2ef; background: #fbf9ff; }
.example span { display: block; margin-bottom: 4px; color: var(--accent); font-weight: 650; font-size: 11px; }
.example strong { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; line-height: 1.5; font-weight: 620; overflow-wrap: anywhere; }
.example strong b { display: grid; flex: 0 0 22px; place-items: center; height: 22px; border-radius: 6px; background: var(--tint); color: var(--accent); font-weight: 600; }
.result h1 { font-size: clamp(25px, 3vw, 37px); line-height: 1.3; letter-spacing: -.02em; margin: 12px 0 22px; overflow-wrap: anywhere; }
.result-kicker { font-size: 12px; color: var(--accent); font-weight: 700; margin: 0; }
.answer-card { padding: clamp(18px, 3vw, 28px); background: white; border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 5px 18px #26203f06; }
.answer-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 15px; }
.answer-head h2 { font-size: 14px; margin: 0; }
.answer-head span, .view-hits { font-size: 11px; color: var(--accent); background: var(--tint); border-radius: 6px; padding: 4px 7px; }
.view-hits { border: 1px solid transparent; }
.view-hits:hover { border-color: #bcaaed; }
.answer-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.85; margin: 0; }
.citation-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.loading { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 9px; }
.loading::before { content: ""; width: 15px; height: 15px; border-radius: 50%; border: 2px solid #e5d9ff; border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.composer-area { padding: 8px clamp(23px, 5vw, 72px) 20px; }
.composer { max-width: 790px; margin-inline: auto; border: 1px solid #dedbed; border-radius: 16px; background: #fff; padding: 12px; box-shadow: 0 6px 22px #2b205412; }
.composer:focus-within { border-color: #a894e7; box-shadow: 0 0 0 3px #f0eaff, 0 6px 22px #2b205412; }
.composer textarea { display: block; width: 100%; padding: 7px 8px; resize: vertical; min-height: 60px; max-height: 180px; border: 0; color: var(--ink); outline: 0; line-height: 1.5; font-size: 14px; }
.composer textarea::placeholder { color: #747287; }
.composer-bar { display: flex; justify-content: space-between; align-items: end; gap: 8px; margin-top: 6px; padding-top: 9px; border-top: 1px solid #efedf5; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; min-width: 0; }
.engine-field { display: inline-flex; position: relative; }
.settings { position: relative; }
.settings summary, .engine-field select {
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid #e8e3f3;
  border-radius: 8px;
  background: #f8f6fc;
  color: #4d4967;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.settings summary { display: flex; align-items: center; gap: 9px; list-style: none; }
.settings summary::-webkit-details-marker { display: none; }
.settings summary:hover, .engine-field select:hover:not(:disabled) { border-color: #d5c7ee; background: #f3eeff; }
.settings[open] summary { border-color: #cbbcf1; background: var(--tint); color: var(--accent-dark); }
.settings summary::after, .engine-field::after {
  content: "";
  flex: 0 0 auto;
  inline-size: 6px;
  block-size: 6px;
  border-inline-end: 1.5px solid currentColor;
  border-block-end: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}
.settings[open] summary::after { transform: translateY(1px) rotate(225deg); }
.engine-field select { appearance: none; padding-inline-end: 28px; }
.engine-field::after { position: absolute; top: 50%; inset-inline-end: 12px; transform: translateY(-70%) rotate(45deg); color: #4d4967; pointer-events: none; }
.engine-field select:disabled { opacity: .65; cursor: wait; }
@supports (appearance: base-select) and selector(select::picker(select)) {
  .engine-field select, .engine-field select::picker(select) { appearance: base-select; }
  .engine-field::after { content: none; }
  .engine-field select { align-items: center; gap: 9px; padding-inline-end: 11px; }
  .engine-field select:open { border-color: #cbbcf1; background: var(--tint); color: var(--accent-dark); }
  .engine-field select::picker-icon {
    content: "";
    flex: 0 0 auto;
    inline-size: 6px;
    block-size: 6px;
    border-inline-end: 1.5px solid currentColor;
    border-block-end: 1.5px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
  }
  .engine-field select:open::picker-icon { transform: translateY(1px) rotate(225deg); }
  .engine-field select::picker(select) {
    min-width: 158px;
    margin-block: 6px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: #fff;
    box-shadow: 0 8px 24px #21174623;
  }
  .engine-field option { min-height: 32px; gap: 10px; padding: 6px 9px; border-radius: 6px; color: #4d4967; }
  .engine-field option:checked { background: var(--tint); color: var(--accent-dark); font-weight: 650; }
  .engine-field option:hover, .engine-field option:focus-visible { background: #eae3fb; }
  .engine-field option::checkmark { order: 1; margin-inline-start: auto; color: var(--accent); }
}
.settings-panel {
  display: grid;
  gap: 10px;
  position: absolute;
  bottom: calc(100% + 8px);
  inset-inline-start: 0;
  z-index: 2;
  width: min(225px, calc(100vw - 48px));
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fff;
  box-shadow: 0 8px 24px #21174623;
}
.settings-panel label { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: #4d4967; font-size: 12px; font-weight: 600; }
.settings-panel input { width: 68px; min-height: 32px; border: 1px solid #d8d4e4; background: #fcfbff; color: var(--ink); padding: 4px 6px; border-radius: 6px; font-variant-numeric: tabular-nums; }
.composer-bar .run-button { flex: 0 0 auto; min-height: 36px; }
.run-button { background: var(--accent); color: white; border: 0; border-radius: 9px; padding: 8px 13px; font-size: 13px; font-weight: 650; min-width: 80px; white-space: nowrap; }
.run-button:hover { background: var(--accent-dark); }
.run-button:disabled { opacity: .7; }
.composer-note { max-width: 790px; margin: 9px auto 0; color: var(--muted); text-align: center; font-size: 11px; min-height: 16px; }
.composer-note.error { color: #a22c48; font-size: 12px; }

.inspector { background: #fff; border-left: 1px solid var(--border); min-width: 0; }
.inspector-header { padding: 20px 20px 7px; }
.inspector-header h2 { font-size: 16px; margin: 0; }
.tab-bar { display: flex; gap: 16px; border-bottom: 1px solid var(--border); padding: 0 20px; }
.tab-bar button { border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: 12px; font-weight: 650; padding: 11px 0 9px; }
.tab-bar button:hover, .tab-bar button.active { color: var(--accent); }
.tab-bar button.active { border-bottom-color: var(--accent); }
#hit-count { background: var(--tint); margin-left: 2px; padding: 1px 5px; border-radius: 4px; color: var(--accent); }
.details { padding: 20px; }
.detail-note { color: var(--muted); font-size: 12px; line-height: 1.65; margin: 0 0 16px; }
.trace-summary { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 16px; font-size: 12px; }
.trace-header, .trace-phase-list li { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.trace-header > span, .trace-phase-list code { font: 11px var(--mono); white-space: nowrap; color: var(--muted); }
.trace-status { padding: 3px 7px; border-radius: 5px; color: #24654d; background: #edf7f1; }
.trace-status[data-status="completed_with_errors"], .trace-status[data-status="failed"] { color: #a22c48; background: #fae9ee; }
.step-error { color: #a22c48; }
.trace-metrics { display: flex; flex-wrap: wrap; gap: 6px 10px; margin: 8px 0 0; color: var(--muted); }
.trace-diagnostics { border-top: 1px solid var(--border); padding-top: 9px; margin-top: 10px; }
.trace-config { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 10px; margin: 12px 0 0; }
.trace-config dt { color: var(--muted); }
.trace-config dd { margin: 0; overflow-wrap: anywhere; }
.trace-id { display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 5px; }
.trace-id code { font: 10px var(--mono); }
.trace-id button { font-size: 11px; padding: 0; }
.trace-phases { border-top: 1px solid var(--border); padding-top: 9px; margin-top: 10px; }
.trace-phases h3 { margin: 0; font-size: 12px; }
.trace-phase-list { list-style: none; padding: 0; margin: 7px 0 0; }
.trace-phase-list li + li { margin-top: 5px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.step { position: relative; margin-left: 10px; border-left: 1px solid #e9e2fb; padding: 0 0 18px 16px; font-size: 13px; min-width: 0; }
.step:last-child { border-color: transparent; padding-bottom: 0; }
.step::before { content: ""; position: absolute; top: 4px; left: -5px; width: 7px; height: 7px; border: 1px solid #b898f0; background: var(--tint); border-radius: 50%; }
.step-label { display: block; font-weight: 650; overflow-wrap: anywhere; }
.step-node { display: block; font-family: var(--mono); color: var(--muted); font-size: 11px; margin-top: 4px; }
.step pre { font: 11px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; margin: 8px 0 0; padding: 8px; border-radius: 6px; background: #f8f7fc; }
.step-detail { margin-top: 7px; }
.step-detail pre { max-block-size: 260px; overflow: auto; }
.call-id { display: block; margin-top: 6px; color: var(--muted); font: 10px/1.4 var(--mono); overflow-wrap: anywhere; }
.hit-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; }
.detail-toggle { cursor: pointer; color: var(--accent-dark); font-size: 12px; font-weight: 650; }
.detail-toggle:hover { text-decoration: underline; }
.detail-toggle::marker { font-size: 10px; }
.hit { border: 1px solid var(--border); border-radius: 9px; padding: 12px; min-width: 0; background: #fff; }
.hit-cited { border-color: #e4dcf5; }
.hit-title { margin: 0; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.hit-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 9px; margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.hit-score { font-variant-numeric: tabular-nums; }
.hit-keyword { color: var(--accent-dark); }
.hit-quote, .hit-text { font-size: 12px; line-height: 1.65; color: #4e4b60; white-space: pre-wrap; overflow-wrap: anywhere; }
.hit-quote { margin: 10px 0 0; padding: 7px 9px; border-inline-start: 2px solid #bba4e9; background: #f8f5fd; }
.hit-quote-text { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.hit:has(.hit-context[open]) .hit-quote { display: none; }
.hit-context { margin-top: 9px; }
.hit-text { margin: 8px 0 0; }
.hit mark { color: inherit; background: #eee6ff; border-radius: 3px; }

.library { padding: clamp(28px, 6vh, 68px) clamp(16px, 3vw, 32px) 40px; }
.library-header { margin-bottom: 24px; }
.library-header h1 { font-size: clamp(28px, 4vw, 42px); line-height: 1.15; margin: 0 0 12px; }
.library-header p, .import-card p { color: var(--muted); font-size: 13px; line-height: 1.6; }
.library-header p { margin: 0; }
.import-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: clamp(17px, 3vw, 25px); margin-bottom: 16px; }
.import-card h2 { margin: 0; font-size: 16px; }
.import-card p { margin: 8px 0 14px; }
.import-card input[type="file"] { display: block; width: 100%; color: var(--muted); background: #faf9fe; border: 1px dashed #cdc3ea; border-radius: 8px; padding: 10px; font-size: 13px; }
.import-card input::file-selector-button { border: 0; border-radius: 6px; padding: 7px 10px; margin-right: 10px; color: var(--accent-dark); background: var(--tint); cursor: pointer; }
.upload-selection { padding-left: 18px; color: var(--muted); font-size: 12px; line-height: 1.65; overflow-wrap: anywhere; }
.upload-access { display: grid; gap: 6px; max-width: 310px; margin-top: 12px; color: var(--ink); font-size: 13px; }
.upload-access input { border: 1px solid var(--border); border-radius: 6px; padding: 8px; min-width: 0; }
.import-controls, .document-heading { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.import-controls { margin-top: 14px; }
.document-heading { justify-content: space-between; }
.import-card .upload-status { margin: 0; overflow-wrap: anywhere; }
.import-card .upload-context { background: var(--tint); padding: 7px 9px; border-radius: 5px; }
.import-card .error { color: #a22c48; }
#document-count { color: var(--accent); background: var(--tint); padding: 2px 7px; border-radius: 6px; font-size: 12px; margin-left: 4px; }
.library-link { color: var(--accent-dark); background: transparent; border: 0; padding: 4px; font-size: 13px; font-weight: 650; }
.library-link:hover { text-decoration: underline; }
.document-list { list-style: none; margin: 12px 0 0; padding: 0; }
.document-list li { border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 10px 0; font-size: 13px; overflow-wrap: anywhere; }
.document-source { min-width: 0; }
.document-actions { display: flex; align-items: baseline; flex-shrink: 0; gap: 8px; }
.document-chunks { color: var(--muted); font-size: 12px; }
.document-delete-button { color: #a22c48; }
.document-delete-notice:empty { display: none; }
.document-delete-summary { margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.document-delete-confirm { background: #a22c48; }
.document-delete-confirm:hover { background: #80213a; }

@media (max-width: 1130px) {
  .shell { grid-template-columns: 192px minmax(0, 1fr); }
  .columns { grid-template-columns: minmax(0, 1fr) 284px; }
  .content, .composer-area { padding-inline: 29px; }
}
@media (max-width: 1020px) {
  .guest-budget-layout { grid-template-columns: minmax(0, 1fr); gap: 9px; }
  .usage-report .usage-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .usage-report .usage-filters .run-button { justify-self: start; }
}
@media (max-width: 900px) {
  .usage-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .usage-totals div:nth-child(3) { border-inline-start: 0; }
  .usage-totals div:nth-child(n+3) { border-top: 1px solid #eae5f5; }
  .columns { grid-template-columns: minmax(0, 1fr); }
  .experiment { min-height: 510px; }
  .inspector { border-left: 0; border-top: 1px solid var(--border); }
}
@media (min-width: 641px) and (max-height: 680px) {
  .sidebar { gap: 16px; padding-block: 18px 12px; }
  .mode-button { padding-block: 8px; }
  .side-history { flex: none; min-height: 0; }
  .history { overflow: visible; scrollbar-gutter: auto; }
}
@media (max-width: 640px) {
  .shell { display: block; }
  .sidebar { position: static; height: auto; padding: 13px 16px; gap: 12px; overflow: visible; }
  .brand { padding: 0; }
  .brand-avatar { width: 34px; height: 34px; flex-basis: 34px; }
  .sidebar-actions { margin-bottom: 0; padding-bottom: 4px; }
  .new-run { position: absolute; right: 16px; top: 15px; min-height: 32px; padding: 4px 8px; font-size: 12px; }
  .mode-list { display: flex; gap: 4px; }
  .mode-button { width: auto; flex: 1; font-size: 11px; padding: 8px 6px; gap: 5px; justify-content: center; }
  .side-section > .side-label, .side-history:has(.no-history):has(#open-run-history[hidden]) { display: none; }
  .side-admin > .side-label { display: block; margin: 0 0 5px; }
  .side-history { min-height: 0; max-width: 100%; }
  .history { display: flex; overflow: auto; scrollbar-gutter: auto; }
  .history button { width: auto; flex: 0 0 auto; max-width: 200px; padding: 5px 8px; font-size: 11px; }
  .run-history-row { grid-template-columns: auto minmax(0, 1fr); }
  .run-history-row strong { grid-column: 1 / -1; }
  .orders-table .order-secondary { display: none; }
  .orders-table th, .orders-table td { padding: 9px 6px; overflow-wrap: anywhere; }
  .topbar { height: 50px; padding-inline: 16px; }
  .usage-totals div { padding: 10px 8px; }
  .guest-budget-breakdown > div { grid-template-columns: minmax(0, 1fr) auto; }
  .guest-budget-explanation { grid-column: 1 / -1; }
  .guest-budget-table table { table-layout: fixed; white-space: normal; font-size: 12px; }
  .guest-budget-table th, .guest-budget-table td { padding: 8px 6px; overflow-wrap: anywhere; }
  .guest-budget-table th:first-child { width: 62px; }
  .guest-budget-table th:last-child { width: 84px; }
  .content, .composer-area { padding-inline: 16px; }
  .experiment { min-height: 470px; }
  .examples { gap: 8px; }
  .example { padding: 10px; }
  .inspector-header, .tab-bar, .details { padding-inline: 16px; }
}
@media (max-width: 440px) {
  .mode-button { white-space: nowrap; }
  .mode-icon { display: none; }
  .composer-bar { position: relative; }
  .settings { position: static; }
  .settings-panel { bottom: calc(100% + 1px); }
}
@media (max-width: 360px) {
  .mode-list { display: grid; grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { .loading::before { animation: none; } }
