:root {
  --bg: #faf7f2;
  --card-bg: #ffffff;
  --ink: #2b2420;
  --muted: #8a7f73;
  --accent: #b5652c;
  --border: #e8e0d5;
  --warn-bg: #fff3e0;
  --warn-border: #e8a33d;
  --resource-bg: #edf6f1;
  --resource-ink: #3d735d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}

.topbar {
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
.topbar h1 { margin: 0 0 4px; font-size: 20px; }
.page-nav { display: flex; gap: 7px; margin-bottom: 9px; font-size: 12px; }
.page-nav a, .page-nav span { padding: 3px 9px; border-radius: 999px; text-decoration: none; }
.page-nav span { color: #fff; background: var(--accent); }
.page-nav a { color: var(--accent); background: #f1e8dc; }
.page-nav a:hover { background: #e8d8c5; }
.subtitle { margin: 0 0 12px; color: var(--muted); font-size: 14px; }

.controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
#searchBox {
  flex: 1 1 260px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}
.filter-toggle { font-size: 13px; color: var(--muted); white-space: nowrap; }
.stat-counter { font-size: 13px; color: var(--muted); margin-left: auto; }

main { max-width: 880px; margin: 0 auto; padding: 20px 24px 60px; }

.ep-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 14px;
  overflow: hidden;
}
.ep-card:target { border-color: #c98b5f; box-shadow: 0 0 0 3px rgba(181, 101, 44, .12); }

.ep-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
}
.ep-header:hover { background: #fbf5ec; }
.ep-num {
  font-weight: 700;
  color: var(--accent);
  min-width: 52px;
}
.ep-title { font-weight: 600; flex: 1; }
.ep-badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f1ece2;
  color: var(--muted);
}
.ep-badge.warn { background: var(--warn-bg); color: #a35b00; border: 1px solid var(--warn-border); }
.ep-toggle-icon { color: var(--muted); font-size: 12px; }

.ep-body { display: none; padding: 0 18px 18px; border-top: 1px solid var(--border); }
.ep-card.open .ep-body { display: block; }
.ep-card.open .ep-toggle-icon { transform: rotate(180deg); }
.ep-toggle-icon { transition: transform .18s ease; }

.section-block { margin-top: 16px; }
.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.section-title-row { display: flex; align-items: baseline; gap: 8px; }
.section-count { color: var(--muted); font-size: 12px; }

audio { width: 100%; height: 36px; }
.audio-path-note { font-size: 12px; color: var(--muted); margin-top: 4px; word-break: break-all; }

.resource-badge { background: var(--resource-bg); color: var(--resource-ink); }
.selected-badge { background: var(--accent); color: #fff; }
.supplementary-block {
  border: 1px solid #dce9e1;
  background: #f8fcf9;
  border-radius: 9px;
  padding: 12px;
}
.candidate-list { display: grid; gap: 9px; }
.candidate-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px 10px;
}
.candidate-item.selected { border-color: #9dc4af; box-shadow: inset 3px 0 0 #5b9276; }
.candidate-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; min-width: 0; }
.candidate-index { flex: 0 0 auto; color: var(--resource-ink); font-size: 12px; font-weight: 700; }
.candidate-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.candidate-meta .ep-badge { margin-left: auto; flex: 0 0 auto; }
.resource-hint { color: var(--muted); font-size: 12px; margin-top: 8px; }

.script-list { display: grid; gap: 8px; }
.script-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
}
.script-link:hover { border-color: #9dc4af; background: #f3faf6; }
.script-icon {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--resource-bg);
  color: var(--resource-ink);
  font-weight: 700;
}
.script-copy { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.script-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.script-copy small { color: var(--muted); font-size: 12px; }
.script-arrow { color: var(--resource-ink); font-size: 16px; }

.tabs { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.tab-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
}
.tab-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tab-panel { display: none; white-space: pre-wrap; font-size: 14px; background: #fdfaf5; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.tab-panel.active { display: block; }

.eval-mismatch {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 10px;
}

table.eval-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 8px; }
table.eval-table th, table.eval-table td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; }
table.eval-table th { background: #f6f1e8; }
.eval-winner-row { background: #fbf0e2; font-weight: 600; }
.eval-reason { font-size: 13px; color: var(--muted); margin-top: 4px; }
.eval-none { font-size: 13px; color: var(--muted); font-style: italic; }

.note-block { margin-top: 16px; }
.note-textarea {
  width: 100%;
  min-height: 70px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
.note-actions { display: flex; gap: 10px; margin-top: 8px; align-items: center; flex-wrap: wrap; }
.btn {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}
.btn.secondary { background: #fff; color: var(--accent); }
.note-saved-hint { font-size: 12px; color: #4a8f4a; }

.empty-hint { text-align: center; color: var(--muted); padding: 40px 0; }

@media (max-width: 700px) {
  .topbar { position: static; padding: 16px 14px 12px; }
  main { padding: 14px 12px 40px; }
  .ep-header { align-items: flex-start; flex-wrap: wrap; gap: 7px 9px; padding: 12px 13px; }
  .ep-title { min-width: calc(100% - 74px); }
  .ep-toggle-icon { margin-left: auto; }
  .ep-body { padding: 0 12px 14px; }
  .stat-counter { width: 100%; margin-left: 0; }
  table.eval-table { min-width: 720px; }
  .section-block:has(.eval-table) { overflow-x: auto; }
}
