:root {
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
  --border: #e2e5eb;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --card-bg: #1e2128;
    --text: #eef0f3;
    --muted: #9aa1ac;
    --border: #2c3038;
  }
}

* { box-sizing: border-box; }

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

.topbar {
  background: var(--primary);
  color: #fff;
  padding: 20px 16px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar h1 { margin: 4px 0; font-size: 1.4rem; }
.subtitle { margin: 0; opacity: 0.9; font-size: 0.9rem; }
.back-link {
  display: inline-block;
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
  opacity: 0.9;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.card h2 { margin-top: 0; font-size: 1.1rem; }

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

input[type="text"], select, textarea {
  width: 100%;
  padding: 10px;
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.row { display: flex; gap: 12px; }
.row > label { flex: 1; }

button {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
}
button:hover { background: var(--primary-dark); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.status { font-size: 0.85rem; color: var(--muted); min-height: 1.2em; }
.file-hint { display: block; font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
input[type="file"] { padding: 6px 0; background: transparent; border: none; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-buttons { display: flex; gap: 6px; }
.filter-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 6px 10px;
  font-size: 0.85rem;
}
.filter-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.topics-list { list-style: none; padding: 0; margin: 12px 0 0; }
.topics-list li {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.topics-list li:hover { border-color: var(--primary); }
.topics-list .empty-state { cursor: default; color: var(--muted); justify-content: center; }

.topic-title { font-weight: 600; }
.topic-meta { font-size: 0.8rem; color: var(--muted); }

.progress-badge {
  font-size: 0.8rem;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--border);
  white-space: nowrap;
}

.sticky-header {
  position: sticky;
  top: 0;
  z-index: 30;
}

.sticky-subheader {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-bottom: 10px;
}
.tab-btn {
  background: var(--card-bg);
  color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.hint { color: var(--muted); font-size: 0.9rem; margin: 0; }

.items-list { display: flex; flex-direction: column; gap: 10px; }

.item-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.item-en { font-size: 1.1rem; font-weight: 600; }
.item-pron { color: var(--primary); font-style: italic; margin: 2px 0; }
.item-es { color: var(--muted); }

.item-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}
.icon-btn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 10px;
}
.icon-btn.recording { background: var(--red); color: #fff; }
.icon-btn:disabled { opacity: 0.4; }

.rate-select {
  width: auto;
  padding: 6px 8px;
  margin-top: 0;
  font-size: 0.85rem;
}

.status-pill {
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--border);
}
.status-pill.known { background: var(--green); color: #fff; }
.status-pill.practicing { background: #f59e0b; color: #fff; }

.recognized-text { font-size: 0.85rem; margin-top: 6px; min-height: 1.1em; }
.recognized-text.match { color: var(--green); }
.recognized-text.no-match { color: var(--red); }

.example-block {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 12px;
}
.example-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 4px;
}
.example-en { font-size: 0.95rem; font-weight: 500; }
.example-pron { font-size: 0.85rem; margin: 2px 0; }
.example-block .item-es { font-size: 0.9rem; }

.dialogue-pron { color: var(--primary); }

.dialogue-col { flex: 1; }
.dialogue-text {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 0.95rem;
}

.warning {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 0.9rem;
}
.hidden { display: none; }

@media (max-width: 480px) {
  .row { flex-direction: column; }
  .dialogue-col { margin-bottom: 12px; }
}
