:root {
  --canvas: #f5f5f1;
  --surface: #ffffff;
  --surface-soft: #f0f1ec;
  --ink: #182019;
  --muted: #6b746c;
  --line: #dde1da;
  --green: #177245;
  --green-dark: #0d5632;
  --green-soft: #e4f3ea;
  --orange: #e67e22;
  --red: #b63a3a;
  --shadow: 0 18px 60px rgba(31, 45, 35, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% -10%, rgba(230, 126, 34, 0.10), transparent 30%),
    radial-gradient(circle at 0% 20%, rgba(23, 114, 69, 0.08), transparent 26%),
    var(--canvas);
  font-family: Inter, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { color: inherit; }

.shell { min-height: 100vh; }

.topbar {
  height: 72px;
  padding: 0 clamp(20px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(221, 225, 218, 0.8);
  background: rgba(245, 245, 241, 0.82);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--green);
  border-radius: 10px 10px 10px 3px;
  font: 700 18px/1 Georgia, serif;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: -0.01em; }
.brand small { color: var(--muted); font-size: 11px; margin-top: 2px; }

.top-actions, .credential-summary, .run-row, .run-actions, .results-tools {
  display: flex;
  align-items: center;
}

.top-actions { gap: 16px; }
.credential-summary { gap: 12px; color: var(--muted); font-size: 12px; }
.credential-summary span { display: inline-flex; align-items: center; gap: 6px; }
.credential-summary i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #bbbfb9;
}
.credential-summary .ready i { background: #32a466; box-shadow: 0 0 0 4px rgba(50, 164, 102, .11); }

main {
  max-width: 1500px;
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 64px) 64px;
}

.hero {
  min-height: 250px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 40px;
  padding: 54px 0 34px;
}

.eyebrow {
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .15em;
}

.hero h1 {
  max-width: 760px;
  margin: 12px 0 10px;
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(34px, 4.3vw, 60px);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -.04em;
}

.hero p { max-width: 650px; margin: 0; color: var(--muted); font-size: 14px; }

.dataset-stats {
  display: flex;
  min-width: 330px;
  padding: 20px 0;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--line);
}

.dataset-stats div { flex: 1; padding-left: 18px; border-left: 1px solid var(--line); }
.dataset-stats div:first-child { padding-left: 0; border-left: 0; }
.dataset-stats strong, .dataset-stats span { display: block; }
.dataset-stats strong { font-family: Georgia, serif; font-size: 28px; font-weight: 500; }
.dataset-stats span { color: var(--muted); font-size: 11px; margin-top: 4px; }

.control-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.control-grid {
  display: grid;
  grid-template-columns: 1.3fr .8fr 1.2fr auto;
  gap: 1px;
  background: var(--line);
}

.field, .toggle-field {
  min-width: 0;
  background: var(--surface);
  padding: 17px 20px;
}

.field { display: flex; flex-direction: column; gap: 7px; }
.field > span, .toggle-field strong { font-size: 11px; font-weight: 700; }
.field small, .toggle-field small { color: var(--muted); font-size: 10px; }

.field input, .field select, .search-field input {
  width: 100%;
  height: 36px;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  outline: none;
  font-size: 13px;
}

.field input:focus, .field select:focus, .search-field input:focus { border-color: var(--green); }

.toggle-field {
  min-width: 195px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}
.toggle-field input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-field strong, .toggle-field small { display: block; }
.toggle-field small { margin-top: 4px; }
.toggle {
  width: 38px;
  height: 22px;
  padding: 3px;
  flex: none;
  border-radius: 999px;
  background: #c9cec8;
  transition: .2s;
}
.toggle::after {
  content: "";
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
  transition: .2s;
}
.toggle-field input:checked + .toggle { background: var(--green); }
.toggle-field input:checked + .toggle::after { transform: translateX(16px); }

.run-row {
  min-height: 68px;
  gap: 22px;
  padding: 13px 18px;
}
.run-actions { gap: 9px; }

.button {
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  transition: transform .15s, border-color .15s, background .15s;
}
.button:hover:not(:disabled) { transform: translateY(-1px); border-color: #aeb8af; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button-primary { color: #fff; background: var(--green); border-color: var(--green); }
.button-primary:hover:not(:disabled) { background: var(--green-dark); border-color: var(--green-dark); }
.button-secondary { color: var(--green-dark); background: var(--green-soft); border-color: #c7e3d2; }
.button-quiet { background: transparent; }
.button-mini { height: 30px; padding: 0 11px; font-size: 11px; }

.job-panel { flex: 1; min-width: 260px; }
.job-copy { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 11px; }
.job-copy span { color: var(--muted); }
.progress-track { height: 4px; overflow: hidden; border-radius: 4px; background: var(--surface-soft); }
.progress-track span { display: block; width: 0; height: 100%; background: var(--green); transition: width .25s; }
.notice { margin-left: auto; color: var(--muted); font-size: 11px; text-align: right; }
.notice[data-type="error"] { color: var(--red); }
.notice[data-type="success"] { color: var(--green); }
.notice[data-type="warning"] { color: var(--orange); }

.upload-panel {
  margin-top: 22px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.72);
  box-shadow: 0 12px 40px rgba(31,45,35,.045);
}
.upload-heading,
.upload-grid,
.upload-options,
.upload-result-head,
.upload-result-metrics {
  display: flex;
}
.upload-heading { align-items: flex-start; justify-content: space-between; gap: 20px; }
.upload-heading h2 { margin: 7px 0 5px; font: 500 24px/1.2 Georgia, "Songti SC", serif; }
.upload-heading p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.upload-target-pill {
  max-width: 360px;
  padding: 7px 10px;
  overflow: hidden;
  border: 1px solid #c7e3d2;
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 10px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upload-grid { gap: 18px; margin-top: 20px; }
.upload-file-column { min-width: 0; flex: 1.05; }
.upload-dropzone {
  min-height: 138px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1.5px dashed #b9c2ba;
  border-radius: 14px;
  background: #fafbf8;
  cursor: pointer;
  text-align: center;
  transition: border-color .18s, background .18s, transform .18s;
}
.upload-dropzone:hover,
.upload-dropzone.is-dragging { border-color: var(--green); background: var(--green-soft); transform: translateY(-1px); }
.upload-dropzone.has-file { border-style: solid; border-color: #a9d2b9; background: #f4fbf7; }
.upload-dropzone input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.upload-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; color: #fff; background: var(--green); font-size: 18px; }
.upload-dropzone strong { max-width: 100%; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.upload-dropzone small { color: var(--muted); font-size: 9px; line-height: 1.5; }
.upload-preview { width: 100%; height: 34px; margin-top: 10px; }
.upload-file-list {
  max-height: 260px;
  margin-top: 10px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.upload-file-item {
  min-height: 58px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}
.upload-file-item:last-child { border-bottom: 0; }
.upload-file-index { color: #a8afa9; font: 400 13px/1 Georgia, serif; }
.upload-file-item > div { min-width: 0; }
.upload-file-item strong,
.upload-file-item small,
.upload-file-item em,
.upload-file-item b { display: block; }
.upload-file-item strong { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.upload-file-item small { margin-top: 4px; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.upload-file-item em { color: var(--muted); font-size: 9px; font-style: normal; text-align: right; }
.upload-file-item b { margin-top: 4px; color: var(--ink); font-size: 9px; }
.upload-file-item[data-status="running"] { background: #fbf7ed; }
.upload-file-item[data-status="running"] b { color: #8a6505; }
.upload-file-item[data-status="success"] { background: #f5faf6; }
.upload-file-item[data-status="success"] b { color: var(--green); }
.upload-file-item[data-status="failed"] { background: #fdf5f4; }
.upload-file-item[data-status="failed"] b { color: var(--red); }
.upload-options { flex: 1.4; align-items: flex-end; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.compact-field { align-self: stretch; flex: .8; padding: 18px; }
.upload-expected-field { flex: 1.3; }
.upload-expectation-options {
  align-self: stretch;
  flex: 1.4;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--line);
}
.filename-expectation-toggle {
  min-height: 64px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  cursor: pointer;
}
.filename-expectation-toggle input { accent-color: var(--green); }
.filename-expectation-toggle strong,
.filename-expectation-toggle small { display: block; }
.filename-expectation-toggle strong { font-size: 10px; }
.filename-expectation-toggle small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.upload-expectation-options .compact-field { flex: 1; }
.upload-run-button { margin: 0 16px 18px; flex: 0 0 auto; }
.upload-result { margin-top: 18px; padding: 18px; border-left: 3px solid var(--green); border-radius: 0 12px 12px 0; background: #f4f8f4; }
.upload-result-head { align-items: center; justify-content: space-between; gap: 20px; }
.upload-result-head span,
.upload-result-head strong { display: block; }
.upload-result-head > div:first-child > span { color: var(--green); font-size: 9px; font-weight: 800; letter-spacing: .12em; }
.upload-result-head > div:first-child > strong { margin-top: 5px; font-size: 12px; }
.upload-result-metrics { gap: 24px; }
.upload-result-metrics span { color: var(--muted); font-size: 9px; text-align: right; }
.upload-result-metrics strong { margin-bottom: 4px; color: var(--ink); font: 500 18px/1 Georgia, serif; }
.upload-result-metrics strong.score-high { color: #11643a; }
.upload-result-metrics strong.score-mid { color: #805c04; }
.upload-result-metrics strong.score-low { color: #9c352d; }
.upload-transcript { margin: 15px 0 8px; font-size: 14px; line-height: 1.65; white-space: pre-wrap; }
.upload-result > small { color: var(--muted); font-size: 10px; }

.workspace {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  margin-top: 28px;
  border-top: 1px solid var(--line);
}

.language-sidebar { padding: 28px 24px 0 0; border-right: 1px solid var(--line); }
.sidebar-head { display: flex; justify-content: space-between; margin-bottom: 14px; color: var(--muted); font-size: 11px; }
.sidebar-head strong { color: var(--ink); }
.language-nav { display: grid; gap: 4px; }
.language-item {
  width: 100%;
  height: 40px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 0;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  text-align: left;
}
.language-item small { color: var(--muted); font-size: 10px; }
.language-item:hover { background: rgba(255,255,255,.6); }
.language-item.active { color: #fff; background: var(--ink); }
.language-item.active small { color: rgba(255,255,255,.6); }

.results-panel { min-width: 0; padding: 28px 0 0 30px; }
.results-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 17px; }
.results-head h2 { margin: 5px 0 0; font-family: Georgia, "Songti SC", serif; font-size: 24px; font-weight: 500; }
.results-tools { gap: 10px; flex-wrap: wrap; }
.expectation-filter-field select {
  min-width: 126px;
  height: 36px;
  padding: 0 31px 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  background: rgba(255,255,255,.72);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.search-field input { width: 190px; }

.audio-list { min-width: 0; }
.comparison-scroll {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255,255,255,.82);
  box-shadow: 0 12px 35px rgba(31,45,35,.04);
}
.comparison-table {
  width: 100%;
  min-width: 1040px;
  border-spacing: 0;
  table-layout: fixed;
}
.comparison-table th,
.comparison-table td {
  width: 200px;
  padding: 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
}
.comparison-table tr:last-child td { border-bottom: 0; }
.comparison-table th:last-child,
.comparison-table td:last-child { border-right: 0; }
.comparison-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f4f0e8;
}
.comparison-table th span,
.comparison-table th small,
.comparison-table th strong,
.comparison-table th em { display: block; }
.comparison-table th span { color: var(--ink); font-size: 12px; font-weight: 800; }
.comparison-table th small { min-height: 16px; margin-top: 3px; color: var(--muted); font-size: 9px; font-weight: 500; }
.comparison-table th strong { margin-top: 12px; color: var(--green-dark); font: 500 25px/1 Georgia, serif; }
.comparison-table th em { margin-top: 4px; color: var(--muted); font-size: 9px; font-style: normal; font-weight: 500; }
.comparison-table .reference-column,
.comparison-table .reference-cell {
  position: sticky;
  left: 0;
  width: 240px;
  z-index: 2;
  background: #fffdf9;
}
.comparison-table .reference-column { z-index: 4; background: #ece6dc; }
.comparison-table tbody tr:hover td { background: #fbfcfa; }
.comparison-table tbody tr:hover .reference-cell { background: #f6f7f3; }
.comparison-table tr.excluded { opacity: .48; }
.reference-cell .audio-index {
  display: block;
  margin-bottom: 8px;
  color: #a8afa9;
  font: 400 16px/1 Georgia, serif;
}
.reference-cell > strong {
  display: -webkit-box;
  overflow: hidden;
  min-height: 40px;
  font-size: 12px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.reference-cell audio { width: 100%; height: 30px; margin-top: 12px; }
.model-result-cell { position: relative; min-height: 150px; }
.model-cell-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.model-cell-head > span { color: var(--muted); font-size: 9px; }
.score-pill {
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 11px;
}
.score-pill.score-high { color: #11643a; background: #dff2e6; }
.score-pill.score-mid { color: #805c04; background: #f6eac7; }
.score-pill.score-low { color: #9c352d; background: #f7dfdc; }
.transcript-text {
  display: -webkit-box;
  overflow: hidden;
  min-height: 58px;
  margin: 11px 0 7px;
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}
.evaluation-note {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.evaluation-note.evaluation-error { color: #a34b44; }
.model-cell-empty { min-height: 98px; color: #a0a69f; font-size: 11px; }
.table-run-button {
  margin-top: 9px;
  padding: 0;
  border: 0;
  color: var(--green-dark);
  background: transparent;
  cursor: pointer;
  font-size: 10px;
  font-weight: 750;
}
.table-run-button:hover { text-decoration: underline; }
.table-run-button:disabled { cursor: not-allowed; opacity: .45; }
.empty-state { padding: 70px 20px; color: var(--muted); text-align: center; }

.settings-dialog {
  width: min(680px, calc(100vw - 30px));
  max-height: calc(100vh - 40px);
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: var(--canvas);
  box-shadow: 0 30px 100px rgba(15,25,18,.28);
}
.settings-dialog::backdrop { background: rgba(12,18,14,.46); backdrop-filter: blur(4px); }
.settings-dialog form { padding: 26px; }
.dialog-head { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.dialog-head h2 { margin: 7px 0 5px; font: 500 28px/1.1 Georgia, "Songti SC", serif; }
.dialog-head p { max-width: 520px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.icon-button { width: 34px; height: 34px; border: 0; background: transparent; cursor: pointer; font-size: 26px; }
.credential-card { padding: 18px; margin-top: 10px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.credential-title { display: flex; align-items: center; gap: 11px; }
.credential-title div { flex: 1; }
.credential-title strong, .credential-title small { display: block; }
.credential-title strong { font-size: 13px; }
.credential-title small { color: var(--muted); font-size: 10px; margin-top: 3px; }
.provider-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; font-weight: 800; font-size: 12px; }
.openai-icon { color: #fff; background: #111; }
.doubao-icon { color: #fff; background: #3067e8; }
.credential-card .field { padding: 16px 0 0; }
.status-pill { padding: 5px 8px; color: var(--muted); background: var(--surface-soft); border-radius: 999px; font-size: 9px; }
.status-pill.configured { color: var(--green-dark); background: var(--green-soft); }
.credential-test-row { display: flex; align-items: center; gap: 10px; min-height: 34px; margin-top: 14px; }
.credential-test-button { min-width: 82px; padding: 8px 12px; font-size: 10px; }
.connection-status { color: var(--muted); font-size: 10px; line-height: 1.45; }
.connection-status[data-state="testing"] { color: #755900; }
.connection-status[data-state="success"] { color: var(--green-dark); }
.connection-status[data-state="error"] { color: #a33b32; }
details { margin-top: 14px; color: var(--muted); font-size: 11px; }
summary { cursor: pointer; }
.legacy-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 980px) {
  .hero { align-items: flex-start; flex-direction: column; }
  .dataset-stats { width: 100%; min-width: 0; }
  .control-grid { grid-template-columns: 1fr 1fr; }
  .workspace { grid-template-columns: 1fr; }
  .language-sidebar { padding: 22px 0 12px; border-right: 0; }
  .language-nav { display: flex; overflow-x: auto; }
  .language-item { min-width: 105px; }
  .results-panel { padding-left: 0; }
  .upload-grid { flex-direction: column; }
}

@media (max-width: 680px) {
  .topbar { height: auto; min-height: 68px; padding: 12px 18px; }
  .brand small, .credential-summary { display: none; }
  main { padding: 0 14px 40px; }
  .hero { min-height: auto; padding: 42px 0 28px; }
  .hero h1 { font-size: 38px; }
  .control-grid { grid-template-columns: 1fr; }
  .run-row { align-items: stretch; flex-direction: column; }
  .notice { margin-left: 0; text-align: left; }
  .results-head { align-items: flex-start; flex-direction: column; }
  .results-tools { width: 100%; }
  .expectation-filter-field { flex: 0 0 126px; }
  .search-field { flex: 1; }
  .search-field input { width: 100%; }
  .comparison-table { min-width: 1040px; }
  .comparison-table th,
  .comparison-table td { width: 200px; padding: 12px; }
  .comparison-table .reference-column,
  .comparison-table .reference-cell { width: 240px; }
  .legacy-grid { grid-template-columns: 1fr; gap: 0; }
  .upload-panel { padding: 18px; }
  .upload-heading { flex-direction: column; }
  .upload-options { align-items: stretch; flex-direction: column; }
  .upload-expectation-options { width: 100%; }
  .upload-run-button { margin: 14px 16px 16px; }
  .upload-result-head { align-items: flex-start; flex-direction: column; }
}
