/* =========================================================
   Hören – Übungstests B1+  ·  shared styles
   (matches the Lesen pages: header, cards, buttons, result modal)
   ========================================================= */
:root {
  --bg: #eceef2;
  --card: #ffffff;
  --text: #1e2433;
  --muted: #5b6475;
  --border: #d8dce3;
  --blue: #4169ad;
  --blue-dark: #33568f;
  --blue-soft: #eef2f9;
  --blue-line: #c9d3e4;
  --dark: #1f2633;
  --red: #c0392b;
  --red-soft: #fdecea;
  --green: #2e7d4f;
  --green-soft: #e7f4ec;
  --label-dark: #b9bfc9;
  --label-light: #e1e4e9;
  --mark: #fff1b8;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(20, 30, 50, .06), 0 4px 16px rgba(20, 30, 50, .05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 96px; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 17px; line-height: 1.5; }
a { color: var(--blue); }
button { font: inherit; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: #fff; box-shadow: 0 1px 0 var(--border), 0 2px 8px rgba(0,0,0,.04);
}
.topbar-inner {
  max-width: 1400px; margin: 0 auto; padding: 12px 28px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand { display: inline-flex; border-radius: 8px; overflow: hidden; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: 15px; text-decoration: none; color: var(--text); }
.brand span { padding: 9px 14px; }
.brand span:first-child { background: var(--label-dark); }
.brand span:first-child em { font-style: normal; color: #fff; }
.brand span:last-child { background: var(--label-light); }

.btn-back {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--blue); color: #fff; text-decoration: none; font-weight: 600;
  padding: 10px 18px; border-radius: 8px; white-space: nowrap;
}
.btn-back:hover { background: var(--blue-dark); }
.topbar-title { font-weight: 700; font-size: 19px; white-space: nowrap; }
.tabs { display: flex; gap: 8px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 1px solid var(--blue-line); background: var(--blue-soft); color: var(--blue);
  border-radius: 999px; padding: 7px 18px; text-decoration: none; white-space: nowrap; cursor: pointer; font-size: 16px;
}
.tab:hover { background: #e2e9f5; }
.timer {
  background: var(--dark); color: #fff; font-weight: 700; font-variant-numeric: tabular-nums;
  border: 0; border-radius: 8px; padding: 9px 16px; cursor: pointer; white-space: nowrap; font-size: 17px;
}
.timer.paused { background: #6b7385; }
.timer.low { background: var(--red); }

/* ---------- Layout ---------- */
.page { max-width: 1400px; margin: 0 auto; padding: 32px 28px 64px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 40px 48px; margin-bottom: 28px; }
.card h1 { font-size: 40px; line-height: 1.15; margin: 0 0 12px; letter-spacing: -.01em; }
.lead { color: var(--muted); font-size: 19px; margin: 0; }

/* summary table (test intro) */
.overview { width: 100%; border-collapse: collapse; margin-top: 28px; font-size: 17px; }
.overview th { text-align: left; background: #f5f6f8; padding: 14px 12px; font-weight: 700; }
.overview td { padding: 16px 12px; border-top: 1px solid var(--border); }
.overview tr:last-child td { border-bottom: 1px solid var(--border); }

/* ---------- Category page ---------- */
.search-row { display: flex; align-items: center; gap: 24px; margin-bottom: 28px; }
.search {
  flex: 1; display: flex; align-items: center; gap: 10px; background: #fff;
  border: 1px solid var(--border); border-radius: 10px; padding: 0 18px;
}
.search input { flex: 1; border: 0; outline: 0; font: inherit; font-size: 18px; padding: 16px 0; background: transparent; color: var(--text); }
.search:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(65,105,173,.15); }
.count { color: var(--muted); white-space: nowrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 28px; }
.test-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 32px 36px 26px; display: flex; flex-direction: column;
}
.badge { align-self: flex-start; background: var(--blue); color: #fff; font-weight: 700; font-size: 15px; border-radius: 6px; padding: 4px 12px; }
.test-card h3 { font-size: 26px; margin: 18px 0 12px; }
.teil-list { list-style: none; margin: 0 0 20px; padding: 0; color: var(--muted); flex: 1; }
.teil-list li { margin: 4px 0; }
.teil-list b { color: var(--text); font-weight: 600; margin-right: 10px; }
.teil-list .soon { font-style: italic; }
.test-card footer { border-top: 1px solid var(--border); padding-top: 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; font-weight: 600; }
.start { color: var(--blue); text-decoration: none; font-weight: 700; white-space: nowrap; }
.start:hover { text-decoration: underline; }
.empty { color: var(--muted); padding: 24px 4px; }

/* ---------- Exam sheet ---------- */
.sheet-label { display: grid; grid-template-columns: auto auto; justify-content: center; margin: 0 auto 36px; width: max-content; max-width: 100%; text-transform: uppercase; font-size: 16px; letter-spacing: .04em; }
.sheet-label span { padding: 8px 18px; }
.sheet-label .l1 { background: var(--label-dark); font-weight: 700; text-align: right; }
.sheet-label .l1 em { font-style: normal; color: #fff; }
.sheet-label .l2 { background: var(--label-light); font-weight: 700; }
.sheet-label .l3 { background: var(--label-light); text-align: right; }
.sheet-label .l4 { background: var(--label-light); }

.teil-head { display: flex; align-items: baseline; gap: 24px; flex-wrap: wrap; margin-bottom: 14px; }
.teil-head h2 { font-size: 30px; margin: 0; }
.teil-head .meta { color: var(--muted); font-size: 18px; }
.instructions p { margin: 0 0 4px; font-size: 19px; }
.situation { font-style: italic; margin: 18px 0 0; font-size: 18px; }
.box-word { display: inline-block; border: 1.5px solid var(--text); border-radius: 3px; padding: 0 10px; font-size: .9em; line-height: 1.5; }
.box-word.it { font-style: italic; }

.text-block { margin-top: 30px; }
.text-block h3 { font-size: 19px; color: var(--muted); margin: 0 0 12px; }

/* ---------- Audio player ---------- */
.player {
  display: flex; align-items: center; gap: 18px;
  background: var(--blue-soft); border: 1px solid var(--blue-line); border-radius: 12px;
  padding: 14px 18px; margin: 0 0 22px;
}
.player-btn {
  flex: none; width: 52px; height: 52px; border-radius: 50%; border: 0;
  background: var(--blue); color: #fff; cursor: pointer; display: grid; place-items: center;
}
.player-btn:hover:not(:disabled) { background: var(--blue-dark); }
.player-btn:disabled { background: #a9b3c4; cursor: not-allowed; }
.player-btn svg { width: 22px; height: 22px; fill: currentColor; }
.player-main { flex: 1; min-width: 0; }
.player-top { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; font-size: 16px; }
.player-title { font-weight: 700; }
.player-status { color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.dots { display: inline-flex; gap: 4px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--blue); }
.dot.used { background: #c3cad6; }
.player-bar { height: 8px; background: #d5dcea; border-radius: 999px; overflow: hidden; }
.player-fill { height: 100%; width: 0; background: var(--blue); transition: width .2s linear; }
.player-time { flex: none; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 15px; min-width: 96px; text-align: right; }
.player.is-playing { border-color: var(--blue); }
.player.is-locked { background: #f1f2f5; border-color: var(--border); }
.player.is-locked .player-fill { background: #a9b3c4; }
.player.is-free .player-bar { cursor: pointer; }
.player.is-error { background: var(--red-soft); border-color: #f2c2bc; }
.player.is-error .player-status { color: var(--red); }

/* ---------- Questions ---------- */
.q { display: grid; grid-template-columns: 40px 1fr auto; gap: 8px 16px; align-items: start; padding: 16px 0; border-top: 1px solid #eef0f3; }
.q:first-of-type { border-top: 0; }
.q-num { font-weight: 700; font-size: 18px; }
.q-text { font-size: 18px; }
.q-opts { display: flex; gap: 14px; }
.q-opts.col { flex-direction: column; gap: 8px; }

.opt { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 17px; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt .box {
  flex: none; min-width: 28px; height: 28px; border: 1.5px solid #555c69; border-radius: 4px;
  display: inline-grid; place-items: center; font-size: 14px; background: #fff; padding: 0 8px;
}
.opt.rf .box { min-width: 92px; font-size: 15px; }
.opt.rf.it .box { font-style: italic; }
.opt input:focus-visible + .box { outline: 3px solid rgba(65,105,173,.35); outline-offset: 2px; }
.opt input:checked + .box { background: var(--blue); border-color: var(--blue); color: #fff; }
.opt:hover input:not(:disabled) + .box { border-color: var(--blue); }
.opt input:disabled { cursor: default; }
.locked .opt { cursor: default; }

/* MC layout: stem left, options right (exam style) */
.q.mc { grid-template-columns: 40px minmax(0, 1fr) minmax(0, 1.2fr); }

/* Teil 4 – wer sagt was? */
.who-head, .q.who { grid-template-columns: 40px 1fr repeat(var(--cols, 3), 110px); }
.who-head { display: grid; gap: 16px; align-items: end; padding-bottom: 8px; font-weight: 600; color: var(--muted); font-size: 15px; }
.who-head span { text-align: center; }
.q.who .opt { justify-content: center; }
.q.who .opt .lbl { display: none; }

/* ---------- Solutions ---------- */
.revealed .opt input:checked + .box { background: var(--red); border-color: var(--red); }
.revealed .opt.is-answer input:checked + .box { background: var(--green); border-color: var(--green); }
.revealed .opt.is-answer .box { border-color: var(--green); box-shadow: 0 0 0 3px rgba(46,125,79,.2); }
.explain { display: none; grid-column: 2 / -1; border-radius: 10px; padding: 12px 16px; font-size: 16px; }
.revealed .explain { display: block; }
.explain.ok { background: var(--green-soft); }
.explain.bad { background: var(--red-soft); }
.explain strong { display: block; margin-bottom: 2px; }
.explain .quote { color: var(--muted); font-style: italic; margin-top: 4px; }

.transcript { display: none; margin-top: 18px; border: 1px solid var(--border); border-radius: 12px; padding: 0 20px; background: #fafbfc; }
.revealed .transcript { display: block; }
.transcript summary { cursor: pointer; font-weight: 600; padding: 14px 0; color: var(--blue); }
.transcript .tx { padding-bottom: 16px; font-size: 17px; line-height: 1.7; }
.transcript .tx p { margin: 0 0 8px; }
.transcript mark { background: var(--mark); padding: 1px 2px; border-radius: 3px; }
.transcript mark sup { font-weight: 700; color: var(--blue); margin-left: 2px; }

/* ---------- Action buttons ---------- */
.actions { display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; margin-top: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px;
  padding: 16px 30px; border-radius: 12px; cursor: pointer; border: 1.5px solid var(--border); background: #fff; color: var(--text);
}
.btn:hover { background: #f6f7f9; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-danger { color: var(--red); border-color: #efc5c0; }
.btn-danger:hover { background: var(--red-soft); }

/* ---------- Result modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 26, 38, .45); display: none; align-items: center; justify-content: center; padding: 20px; z-index: 100; }
.modal-bg.open { display: flex; }
.modal { background: #fff; border-radius: 18px; width: 100%; max-width: 460px; max-height: calc(100vh - 40px); overflow-y: auto; padding: 30px 32px 26px; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal h2 { margin: 0 0 6px; font-size: 28px; }
.modal-close { position: absolute; top: 14px; right: 16px; border: 0; background: none; font-size: 28px; color: var(--muted); cursor: pointer; line-height: 1; }
.modal .meta { color: var(--muted); margin: 0 0 20px; }
.ring { display: block; margin: 0 auto; }
.ring-wrap { position: relative; width: 180px; height: 180px; margin: 0 auto 16px; }
.ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-label b { font-size: 46px; line-height: 1; }
.ring-label b small { font-size: 20px; color: var(--muted); font-weight: 400; }
.ring-label span { color: var(--muted); }
.verdict { text-align: center; font-weight: 700; font-size: 20px; margin: 0 0 8px; }
.verdict.pass { color: var(--green); }
.verdict.fail { color: var(--red); }
.hint { text-align: center; color: var(--muted); margin: 0 0 18px; }
.score-table { width: 100%; border-collapse: collapse; margin-bottom: 24px; }
.score-table td { padding: 12px 8px; border-top: 1px solid var(--border); }
.score-table td:last-child { text-align: right; font-weight: 700; white-space: nowrap; }
.modal-actions { display: flex; gap: 14px; justify-content: flex-end; }
.modal-actions .btn { font-size: 18px; padding: 12px 22px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .topbar-inner { padding: 10px 16px; gap: 10px; }
  .topbar-title { order: 2; font-size: 17px; }
  .timer { order: 3; margin-left: auto; }
  .tabs { order: 4; width: 100%; margin-left: 0; }
  .page { padding: 20px 14px 48px; }
  .card { padding: 26px 20px; }
  .card h1 { font-size: 30px; }
  .q.mc { grid-template-columns: 34px 1fr; }
  .q.mc .q-opts { grid-column: 2; }
  .who-head { display: none; }
  .q.who { grid-template-columns: 34px 1fr; }
  .q.who .q-opts { grid-column: 2; flex-wrap: wrap; }
  .q.who .opt .lbl { display: inline; }
  .q.who .opt { justify-content: flex-start; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .search-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .count { text-align: right; }
  .grid { grid-template-columns: 1fr; gap: 18px; }
  .test-card { padding: 24px 22px 20px; }
  .q { grid-template-columns: 34px 1fr; }
  .q .q-opts { grid-column: 2; }
  .opt.rf .box { min-width: 84px; }
  .player { flex-wrap: wrap; gap: 12px; padding: 12px 14px; }
  .player-btn { width: 46px; height: 46px; }
  .player-top { flex-direction: column; gap: 2px; }
  .player-time { min-width: 0; font-size: 14px; }
  .overview th:nth-child(3), .overview td:nth-child(3) { display: none; }
  .btn { width: 100%; justify-content: center; }
  .modal { padding: 24px 20px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; justify-content: center; }
  .sheet-label { font-size: 13px; }
  .sheet-label span { padding: 6px 10px; }
}
