:root {
  --bg: #0f1216;
  --panel: #171b21;
  --panel-2: #1e232b;
  --border: #2a303a;
  --text: #e8eaed;
  --text-dim: #9aa3af;
  --accent: #c9a24b;
  --accent-dim: #8c7433;
  --good: #4caf7d;
  --bad: #d9695f;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

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

header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0;
  justify-self: start;
}

.topic-filter-centered {
  justify-self: center;
}

header .btn-link {
  justify-self: end;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  background: var(--accent);
  color: #1a1a1a;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-link:hover {
  background: #d9b45f;
}

.filter-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.custom-select {
  position: relative;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 40px;
  box-sizing: border-box;
  min-width: 200px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.custom-select-trigger:hover {
  border-color: var(--accent-dim);
}

.custom-select.open .custom-select-trigger {
  border-color: var(--accent);
}

.custom-select-caret {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  color: var(--text-dim);
  transition: transform 0.15s;
}

.custom-select.open .custom-select-caret {
  transform: rotate(180deg);
}

.custom-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 260px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  padding: 6px;
  z-index: 40;
}

.custom-select-group-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  padding: 10px 10px 4px;
}

.custom-select-option {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.custom-select-option:hover {
  background: var(--panel-2);
}

.custom-select-option.active {
  background: var(--accent-dim);
  color: #fff3da;
}

.custom-select-option.indent {
  padding-left: 20px;
  font-size: 12.5px;
  color: var(--text-dim);
}

.custom-select-option.indent.active {
  color: #fff3da;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  box-sizing: border-box;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  cursor: pointer;
  line-height: 1;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.icon-btn:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
}

.missed-only-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}

.toggle-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.toggle-switch {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 24px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background 0.15s, border-color 0.15s;
}

.toggle-switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform 0.15s, background 0.15s;
}

.toggle-input:checked + .toggle-switch {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.toggle-input:checked + .toggle-switch::before {
  transform: translateX(20px);
  background: var(--accent);
}

.toggle-input:focus-visible + .toggle-switch {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sidebar-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: calc(100vh - 65px);
}

.topic-sidebar {
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  height: 100%;
  overflow-y: auto;
}

.sidebar-loading,
.empty-state-text {
  color: var(--text-dim);
  font-size: 14px;
  padding: 8px;
}

.sidebar-topic-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.sidebar-toggle {
  flex-shrink: 0;
  width: 18px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 10px;
  cursor: pointer;
  padding: 0;
}

.sidebar-toggle:hover {
  color: var(--text);
}

.sidebar-topic {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.sidebar-topic:hover {
  background: var(--panel-2);
}

.sidebar-topic.active {
  background: var(--accent-dim);
  color: #fff3da;
}

.sidebar-topic .count {
  font-size: 12px;
  color: var(--text-dim);
}

.sidebar-topic.active .count {
  color: #fff3da;
}

.sidebar-subtopic {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  text-align: left;
  padding: 7px 10px 7px 32px;
  border-radius: 6px;
  cursor: pointer;
}

.sidebar-subtopic:hover {
  background: var(--panel-2);
  color: var(--text);
}

.sidebar-subtopic.active {
  background: var(--accent-dim);
  color: #fff3da;
}

.sidebar-subtopic .count {
  font-size: 11px;
  opacity: 0.75;
}

.stat-badges {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.stat-badge {
  display: inline-block;
  box-sizing: border-box;
  min-width: 22px;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 10px;
  text-align: center;
}

.stat-badge.correct {
  background: rgba(76, 175, 125, 0.18);
  color: var(--good);
}

.stat-badge.wrong {
  background: rgba(217, 105, 95, 0.18);
  color: var(--bad);
}

.sidebar-topic.active .stat-badge.correct,
.sidebar-subtopic.active .stat-badge.correct {
  background: rgba(255, 255, 255, 0.18);
  color: #d7f5e6;
}

.sidebar-topic.active .stat-badge.wrong,
.sidebar-subtopic.active .stat-badge.wrong {
  background: rgba(255, 255, 255, 0.18);
  color: #ffd9d3;
}

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  overflow-y: auto;
  height: 100%;
  box-sizing: border-box;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 800px;
  max-width: 100%;
  height: 700px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

#drillContent {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.badge {
  background: var(--accent-dim);
  color: #fff3da;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 9px;
  border-radius: 20px;
}

.topic {
  font-size: 13px;
  color: var(--text-dim);
}

.empty-state {
  text-align: center;
  padding: 20px 0;
  margin: auto 0;
}

.empty-state p {
  color: var(--text-dim);
  font-size: 15px;
  margin: 0 0 16px;
}

.question {
  font-size: 20px;
  line-height: 1.5;
  margin: 0 0 28px;
  font-weight: 500;
}

.mic-area {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.record-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--accent);
  color: #1a1a1a;
  border: none;
  border-radius: 24px;
  padding: 11px 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.record-btn:hover {
  background: #d9b45f;
}

.record-btn:active {
  transform: scale(0.98);
}

.record-btn.recording {
  background: var(--bad);
  color: #fff;
}

.mic-icon {
  font-size: 10px;
}

.recording-indicator {
  font-size: 13px;
  color: var(--bad);
  display: flex;
  align-items: center;
  gap: 6px;
}

.recording-indicator::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bad);
  animation: pulse 1.1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.transcript-box {
  display: block;
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  flex: 1;
  min-height: 120px;
  font-size: 15px;
  font-family: inherit;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 20px;
  resize: vertical;
}

.transcript-box:focus {
  outline: none;
  border-color: var(--accent-dim);
}

.transcript-box::placeholder {
  color: var(--text-dim);
  font-style: italic;
}

.actions {
  display: flex;
  gap: 10px;
}

.primary-btn {
  background: var(--accent);
  color: #1a1a1a;
  border: none;
  border-radius: 8px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.primary-btn:disabled {
  background: var(--panel-2);
  color: var(--text-dim);
  cursor: not-allowed;
}

.secondary-btn {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 18px;
  font-size: 14px;
  cursor: pointer;
}

.secondary-btn:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

.result {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  width: 800px;
  max-width: 100%;
  height: 700px;
  overflow-y: auto;
}

.result-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.score-badge {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
}

.verdict {
  font-size: 15px;
  color: var(--text-dim);
}

.result h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin: 0 0 8px;
}

.model-answer-text {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 0 0 18px;
}

mark.buzzword-hit {
  background: rgba(76, 175, 125, 0.18);
  color: var(--good);
  padding: 0 2px;
  border-radius: 3px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.1s;
}

mark.buzzword-miss {
  background: rgba(217, 105, 95, 0.18);
  color: var(--bad);
  padding: 0 2px;
  border-radius: 3px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.1s;
}

mark.buzzword-hit:hover,
mark.buzzword-miss:hover {
  opacity: 0.65;
}


.banner {
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  font-size: 13px;
  text-align: center;
  color: var(--text-dim);
}

.banner.error {
  background: #3a1f1f;
  color: #f0b4ae;
  border: 1px solid #5c2c26;
  border-radius: 8px;
  margin: 0;
}

.hidden {
  display: none !important;
}
