*, *::before, *::after { box-sizing: border-box; }
:root {
  --bg: #0d1b2a;
  --bg-2: #112236;
  --fg: #f5efe6;
  --fg-2: #b8c4d0;
  --accent: #c9a84c;
  --line: #1f3450;
  --rose: #d99c7a;
}
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(180deg, var(--bg) 0%, #08111a 100%);
  color: var(--fg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 28px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
  background: rgba(13, 27, 42, 0.92); backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.brand h1 { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: 0.3px; }
.brand h1 em { color: var(--fg-2); font-style: normal; font-weight: 400; margin-left: 4px; }

main { max-width: 1100px; margin: 0 auto; padding: 28px; }
footer { text-align: center; color: var(--fg-2); padding: 32px 16px; opacity: 0.6; }

.view { animation: fade 0.3s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.lead h2 { font-size: 28px; margin: 0 0 4px; }
.lead p { color: var(--fg-2); margin: 0 0 28px; }

/* Scenario grid */
.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.scenario-card {
  position: relative; overflow: hidden; border-radius: 16px;
  padding: 22px 20px 20px;
  background: linear-gradient(140deg, var(--card-bg, #1a3a5c) 0%, rgba(0,0,0,0.4) 100%);
  border: 1px solid rgba(255,255,255,0.08);
  cursor: pointer; transition: transform 0.2s, box-shadow 0.2s;
  color: #fff;
  min-height: 160px; display: flex; flex-direction: column; justify-content: space-between;
}
.scenario-card:hover { transform: translateY(-4px); box-shadow: 0 12px 30px rgba(0,0,0,0.4); }
.scenario-card h3 { margin: 0 0 8px; font-size: 22px; }
.scenario-card .count { color: rgba(255,255,255,0.7); font-size: 13px; }
.scenario-card .vocab-mini { font-size: 12px; color: rgba(255,255,255,0.85); margin-top: 12px; }

/* Dialogue list */
.dialogue-list { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.vocab { color: var(--accent); font-size: 13px; letter-spacing: 0.5px; text-transform: uppercase; margin: 8px 0 0; }
.dialogue-row {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px;
  background: var(--bg-2); border-radius: 12px; border: 1px solid var(--line);
  cursor: pointer; transition: border-color 0.2s, background 0.2s;
}
.dialogue-row:hover { border-color: var(--accent); background: #15273e; }
.dialogue-row .lang {
  display: inline-flex; width: 38px; height: 28px; align-items: center; justify-content: center;
  background: var(--accent); color: #1a1a1a; font-weight: 700; font-size: 12px; border-radius: 6px;
}
.dialogue-row .lvl {
  background: rgba(217, 156, 122, 0.18); color: var(--rose);
  border: 1px solid var(--rose); padding: 2px 8px; border-radius: 999px; font-size: 11px;
}
.dialogue-row .title { flex: 1; }
.dialogue-row .arrow { color: var(--fg-2); }

/* Hero player */
.hero { position: relative; border-radius: 16px; overflow: hidden; height: 260px; margin-bottom: 22px; }
.hero img { width: 100%; height: 100%; object-fit: cover; }
.hero::after { content:""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 30%, rgba(8,17,26,0.95) 100%); }
.hero-meta { position: absolute; bottom: 14px; left: 16px; display: flex; gap: 8px; z-index: 2; }
.flag, .lvl {
  background: rgba(0,0,0,0.6); color: #fff; padding: 4px 10px; border-radius: 6px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.5px; backdrop-filter: blur(4px);
}

.player { background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.player h2 { margin: 0 0 4px; }
.context { color: var(--fg-2); margin: 0 0 18px; font-style: italic; }

.intro-box {
  background: linear-gradient(135deg, rgba(201,168,76,0.12), rgba(201,168,76,0.04));
  border: 1px solid rgba(201,168,76,0.35);
  border-radius: 12px; padding: 16px 18px; margin-bottom: 14px;
}
.intro-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.intro-tag { color: var(--accent); font-size: 13px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; }
.intro-play { padding: 8px 16px; font-size: 13px; }
.intro-text { color: var(--fg); font-size: 14px; line-height: 1.6; margin: 0; }

.sop-box {
  background: rgba(45,106,79,0.12); border: 1px solid rgba(45,106,79,0.4);
  border-radius: 10px; padding: 12px 16px; margin-bottom: 14px; font-size: 13px;
}
.sop-box a { color: #6bbf94; text-decoration: none; border-bottom: 1px dotted #6bbf94; }
.sop-box a:hover { color: #8fd6b1; }

.controls {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center;
  padding: 14px; background: rgba(0,0,0,0.18); border-radius: 10px; margin-bottom: 14px;
}
.seg { display: inline-flex; background: rgba(0,0,0,0.3); border-radius: 8px; padding: 3px; }
.seg-btn {
  padding: 8px 14px; border: none; background: transparent; color: var(--fg-2);
  cursor: pointer; border-radius: 6px; font-size: 13px; transition: all 0.2s;
}
.seg-btn.active { background: var(--accent); color: #1a1a1a; font-weight: 600; }
.seg-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.speed, .toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--fg-2); }
.speed select {
  background: var(--bg); color: var(--fg); border: 1px solid var(--line);
  padding: 6px 10px; border-radius: 6px; font-size: 13px;
}
.toggle input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.actions { display: flex; gap: 10px; margin-bottom: 18px; }
.btn-primary, .btn-ghost {
  font-size: 14px; padding: 10px 18px; border-radius: 8px; border: 1px solid transparent;
  cursor: pointer; transition: all 0.2s; font-weight: 500;
}
.btn-primary { background: var(--accent); color: #1a1a1a; }
.btn-primary:hover { background: #d9b85c; }
.btn-ghost { background: transparent; color: var(--fg); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.transcript { list-style: none; padding: 0; margin: 0; }
.transcript li {
  display: flex; gap: 12px; padding: 14px 16px; border-radius: 10px; margin-bottom: 6px;
  cursor: pointer; transition: background 0.15s; align-items: flex-start;
}
.transcript li:hover { background: rgba(201, 168, 76, 0.08); }
.transcript li.active { background: rgba(201, 168, 76, 0.18); border-left: 3px solid var(--accent); padding-left: 13px; }
.transcript li.muted { opacity: 0.35; }
.transcript .role {
  flex-shrink: 0; width: 100px; font-size: 12px; color: var(--fg-2);
  text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; margin-top: 3px;
}
.transcript .role.guest { color: var(--rose); }
.transcript .role.recept { color: var(--accent); }
.transcript .text { flex: 1; line-height: 1.55; }
.transcript .play-btn {
  background: transparent; border: 1px solid var(--line); color: var(--fg-2);
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.transcript .play-btn:hover { border-color: var(--accent); color: var(--accent); }

body.hide-transcript .transcript .text { filter: blur(6px); transition: filter 0.2s; }
body.hide-transcript .transcript li.active .text,
body.hide-transcript .transcript li:hover .text { filter: blur(0); }

@media (max-width: 720px) {
  .topbar { padding: 14px 18px; }
  .brand h1 { font-size: 14px; }
  main { padding: 18px 14px; }
  .hero { height: 180px; }
  .controls { flex-direction: column; align-items: stretch; }
  .actions { flex-wrap: wrap; }
  .transcript .role { width: 70px; font-size: 10px; }
}
