/* ═══════════════════════════════════════════════
   BASE
═══════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f0f4f8;
  color: #1a202c;
  min-height: 100vh;
}

/* ═══════════════════════════════════════════════
   AUTH SCREEN
═══════════════════════════════════════════════ */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a365d 0%, #2c5282 100%);
  padding: 1rem;
}

.auth-card {
  background: white;
  border-radius: 20px;
  padding: 2.5rem 2rem;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 25px 60px rgba(0,0,0,0.3);
  text-align: center;
}

.auth-logo  { font-size: 3rem; margin-bottom: 0.6rem; }
.auth-title { font-size: 1.5rem; font-weight: 700; color: #1a365d; margin-bottom: 0.3rem; }
.auth-sub   { color: #718096; font-size: 0.88rem; margin-bottom: 1.5rem; }

.auth-tabs {
  display: flex;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid #e2e8f0;
  margin-bottom: 1.5rem;
}
.auth-tab {
  flex: 1;
  padding: 0.6rem;
  border: none;
  background: white;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  color: #718096;
  transition: all 0.2s;
}
.auth-tab.active { background: #1a365d; color: white; }

.auth-form  { display: flex; flex-direction: column; gap: 0.8rem; }
.auth-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  outline: none;
  transition: border-color 0.2s;
}
.auth-input:focus { border-color: #1a365d; }

.auth-submit {
  padding: 0.8rem;
  background: #1a365d;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 0.3rem;
}
.auth-submit:hover { background: #2a4a7f; }
.auth-submit:disabled { opacity: 0.6; cursor: default; }

.auth-message {
  margin-top: 1rem;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
}
.auth-message.error   { background: #fff5f5; color: #c53030; border: 1px solid #fed7d7; }
.auth-message.success { background: #f0fff4; color: #276749; border: 1px solid #c6f6d5; }

/* ═══════════════════════════════════════════════
   APP HEADER
═══════════════════════════════════════════════ */
.app-header {
  background: #1a365d;
  color: white;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-title { font-size: 1.1rem; font-weight: 700; }
.header-right { display: flex; align-items: center; gap: 0.8rem; }
.header-email { font-size: 0.8rem; opacity: 0.75; }
.signout-btn {
  padding: 0.3rem 0.8rem;
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s;
}
.signout-btn:hover { background: rgba(255,255,255,0.25); }

/* ═══════════════════════════════════════════════
   CATEGORY FILTER
═══════════════════════════════════════════════ */
.filter-wrap {
  background: white;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.7rem 1rem;
}
.filter-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #a0aec0;
  margin-bottom: 0.4rem;
}
.tab-row { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.cat-btn {
  padding: 0.3rem 0.75rem;
  border: 2px solid #e2e8f0;
  border-radius: 999px;
  font-size: 0.75rem;
  cursor: pointer;
  font-weight: 600;
  background: white;
  color: #4a5568;
  transition: all 0.15s;
  white-space: nowrap;
}
.cat-btn:hover  { border-color: #a0aec0; }
.cat-btn.active { color: white; border-color: transparent; background: var(--cat-color, #1a365d); }

/* ═══════════════════════════════════════════════
   CARD AREA
═══════════════════════════════════════════════ */
.card-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 1rem 2rem;
}

/* Loading */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 3rem 0;
  color: #718096;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid #e2e8f0;
  border-top-color: #1a365d;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Progress */
.progress-row {
  width: 100%;
  max-width: 680px;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}
.progress-bar  { flex: 1; height: 6px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: #1a365d; border-radius: 999px; transition: width 0.3s; }
.stats-text    { font-size: 0.8rem; color: #718096; white-space: nowrap; }

/* Flip card */
.card-container { width: 100%; max-width: 680px; perspective: 1200px; cursor: pointer; }
.card-inner {
  display: grid;
  width: 100%;
  min-height: 240px;
  transition: transform 0.45s ease;
  transform-style: preserve-3d;
}
.card-inner.flipped { transform: rotateY(180deg); }

.card-face {
  grid-row: 1;
  grid-column: 1;
  width: 100%;
  min-height: 240px;
  backface-visibility: hidden;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.8rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.10);
  text-align: center;
}
.card-front {
  background: white;
  border-top: 6px solid var(--cat-color, #1a365d);
}
.card-back {
  background: var(--cat-bg, #ebf8ff);
  border-top: 6px solid var(--cat-color, #1a365d);
  transform: rotateY(180deg);
}

.card-label        { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.4; margin-bottom: 0.5rem; }
.card-question     { font-size: 1.2rem; font-weight: 600; line-height: 1.45; }
.card-hint         { font-size: 0.73rem; color: #a0aec0; margin-top: 0.9rem; }
.card-session-stats{ font-size: 0.7rem; color: #a0aec0; margin-top: 0.6rem; }
.card-last-result  { font-size: 0.72rem; font-weight: 700; padding: 0.18rem 0.65rem; border-radius: 999px; margin-top: 0.5rem; }
.card-last-result.known    { background: #c6f6d5; color: #22543d; }
.card-last-result.learning { background: #fed7d7; color: #742a2a; }
.card-badge {
  display: inline-block;
  padding: 0.18rem 0.65rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: white;
  background: var(--cat-color, #1a365d);
  margin-bottom: 0.6rem;
}
.card-answer { font-size: 1.02rem; line-height: 1.65; color: #2d3748; }

/* Self-assessment */
.assess-row {
  display: flex;
  gap: 0.8rem;
  margin-top: 0.9rem;
  width: 100%;
  max-width: 680px;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.assess-row.visible { opacity: 1; pointer-events: all; }
.assess-btn {
  flex: 1; max-width: 220px;
  padding: 0.55rem 1rem;
  border: none; border-radius: 10px;
  font-size: 0.88rem; font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s;
}
.assess-btn:hover { transform: scale(1.04); }
.assess-btn.known    { background: #c6f6d5; color: #22543d; }
.assess-btn.learning { background: #fed7d7; color: #742a2a; }

/* Navigation */
.nav-buttons {
  display: flex; gap: 0.8rem;
  margin-top: 0.7rem;
  width: 100%; max-width: 680px;
  justify-content: center;
}
.nav-btn {
  padding: 0.55rem 1.6rem;
  border: none; border-radius: 999px;
  font-size: 0.95rem; font-weight: 700;
  cursor: pointer; transition: all 0.15s;
}
.nav-btn.prev { background: white; color: #4a5568; box-shadow: 0 1px 4px rgba(0,0,0,0.12); }
.nav-btn.next { background: #1a365d; color: white; }
.nav-btn:hover    { opacity: 0.85; transform: scale(1.03); }
.nav-btn:disabled { opacity: 0.35; cursor: default; transform: none; }

.shuffle-btn {
  margin-top: 0.5rem;
  background: none; border: none;
  color: #718096; font-size: 0.82rem;
  cursor: pointer; text-decoration: underline;
}
.shuffle-btn:hover { color: #1a365d; }
.shortcuts { text-align: center; font-size: 0.72rem; color: #a0aec0; margin-top: 0.3rem; }

/* Summary panel */
.summary-toggle {
  margin-top: 1rem;
  background: white; border: 1px solid #e2e8f0;
  border-radius: 8px; padding: 0.4rem 1rem;
  font-size: 0.8rem; color: #718096; cursor: pointer;
}
.summary-toggle:hover { background: #f7fafc; }

.summary-panel {
  display: none;
  width: 100%; max-width: 680px;
  background: white; border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  padding: 1.2rem; margin-top: 0.6rem;
}
.summary-panel.open { display: block; }
.summary-panel h3   { font-size: 0.9rem; font-weight: 700; margin-bottom: 0.8rem; color: #2d3748; }

.summary-table       { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.summary-table th    { text-align: left; color: #718096; font-weight: 600; padding: 0.3rem 0.5rem; border-bottom: 1px solid #e2e8f0; }
.summary-table td    { padding: 0.35rem 0.5rem; border-bottom: 1px solid #f7fafc; vertical-align: top; }
.pill-known    { background: #c6f6d5; color: #22543d; padding: 0.1rem 0.4rem; border-radius: 999px; font-weight: 700; font-size: 0.72rem; }
.pill-learning { background: #fed7d7; color: #742a2a; padding: 0.1rem 0.4rem; border-radius: 999px; font-weight: 700; font-size: 0.72rem; }

.reset-btn {
  margin-top: 0.8rem;
  background: none; border: 1px solid #e2e8f0;
  border-radius: 6px; padding: 0.3rem 0.8rem;
  font-size: 0.78rem; color: #e53e3e; cursor: pointer;
}
.reset-btn:hover { background: #fff5f5; }

/* ═══════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════ */
@media (max-width: 600px) {
  .card-question      { font-size: 1.05rem; }
  .card-answer        { font-size: 0.95rem; }
  .card-face          { padding: 1.3rem; min-height: 200px; }
  .card-inner         { min-height: 200px; }
  .auth-card          { padding: 2rem 1.2rem; }
  .header-email       { display: none; }
  .assess-btn         { font-size: 0.95rem; padding: 0.7rem 0.5rem; }
  .nav-btn            { padding: 0.6rem 1.2rem; font-size: 0.9rem; }
  .cat-btn            { font-size: 0.7rem; padding: 0.28rem 0.6rem; }
  .card-area          { padding: 0.7rem 0.7rem 2rem; }
  .filter-wrap        { padding: 0.5rem 0.7rem; }
  .summary-panel      { padding: 0.9rem; }
}
