:root {
  --bg-top: #eef2ff;
  --bg-bottom: #e0f2fe;
  --panel: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #4f46e5;
  --brand-strong: #4338ca;
  --accent: #f59e0b;
  --good: #16a34a;
  --good-bg: #dcfce7;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  --shadow: 0 12px 32px rgba(79, 70, 229, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Heebo', sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

h1,
h2,
h3 {
  font-family: 'Rubik', sans-serif;
  margin: 0 0 4px;
}

.hidden {
  display: none !important;
}

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

code {
  background: var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  direction: ltr;
  display: inline-block;
}

.layout {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  padding: 10px 16px;
}

.home-icon {
  font-size: 1.2rem;
  padding: 6px 10px;
}

.topbar-metrics {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
}

.metric {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.metric strong {
  font-family: 'Rubik', sans-serif;
  font-size: 1.05rem;
  color: var(--brand-strong);
}

.metric span {
  font-size: 0.72rem;
  color: var(--muted);
}

.view {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

button {
  font-family: 'Rubik', sans-serif;
  font-size: 0.95rem;
  border: none;
  border-radius: 12px;
  padding: 11px 16px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}

button:hover {
  background: var(--brand-strong);
}

button:active {
  transform: scale(0.97);
}

button.ghost {
  background: transparent;
  color: var(--brand-strong);
  border: 1px solid var(--line);
}

button.ghost:hover {
  background: #f1f5f9;
}

button.warn-btn {
  background: var(--bad-bg);
  color: var(--bad);
}

button.warn-btn:hover {
  background: #fecaca;
}

input,
select,
textarea {
  font-family: 'Heebo', sans-serif;
  font-size: 0.95rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
  background: #fff;
  color: var(--ink);
}

textarea {
  resize: vertical;
  direction: ltr;
  text-align: left;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.inline-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-form input {
  flex: 1;
  min-width: 120px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.shortcuts-row {
  grid-template-columns: repeat(3, 1fr);
}

.shortcut-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 1.6rem;
  padding: 16px 8px;
}

.shortcut-card span {
  font-size: 0.85rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card .card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.card .card-actions button {
  flex: 1;
  padding: 8px 10px;
  font-size: 0.85rem;
}

.toggle-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.toggle-btn {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.toggle-btn.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.table-scroll {
  overflow-x: auto;
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
}

.preview-table th,
.preview-table td {
  border-bottom: 1px solid var(--line);
  padding: 6px 8px;
  text-align: right;
}

.preview-table th:first-child,
.preview-table td:first-child {
  direction: ltr;
  text-align: left;
}

.preview-table input {
  padding: 6px 8px;
}

.preview-table td:first-child input {
  direction: ltr;
  text-align: left;
}

.row-delete-btn {
  background: transparent;
  color: var(--bad);
  padding: 4px 8px;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.list li {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.actions.center {
  justify-content: center;
}

.flashcard {
  min-height: 180px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 30px 20px;
  text-align: center;
}

.flashcard-face {
  font-family: 'Rubik', sans-serif;
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--brand-strong);
}

.flashcard-back {
  border-top: 1px dashed var(--line);
  padding-top: 14px;
  width: 100%;
}

.flashcard-face-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.speak-btn-small {
  font-size: 1rem;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  padding: 0;
  flex-shrink: 0;
}

.quiz-word {
  font-family: 'Rubik', sans-serif;
  font-size: 1.6rem;
  font-weight: 600;
  text-align: center;
  margin: 4px 0 14px;
}

.quiz-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.quiz-option-btn {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 14px 10px;
  font-size: 1rem;
  min-height: 56px;
}

.quiz-option-btn.correct {
  background: var(--good-bg);
  border-color: var(--good);
  color: var(--good);
}

.quiz-option-btn.wrong {
  background: var(--bad-bg);
  border-color: var(--bad);
  color: var(--bad);
}

.match-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.match-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
  text-align: center;
  cursor: pointer;
}

.match-item.selected {
  border-color: var(--brand);
  background: #eef2ff;
}

.match-item.matched {
  background: var(--good-bg);
  border-color: var(--good);
  color: var(--good);
  cursor: default;
}

.match-item.shake {
  background: var(--bad-bg);
  border-color: var(--bad);
}

.speak-btn {
  display: block;
  margin: 0 auto 14px;
  font-size: 1.4rem;
  border-radius: 50%;
  width: 64px;
  height: 64px;
}

.record-banner {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 600;
  color: #92400e;
  text-align: center;
}

.feedback-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feedback-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.feedback-toast.good {
  background: var(--good);
}

.feedback-toast.bad {
  background: var(--bad);
}

.admin-icon-btn {
  position: fixed;
  bottom: 14px;
  left: 14px;
  z-index: 30;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.55;
}

.admin-icon-btn:hover {
  opacity: 1;
}

@media (max-width: 480px) {
  .quiz-options {
    grid-template-columns: 1fr;
  }

  .match-columns {
    gap: 6px;
  }

  .topbar-metrics {
    gap: 4px;
  }

  .metric strong {
    font-size: 0.9rem;
  }
}
