:root {
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f6f8fb;
  color: #111827;
  font-size: 16px;
  line-height: 1.5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

button,
a,
input,
textarea {
  font: inherit;
}


.app-shell {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px 24px 32px;
}

.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
  margin-bottom: 16px;
}

.app-bar-brand {
  font-weight: 800;
  font-size: 1.1rem;
  color: #4338ca;
  letter-spacing: -0.02em;
}

.app-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-bar-nav {
  display: flex;
  gap: 4px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 14px;
}

.auth-section {
  display: flex;
  align-items: center;
}

.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
}

.login-card {
  background: #ffffff;
  border-radius: 24px;
  padding: 48px 40px;
  text-align: center;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
  max-width: 360px;
  width: 100%;
}

.login-card-logo {
  font-size: 1.8rem;
  font-weight: 800;
  color: #4338ca;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.login-input {
  display: block;
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  font-size: 0.95rem;
  margin-bottom: 10px;
  background: #f8fafc;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.login-input:focus {
  outline: none;
  border-color: #4338ca;
  background: #fff;
}

.login-submit-btn {
  width: 100%;
  margin-top: 4px;
}

.login-error {
  color: #dc2626;
  font-size: 0.85rem;
  margin: 8px 0 0;
  text-align: center;
}

.auth-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: #374151;
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-signout-btn {
  padding: 5px 10px;
  background: transparent;
  color: #64748b;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.auth-signout-btn:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.app-bar-link {
  padding: 8px 16px;
  border-radius: 10px;
  text-decoration: none;
  color: #64748b;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.app-bar-link:hover {
  background: #e2e8f0;
  color: #1e293b;
}

body[data-page="entry"] .app-bar-link[href="index.html"],
body[data-page="review"] .app-bar-link[href="review.html"] {
  background: #ffffff;
  color: #4338ca;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

main {
  display: grid;
  gap: 22px;
}

/* ── Mode picker ─────────────────────────────────────────────────────────── */

.mode-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #f1f5f9;
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 2px solid transparent;
  background: #f8fafc;
  cursor: pointer;
  min-width: 72px;
  transition: background 0.15s, border-color 0.15s;
}

.mode-btn:hover {
  background: #eef2ff;
  border-color: #c7d2fe;
}

.mode-btn.active {
  background: #eef2ff;
  border-color: #4338ca;
}

.mode-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.mode-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #475569;
}

.mode-btn.active .mode-label {
  color: #4338ca;
}

.panel {
  background: #ffffff;
  border-radius: 24px;
  padding: 22px;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.06);
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}

.panel-header h2 {
  margin: 0 0 6px;
  font-size: 1.35rem;
}

.panel-header p {
  margin: 0;
  color: #64748b;
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
  color: #334155;
}

.deck-row {
  margin-bottom: 18px;
}

.deck-label {
  width: 100%;
}

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

.deck-controls select {
  min-width: 180px;
  flex: 1 1 200px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid #d1d5db;
  background: #f8fafc;
}

.new-deck-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.new-deck-name-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1.5px solid #4338ca;
  background: #fff;
  font-size: 0.95rem;
  outline: none;
  width: auto;
}

.new-deck-name-input:focus {
  box-shadow: 0 0 0 3px rgba(67, 56, 202, 0.15);
}

input,
textarea {
  width: 100%;
  border-radius: 16px;
  border: 1px solid #d1d5db;
  background: #f8fafc;
  padding: 14px 16px;
  color: #0f172a;
}

textarea {
  resize: vertical;
}

.actions-row,
.panel-actions,
.review-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.mode-panel {
  margin-top: 20px;
}

.match-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

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

.match-item {
  border: none;
  border-radius: 12px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #d1d5db;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}

.match-item:hover:not(:disabled) {
  background: #eef2ff;
  border-color: #4338ca;
}

.match-item.selected {
  background: #4338ca;
  color: white;
  border-color: #4338ca;
}

.match-item:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.blocks-board {
  margin-bottom: 20px;
}

.blocks-prompt {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 4px;
}

.blocks-progress {
  font-size: 0.8rem;
  color: #94a3b8;
  margin: 0 0 14px;
}

.blocks-selection {
  min-height: 60px;
  padding: 16px;
  background: #eef2ff;
  border-radius: 16px;
  border: 2px solid #4338ca;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 1.1rem;
  color: #334155;
  margin-bottom: 16px;
}

.blocks-fragments {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.block-fragment {
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid #d1d5db;
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.2s ease;
}

.block-fragment:hover:not(:disabled) {
  background: #eef2ff;
  border-color: #4338ca;
  transform: translateY(-2px);
}

.block-fragment:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.mode-feedback {
  margin-top: 12px;
  padding: 12px;
  background: #f0fdf4;
  border-radius: 12px;
  color: #166534;
}

@media (max-width: 720px) {
  .match-grid {
    grid-template-columns: 1fr;
  }
}


button {
  border: none;
  border-radius: 14px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button.primary {
  background: #4338ca;
  color: white;
}

button.secondary {
  background: #f8fafc;
  color: #1f2937;
  box-shadow: inset 0 0 0 1px rgba(100, 116, 139, 0.18);
}

button.danger {
  background: #fee2e2;
  color: #991b1b;
}

.card-list {
  display: grid;
  gap: 14px;
}

.flashcard {
  border-radius: 18px;
  padding: 18px;
  background: #f8fafc;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.1);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.flashcard--editing {
  box-shadow: inset 0 0 0 2px #4338ca;
  background: #eef2ff;
}

.flashcard-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.flashcard-body {
  flex: 1;
  min-width: 0;
}

.flashcard-move-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.flashcard-move-row select {
  flex: 1;
  min-width: 120px;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  background: #fff;
  font-size: 0.85rem;
}

.flashcard-move-row button {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.flashcard h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.flashcard p {
  margin: 0;
  color: #475569;
  white-space: pre-wrap;
}

.flashcard-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.flashcard-actions button {
  padding: 5px 12px;
  font-size: 0.8rem;
}

.review-card {
  min-height: 260px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  border-radius: 28px;
  padding: 28px;
  background: linear-gradient(180deg, #eef2ff 0%, #ffffff 100%);
  border: 1px solid rgba(99, 102, 241, 0.18);
  position: relative;
}

.review-card:focus {
  outline: 3px solid rgba(99, 102, 241, 0.35);
}

.review-card .front,
.review-card .back {
  font-size: 1.3rem;
  line-height: 1.5;
  max-width: 90%;
}

.review-card .back {
  color: #334155;
}

.review-tip {
  margin-top: 18px;
  color: #64748b;
  font-size: 0.95rem;
}

.hidden {
  display: none;
}

.footer {
  text-align: center;
  margin: 30px 0 0;
  color: #64748b;
  font-size: 0.875rem;
}

.footer a {
  color: #6366f1;
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

/* ── Policy page ─────────────────────────────────────────────────────────── */

.policy-content h1 {
  margin: 0 0 6px;
  font-size: 1.6rem;
}

.policy-updated {
  margin: 0 0 28px;
  font-size: 0.875rem;
  color: #64748b;
}

.policy-content h2 {
  margin: 32px 0 10px;
  font-size: 1.15rem;
  color: #1e293b;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 6px;
}

.policy-content h3 {
  margin: 20px 0 8px;
  font-size: 1rem;
  color: #334155;
}

.policy-content p,
.policy-content li {
  color: #475569;
  line-height: 1.7;
  max-width: 72ch;
}

.policy-content ul {
  padding-left: 20px;
  margin: 10px 0;
}

.policy-content li {
  margin-bottom: 4px;
}

.policy-content a {
  color: #4338ca;
  text-decoration: none;
}

.policy-content a:hover {
  text-decoration: underline;
}

.policy-content code {
  font-family: ui-monospace, "Cascadia Code", "Fira Code", monospace;
  font-size: 0.875em;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 5px;
  color: #334155;
}

.policy-table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0 20px;
  font-size: 0.9rem;
}

.policy-table th,
.policy-table td {
  text-align: left;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  color: #475569;
  line-height: 1.5;
}

.policy-table th {
  background: #f8fafc;
  font-weight: 600;
  color: #334155;
}

@media (max-width: 720px) {
  .panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-actions,
  .actions-row,
  .review-controls {
    justify-content: stretch;
  }

  .app-bar-link {
    padding: 7px 12px;
    font-size: 0.8rem;
  }
}

/* ── Learn mode ─────────────────────────────────────────────────────────── */

.learn-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.learn-progress-bar {
  flex: 1;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.learn-progress-fill {
  height: 100%;
  width: 0%;
  background: #4338ca;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.learn-progress-text {
  font-size: 0.875rem;
  color: #64748b;
  white-space: nowrap;
}

.learn-phase-label {
  margin: 0 0 10px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #6366f1;
}

.learn-prompt {
  margin: 0 0 20px;
  font-size: 1.3rem;
  font-weight: 600;
  color: #1e293b;
}

.mc-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

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

.mc-option {
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid #e2e8f0;
  background: #f8fafc;
  text-align: left;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1.4;
  transition: border-color 0.15s, background 0.15s;
}

.mc-option:hover:not(:disabled) {
  border-color: #4338ca;
  background: #eef2ff;
}

.mc-option.correct {
  border-color: #16a34a;
  background: #f0fdf4;
  color: #15803d;
}

.mc-option.incorrect {
  border-color: #dc2626;
  background: #fef2f2;
  color: #dc2626;
}

.learn-feedback {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #f0fdf4;
  color: #166534;
  font-size: 0.95rem;
}

/* ── Test mode ──────────────────────────────────────────────────────────── */

.test-question {
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 16px 18px;
  margin-bottom: 14px;
}

.test-question-type {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
}

.test-question-prompt {
  margin: 0 0 14px;
  font-weight: 600;
  color: #1e293b;
}

.test-mc-options {
  display: grid;
  gap: 8px;
}

.test-mc-option {
  padding: 10px 14px;
  border-radius: 10px;
  border: 2px solid #e2e8f0;
  background: #f8fafc;
  text-align: left;
  cursor: pointer;
  font-size: 0.9rem;
  transition: border-color 0.15s, background 0.15s;
}

.test-mc-option:hover { border-color: #4338ca; background: #eef2ff; }
.test-mc-option.selected { border-color: #4338ca; background: #eef2ff; color: #3730a3; }

.test-tf-options {
  display: flex;
  gap: 10px;
}

.test-tf-btn {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  border: 2px solid #e2e8f0;
  background: #f8fafc;
  cursor: pointer;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s;
}

.test-tf-btn:hover { border-color: #4338ca; background: #eef2ff; }
.test-tf-btn.selected { border-color: #4338ca; background: #eef2ff; color: #3730a3; }

.test-written-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  background: #f8fafc;
  font: inherit;
  color: #0f172a;
}

.test-score-banner {
  text-align: center;
  padding: 22px;
  background: linear-gradient(135deg, #eef2ff, #f0fdf4);
  border-radius: 16px;
  margin-bottom: 20px;
}

.test-score-banner p {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  color: #1e293b;
}

.test-result-feedback {
  margin: 4px 0 0;
  font-size: 0.875rem;
  padding: 5px 10px;
  border-radius: 8px;
  display: inline-block;
}

.test-result-feedback.correct { background: #f0fdf4; color: #15803d; }
.test-result-feedback.incorrect { background: #fef2f2; color: #dc2626; }

/* ── Match timer ────────────────────────────────────────────────────────── */

.match-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 0.95rem;
  color: #475569;
}

.match-header strong {
  color: #4338ca;
  font-size: 1.1rem;
}

.match-best-time {
  font-size: 0.875rem;
  color: #64748b;
}

/* ── Gravity mode ───────────────────────────────────────────────────────── */

.gravity-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
}

.gravity-board {
  position: relative;
  height: 220px;
  background: linear-gradient(180deg, #1e1b4b 0%, #312e81 100%);
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 14px;
}

.gravity-term {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -70px;
  background: #4338ca;
  color: #fff;
  padding: 10px 22px;
  border-radius: 10px;
  font-size: 1.1rem;
  font-weight: 600;
  white-space: nowrap;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gravity-term.falling {
  animation-name: gravityFall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

.gravity-term.hit {
  background: #dc2626;
}

.gravity-term.cleared {
  background: #16a34a;
  transition: background 0.15s;
}

@keyframes gravityFall {
  from { top: -70px; }
  to   { top: 250px; }
}

.gravity-input {
  margin-bottom: 10px;
}

.gravity-start-screen {
  text-align: center;
  padding: 16px 0 4px;
}

.gravity-start-screen p {
  margin: 0 0 14px;
  color: #64748b;
}
