:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e0ea;
  --paper: #f7f5f0;
  --panel: #ffffff;
  --soft: #f3f6fb;
  --green: #138a56;
  --red: #cf3f3f;
  --blue: #2563eb;
  --yellow: #f0b429;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

button, select, input, textarea { font: inherit; }

button, .file-button, .file-picker {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: white;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  text-align: center;
}

button:disabled { cursor: not-allowed; opacity: .45; }

.secondary {
  background: white;
  color: var(--ink);
  border-color: var(--line);
}

.danger { color: var(--red); }

select, input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: white;
  color: var(--ink);
}

input[type="file"] { display: none; }

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 42px;
}

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

h1, h2, p { margin: 0; }
h1 { font-size: 34px; line-height: 1.1; }
h2 { font-size: 21px; }
.app-header p, .section-head p, .status-text, .feedback-row, .progress { color: var(--muted); }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab {
  background: white;
  color: var(--ink);
  border-color: var(--line);
}

.tab.active {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin: 18px 0;
}

.stats div, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stats div { padding: 14px; }
.stats strong { display: block; font-size: 25px; line-height: 1.1; }
.stats span { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; }

.view { display: none; }
.view.active { display: grid; gap: 16px; }
.panel { padding: 18px; }

.controls-panel, .upload-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: end;
  gap: 12px;
}

.primary-controls {
  grid-template-columns: minmax(170px, 240px) minmax(190px, 260px) auto;
  justify-content: start;
}

.advanced-settings summary {
  cursor: pointer;
  font-weight: 700;
}

.advanced-settings .controls-panel {
  margin-top: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.progress { display: grid; gap: 8px; font-size: 14px; }
.progress-track { height: 10px; overflow: hidden; border-radius: 999px; background: #edf1f7; }
#progressBar { width: 0%; height: 100%; background: var(--green); transition: width 180ms ease; }

.word-card {
  margin: 18px 0;
  min-height: 210px;
  display: grid;
  align-content: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background: #fbfcff;
  text-align: center;
}

#tag {
  justify-self: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--muted);
  font-size: 13px;
}

#word {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(42px, 7vw, 82px);
  line-height: 1.08;
  letter-spacing: 0;
}

#hint { color: var(--muted); }

.timer {
  margin: -6px 0 12px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.timer.fast {
  color: var(--green);
  font-weight: 700;
}

.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.choice {
  min-height: 66px;
  border-color: var(--line);
  background: white;
  color: var(--ink);
  text-align: left;
}

.choice.correct { border-color: var(--green); background: #e8f7ef; }
.choice.wrong { border-color: var(--red); background: #fff0f0; }

.typing-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.typing-panel[hidden], [hidden] { display: none !important; }
.typing-panel input { min-height: 54px; font: 24px Georgia, "Times New Roman", serif; }

.feedback-row, .section-head, .button-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.feedback-row { min-height: 54px; margin-top: 12px; }
.button-row { justify-content: flex-start; flex-wrap: wrap; }
.status-text { margin-top: 12px; }

.table-wrap { overflow-x: auto; }
.text-import {
  min-height: 150px;
  margin-top: 12px;
  resize: vertical;
}
.review-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.review-table th, .review-table td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; vertical-align: top; }
.review-table th { color: var(--muted); font-weight: 600; font-size: 13px; }
.review-table input { min-width: 130px; }

.deck-list, .word-list, .report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.deck-card, .word-chip, .report-card, .session-report-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 12px;
}

.deck-card strong, .word-chip strong, .report-card strong {
  display: block;
  font-size: 18px;
}

.meta, .word-chip span, .report-card span {
  color: var(--muted);
  font-size: 13px;
}

.session-report {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

@media (max-width: 860px) {
  .app-shell { width: min(100% - 20px, 1180px); padding-top: 18px; }
  .app-header, .feedback-row, .section-head { align-items: stretch; flex-direction: column; }
  .tabs { display: grid; grid-template-columns: repeat(4, 1fr); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .controls-panel, .upload-grid { grid-template-columns: 1fr; }
  .choices, .typing-panel { grid-template-columns: 1fr; }
  .button-row button, .file-button, .file-picker { width: 100%; }
}
