:root {
  color-scheme: light;
  --page: #eef1f4;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --surface-3: #e9eef1;
  --text: #172027;
  --text-soft: #3f4b53;
  --muted: #66737d;
  --line: #d4dce1;
  --line-strong: #aebbc3;
  --accent: #2f6feb;
  --accent-strong: #1d57c9;
  --accent-soft: #dce8fb;
  --danger: #a43b35;
  --danger-soft: #f8e9e7;
  --warning: #8a6418;
  --warning-soft: #f8efd8;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #111719;
  --surface: #182124;
  --surface-2: #1d282c;
  --surface-3: #273438;
  --text: #eef5f2;
  --text-soft: #c4d0cc;
  --muted: #9eaca7;
  --line: #334145;
  --line-strong: #526166;
  --accent: #4c8dff;
  --accent-strong: #7aa8ff;
  --accent-soft: #1d3350;
  --danger: #ed938b;
  --danger-soft: #452b2a;
  --warning: #dfb85e;
  --warning-soft: #403722;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--page); color: var(--text); }
button, input { font: inherit; color: inherit; }

.app-shell { min-height: 100dvh; }

.topbar {
  min-height: 64px;
  padding: 10px 18px;
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand-block { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 36px; height: 36px; display: grid; place-items: center;
  background: var(--accent); color: #fff; border-radius: 8px; font-weight: 800;
}
.brand-name { font-size: 12px; font-weight: 800; letter-spacing: 0.08em; }
.brand-subtitle { margin-top: 2px; color: var(--muted); font-size: 12px; }
.topbar-meta { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: 12px; }
.topbar-meta strong { color: var(--text); font-variant-numeric: tabular-nums; }

.icon-button, .secondary-button, .chip, .primary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  cursor: pointer;
}
.icon-button { min-width: 48px; height: 34px; font-size: 12px; }
.icon-button:hover, .secondary-button:hover, .chip:hover { border-color: var(--accent); color: var(--accent-strong); }

.workspace {
  min-height: calc(100dvh - 64px);
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 1px;
  background: var(--line);
}

.subject-panel, .scene-panel { background: var(--surface); min-width: 0; }
.subject-panel { padding: 16px 12px; }
.scene-panel { padding: 16px 20px 32px; overflow-y: auto; }

.panel-kicker {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.subject-list { display: grid; gap: 8px; }
.subject-btn, .scene-btn, .agent-chip {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.scene-btn { width: auto; }
.subject-btn.active, .scene-btn.active, .agent-chip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
}

.scene-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }

.conclusion-block { margin: 8px 0 18px; }
.conclusion-block h2 { margin: 0 0 8px; font-size: 15px; }
.conclusion-main { margin: 0 0 6px; font-size: 16px; font-weight: 750; }
.conclusion-line { margin: 0 0 4px; color: var(--text-soft); font-size: 13px; }

.query-boards { display: grid; gap: 14px; }
.query-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.query-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.pill {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 750;
}
.pill.fuzzy { background: var(--warning-soft); color: var(--warning); }
.query-head small { color: var(--muted); font-size: 11px; }
.query-text { margin: 0 0 8px; font-size: 16px; font-weight: 650; line-height: 1.55; overflow-wrap: anywhere; }
.query-empty { color: var(--muted); font-weight: 550; }
.query-note, .query-winner { margin: 0 0 8px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.query-winner { color: var(--text); font-weight: 750; font-size: 14px; }

.radar-wrap { margin: 10px 0 14px; }
.radar-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 8px; font-size: 12px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: middle; }
.radar-svg { width: min(100%, 460px); height: auto; display: block; overflow: visible; }
.radar-caption { margin: 6px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

.query-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.primary-button, .secondary-button {
  min-height: 36px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 650;
}
.primary-button {
  border: 0;
  background: var(--accent);
  color: #fff;
}
.primary-button:hover { background: var(--accent-strong); }
.primary-button:disabled { opacity: 0.7; cursor: wait; }

.add-panel, .detail-panel {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
}
.add-panel h3, .detail-panel h3 { margin: 0; font-size: 13px; }
.add-help { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.agent-row { display: flex; flex-wrap: wrap; gap: 8px; }
.agent-chip { width: auto; }
.upload-row {
  min-height: 56px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}
.upload-row input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.upload-row span { font-size: 12px; font-weight: 700; }
.upload-row small { color: var(--muted); font-size: 11px; }
.file-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.file-chip {
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  font-size: 11px;
}
.form-error { margin: 0; padding: 8px 10px; border-radius: 7px; background: var(--danger-soft); color: var(--danger); font-size: 12px; }
.form-status { margin: 0; color: var(--muted); font-size: 12px; }

.detail-query { margin: 0; font-weight: 700; font-size: 14px; }
.detail-meta { margin: 0; color: var(--text-soft); font-size: 12px; line-height: 1.6; }
.slot-list, .clarify-list { margin: 0; padding-left: 18px; font-size: 12px; line-height: 1.6; }
.dim-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.dim-table th, .dim-table td {
  padding: 8px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.dim-table th { background: var(--surface-3); color: var(--muted); font-weight: 650; }
.dim-section { display: grid; gap: 8px; }
.dim-section h4 { margin: 0; font-size: 13px; }
.shot-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px; align-items: start; }
.shot-card { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.shot-card strong { display: block; margin-bottom: 4px; font-size: 12px; }
.shot-card p, .shot-card img { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.shot-card img {
  display: block;
  width: min(100%, 280px);
  height: auto;
  max-height: none;
  object-fit: contain;
  object-position: top center;
  border-radius: 16px;
  margin: 8px auto 10px;
  background: var(--surface-3);
  box-shadow: 0 12px 28px color-mix(in srgb, var(--page) 72%, transparent);
}

.api-status { position: relative; padding-left: 13px; }
.api-status::before {
  content: "";
  position: absolute; left: 0; top: 50%;
  width: 7px; height: 7px; border-radius: 50%;
  transform: translateY(-50%);
  background: var(--warning);
}
.api-status.ready::before { background: #3dbf7a; }
.api-status.error::before { background: var(--danger); }

.text-button { padding: 0; border: 0; color: var(--accent-strong); background: transparent; cursor: pointer; font-size: 12px; }
.cloud-user { display: flex; align-items: center; gap: 12px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.cloud-user[hidden] { display: none; }
.cloud-user > span { display: flex; align-items: center; gap: 7px; font-size: 12px; white-space: nowrap; }
.cloud-dot { width: 8px; height: 8px; border-radius: 50%; background: #14a06f; box-shadow: 0 0 0 4px rgb(20 160 111 / 12%); }

.access-dialog { width: min(480px, calc(100vw - 32px)); max-width: none; padding: 0; border: 0; border-radius: 20px; color: var(--text); background: transparent; box-shadow: 0 30px 90px rgb(10 25 32 / 24%); }
.access-dialog::backdrop { background: rgb(12 24 30 / 58%); backdrop-filter: blur(9px); }
.access-card { display: grid; gap: 18px; padding: 28px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.access-card h2 { margin: 4px 0 8px; font-size: 23px; }
.access-card p { margin: 0; color: var(--muted); line-height: 1.6; }
.access-kicker { color: var(--accent) !important; font: 700 11px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .14em; }
.access-field { display: grid; gap: 8px; font-size: 13px; font-weight: 650; }
.access-field input { width: 100%; min-height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.access-error { padding: 9px 11px; border-radius: 8px; color: var(--danger) !important; background: var(--danger-soft); font-size: 12px; }
.invite-output { display: grid; gap: 6px; padding: 14px; border: 1px solid rgb(20 160 111 / 28%); border-radius: 12px; background: rgb(20 160 111 / 8%); }
.invite-output span, .invite-output small { color: var(--muted); }
.invite-output strong { font: 800 21px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .05em; user-select: all; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dialog-actions button { width: 100%; }

html.embed .topbar,
html.embed .subject-panel { display: none; }
html.embed .workspace { grid-template-columns: 1fr; min-height: 100dvh; }
html.embed, html.embed body { min-height: 100%; background: transparent; }
html.embed .scene-panel { padding: 12px 14px 28px; }

@media (max-width: 860px) {
  .topbar { grid-template-columns: 1fr auto; }
  .topbar-meta { display: none; }
  .cloud-user { grid-column: 1 / -1; justify-content: space-between; }
  .workspace { display: block; }
  .subject-list { display: flex; flex-wrap: wrap; }
  .subject-btn { width: auto; }
  .shot-grid { grid-template-columns: 1fr; }
  .shot-card img { width: min(100%, 340px); }
}
