:root {
  --bg: #f4efe4;
  --bg-panel: rgba(255, 252, 246, 0.88);
  --bg-panel-strong: #fffaf0;
  --line: rgba(33, 54, 43, 0.12);
  --text: #1f2f29;
  --muted: #66776f;
  --deep: #17342d;
  --accent: #c96f2d;
  --accent-soft: #f6ddc6;
  --green: #2f6d5a;
  --green-soft: #dff0e7;
  --gold: #9c6d14;
  --gold-soft: #f7edcb;
  --shadow: 0 18px 48px rgba(31, 47, 41, 0.08);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --font-sans: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(201, 111, 45, 0.18), transparent 32%),
    radial-gradient(circle at top right, rgba(47, 109, 90, 0.14), transparent 30%),
    linear-gradient(180deg, #f7f1e7 0%, var(--bg) 42%, #efe8db 100%);
  font-family: var(--font-sans);
}

.page-shell {
  width: min(1560px, calc(100vw - 32px));
  margin: 18px auto;
  display: grid;
  grid-template-columns: clamp(388px, 28vw, 430px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 16px;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-gutter: stable;
}

.panel {
  border: 1px solid var(--line);
  background: var(--bg-panel);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.hero-panel {
  padding: 24px 24px 20px;
  background:
    linear-gradient(145deg, rgba(255, 250, 240, 0.94), rgba(247, 239, 226, 0.82)),
    linear-gradient(180deg, rgba(255,255,255,0.5), rgba(255,255,255,0.2));
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--green);
}

.hero-panel h1 {
  margin: 0 0 10px;
  font-size: 30px;
  line-height: 1.08;
}

.subcopy {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.mode-badge-row {
  margin: 0 0 12px;
  display: flex;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
}

.mode-badge.is-browse {
  background: rgba(47, 109, 90, 0.12);
  color: var(--green);
  border-color: rgba(47, 109, 90, 0.16);
}

.mode-badge.is-match {
  background: rgba(201, 111, 45, 0.14);
  color: #8b4f1d;
  border-color: rgba(201, 111, 45, 0.2);
}

.control-panel {
  padding: 0 20px 16px;
  overflow: hidden;
}

.control-panel summary {
  list-style: none;
  cursor: pointer;
  padding: 18px 0 14px;
  font-size: 18px;
  font-weight: 700;
  border-bottom: 1px solid rgba(31, 47, 41, 0.08);
}

.control-panel summary::-webkit-details-marker {
  display: none;
}

.control-panel form {
  display: grid;
  gap: 14px;
}

.panel-intro {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.fixed-pool-note {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(47, 109, 90, 0.14);
  background: rgba(47, 109, 90, 0.08);
}

.fixed-pool-note strong {
  font-size: 13px;
  color: var(--green);
}

.fixed-pool-note span {
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
}

.filter-group {
  border: 1px solid rgba(31, 47, 41, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.68);
  padding: 0 14px 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.filter-group summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--deep);
}

.filter-group summary::-webkit-details-marker {
  display: none;
}

.filter-group-static {
  padding-top: 14px;
}

.filter-group-title {
  padding: 0 0 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--deep);
}

.filter-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.field-stack {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(31, 47, 41, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  padding: 11px 12px;
  font: inherit;
}

select[multiple] {
  padding: 6px;
}

textarea {
  resize: vertical;
  min-height: 150px;
  line-height: 1.55;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.sidebar .field-row {
  grid-template-columns: 1fr;
  gap: 12px;
}

.mode-hint {
  display: grid;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(201, 111, 45, 0.08);
  color: #7c4b20;
  font-size: 13px;
  line-height: 1.6;
}

.llm-row {
  align-items: start;
}

.llm-switch-card {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  min-height: 100%;
  border-radius: 14px;
  border: 1px solid rgba(31, 47, 41, 0.08);
  background: linear-gradient(180deg, rgba(255, 250, 240, 0.9), rgba(255, 255, 255, 0.66));
}

.llm-switch-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.llm-switch-label input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.status-strip {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 16px 18px;
  border-radius: 20px;
  border: 1px solid rgba(31, 47, 41, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 250, 240, 0.92), rgba(255, 255, 255, 0.66)),
    radial-gradient(circle at top right, rgba(201, 111, 45, 0.08), transparent 28%);
}

.status-strip-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.status-strip h2 {
  margin: 0 0 6px;
  font-size: 22px;
  line-height: 1.2;
}

.status-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.status-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.is-on {
  background: var(--green-soft);
  color: var(--green);
  border-color: rgba(47, 109, 90, 0.18);
}

.status-pill.is-off {
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  border-color: rgba(31, 47, 41, 0.12);
}

.status-pill.is-quiet {
  background: var(--gold-soft);
  color: var(--gold);
  border-color: rgba(156, 109, 20, 0.14);
}

.checkbox-grid {
  display: grid;
  gap: 10px;
  padding: 6px 0;
}

.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

.checkbox-grid input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  text-decoration: none;
  font-weight: 700;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.primary {
  background: linear-gradient(135deg, var(--deep), #245144);
  color: #fff;
  box-shadow: 0 10px 24px rgba(23, 52, 45, 0.18);
}

.btn.secondary {
  background: rgba(255, 255, 255, 0.72);
  color: var(--deep);
  border-color: rgba(23, 52, 45, 0.12);
}

.btn.small {
  min-height: 38px;
  padding: 0 12px;
  font-size: 13px;
}

.main {
  display: grid;
  gap: 16px;
}

.top-tabs {
  display: flex;
  gap: 12px;
}

.tab-link {
  padding: 12px 20px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--deep);
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid transparent;
  font-weight: 700;
}

.tab-link.active {
  background: linear-gradient(135deg, #fff4e2, #f7e6cb);
  border-color: rgba(201, 111, 45, 0.22);
  color: #6d3e15;
  box-shadow: 0 10px 24px rgba(201, 111, 45, 0.14);
}

.mode-panel {
  padding: 20px 24px;
}

.mode-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.mode-panel h2 {
  margin: 0 0 6px;
  font-size: 28px;
  line-height: 1.1;
}

.mode-panel-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.advisor-metric-grid {
  margin-top: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.advisor-card {
  background:
    linear-gradient(180deg, rgba(255, 250, 240, 0.92), rgba(255, 255, 255, 0.68)),
    radial-gradient(circle at top right, rgba(47, 109, 90, 0.06), transparent 34%);
}

.metric-card {
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: var(--bg-panel-strong);
  border: 1px solid rgba(31, 47, 41, 0.08);
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  line-height: 1;
}

.action-row {
  margin-top: 16px;
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

.history-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.history-card {
  padding: 18px 20px;
  border-radius: 20px;
  border: 1px solid rgba(31, 47, 41, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 250, 240, 0.92), rgba(255, 255, 255, 0.68)),
    radial-gradient(circle at top right, rgba(201, 111, 45, 0.06), transparent 30%);
}

.history-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.history-head h3 {
  margin: 4px 0 0;
  font-size: 18px;
  line-height: 1.25;
}

.history-id,
.history-head-tip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(47, 109, 90, 0.08);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.history-kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.history-kv-grid div {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(31, 47, 41, 0.06);
}

.history-kv-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.history-kv-grid strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  word-break: break-all;
}

.history-note {
  margin: 12px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.history-empty {
  padding: 16px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.66);
  color: var(--muted);
  line-height: 1.7;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-list-item {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(31, 47, 41, 0.08);
  background: rgba(255, 255, 255, 0.7);
}

.history-list-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.history-list-top strong {
  color: var(--deep);
  font-size: 14px;
}

.history-list-top span,
.history-list-meta {
  color: var(--muted);
  font-size: 12px;
}

.history-list-meta {
  margin: 6px 0 0;
}

.history-list-badges {
  margin: 8px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sidebar-action-row {
  flex-direction: column;
  align-items: stretch;
}

.sidebar-action-row .btn {
  width: 100%;
}

.sidebar-primary-btn {
  min-height: 48px;
}

.compact-actions {
  margin-top: 12px;
}

.operation-panel {
  margin-top: 14px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(31, 47, 41, 0.08);
  background: linear-gradient(180deg, rgba(255, 250, 240, 0.84), rgba(255, 255, 255, 0.62));
}

.operation-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 10px;
}

.operation-head strong {
  font-size: 14px;
  color: var(--deep);
}

.operation-head span {
  color: var(--muted);
  font-size: 12px;
}

.compact-operation {
  margin-top: 12px;
}

.profile-box,
.section-title,
.group-panel {
  padding: 22px 24px;
}

.record-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 20px;
  padding: 22px 24px;
}

.record-card.record-card-folded {
  display: block;
  padding: 18px 22px;
}

.record-card.compact {
  grid-template-columns: minmax(0, 1fr) 180px;
}

.record-main h2,
.record-main h3 {
  margin: 0 0 10px;
  line-height: 1.25;
}

/* --- Card three-layer folding --- */

.card-layer1 {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 8px 16px;
}

.card-summary {
  min-width: 0;
  grid-column: 1;
  grid-row: 1 / 3;
}

.card-summary h2 {
  margin: 0 0 6px;
  font-size: 17px;
  line-height: 1.3;
}

.card-meta-compact {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.card-layer1 .chip-row {
  margin-bottom: 6px;
}

.card-brief {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-qr-area {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  align-self: start;
}

.qr-thumb {
  width: 88px;
  height: 88px;
  border-radius: 10px;
  border: 1px solid rgba(31, 47, 41, 0.08);
  background: #fff;
  object-fit: cover;
  display: block;
}

.card-actions-compact {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.video-icon {
  margin-left: 4px;
}

.card-actions-compact .btn.card-expand-btn {
  font-size: 12px;
  min-height: 32px;
  padding: 0 10px;
  color: var(--green);
  border-color: rgba(47, 109, 90, 0.18);
}

.card-layer2 {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  animation: fadeInLayer 200ms ease;
  display: grid;
  gap: 12px;
}

.card-layer2[hidden] {
  display: none;
}

.detail-card {
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid rgba(31, 47, 41, 0.08);
  background: rgba(255, 255, 255, 0.5);
}

.detail-card.is-highlight {
  background: rgba(47, 109, 90, 0.04);
  border-color: rgba(47, 109, 90, 0.12);
}

.detail-card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

.detail-card p {
  margin: 0 0 6px;
  font-size: 13px;
  line-height: 1.6;
}

.detail-card p:last-child {
  margin-bottom: 0;
}

.detail-card .action-row {
  margin-top: 10px;
}

.detail-card .body-copy {
  font-size: 13px;
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
}

.detail-card .quotes {
  margin-top: 8px;
}

.detail-card blockquote {
  margin: 6px 0;
  padding: 8px 12px;
  border-left: 3px solid var(--gold);
  background: rgba(247, 237, 203, 0.3);
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  line-height: 1.6;
}

@keyframes fadeInLayer {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-tags-section {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}

.card-tags-section p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
}

.card-recommendation {
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(47, 109, 90, 0.06);
  border: 1px solid rgba(47, 109, 90, 0.12);
}

.card-recommendation p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
}

.card-operations {
  margin-bottom: 12px;
}

.card-metadata {
  margin-bottom: 12px;
}

.card-metadata p {
  margin: 2px 0;
}

.card-evidence {
  margin-bottom: 12px;
}

.meta-line,
.stats-line,
.soft,
.status-text {
  color: var(--muted);
  line-height: 1.6;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.chip,
.inline-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
}

.chip-gold {
  background: var(--gold-soft);
  color: var(--gold);
}

.chip-green {
  background: var(--green-soft);
  color: var(--green);
}

.chip-advisor-tier {
  background: rgba(23, 52, 45, 0.12);
  color: var(--deep);
}

.chip-direct-ready {
  background: rgba(47, 109, 90, 0.16);
  color: var(--green);
}

.chip-canonical {
  background: rgba(156, 109, 20, 0.14);
  color: var(--gold);
}

.chip-scene {
  background: rgba(201, 111, 45, 0.14);
  color: #8b4f1d;
}

.inline-chip {
  margin-right: 6px;
  margin-bottom: 6px;
  background: rgba(47, 109, 90, 0.1);
  color: var(--green);
}

.quotes {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

blockquote {
  margin: 0;
  padding: 14px 16px;
  border-left: 3px solid rgba(47, 109, 90, 0.35);
  background: rgba(47, 109, 90, 0.05);
  border-radius: 0 14px 14px 0;
}

.body-toggle {
  margin-top: 14px;
  border-top: 1px solid rgba(31, 47, 41, 0.08);
  padding-top: 12px;
}

.advisor-line {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(31, 47, 41, 0.08);
  background: rgba(255, 255, 255, 0.68);
  color: var(--muted);
  line-height: 1.6;
}

.body-toggle summary {
  cursor: pointer;
  font-weight: 700;
}

.body-copy {
  margin-top: 12px;
  line-height: 1.75;
  white-space: pre-wrap;
}

.preview-image,
.qr-image {
  width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(31, 47, 41, 0.08);
  background: #fff;
}

.preview-image {
  margin-bottom: 14px;
  max-height: 360px;
  object-fit: cover;
}

.record-side {
  display: grid;
  align-content: start;
  gap: 12px;
}

.qr-placeholder {
  min-height: 180px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(135deg, #edf4ff, #d9e8ff);
  color: #1d5fb1;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  padding: 18px;
}

.reason-list {
  margin: 10px 0 0;
  padding-left: 20px;
  line-height: 1.7;
}

.empty-state,
.alert {
  padding: 26px 24px;
  color: var(--muted);
}

.empty-guide {
  padding: 26px 24px;
}

.guide-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.guide-list span {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(47, 109, 90, 0.08);
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
}

.track-card {
  padding: 22px 24px;
}

.track-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.track-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.track-actions .btn,
.operation-panel .btn {
  white-space: nowrap;
}

.btn[aria-disabled="true"] {
  pointer-events: none;
  opacity: 0.45;
}

.timeline-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.timeline-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 16px;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(31, 47, 41, 0.08);
  background: rgba(255, 255, 255, 0.62);
}

.timeline-main h3 {
  margin: 0 0 8px;
  line-height: 1.35;
}

.timeline-side {
  display: grid;
  align-content: start;
}

.timeline-qr {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(31, 47, 41, 0.08);
  background: #fff;
}

.timeline-noteid {
  min-height: 120px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #edf4ff, #d9e8ff);
  color: #1d5fb1;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  padding: 14px;
}

.copy-payload {
  display: none;
}

.alert.error {
  color: #8a1d16;
  background: rgba(196, 60, 48, 0.08);
}

/* --- Metric + export inline row --- */

.metric-export-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.metric-export-row .metric-grid {
  flex: 1;
  min-width: 0;
}

.export-buttons {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}

/* --- Result drawer (collapsed groups / tracks) --- */

.result-drawer {
  padding: 16px 0 0;
}

.result-drawer summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: var(--deep);
  padding: 12px 16px;
}

.result-drawer[open] summary {
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.group-section {
  margin-bottom: 20px;
}

.group-section h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--deep);
  margin: 0 0 12px;
  padding: 0 4px;
}

/* --- Pool bar (browse tab summary) --- */

.pool-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
}

.pool-summary {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

.pool-summary strong {
  color: var(--text);
  font-size: 18px;
}

/* --- History Tab --- */

.history-page-head {
  padding: 20px 24px 0;
  margin-bottom: 8px;
}

.history-page-head h2 {
  margin: 0 0 4px;
}

.history-run-item {
  border-top: 1px solid var(--line);
  margin: 0 24px;
}

.history-run-item:last-child {
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.history-run-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  cursor: pointer;
  gap: 16px;
  list-style: none;
  overflow: hidden;
}

.history-run-summary::-webkit-details-marker {
  display: none;
}

.history-run-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.history-run-time {
  font-size: 13px;
  color: var(--deep);
}

.history-run-profile {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-run-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.history-run-stats {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.history-run-detail {
  padding: 4px 0 24px;
  display: grid;
  gap: 16px;
}

.history-run-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}

.history-profile-text {
  font-size: 12px;
  color: var(--muted);
  background: rgba(255,255,255,0.5);
  padding: 10px 12px;
  border-radius: 10px;
  white-space: pre-wrap;
  margin: 8px 0 0;
}

.history-case-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(31,47,41,0.06);
}

.history-case-info {
  flex: 1;
  min-width: 0;
}

.history-case-qr {
  flex-shrink: 0;
}

.history-case-qr img {
  border-radius: 6px;
  display: block;
}

.history-run-more summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.history-case-item:last-child {
  border-bottom: none;
}

.history-case-rank {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.history-case-item strong {
  font-size: 14px;
}

.history-case-item .soft {
  font-size: 12px;
  margin: 2px 0 0;
}

.history-run-actions {
  padding-top: 8px;
}

/* --- Login Page --- */

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-container {
  width: 100%;
  max-width: 400px;
}

.login-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  padding: 40px 36px;
  text-align: center;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
  color: var(--deep);
}

.login-subtitle {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 14px;
}

.login-error {
  background: rgba(180, 60, 40, 0.08);
  border: 1px solid rgba(180, 60, 40, 0.2);
  color: #8b3a2a;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 20px;
  text-align: left;
}

.login-field {
  margin-bottom: 18px;
  text-align: left;
}

.login-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--deep);
  margin-bottom: 6px;
}

.login-field input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  font-family: var(--font-sans);
  background: rgba(255, 255, 255, 0.7);
  transition: border-color 150ms ease;
}

.login-field input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 109, 90, 0.1);
}

.login-btn {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  font-size: 15px;
}

@media (max-width: 900px) {
  .metric-export-row {
    flex-direction: column;
  }

  .export-buttons {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .pool-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
}

/* --- Chip-select filter (Task B) --- */

.chip-option input[type="checkbox"] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.chip-select {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-option {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 4px 12px;
  border-radius: 8px;
  border: 1px solid rgba(31, 47, 41, 0.14);
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: background 120ms ease, border-color 120ms ease;
}

.chip-option:hover {
  background: rgba(47, 109, 90, 0.06);
  border-color: rgba(47, 109, 90, 0.22);
}

.chip-option.is-selected {
  background: var(--green-soft);
  border-color: var(--green);
  color: var(--green);
  font-weight: 700;
}

.chip-option.is-selected:hover {
  background: rgba(47, 109, 90, 0.22);
}

/* --- Selected summary bar --- */

.selected-summary {
  display: none;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(47, 109, 90, 0.14);
  background: rgba(47, 109, 90, 0.06);
  margin-bottom: 4px;
}

.selected-summary.has-selections {
  display: grid;
}

.selected-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--green);
  white-space: nowrap;
}

.selected-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.selected-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 600;
}

.selected-chip-remove {
  all: unset;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  color: var(--green);
  opacity: 0.6;
}

.selected-chip-remove:hover {
  opacity: 1;
}

.btn-text {
  all: unset;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-text:hover {
  color: var(--text);
}

.history-drawer {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.history-drawer summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.match-status-line {
  margin: 0;
  padding: 8px 0;
  font-size: 13px;
  color: var(--green);
  font-weight: 600;
}

.match-status-line.is-degraded {
  color: var(--accent);
}

.card-layer2-group {
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(31, 47, 41, 0.06);
  margin-bottom: 12px;
}

.card-layer2-group.is-primary {
  background: rgba(47, 109, 90, 0.05);
  border-color: rgba(47, 109, 90, 0.12);
}

.card-layer2-group.is-actions {
  background: linear-gradient(180deg, rgba(255, 250, 240, 0.84), rgba(255, 255, 255, 0.62));
}

.card-layer2-group.is-meta {
  background: rgba(255, 255, 255, 0.4);
}

.card-layer2-group.is-meta p {
  font-size: 12px;
  color: var(--muted);
}

.more-actions summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.btn.is-copied {
  background: var(--green-soft);
  color: var(--green);
  border-color: rgba(47, 109, 90, 0.22);
  transition: background 100ms ease, color 100ms ease;
}

.tab-loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 3px;
  background: var(--accent);
  z-index: 2000;
  transition: none;
}

.tab-loading-bar.is-loading {
  width: 100%;
  transition: width 1.5s ease-out;
}

.match-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(244, 239, 228, 0.85);
}

.match-overlay[hidden] {
  display: none;
}

.match-overlay-card {
  display: grid;
  gap: 16px;
  justify-items: center;
  padding: 36px 48px;
  border-radius: var(--radius-xl);
  background: var(--bg-panel-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  text-align: center;
}

.match-overlay-card p {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--deep);
}

.match-overlay-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: overlay-spin 0.8s linear infinite;
}

@keyframes overlay-spin {
  to { transform: rotate(360deg); }
}

.btn:disabled {
  pointer-events: none;
  opacity: 0.55;
}


@media (max-width: 1180px) {
  .page-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    max-height: none;
  }
}

@media (max-width: 900px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-grid {
    grid-template-columns: 1fr;
  }

  .history-kv-grid {
    grid-template-columns: 1fr;
  }

  .record-card,
  .record-card.compact {
    grid-template-columns: 1fr;
  }

  .card-layer1 {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .card-summary {
    grid-column: 1;
    grid-row: auto;
  }

  .card-qr-area {
    grid-column: 1;
    grid-row: auto;
    justify-self: start;
  }

  .card-actions-compact {
    grid-column: 1;
    grid-row: auto;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .track-head,
  .timeline-item {
    grid-template-columns: 1fr;
  }

  .status-strip-head {
    flex-direction: column;
  }

  .status-pill-row {
    justify-content: flex-start;
  }

  .mode-panel-head {
    flex-direction: column;
  }

  .page-shell {
    width: min(100vw - 20px, 1560px);
  }
}
