:root {
  --bg: #f5f2ec;
  --surface: #ffffff;
  --surface-soft: #fbfaf7;
  --text: #22302d;
  --muted: #6e7975;
  --line: #dfdbd1;
  --primary: #167a78;
  --primary-deep: #0f5d5c;
  --primary-soft: #e5f3f1;
  --coral: #d85c4d;
  --coral-soft: #fae9e6;
  --amber: #e4a53e;
  --amber-soft: #fbf0dc;
  --success: #33835a;
  --success-soft: #e5f2e9;
  --shadow: 0 12px 30px rgba(41, 52, 48, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

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

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.hidden {
  display: none !important;
}

.app-header {
  min-height: 82px;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: #123e3c;
  color: #fff;
  box-shadow: 0 2px 12px rgba(16, 48, 46, 0.18);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
  color: #f6d489;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: 0;
}

.brand p {
  margin: 4px 0 0;
  color: #d4e3e0;
  font-size: 13px;
}

.header-actions {
  flex-shrink: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #eef7f5;
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e4a53e;
}

.status-pill.ready .status-dot {
  background: #75d09a;
}

.status-pill.error .status-dot {
  background: #f08373;
}

.workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 22px;
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px 28px 40px;
}

.source-panel,
.practice-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.source-panel {
  align-self: start;
  position: sticky;
  top: 18px;
  overflow: hidden;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 8px;
  gap: 6px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}

.mode-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.mode-tab svg {
  width: 17px;
  height: 17px;
}

.mode-tab.active {
  background: var(--surface);
  border-color: var(--line);
  color: var(--primary-deep);
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(34, 48, 45, 0.08);
}

.source-section {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.settings-section {
  background: var(--surface-soft);
  border-bottom: 0;
}

.field {
  margin-bottom: 13px;
}

.field:last-child {
  margin-bottom: 0;
}

.field label,
.setting-row label {
  display: block;
  margin-bottom: 6px;
  color: #4c5a56;
  font-size: 13px;
  font-weight: 700;
}

select,
input[type="search"],
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  outline: none;
}

select,
input[type="search"] {
  height: 42px;
  padding: 0 11px;
}

textarea {
  resize: vertical;
  min-height: 130px;
  padding: 11px;
  line-height: 1.55;
}

select:focus,
input[type="search"]:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 122, 120, 0.12);
}

.search-wrap {
  position: relative;
}

.search-wrap svg {
  position: absolute;
  left: 11px;
  top: 12px;
  width: 17px;
  height: 17px;
  color: var(--muted);
  pointer-events: none;
}

.search-wrap input {
  padding-left: 36px;
}

.field-hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.word-list {
  max-height: 290px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  margin-bottom: 13px;
}

.word-item {
  width: 100%;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 10px 11px;
  border: 0;
  border-bottom: 1px solid #eeeae1;
  background: #fff;
  text-align: left;
}

.word-item:last-child {
  border-bottom: 0;
}

.word-item:hover,
.word-item.selected {
  background: var(--primary-soft);
}

.word-check {
  width: 18px;
  height: 18px;
  border: 1px solid #c8c4ba;
  border-radius: 50%;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
}

.word-item.selected .word-check {
  background: var(--primary);
  border-color: var(--primary);
}

.word-text {
  min-width: 0;
}

.word-text strong {
  display: block;
  color: var(--text);
  overflow-wrap: anywhere;
}

.word-text span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.word-text .word-phonetic {
  color: var(--primary);
  font-size: 11px;
}

.word-play {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--primary);
}

.word-play:hover {
  background: #d4ebe8;
}

.word-play svg {
  width: 16px;
  height: 16px;
}

.primary-action,
.secondary-action,
.text-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 6px;
  font-weight: 700;
}

.primary-action {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  background: var(--primary);
  color: #fff;
}

.primary-action:hover:not(:disabled) {
  background: var(--primary-deep);
}

.primary-action svg,
.secondary-action svg,
.text-button svg,
.icon-button svg {
  width: 17px;
  height: 17px;
}

.secondary-action {
  min-height: 40px;
  padding: 0 13px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--text);
}

.secondary-action:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary-deep);
}

.setting-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.setting-row label {
  margin: 0;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #4c5a56;
  font-size: 13px;
}

.check-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.practice-panel {
  min-height: 620px;
  overflow: hidden;
}

.practice-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.practice-toolbar h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.practice-toolbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.practice-actions {
  display: flex;
  gap: 9px;
  flex-shrink: 0;
}

.practice-actions .primary-action {
  width: auto;
}

.progress-strip {
  height: 5px;
  background: #e8e4db;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: var(--primary);
  transition: width 0.3s ease;
}

.sentence-list {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.empty-state {
  min-height: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

.empty-icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  margin-bottom: 16px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
}

.empty-icon svg {
  width: 30px;
  height: 30px;
}

.empty-state h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 18px;
}

.empty-state p {
  max-width: 430px;
  margin: 0;
  font-size: 14px;
}

.sentence-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 14px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.sentence-card.current {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 122, 120, 0.12);
}

.sentence-card.completed {
  background: #fbfdf9;
}

.sentence-index {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 800;
}

.sentence-card.current .sentence-index {
  background: var(--primary);
  color: #fff;
}

.sentence-card.completed .sentence-index {
  background: var(--success-soft);
  color: var(--success);
}

.sentence-body {
  min-width: 0;
}

.sentence-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}

.sentence-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.tag.word-tag {
  background: var(--amber-soft);
  border-color: #efd9ae;
  color: #8a5a18;
}

.sentence-en {
  margin: 0;
  color: var(--text);
  font-size: 21px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.sentence-cn {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.sentence-result {
  margin-top: 10px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 28px;
}

.sentence-result .playback-action {
  margin-top: 2px;
}

.result-stars {
  display: flex;
  gap: 2px;
  color: #d3ad64;
}

.result-stars svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  stroke: none;
}

.result-stars .empty-star {
  color: #d8d3c8;
}

.result-text {
  color: var(--muted);
  font-size: 13px;
}

.recognized-line {
  margin-top: 8px;
  padding: 8px 10px;
  border-left: 3px solid var(--primary);
  background: var(--primary-soft);
  color: #37534f;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.ipa-line {
  margin-top: 6px;
  color: #4f5c58;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.word-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.word-chip {
  padding: 3px 7px;
  border-radius: 5px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 12px;
  font-weight: 700;
}

.word-chip.missed {
  background: var(--coral-soft);
  color: var(--coral);
}

.word-chip.extra {
  background: var(--amber-soft);
  color: #8a5a18;
}

.card-actions {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.small-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.small-action:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary-deep);
}

.small-action.record {
  background: var(--coral);
  border-color: var(--coral);
  color: #fff;
}

.small-action.record:hover:not(:disabled) {
  background: #bf4d40;
}

.small-action svg {
  width: 15px;
  height: 15px;
}

.wave-box {
  grid-column: 2;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #f8f6f1;
  border: 1px solid #e6e1d7;
}

.wave-canvas {
  width: 100%;
  height: 46px;
  display: block;
}

.recording-label {
  color: var(--coral);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.interim-text {
  grid-column: 2;
  color: var(--muted);
  font-size: 13px;
  min-height: 20px;
  font-style: italic;
}

.report-panel {
  padding: 22px;
  border-top: 1px solid var(--line);
  background: #fcfbf8;
}

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

.eyebrow {
  margin: 0 0 3px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.report-head h2 {
  margin: 0;
  font-size: 23px;
  letter-spacing: 0;
}

.icon-button {
  width: 36px;
  height: 36px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
}

.icon-button:hover {
  color: var(--text);
  border-color: #bbb6aa;
}

.report-summary {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(300px, 1.2fr);
  gap: 22px;
  align-items: center;
  margin-top: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.overall-score {
  display: flex;
  align-items: center;
  gap: 18px;
}

.score-ring {
  --score: 0deg;
  width: 116px;
  height: 116px;
  flex: 0 0 116px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--primary) var(--score), #e8e4db 0);
  position: relative;
}

.score-ring::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: #fff;
}

.score-value {
  position: relative;
  text-align: center;
}

.score-value strong {
  font-size: 38px;
  line-height: 1;
  color: var(--primary-deep);
}

.score-value span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.star-row {
  display: flex;
  gap: 3px;
  margin-bottom: 8px;
  color: #d3ad64;
}

.star-row svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  stroke: none;
}

.star-row .empty-star {
  color: #ddd7ca;
}

#report-comment {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 22px;
}

.metric {
  min-width: 0;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin: 2px 0 6px;
  color: var(--text);
  font-size: 20px;
}

.metric-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8e4db;
}

.metric-bar i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.5s ease;
}

.metric:nth-child(2) .metric-bar i {
  background: var(--coral);
}

.metric:nth-child(3) .metric-bar i {
  background: var(--amber);
}

.metric:nth-child(4) .metric-bar i {
  background: var(--success);
}

.metric:nth-child(5) .metric-bar i {
  background: var(--primary-deep);
}

.report-detail {
  margin-top: 18px;
}

.report-detail h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.report-detail-list {
  display: grid;
  gap: 8px;
}

.report-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.report-row .row-index {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.report-row .row-text {
  min-width: 0;
}

.report-row .row-text strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-row .row-text span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-score {
  color: var(--primary-deep);
  font-weight: 800;
  white-space: nowrap;
}

.report-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

.report-actions .primary-action {
  width: auto;
  min-width: 140px;
}

.mic-hint {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(600px, calc(100% - 36px));
  padding: 14px 16px;
  border-radius: 8px;
  background: #173f3d;
  color: #fff;
  box-shadow: 0 16px 36px rgba(14, 43, 41, 0.28);
}

.permission-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(23, 35, 33, 0.5);
}

.permission-dialog {
  width: min(480px, 100%);
  padding: 26px;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 24px 60px rgba(17, 31, 29, 0.28);
  text-align: center;
}

.permission-icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
}

.permission-icon svg {
  width: 28px;
  height: 28px;
}

.permission-dialog h2 {
  margin: 0 0 8px;
  font-size: 21px;
  letter-spacing: 0;
}

.permission-dialog p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.permission-hint {
  min-height: 22px;
  margin-top: 8px !important;
  color: var(--coral) !important;
  font-size: 13px !important;
}

.compat-url {
  margin-top: 8px !important;
  color: var(--primary-deep) !important;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(3px);
}

.loading-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.loading-spinner {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border: 3px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: loading-spin 0.8s linear infinite;
}

.loading-box p {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

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

.permission-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 18px;
}

.permission-actions .primary-action,
.permission-actions .secondary-action {
  width: 100%;
}

.mic-hint > svg {
  width: 24px;
  height: 24px;
  color: #f6d489;
  flex: 0 0 auto;
}

.mic-hint div {
  min-width: 0;
  flex: 1;
}

.mic-hint strong {
  display: block;
  font-size: 14px;
}

.mic-hint span {
  display: block;
  color: #d4e3e0;
  font-size: 12px;
}

.text-button {
  min-height: 34px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  white-space: nowrap;
}

.text-button:hover {
  background: rgba(255, 255, 255, 0.18);
}

.browser-note {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  width: min(600px, calc(100% - 36px));
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--coral-soft);
  border: 1px solid #efbdb4;
  color: #84362d;
  font-size: 13px;
  text-align: center;
}

@media (max-width: 1000px) {
  .workspace {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .source-panel {
    position: static;
  }

  .word-list {
    max-height: 230px;
  }
}

@media (max-width: 720px) {
  .app-header {
    padding: 15px 16px;
    align-items: flex-start;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    font-size: 17px;
  }

  .brand h1 {
    font-size: 18px;
  }

  .brand p {
    font-size: 11px;
  }

  .header-actions {
    display: none;
  }

  .workspace {
    padding: 12px;
    gap: 14px;
  }

  .practice-toolbar {
    flex-direction: column;
    align-items: stretch;
    padding: 15px;
  }

  .practice-actions {
    width: 100%;
  }

  .practice-actions button {
    flex: 1;
  }

  .sentence-list {
    padding: 14px;
    gap: 11px;
  }

  .sentence-card {
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
  }

  .sentence-index {
    width: 38px;
    height: 38px;
  }

  .card-actions,
  .wave-box,
  .interim-text {
    grid-column: 1 / -1;
  }

  .sentence-en {
    font-size: 18px;
  }

  .report-summary {
    grid-template-columns: 1fr;
  }

  .overall-score {
    justify-content: center;
  }

  .report-row {
    grid-template-columns: 30px minmax(0, 1fr) auto;
  }
}
