/* v2 */
:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface2: #25253d;
  --surface3: #2f2f4a;
  --primary: #6c63ff;
  --primary-dim: #4a43cc;
  --success: #2ecc71;
  --success-dim: #1a8a4a;
  --danger: #e74c3c;
  --danger-dim: #a93226;
  --warn: #f39c12;
  --warn-dim: #b87b0e;
  --text: #e8e8f0;
  --text-dim: #9a9ab0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100%;
}

/* ─── Typo ─── */
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 600; }
p { color: var(--text-dim); }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dim); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: var(--success-dim); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-dim); }
.btn-warn { background: var(--warn); color: #000; }
.btn-warn:hover { background: var(--warn-dim); }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--surface3);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-icon { padding: 8px; min-width: 36px; }

/* ─── Cards ─── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }

/* ─── Form ─── */
label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; color: var(--text-dim); }
input, select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--surface3);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus { border-color: var(--primary); }
input[type="checkbox"] { width: auto; }

/* ─── Nav ─── */
nav {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 16px;
  overflow-x: auto;
}
nav button {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
nav button.active { background: var(--primary); color: #fff; }
nav button:hover:not(.active) { background: var(--surface2); }

/* ─── Login ─── */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  gap: 24px;
}
.login-title { font-size: 2rem; font-weight: 800; text-align: center; }
.login-subtitle { color: var(--text-dim); text-align: center; }
.user-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 400px;
}
.user-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 12px;
  background: var(--surface);
  border: 2px solid var(--surface3);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
}
.user-card:hover { border-color: var(--primary); }
.user-card.selected { border-color: var(--primary); background: var(--surface2); }
.user-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--surface3);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}
.user-name { font-weight: 600; }
.login-pw { width: 100%; max-width: 400px; }
.remember-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.9rem; color: var(--text-dim);
}
.remember-row input { width: auto; }

/* ─── Dashboard ─── */
.dashboard { display: flex; flex-direction: column; gap: 16px; }
.streak-row {
  display: flex; align-items: center; gap: 16px;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius);
}
.streak-count {
  font-size: 2.5rem; font-weight: 800;
  color: var(--warn);
  min-width: 64px; text-align: center;
}
.due-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius);
}
.due-count {
  font-size: 1.5rem; font-weight: 700;
  color: var(--primary);
}

/* ─── Raster-Liste (Schnell-Raster) ─── */
.raster-page-info {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-dim);
  background: var(--surface2);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}
.raster-summary {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}
.sum-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
}
.bg-green { background: var(--success-dim); color: #fff; }
.bg-yellow { background: var(--warn-dim); color: #fff; }
.bg-red { background: var(--danger-dim); color: #fff; }

.raster-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.raster-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
  font-size: 0.85rem;
  border-left: 4px solid var(--surface3);
  background: var(--surface);
}
.raster-row:active { opacity: 0.6; }
.raster-row.box-6 { border-left-color: var(--success); }
.raster-row.box-3 { border-left-color: var(--warn); }
.raster-row.box-1 { border-left-color: var(--danger); }
.raster-idx {
  min-width: 22px;
  font-size: 0.7rem;
  color: var(--text-dim);
  text-align: right;
}
.raster-de {
  flex: 1;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.raster-foreign {
  flex: 1;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.raster-status {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  min-width: 60px;
  text-align: center;
}
.box-6 .raster-status { background: var(--success-dim); color: #fff; }
.box-3 .raster-status { background: var(--warn-dim); color: #fff; }
.box-1 .raster-status { background: var(--danger-dim); color: #fff; }

.raster-bottom {
  margin-top: 10px;
}
.raster-bottom .btn { width: 100%; }

/* ─── Flashcards ─── */
.flashcard-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  margin: 24px 0;
}
.flashcard {
  width: 100%;
  max-width: 500px;
  min-height: 220px;
  background: var(--surface);
  border: 2px solid var(--surface3);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}
.flashcard:active { transform: scale(0.98); }
.flashcard.revealed { border-color: var(--primary); }
.flashcard .de {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
}
.flashcard .foreign {
  font-size: 1.3rem;
  color: var(--primary);
  text-align: center;
  margin-top: 12px;
  display: none;
}
.flashcard.revealed .foreign { display: block; }
.flashcard-hint {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 8px;
}
.flash-actions {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 500px;
}
.flash-actions .btn { flex: 1; }
.flash-progress {
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* ─── Filters ─── */
.filter-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}
.filter-row select { width: 100%; }

/* ─── Checkbox list ─── */
.vocab-list { display: flex; flex-direction: column; gap: 4px; max-height: 400px; overflow-y: auto; }
.vocab-check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: background 0.1s;
}
.vocab-check-item:hover { background: var(--surface2); }
.vocab-check-item input { width: auto; }
.vocab-check-item .de { font-weight: 600; flex: 1; }
.vocab-check-item .foreign { color: var(--text-dim); font-size: 0.85rem; }

/* ─── Header ─── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-user {
  font-size: 0.85rem;
  color: var(--text-dim);
}
.back-btn {
  background: none; border: none;
  color: var(--primary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
}

/* ─── Empty state ─── */
.empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-dim);
}
.empty h3 { margin-bottom: 8px; }

/* ─── Loading ─── */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-dim);
}

/* ─── Toast ─── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 100;
  animation: toastIn 0.2s ease-out;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ─── Responsive ─── */
@media (max-width: 480px) {
  #app { padding: 12px; }
  .user-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .user-card { padding: 12px 8px; }
  .raster-grid { grid-template-columns: repeat(2, 1fr); }
  .flashcard { min-height: 180px; padding: 24px 16px; }
  .flashcard .de { font-size: 1.2rem; }
  .flashcard .foreign { font-size: 1.1rem; }
}
