:root {
  --teal: #0e6a5e;
  --teal-dark: #0a544b;
  --teal-soft: #f1f8f5;
  --teal-line: #dbe7e2;
  --teal-mid: #c9d9d3;
  --ok: #12a37a;
  --paper: #f4f4f1;
  --surface: #fafaf8;
  --white: #ffffff;
  --ink: #15181c;
  --muted: #8b8f96;
  --muted-2: #7a7f86;
  --text-2: #3f444c;
  --line: #e5e4df;
  --line-soft: #ecebe6;
  --line-faint: #f2f1ed;
  --warn-bg: #fdf6e8;
  --warn-border: #eddfc4;
  --warn-ink: #8a5a12;
  --warn-body: #6b6250;
  --quote-bg: #fdf8ec;
  --quote-border: #e3c98a;
  --quote-ink: #4a4437;
  --shadow: 0 1px 2px rgba(20, 24, 28, 0.05);
  --font: Manrope, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --left-w: 248px;
  --right-w: 330px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 500 13.5px/1.45 var(--font);
  overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.min0 { min-width: 0; }
.flex-spacer { flex: 1; }
.pad { padding: 12px; }

.app {
  height: 100vh;
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr);
  overflow: hidden;
  background: var(--paper);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 12px 0 14px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--teal); color: #fff;
  display: grid; place-items: center;
  font: 800 10px var(--font); letter-spacing: -0.02em;
}
.brand-mark.lg { width: 34px; height: 34px; border-radius: 10px; font-size: 13px; }
.brand-name { font: 700 13.5px var(--font); }
.topbar-sep { width: 1px; height: 20px; background: var(--line); }

.source-pill {
  display: flex; align-items: center; gap: 7px;
  height: 28px; padding: 0 9px;
  border: 1px solid var(--line); background: #fbfbf9;
  border-radius: 8px; font: 600 12px var(--font);
}
.source-pill:hover { border-color: #cfcdc6; }
.dot-ok {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok);
}

.index-chip {
  display: flex; align-items: center; gap: 9px;
  height: 28px; padding: 0 10px;
  border: 1px solid var(--teal-line); background: var(--teal-soft);
  border-radius: 8px; font: 600 11.5px var(--font); color: var(--teal);
}
.index-bar {
  width: 54px; height: 4px; border-radius: 4px;
  background: #d5e6df; display: block; overflow: hidden;
}
.index-bar i {
  display: block; height: 100%; width: 0;
  background: var(--teal); border-radius: 4px;
}

.icon-btn {
  width: 28px; height: 28px; display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--white);
  border-radius: 8px; color: var(--muted);
}
.icon-btn svg {
  width: 15px; height: 15px; fill: none;
  stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round;
}
.icon-btn:hover { color: var(--ink); border-color: #cfcdc6; }
.icon-btn.active {
  border-color: var(--teal-mid); background: var(--teal-soft); color: var(--teal);
}

.shell {
  display: grid;
  grid-template-columns: var(--left-w) minmax(0, 1fr) var(--right-w);
  min-height: 0;
}
.shell.no-left { grid-template-columns: minmax(0, 1fr) var(--right-w); }
.shell.no-right { grid-template-columns: var(--left-w) minmax(0, 1fr); }
.shell.no-left.no-right { grid-template-columns: minmax(0, 1fr); }
.shell.no-left #colLeft,
.shell.no-right #colRight { display: none; }

@media (min-width: 1360px) {
  :root { --right-w: 372px; }
}
@media (max-width: 1179px) {
  .shell:not(.force-right) { grid-template-columns: var(--left-w) minmax(0, 1fr); }
  .shell:not(.force-right) #colRight { display: none; }
}
@media (max-width: 979px) {
  .shell:not(.force-left) { grid-template-columns: minmax(0, 1fr); }
  .shell:not(.force-left) #colLeft { display: none; }
}

.col-left {
  border-right: 1px solid var(--line);
  background: var(--surface);
  display: flex; flex-direction: column; min-height: 0;
}
.col-right {
  border-left: 1px solid var(--line);
  background: var(--white);
  display: flex; flex-direction: column; min-height: 0;
}
.col-center {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--paper);
}

.side-tabs {
  display: flex; gap: 2px; padding: 8px;
  border-bottom: 1px solid var(--line-soft);
}
.side-tab {
  flex: 1; height: 28px;
  border: 1px solid transparent; background: transparent;
  border-radius: 8px; font: 700 12px var(--font); color: var(--muted);
}
.side-tab.active {
  border-color: #dedcd6; background: var(--white); color: var(--ink);
  box-shadow: var(--shadow);
}

.left-pane, .right-pane {
  display: flex; flex-direction: column; min-height: 0; flex: 1;
}
.left-tools {
  padding: 10px 10px 8px;
  display: flex; flex-direction: column; gap: 8px;
}
.search-field {
  display: flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 9px;
  border: 1px solid var(--line); background: var(--white);
  border-radius: 8px;
}
.search-field svg {
  width: 14px; height: 14px; fill: none; stroke: #9a9ea5;
  stroke-width: 2; stroke-linecap: round; flex: none;
}
.search-field input {
  border: 0; outline: 0; width: 100%;
  font-size: 12.5px; background: transparent;
}

.btn-primary {
  border: 1px solid var(--teal); background: var(--teal); color: #fff;
  border-radius: 9px; font: 700 12.5px var(--font);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 32px; padding: 0 13px;
}
.btn-primary:hover { background: var(--teal-dark); }
.btn-primary:disabled { opacity: 0.55; cursor: wait; }
.btn-primary.wide { width: 100%; }
.btn-primary.sm { height: 28px; padding: 0 11px; font-size: 11.5px; border-radius: 8px; }
.btn-primary svg {
  width: 14px; height: 14px; fill: none; stroke: currentColor;
  stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
}
.btn-ghost {
  height: 28px; padding: 0 10px;
  border: 1px solid var(--line); background: var(--white);
  border-radius: 8px; font: 600 11.5px var(--font); color: var(--text-2);
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-ghost:hover { border-color: #cfcdc6; }
.btn-ghost.sm { height: 27px; padding: 0 10px; background: #fbfbf9; }
.btn-ghost svg {
  width: 13px; height: 13px; fill: none; stroke: currentColor;
  stroke-width: 1.9; stroke-linecap: round;
}

.history-list, .catalog-tree {
  overflow: auto; padding: 0 8px 12px; flex: 1;
}
.history-group { margin-top: 10px; }
.history-label {
  padding: 0 6px 6px;
  font: 700 10.5px var(--font);
  letter-spacing: 0.07em; text-transform: uppercase; color: #9a9ea5;
}
.history-item {
  width: 100%; display: block; text-align: left;
  padding: 8px 10px; border: 1px solid transparent;
  background: transparent; border-radius: 9px; color: var(--ink);
}
.history-item:hover { background: #f3f2ee; }
.history-item.active {
  border-color: #dedcd6; background: var(--white);
  box-shadow: var(--shadow);
}
.history-item .t {
  display: block; font: 600 12.5px/1.35 var(--font);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.history-item .m {
  display: flex; align-items: center; gap: 6px; margin-top: 3px;
  font: 500 11px var(--font); color: var(--muted);
}

.catalog-node {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 6px; border-radius: 8px; cursor: pointer;
}
.catalog-node:hover { background: #f6f5f2; }
.catalog-node.selected { background: var(--teal-soft); color: var(--teal); }
.catalog-node .count {
  margin-left: 4px; font: 500 10.5px var(--mono); color: #9a9ea5; flex: none;
}
.catalog-name {
  font: 600 12.5px var(--font);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1;
}
.catalog-toolbar {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 0 2px;
}
.catalog-tree-meta {
  padding: 0 4px 2px;
  font: 500 11px var(--font);
}
.catalog-summary-btn {
  flex: none; height: 22px; padding: 0 7px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--white); color: var(--muted-2);
  font: 600 10.5px var(--font); margin-left: auto;
}
.catalog-summary-btn:hover {
  border-color: var(--teal-mid); color: var(--teal); background: var(--teal-soft);
}
.catalog-file { cursor: default; }
.catalog-file-name { font-weight: 500; color: var(--text-2); }
.catalog-chevron,
.catalog-check {
  flex: none; display: grid; place-items: center;
  padding: 0; border: 0; background: transparent; cursor: pointer; color: inherit;
}
.catalog-chevron {
  width: 16px; height: 16px; color: #b3b7bd;
}
.catalog-chevron svg {
  width: 12px; height: 12px; fill: none; stroke: currentColor;
  stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round;
  transition: transform 0.15s ease;
}
.catalog-chevron.open svg { transform: rotate(90deg); color: var(--muted-2); }
.catalog-chevron-spacer { width: 16px; flex: none; }
.catalog-check {
  width: 13px; height: 13px; border-radius: 4px;
  border: 1.5px solid #cfcdc6; background: var(--white); color: var(--white);
}
.catalog-check.on {
  border-color: var(--teal); background: var(--teal); color: var(--white);
}
.catalog-check svg {
  width: 9px; height: 9px; fill: none; stroke: currentColor;
  stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round;
  display: none;
}
.catalog-check.on svg { display: block; }
.catalog-children {
  margin: 2px 0 0 11px;
  padding-left: 10px;
  border-left: 1px solid #e9e8e3;
}
.catalog-foot {
  border-top: 1px solid var(--line-soft);
  padding: 9px 10px;
  display: flex; align-items: center; gap: 8px;
}
.catalog-foot .btn-primary { margin-left: auto; }

.screen-search, .screen-settings {
  display: flex; flex-direction: column; min-height: 0; flex: 1;
}
.thread-head, .settings-head {
  display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap;
  padding: 11px 20px; border-bottom: 1px solid var(--line); background: var(--paper);
}
.thread-head-main { min-width: 0; flex: 1 1 220px; }
.thread-title {
  font: 700 13.5px var(--font);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.thread-meta {
  display: flex; gap: 8px; margin-top: 2px;
  font: 500 11px var(--font); color: var(--muted);
  white-space: nowrap; overflow: hidden;
}
.thread-actions { margin-left: auto; display: flex; gap: 6px; flex: none; }

.center-scroll, .settings-body {
  overflow: auto; flex: 1; padding: 20px 20px 8px;
}
.settings-body { padding: 20px; }

.empty-state {
  max-width: 520px; margin: 8vh auto 0; text-align: center;
  display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.empty-title { font: 700 15px var(--font); }
.empty-text {
  font: 500 12.5px/1.6 var(--font); color: var(--muted);
  text-wrap: pretty;
}

.thread {
  max-width: 760px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 14px;
}
.user-bubble-row { display: flex; gap: 10px; align-items: flex-start; }
.avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: #e9e7e0; display: grid; place-items: center;
  font: 700 10px var(--font); color: #5c616a; flex: none; margin-top: 2px;
}
.user-bubble {
  background: var(--white); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 14px;
  font: 500 13.5px/1.5 var(--font);
}

.answer-card {
  background: var(--white); border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden;
}
.answer-card-head {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 16px; border-bottom: 1px solid var(--line-soft);
  font: 700 12.5px var(--font);
}
.answer-card-head svg {
  width: 15px; height: 15px; fill: none; stroke: var(--teal);
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none;
}
.answer-card-head .muted { font-weight: 500; font-size: 11px; }
.answer-card-body { padding: 6px 16px 16px; }

.verdict {
  padding: 12px 0 4px;
  font: 600 14px/1.55 var(--font);
  text-wrap: pretty;
}
.claim {
  padding: 12px 0;
  border-bottom: 1px solid var(--line-faint);
}
.claim:last-child { border-bottom: 0; }
.claim-text {
  font: 500 13.5px/1.6 var(--font);
  text-wrap: pretty;
}
.claim-meta {
  display: flex; align-items: center; gap: 8px;
  margin-top: 8px; flex-wrap: wrap;
}
.cite-chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 26px; padding: 0 9px 0 6px;
  border: 1px solid var(--line); background: var(--white);
  border-radius: 8px; cursor: pointer;
}
.cite-chip:hover, .cite-chip.active {
  border-color: var(--teal); background: var(--teal-soft);
}
.cite-n {
  display: inline-grid; place-items: center;
  width: 14px; height: 14px; border-radius: 4px;
  background: var(--teal); color: #fff; font: 800 9px var(--font);
}
.cite-file { font: 600 11.5px var(--font); }
.cite-loc { font: 500 11px var(--mono); color: var(--muted-2); }
.cost-tag {
  display: inline-flex; align-items: center;
  height: 22px; padding: 0 8px; border-radius: 999px;
  background: #f3f2ee; color: #6b7078;
  font: 600 10.5px var(--font);
}
.claim-quote {
  margin-top: 8px; padding: 9px 12px;
  border-left: 2px solid var(--quote-border);
  background: var(--quote-bg); border-radius: 0 8px 8px 0;
  font: 500 12.5px/1.55 var(--font); color: var(--quote-ink);
}

.gaps {
  margin-top: 14px; padding: 11px 13px;
  border: 1px solid var(--warn-border); background: var(--warn-bg);
  border-radius: 10px;
}
.gaps-title { font: 700 12px var(--font); color: var(--warn-ink); }
.gaps ul {
  margin: 6px 0 0; padding-left: 18px;
  font: 500 12.5px/1.6 var(--font); color: var(--warn-body);
}

.materials-head {
  display: flex; align-items: center; gap: 9px;
  padding: 0 2px 8px; flex-wrap: wrap;
}
.materials-title { font: 700 12.5px var(--font); }
.materials-count { font: 600 11px var(--mono); color: var(--muted); }
.materials-tabs { margin-left: auto; display: flex; gap: 5px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center;
  height: 24px; padding: 0 9px; border-radius: 7px;
  border: 1px solid #e2e1dc; background: var(--white);
  color: var(--muted-2); font: 600 11px var(--font);
}
.chip.active {
  border-color: var(--teal); background: var(--teal-soft); color: var(--teal);
}
.materials-list { display: flex; flex-direction: column; gap: 7px; }
.thumb-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.thumb-card {
  display: flex; flex-direction: column; gap: 5px;
  padding: 0; border: 1px solid #e8e7e2; border-radius: 10px;
  background: var(--white); overflow: hidden; cursor: pointer;
  text-align: left; width: 100%;
}
.thumb-card:hover { border-color: var(--teal-mid); }
.thumb-card.active {
  border-color: var(--teal); box-shadow: 0 0 0 2px rgba(14, 106, 94, 0.15);
}
.thumb-card .thumb-frame {
  aspect-ratio: 1; background: #f3f2ee;
  display: grid; place-items: center; overflow: hidden;
}
.thumb-card img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.thumb-card .thumb-name {
  padding: 0 7px 7px;
  font: 600 10.5px/1.3 var(--font); color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.materials-section-label {
  margin: 4px 2px 6px;
  font: 700 11px var(--font); color: var(--muted);
  letter-spacing: 0.02em;
}
.material-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border: 1px solid #e8e7e2;
  background: var(--white); border-radius: 10px;
  cursor: pointer; text-align: left; width: 100%;
}
.material-row:hover { border-color: var(--teal-mid); }
.material-row.active {
  border-color: var(--teal-mid); background: #f7fbf9;
}
.file-badge {
  display: inline-grid; place-items: center;
  width: 26px; height: 20px; border-radius: 4px;
  font: 800 8.5px var(--font); flex: none;
  color: #1c4f9c; background: #e8effb;
}
.file-badge.pdf { color: #b42318; background: #fdeceb; }
.file-badge.xls { color: #107c41; background: #e7f6ed; }
.file-badge.img { color: #9b5a00; background: #fff2dd; }
.material-row .name {
  display: block; font: 600 12.5px var(--font);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.material-row .path {
  display: block; margin-top: 2px;
  font: 500 11px var(--mono); color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.material-hits { font: 600 11px var(--font); color: var(--muted-2); flex: none; }
.status-pill {
  display: inline-flex; align-items: center;
  height: 21px; padding: 0 8px; border-radius: 999px;
  font: 700 10px var(--font); flex: none;
  color: var(--teal); background: #eaf6f1;
}

.next-actions {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 2px 0 8px;
}
.next-actions button {
  height: 28px; padding: 0 11px;
  border: 1px dashed #d2d0ca; background: transparent;
  border-radius: 8px; font: 600 11.5px var(--font); color: var(--muted-2);
}
.next-actions button:hover {
  border-color: var(--teal); color: var(--teal); background: var(--teal-soft);
}

.composer-wrap {
  border-top: 1px solid var(--line);
  background: var(--paper);
  padding: 12px 20px 14px;
}
.composer {
  max-width: 760px; margin: 0 auto;
  background: var(--white); border: 1px solid #dedcd6;
  border-radius: 14px; padding: 11px 12px 9px;
  box-shadow: 0 1px 2px rgba(20, 24, 28, 0.04);
}
.composer textarea {
  width: 100%; border: 0; outline: 0; resize: none;
  font: 500 13.5px/1.55 var(--font); background: transparent;
  min-height: 52px;
}
.composer-row {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
}
.composer-hint {
  font: 500 11px var(--font); color: #9a9ea5; flex: none;
}
.composer-row .btn-primary { margin-left: auto; flex: none; height: 30px; }

@media (max-width: 1279px) {
  .composer-hint { display: none; }
}

.source-empty { padding: 18px 16px; line-height: 1.5; }
.source-detail {
  display: flex; flex-direction: column; min-height: 0; flex: 1;
}
.source-scroll { overflow: auto; flex: 1; min-height: 0; }
.source-file {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 14px 16px; border-bottom: 1px solid var(--line-faint);
}
.source-name-row {
  display: flex; align-items: flex-start; gap: 8px;
}
.source-name {
  font: 700 13px/1.35 var(--font); text-wrap: pretty; flex: 1; min-width: 0;
}
.source-name-row .status-pill {
  flex: none; margin-top: 1px;
}
.source-path {
  margin-top: 3px; font: 500 11px/1.5 var(--mono); color: var(--muted);
}

.source-footer {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line);
  background: var(--white);
  flex: none;
}
.btn-action {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 44px; padding: 0 14px;
  border-radius: 10px; font: 700 13.5px var(--font);
  text-align: center; box-sizing: border-box;
}
.btn-action-primary {
  border: 1px solid var(--teal); background: var(--teal); color: #fff;
}
.btn-action-primary:hover { background: var(--teal-dark); }
.btn-action-secondary {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.btn-action-secondary:hover { border-color: #cfcdc6; background: #f3f2ee; }
.btn-action-outline {
  border: 1px solid var(--line); background: transparent; color: var(--muted-2);
  font-weight: 600;
}
.btn-action-outline:hover { border-color: #cfcdc6; color: var(--text-2); }
.btn-action[aria-disabled="true"],
.btn-action.is-disabled {
  opacity: 0.45; pointer-events: none;
}

.fragment-block { padding: 14px 16px; }
.fragment-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 9px;
  font: 700 11.5px var(--font);
}
.fragment-preview {
  border: 1px solid #e9e8e3; border-radius: 10px;
  background: var(--surface); padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.quote {
  padding: 8px 9px; border-radius: 6px;
  background: #fdf1cf; border: 1px solid #eddfae;
  font: 500 12px/1.55 var(--font); color: var(--quote-ink);
}
.preview-hint {
  font: 500 10.5px var(--font); color: #a8aab0; text-align: center;
}
.preview-frame {
  border-radius: 8px; overflow: hidden;
  border: 1px solid var(--line); background: #fff;
  min-height: 120px;
}
.preview-frame img {
  display: block; width: 100%; border: 0;
  max-height: 200px; object-fit: contain; background: #fff;
}
.preview-placeholder {
  display: grid; place-items: center;
  min-height: 120px; padding: 16px;
  font: 600 12.5px var(--font); color: var(--muted);
  text-align: center; background: #fafaf8;
}

.filter-section { padding: 14px 16px; }
.filter-title { font: 700 11.5px var(--font); margin-bottom: 8px; }
.filter-hint { font-size: 11px; margin-bottom: 10px; }
.filter-row {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; border-radius: 8px; cursor: pointer;
}
.filter-row:hover { background: #f6f5f2; }
.filter-row input { accent-color: var(--teal); width: 14px; height: 14px; }

.settings-block { max-width: 720px; margin: 0 auto 22px; }
.settings-block-head {
  display: flex; align-items: center; gap: 9px; margin-bottom: 9px;
  font: 700 12.5px var(--font); flex-wrap: wrap;
}
.settings-block-head .btn-ghost { margin-left: auto; }
.provider-list, .source-card {
  background: var(--white); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden;
}
.provider-item { border-top: 1px solid var(--line-faint); }
.provider-item:first-child { border-top: 0; }
.provider-row {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 16px; cursor: pointer; user-select: none;
}
.provider-row:hover { background: var(--teal-soft); }
.provider-row.is-open { background: var(--teal-soft); }
.provider-dot {
  width: 9px; height: 9px; border-radius: 50%; flex: none;
  background: #dcd6c4;
}
.provider-dot.ok { background: var(--ok); }
.provider-dot.err { background: #c45c4a; }
.provider-name { font: 700 12.5px var(--font); min-width: 132px; }
.provider-key {
  font: 500 11.5px var(--mono); color: var(--muted);
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.provider-pill {
  display: inline-flex; align-items: center;
  height: 22px; padding: 0 9px; border-radius: 999px;
  font: 700 10.5px var(--font); flex: none;
  color: var(--warn-ink); background: #fdf1cf;
}
.provider-pill.ok { color: var(--teal); background: #eaf6f1; }
.provider-pill.err { color: #8a2f24; background: #fdecea; }
.provider-pill.used { color: var(--teal); background: #eaf6f1; }
.provider-chevron {
  width: 16px; height: 16px; flex: none; color: var(--muted);
  transition: transform 0.15s ease;
}
.provider-row.is-open .provider-chevron { transform: rotate(90deg); color: var(--teal); }
.provider-detail {
  padding: 0 16px 14px;
  border-top: 1px dashed var(--line-soft);
  background: var(--surface);
}
.provider-detail-grid {
  display: grid; gap: 10px; padding-top: 12px;
}
.settings-field {
  display: grid; gap: 5px;
  font: 600 11.5px var(--font); color: var(--text-2);
}
.settings-field input,
.settings-field select,
.settings-field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--white);
  padding: 9px 11px;
  font: 500 12.5px var(--font);
  color: var(--ink);
  outline: none;
}
.settings-field textarea {
  font: 500 12px var(--mono);
  resize: vertical;
  min-height: 120px;
  line-height: 1.4;
}
.settings-field input:focus,
.settings-field select:focus,
.settings-field textarea:focus {
  border-color: var(--teal-mid);
  box-shadow: 0 0 0 3px rgba(14, 106, 94, 0.12);
}
.settings-actions {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding-top: 2px;
}
.settings-actions .btn-danger {
  margin-left: auto;
  height: 27px; padding: 0 10px; border-radius: 8px;
  border: 1px solid #e8cfc9; background: #fff7f5;
  color: #8a2f24; font: 700 11.5px var(--font);
}
.settings-actions .btn-danger:hover { background: #fdecea; border-color: #dfb4ab; }
.source-card-inner {
  padding: 14px 16px;
  display: grid; gap: 10px;
}
.source-card-top {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.source-card-title { font: 700 12.5px var(--font); }
.source-card-meta {
  display: grid; gap: 4px;
  font: 500 11.5px var(--font); color: var(--muted-2);
}
.source-card-meta .mono {
  color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 100%;
}
.source-card-status { font: 500 12px var(--font); color: var(--text-2); }
.source-card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.drive-form {
  margin-top: 12px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  display: grid; gap: 10px;
}
.settings-form-title {
  font: 700 12.5px var(--font);
  margin-bottom: 2px;
}

.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20, 24, 28, 0.45);
  display: grid; place-items: center; padding: 24px;
}
.overlay-card {
  width: min(960px, 100%); height: min(86vh, 900px);
  background: var(--white); border-radius: 14px;
  border: 1px solid var(--line); overflow: hidden;
  display: grid; grid-template-rows: auto 1fr;
}
.overlay-card header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  font: 700 13px var(--font);
}
.overlay-card header .btn-ghost { margin-left: auto; }
.overlay-body {
  position: relative; min-height: 0; background: #f7f6f2;
}
.overlay-body img, .overlay-body iframe {
  width: 100%; height: 100%; border: 0; display: block;
  object-fit: contain; background: #fff;
}
.overlay-loading,
.overlay-error {
  position: absolute; inset: 0; z-index: 2;
  display: grid; place-items: center; align-content: center; gap: 12px;
  padding: 24px; text-align: center; background: #f7f6f2;
}
.overlay-loading { font: 600 13px var(--font); color: var(--muted); }
.overlay-error-title { font: 700 15px var(--font); }
.overlay-error-text {
  max-width: 420px; margin: 0 auto;
  font: 500 13px/1.5 var(--font); color: var(--muted-2);
}
.overlay-error .btn-primary { min-width: 180px; height: 40px; }

.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; height: 34px; padding: 0 14px;
  border-radius: 10px; background: var(--ink); color: #fff;
  font: 600 12px var(--font);
  box-shadow: 0 8px 24px rgba(20, 24, 28, 0.2);
}

.loading-line {
  padding: 20px; color: var(--muted); text-align: center;
}

.dialog-card {
  width: min(440px, 100%);
  max-height: min(82vh, 720px);
  background: var(--white); border-radius: 14px;
  border: 1px solid var(--line); overflow: hidden;
  display: grid; grid-template-rows: auto 1fr auto;
  box-shadow: 0 16px 40px rgba(20, 24, 28, 0.18);
}
.dialog-card-wide { width: min(640px, 100%); }
.dialog-card header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  font: 700 13px var(--font);
}
.dialog-card header .btn-ghost { margin-left: auto; }
.dialog-body {
  overflow: auto; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 0;
}
.dialog-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-top: 1px solid var(--line);
  background: var(--surface);
}
.dialog-foot .btn-primary { margin-left: auto; }
.index-stat-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  font: 600 12.5px var(--font);
}
.index-progress-track {
  height: 6px; border-radius: 999px; background: #e7ebe8; overflow: hidden;
}
.index-progress-track i {
  display: block; height: 100%; width: 0;
  background: var(--teal); border-radius: 999px;
  transition: width 0.25s ease;
}
.index-errors-wrap { display: grid; gap: 6px; }
.index-errors {
  margin: 0; padding: 0; list-style: none;
  display: flex; flex-direction: column; gap: 4px;
  max-height: 160px; overflow: auto;
}
.index-errors li {
  padding: 7px 9px; border-radius: 8px;
  background: #fdf6f4; border: 1px solid #f0ddd8;
  font: 500 11.5px/1.4 var(--font); color: #6b3a32;
}
.changes-list {
  display: flex; flex-direction: column; gap: 7px;
}
.changes-row {
  display: grid; gap: 3px;
  padding: 9px 11px; border: 1px solid #e8e7e2;
  border-radius: 10px; background: var(--surface);
}
.changes-row .chg-type {
  font: 700 10.5px var(--font); color: var(--teal);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.changes-row .chg-name { font: 600 12.5px var(--font); }
.changes-row .chg-path {
  font: 500 11px var(--mono); color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.changes-row .chg-meta {
  font: 500 11px var(--font); color: var(--muted-2);
}
.changes-row a {
  color: var(--teal); font: 600 11.5px var(--font);
  text-decoration: underline; text-underline-offset: 2px;
}
