:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --warn: #f59e0b;
  --danger: #ef4444;
  --ok: #10b981;
  --border: #334155;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

header {
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

header h1 { margin: 0; font-size: 1.3rem; }

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.hidden { display: none !important; }

.row { display: flex; align-items: center; }
.row.gap { gap: 0.5rem; flex-wrap: wrap; }
.row.between { justify-content: space-between; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

button {
  padding: 0.6rem 1rem;
  border: 0;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s;
}

button.primary { background: var(--accent); color: white; }
button.primary:hover { background: var(--accent-hover); }

button.warn { background: var(--warn); color: #111; }
button.warn:hover { filter: brightness(1.1); }

button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
button.ghost:hover { background: var(--surface-2); }

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

input[type="text"] {
  flex: 1;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.topic-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s;
}
.topic-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.topic-card h3 { margin: 0 0 0.25rem 0; font-size: 1rem; }
.topic-card .meta { font-size: 0.8rem; color: var(--muted); }

.lesson-text {
  background: var(--bg);
  border-left: 3px solid var(--accent);
  padding: 0.9rem 1rem;
  border-radius: 6px;
  margin: 0.8rem 0;
  min-height: 60px;
}

audio {
  width: 100%;
  margin: 0.5rem 0 1rem;
  filter: invert(0.85);
}

.chain {
  background: var(--bg);
  border-radius: 8px;
  padding: 0.5rem;
  margin: 0.75rem 0;
  max-height: 320px;
  overflow-y: auto;
}

.chain-turn {
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.4rem;
  border-radius: 6px;
}
.chain-turn.q { background: var(--surface-2); }
.chain-turn.a { background: #312e81; }
.chain-turn .role {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.banner {
  padding: 0.6rem 1rem;
  margin-top: 0.6rem;
  border-radius: 6px;
  background: #7c2d12;
  color: #fef3c7;
  font-size: 0.85rem;
}

.transcript {
  margin-top: 1.5rem;
  padding: 0.6rem 1rem;
  background: var(--bg);
  border-radius: 8px;
}
.transcript summary { cursor: pointer; color: var(--muted); }
.transcript-entry {
  padding: 0.3rem 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.88rem;
}
.transcript-entry:last-child { border-bottom: 0; }
.transcript-entry .tag {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-right: 0.4rem;
  background: var(--surface-2);
  color: var(--muted);
}

.recording { background: var(--danger) !important; color: white; }

h2 { margin-top: 0; }
h3 { margin-bottom: 0.5rem; }
