/* English Listening Trainer — single dark stylesheet */

:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1c232c;
  --border: #2a313c;
  --text: #e6edf3;
  --muted: #7d8590;
  --accent: #58a6ff;
  --accent-2: #79c0ff;
  --good: #56d364;
  --warn: #d29922;
  --bad: #f85149;
  --shadow: 0 4px 24px rgba(0,0,0,.35);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

header.app {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
header.app h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
header.app .tagline {
  margin-left: 10px;
  font-size: 12px;
  color: var(--muted);
}
header.app nav { display: flex; gap: 6px; }
header.app nav button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}
header.app nav button:hover { color: var(--text); border-color: var(--border); }
header.app nav button.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(88,166,255,.08);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 22px 80px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card.side { flex: 0 0 320px; max-height: 70vh; overflow: hidden; display: flex; flex-direction: column; }
.card.side .list { overflow-y: auto; flex: 1; }
.main-col { flex: 1; min-width: 0; }

.card h2 {
  margin: 0 0 6px;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.card .sub {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 14px;
}

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.fill { align-items: flex-start; }
.row > * { flex: 0 0 auto; }
.row.fill > * { flex: 1; }

label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; }

select, input[type=text], input[type=number], textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}
textarea {
  min-height: 110px;
  resize: vertical;
  font-family: var(--mono);
  line-height: 1.7;
  font-size: 15px;
}

button.btn, .btn {
  padding: 8px 14px;
  background: var(--accent);
  color: #0b0f14;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
  font-size: 14px;
  transition: filter 120ms ease;
}
button.btn:hover, .btn:hover { filter: brightness(1.1); }
button.btn:disabled { opacity: .5; cursor: not-allowed; }
button.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
button.btn.record { background: var(--bad); color: #fff; }
button.btn.record.recording { animation: pulse 1.4s infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 81, 73, .6); }
  50%      { box-shadow: 0 0 0 14px rgba(248, 81, 73, 0); }
}

.range-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.range-row input[type=range] { flex: 1; accent-color: var(--accent); }
.range-row .val {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent-2);
  min-width: 50px;
  text-align: right;
}

.audio-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel-2);
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.audio-wrap audio { flex: 1; }

.diff {
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.85;
  padding: 12px;
  background: var(--panel-2);
  border-radius: 6px;
  border: 1px solid var(--border);
  white-space: pre-wrap;
}
.diff .ok   { color: var(--text); }
.diff .miss { color: var(--bad); background: rgba(248,81,73,.18); padding: 1px 4px; border-radius: 3px; }
.diff .extra{ color: var(--warn); background: rgba(210,153,34,.18); padding: 1px 4px; border-radius: 3px; }

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.metric {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  text-align: center;
}
.metric .v {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-2);
}
.metric .l {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
}

.list { display: flex; flex-direction: column; gap: 6px; }
.list-item {
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.list-item:hover { border-color: var(--accent); }
.list-item.active { border-color: var(--accent); background: rgba(88,166,255,.08); }
.list-item .ti { font-size: 13px; color: var(--text); }
.list-item .meta { font-size: 11px; color: var(--muted); }

.item-del {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0;
  transition: opacity 120ms, color 120ms;
}
.list-item:hover .item-del { opacity: 1; }
.item-del:hover { color: var(--bad); }

.muted { color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }

.score-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.score-badge.high { background: rgba(86,211,100,.18); color: var(--good); }
.score-badge.mid  { background: rgba(210,153,34,.18); color: var(--warn); }
.score-badge.low  { background: rgba(248,81,73,.18); color: var(--bad); }

.recording-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--bad);
}
.recording-indicator::before {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--bad);
  border-radius: 50%;
  animation: pulse2 1s infinite;
}
@keyframes pulse2 { 50% { opacity: 0.3; } }

footer.app { text-align: center; font-size: 12px; color: var(--muted); padding: 30px 0; }

@media (max-width: 640px) {
  header.app nav { flex-wrap: wrap; }
  main { padding: 16px 12px 60px; }
  .card { padding: 14px; }
  .card.side { flex: 0 0 auto; max-height: none; }
}

input.cloze {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  width: auto;
  min-width: 80px;
}
input.cloze::placeholder { color: var(--muted); opacity: 0.6; }

/* ---- EXAM view additions ---- */

.exam-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.exam-option {
  text-align: left;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 15px;
  line-height: 1.4;
  transition: background 0.15s, border-color 0.15s;
}

.exam-option:hover {
  background: #232733;
  border-color: #3a4050;
}

.exam-option.selected {
  background: #1f2a3a;
  border-color: #4a8cff;
}

.exam-option.correct {
  background: #1f3a25;
  border-color: #4ade80;
}

.exam-option.wrong {
  background: #3a1f1f;
  border-color: #f87171;
}

.exam-option:disabled {
  cursor: default;
  opacity: 0.85;
}

.exam-tabs .btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.stat-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
  font-size: 14px;
}

.stat-bar .label {
  flex: 0 0 200px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-bar .track {
  flex: 1;
  height: 12px;
  background: var(--panel-2);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.stat-bar .fill {
  height: 100%;
  background: linear-gradient(90deg, #f87171 0%, #fbbf24 50%, #4ade80 100%);
  border-radius: 6px;
}

.stat-bar .value {
  flex: 0 0 60px;
  text-align: right;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
}

.stat-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 8px 0;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.stat-grid .cell {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  text-align: center;
}

.stat-grid .cell .v {
  font-size: 22px;
  font-weight: bold;
  color: var(--accent);
  font-family: var(--mono);
}

.stat-grid .cell .l {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.exam-tabs { user-select: none; }

.hidden { display: none !important; }
