:root {
  --bg: #eef2f6;
  --bg-soft: #f7f9fb;
  --surface: #ffffff;
  --surface-2: #f2f5f8;
  --surface-3: #e8edf3;
  --text: #18212f;
  --text-strong: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --border: #d8e0ea;
  --border-strong: #b9c5d3;
  --nav: #111827;
  --nav-soft: #1f2937;
  --primary: #0f766e;
  --primary-strong: #0b5d57;
  --blue: #2563eb;
  --amber: #b7791f;
  --red: #b42318;
  --green: #15803d;
  --teal-soft: #d9f3ee;
  --blue-soft: #dbeafe;
  --amber-soft: #fef3c7;
  --green-soft: #dcfce7;
  --red-soft: #fee2e2;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 14px 32px rgba(15, 23, 42, .10);
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { min-width: 320px; }

body {
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    linear-gradient(180deg, #e9eef5 0, #f7f9fb 280px, #eef2f6 100%);
  color: var(--text);
  line-height: 1.6;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

.navbar {
  min-height: 64px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(17, 24, 39, .96);
  border-bottom: 1px solid rgba(148, 163, 184, .22);
  box-shadow: 0 10px 30px rgba(15, 23, 42, .18);
  backdrop-filter: blur(14px);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: #fff;
}

.brand-icon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #14b8a6, #2563eb);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .02em;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .20);
}

.brand-copy {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.brand-copy strong {
  color: #fff;
  font-size: 15px;
  line-height: 1.2;
  white-space: nowrap;
}

.brand-copy span {
  color: #a7f3d0;
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 0;
  scrollbar-width: thin;
}

.nav-links a {
  color: #cbd5e1;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  transition: background .16s ease, color .16s ease, box-shadow .16s ease;
}

.nav-links a:hover {
  color: #fff;
  background: rgba(255, 255, 255, .09);
}

.nav-links a.active {
  color: #062b28;
  background: #99f6e4;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .28) inset;
}

.container {
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 34px 22px 40px;
}

.footer {
  width: min(1160px, calc(100% - 44px));
  margin: 0 auto 26px;
  padding: 18px 0 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.2;
  text-transform: uppercase;
  margin-bottom: 8px;
}

h1 {
  color: var(--text-strong);
  font-size: 32px;
  line-height: 1.18;
  font-weight: 900;
  letter-spacing: 0;
}

h2 {
  color: var(--text-strong);
  font-size: 19px;
  line-height: 1.3;
  font-weight: 850;
  letter-spacing: 0;
}

h3 {
  margin: 24px 0 12px;
  color: var(--text-strong);
  font-size: 17px;
  line-height: 1.3;
  font-weight: 850;
}

.lead,
.hint {
  max-width: 720px;
  color: var(--muted);
  font-size: 15px;
}

.lead { margin-top: 8px; }
.hint { margin: 6px 0 18px; }

.collect-top-grid {
  display: grid;
  grid-template-columns: minmax(290px, 1fr) minmax(320px, .9fr);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 16px;
}

.target-stack {
  display: grid;
  grid-template-columns: repeat(2, minmax(118px, 1fr));
  gap: 10px;
  flex: 0 0 auto;
}

.target-pill {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: grid;
  gap: 2px;
  min-width: 126px;
  text-align: right;
  box-shadow: var(--shadow-sm);
}

.target-pill span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.target-pill strong {
  color: var(--primary);
  font-size: 18px;
  line-height: 1.25;
  font-weight: 900;
  white-space: nowrap;
}

.target-pill.accent-blue strong { color: var(--blue); }

.setup-panel,
.scene-panel,
.sentence-card,
.recorder-panel,
.progress-box,
.result-box,
.home-card,
.dash-stat-card,
.dashboard-panel,
.dash-overall-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.setup-panel,
.scene-panel,
.recorder-panel,
.progress-box,
.dash-overall-bar,
.dashboard-panel {
  padding: 18px;
}

.panel-title,
.section-head,
.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title span,
.progress-head strong,
.section-head h2 {
  color: var(--text-strong);
  font-size: 15px;
  font-weight: 900;
}

.panel-title small,
.refresh-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.setup-panel label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 8px;
}

.setup-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  gap: 10px;
}

input[type="text"],
input[type="search"],
input[type="number"] {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

input::placeholder { color: #94a3b8; }

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, .18);
}

.setup-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px 16px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
  margin-top: 11px;
}

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

.scene-strip span {
  min-height: 48px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: #263545;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 14px;
  font-weight: 850;
}

.progress-box {
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.progress-head {
  margin-bottom: 10px;
}

.progress-bar-wrap {
  height: 11px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, .08);
}

.progress-bar-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--blue));
  transition: width .25s ease;
}

.progress-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.capture-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
  align-items: stretch;
}

.sentence-card {
  min-height: 430px;
  padding: 30px;
  display: grid;
  align-content: center;
  text-align: center;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.sentence-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-top: 4px solid var(--primary);
  pointer-events: none;
}

.sentence-meta {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  max-width: 100%;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e7edf7;
  color: #244078;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.tag.scene { background: var(--teal-soft); color: var(--primary-strong); }
.tag.patient { background: #eef2ff; color: #3730a3; }
.tag.frontdesk { background: var(--amber-soft); color: #92400e; }
.tag.consultant { background: #e0f2fe; color: #075985; }
.tag.dentist { background: var(--green-soft); color: #166534; }
.tag.nurse { background: #fce7f3; color: #9d174d; }
.tag.outreach { background: #ffedd5; color: #9a3412; }

.seq {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.sentence-text {
  max-width: 820px;
  margin: 0 auto;
  color: var(--text-strong);
  font-size: 34px;
  font-weight: 900;
  line-height: 1.55;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.pinyin-hint {
  min-height: 24px;
  max-width: 760px;
  margin: 18px auto 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.recorder-panel {
  min-height: 430px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.recorder-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.nav-controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 16px;
  color: var(--muted);
  font-weight: 900;
}

.nav-controls span {
  min-width: 72px;
  color: var(--text);
  text-align: center;
  font-size: 13px;
}

audio {
  width: 100%;
  margin-top: 14px;
}

.status-msg {
  min-height: 38px;
  margin-top: 12px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface-2);
  text-align: center;
  font-size: 14px;
  font-weight: 750;
}

.status-msg:empty {
  padding: 0;
  min-height: 0;
  background: transparent;
}

.status-msg.qc-pass { color: var(--green); background: var(--green-soft); }
.status-msg.qc-review { color: var(--amber); background: var(--amber-soft); }
.status-msg.qc-reject { color: var(--red); background: var(--red-soft); }

.btn {
  min-height: 44px;
  min-width: 94px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--text);
  background: var(--surface);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease, box-shadow .16s ease;
}

.btn:disabled {
  opacity: .48;
  cursor: not-allowed;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(15, 23, 42, .10);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) { background: var(--primary-strong); }

.btn-secondary {
  background: #e8eef6;
  color: #263545;
  border-color: #cbd5e1;
}

.btn-record {
  background: var(--red);
  color: #fff;
  min-width: 132px;
}

.btn-record.recording {
  animation: pulse 1.1s infinite;
}

.btn-warn {
  background: #fff7ed;
  color: #9a3412;
  border-color: #fed7aa;
}

.btn-ghost {
  background: #fff;
  color: var(--muted);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.btn-sm {
  min-height: 30px;
  min-width: auto;
  padding: 4px 10px;
  font-size: 13px;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .68; }
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.home-card {
  display: block;
  padding: 20px;
  color: var(--text);
  text-decoration: none;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.home-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.home-card .icon { font-size: 24px; }
.home-card h3 { margin: 10px 0 6px; }
.home-card p { color: var(--muted); font-size: 14px; }

.upload-area {
  background: var(--surface);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 38px 20px;
  display: block;
  text-align: center;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease;
}

.upload-area:hover,
.upload-area.drag {
  border-color: var(--primary);
  background: #eef8f5;
}

.upload-area input[type=file] { display: none; }

.result-box {
  padding: 0;
  overflow: hidden;
}

.dashboard-page {
  display: grid;
  gap: 18px;
}

.dashboard-heading {
  margin-bottom: 0;
}

.refresh-note {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(21, 128, 61, .12);
}

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

.dash-stat-card {
  min-height: 118px;
  padding: 16px;
  display: grid;
  align-content: space-between;
  position: relative;
  overflow: hidden;
}

.dash-stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--primary);
}

.dash-stat-card.accent-blue::before { background: var(--blue); }
.dash-stat-card.accent-amber::before { background: var(--amber); }
.dash-stat-card.accent-green::before { background: var(--green); }

.stat-num {
  color: var(--text-strong);
  font-size: 30px;
  font-weight: 950;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.dash-overall-bar {
  margin: 0;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, .85fr);
  gap: 16px;
  align-items: start;
}

.dashboard-panel {
  padding: 16px;
  min-width: 0;
}

.dashboard-panel .result-box {
  border: 0;
  box-shadow: none;
}

.speaker-row {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.speaker-row:first-child { padding-top: 0; }
.speaker-row:last-child { border-bottom: 0; padding-bottom: 0; }

.speaker-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 9px;
}

.speaker-row-head strong {
  color: var(--text-strong);
  overflow-wrap: anywhere;
}

.speaker-row-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-top: 7px;
}

.recent-row {
  display: grid;
  grid-template-columns: 78px 82px 98px minmax(0, 1fr) 50px;
  gap: 8px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  align-items: center;
}

.recent-row:first-child { padding-top: 0; }
.recent-row:last-child { border-bottom: 0; padding-bottom: 0; }

.recent-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.muted { color: var(--muted); }

.utterance {
  padding: 12px;
  border-left: 3px solid var(--border-strong);
  margin: 8px 0;
  background: var(--surface-2);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.utterance .ts { color: var(--muted); font-size: 12px; }

.utterance .emo {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
}

.emo.happy { background: var(--green-soft); color: #166534; }
.emo.sad { background: var(--blue-soft); color: #1e40af; }
.emo.angry { background: var(--red-soft); color: #991b1b; }
.emo.neutral { background: #f1f5f9; color: #475569; }

@media (max-width: 980px) {
  .collect-top-grid,
  .capture-stage,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .recorder-panel,
  .sentence-card {
    min-height: auto;
  }

  .recorder-controls {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 780px) {
  .navbar {
    align-items: stretch;
    flex-direction: column;
    padding: 10px 16px 6px;
    gap: 8px;
  }

  .nav-links {
    justify-content: flex-start;
    padding: 4px 0 6px;
  }

  .container {
    padding: 24px 14px 32px;
  }

  .footer {
    width: calc(100% - 28px);
  }

  .page-heading {
    align-items: stretch;
    flex-direction: column;
  }

  h1 { font-size: 25px; }
  h2 { font-size: 17px; }

  .target-stack,
  .dash-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .target-pill {
    text-align: left;
  }

  .setup-row,
  .scene-strip {
    grid-template-columns: 1fr;
  }

  .sentence-card {
    padding: 24px 16px;
    min-height: 280px;
  }

  .sentence-text {
    font-size: 24px;
    line-height: 1.62;
  }

  .recorder-controls {
    grid-template-columns: 1fr 1fr;
  }

  .nav-controls {
    grid-template-columns: 1fr auto 1fr;
  }

  .btn {
    width: 100%;
    min-width: 0;
    padding-left: 10px;
    padding-right: 10px;
  }

  .recent-row {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .recent-row .hide-sm {
    display: none;
  }
}

@media (max-width: 460px) {
  .brand-copy strong {
    max-width: 230px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .brand-copy span {
    display: none;
  }

  .target-stack,
  .dash-overview,
  .recorder-controls {
    grid-template-columns: 1fr;
  }

  .panel-title,
  .section-head,
  .progress-head,
  .speaker-row-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .sentence-text {
    font-size: 21px;
  }
}
