/* ── Reset & Base ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --site-bg: #0D1117;
  --site-card: #161B22;
  --site-border: #30363D;
  --site-text: #E6EDF3;
  --site-muted: #8B949E;
  --site-primary: #388BFD;
  --site-primary-hover: #58A6FF;
  --site-success: #3FB950;
  --site-danger: #F85149;
  --site-radius: 10px;
  --site-header-h: 58px;
  color-scheme: dark;
}

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--site-bg);
  color: var(--site-text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--site-primary); text-decoration: none; }
a:hover { color: var(--site-primary-hover); text-decoration: underline; }

/* ── Site Header ─────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--site-header-h);
  border-bottom: 1px solid var(--site-border);
  background: color-mix(in srgb, var(--site-bg) 92%, transparent);
  backdrop-filter: blur(12px);
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
}

.site-logo {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--site-text);
  letter-spacing: -.5px;
  text-decoration: none;
}

.site-logo:hover { color: var(--site-primary-hover); text-decoration: none; }

.site-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-link {
  color: var(--site-muted);
  font-size: .9rem;
  text-decoration: none;
  transition: color .15s;
}

.nav-link:hover { color: var(--site-text); text-decoration: none; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--site-border);
  border-radius: 999px;
  background: var(--site-card);
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
}

.user-name {
  font-size: .85rem;
  color: var(--site-text);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-link { font-size: .8rem; color: var(--site-muted); }

.login-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--site-primary);
  border-radius: 6px;
  background: transparent;
  color: var(--site-primary);
  font-size: .875rem;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s, color .15s;
}

.login-btn:hover {
  background: var(--site-primary);
  color: #fff;
  text-decoration: none;
}

/* ── Site Main & Footer ──────────────────────────────────────────── */
.site-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.site-footer {
  border-top: 1px solid var(--site-border);
  padding: 20px;
  text-align: center;
  color: var(--site-muted);
  font-size: .85rem;
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 20px;
  border: none;
  border-radius: 7px;
  background: var(--site-primary);
  color: #fff;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}

.btn-primary:hover { background: var(--site-primary-hover); color: #fff; text-decoration: none; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 20px;
  border: 1px solid var(--site-border);
  border-radius: 7px;
  background: transparent;
  color: var(--site-text);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: border-color .15s, background .15s;
}

.btn-ghost:hover { border-color: var(--site-primary); background: color-mix(in srgb, var(--site-primary) 10%, transparent); text-decoration: none; }

.btn-lg { padding: 12px 28px; font-size: 1rem; }

/* ── Hero ────────────────────────────────────────────────────────── */
.page-hero {
  text-align: center;
  padding: 48px 20px 36px;
}

.hero-title {
  margin: 0 0 8px;
  font-size: 2.8rem;
  font-weight: 900;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #388BFD 0%, #58A6FF 50%, #79C0FF 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  margin: 0 0 24px;
  color: var(--site-muted);
  font-size: 1.1rem;
}

.hero-login-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border: 1px solid var(--site-primary);
  border-radius: 8px;
  color: var(--site-primary);
  font-size: .95rem;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s, color .15s;
}

.hero-login-btn:hover { background: var(--site-primary); color: #fff; text-decoration: none; }

/* ── Quiz List Section ───────────────────────────────────────────── */
.quiz-section { margin-top: 8px; }

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

.section-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--site-text);
}

.quiz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* ── Quiz Card ───────────────────────────────────────────────────── */
.quiz-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  border: 1px solid var(--site-border);
  border-radius: var(--site-radius);
  background: var(--site-card);
  text-decoration: none;
  color: var(--site-text);
  transition: border-color .15s, transform .12s;
  position: relative;
  overflow: hidden;
}

.quiz-card:hover { border-color: var(--site-primary); transform: translateY(-2px); text-decoration: none; color: var(--site-text); }

.quiz-card-theme-dot {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 3px;
}

.quiz-card--history .quiz-card-theme-dot { background: #A63D2F; }
.quiz-card--social .quiz-card-theme-dot { background: #B89000; }
.quiz-card--science .quiz-card-theme-dot { background: #00B5A0; }
.quiz-card--math .quiz-card-theme-dot { background: #2979FF; }
.quiz-card--english .quiz-card-theme-dot { background: #1565C0; }
.quiz-card--korean .quiz-card-theme-dot { background: #C62828; }
.quiz-card--nihongo .quiz-card-theme-dot { background: #D81B60; }
.quiz-card--zhongwen .quiz-card-theme-dot { background: #B71C1C; }
.quiz-card--deutsch .quiz-card-theme-dot { background: #CC2200; }
.quiz-card--francais .quiz-card-theme-dot { background: #1A3A8A; }
.quiz-card--espanol .quiz-card-theme-dot { background: #CC2200; }
.quiz-card--computer .quiz-card-theme-dot { background: #E0E0E0; }
.quiz-card--other .quiz-card-theme-dot { background: var(--site-primary); }
.quiz-card--unofficial .quiz-card-theme-dot { background: #E53935; }

.quiz-card-title {
  margin: 8px 0 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;
}

.quiz-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quiz-card-count {
  color: var(--site-muted);
  font-size: .85rem;
}

.quiz-card-badge {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
}

.quiz-card-badge--history { background: color-mix(in srgb, #A63D2F 20%, transparent); color: #C34B3C; }
.quiz-card-badge--social { background: color-mix(in srgb, #B89000 20%, transparent); color: #DAB800; }
.quiz-card-badge--science { background: color-mix(in srgb, #00B5A0 20%, transparent); color: #00D5BE; }
.quiz-card-badge--math { background: color-mix(in srgb, #2979FF 20%, transparent); color: #5C9BFF; }
.quiz-card-badge--english { background: color-mix(in srgb, #1565C0 20%, transparent); color: #4A8CD6; }
.quiz-card-badge--korean { background: color-mix(in srgb, #C62828 20%, transparent); color: #E53935; }
.quiz-card-badge--nihongo { background: color-mix(in srgb, #D81B60 20%, transparent); color: #F06292; }
.quiz-card-badge--zhongwen { background: color-mix(in srgb, #B71C1C 20%, transparent); color: #E53935; }
.quiz-card-badge--deutsch { background: color-mix(in srgb, #CC2200 20%, transparent); color: #FF5722; }
.quiz-card-badge--francais { background: color-mix(in srgb, #1A3A8A 20%, transparent); color: #5C7BC7; }
.quiz-card-badge--espanol { background: color-mix(in srgb, #CC2200 20%, transparent); color: #FF5722; }
.quiz-card-badge--computer { background: color-mix(in srgb, #E0E0E0 20%, transparent); color: #E0E0E0; }
.quiz-card-badge--other { background: color-mix(in srgb, var(--site-primary) 20%, transparent); color: var(--site-primary); }
.quiz-card-badge--unofficial { background: color-mix(in srgb, #E53935 20%, transparent); color: #FF5252; }

.quiz-card-cta {
  margin-top: auto;
  color: var(--site-primary);
  font-size: .9rem;
  font-weight: 600;
}

/* ── Empty State ─────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--site-muted);
}

.empty-icon { font-size: 2.5rem; margin: 0 0 12px; }
.empty-msg { font-size: 1rem; margin: 0 0 16px; }
.empty-sub { font-size: .9rem; margin: 0; }

/* ── Error Page ──────────────────────────────────────────────────── */
.error-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.error-card {
  text-align: center;
  padding: 40px;
  border: 1px solid var(--site-border);
  border-radius: var(--site-radius);
  background: var(--site-card);
  max-width: 440px;
  width: 100%;
}

.error-icon { font-size: 2.5rem; margin: 0 0 12px; }
.error-title { margin: 0 0 12px; font-size: 1.4rem; font-weight: 800; }
.error-msg { color: var(--site-muted); margin: 0 0 24px; }
.error-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ── Modal ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  background: var(--site-card);
  border: 1px solid var(--site-border);
  border-radius: var(--site-radius);
  padding: 36px;
  max-width: 400px;
  width: 100%;
  text-align: center;
}

.modal-icon { font-size: 2.5rem; margin: 0 0 12px; }
.modal-title { margin: 0 0 10px; font-size: 1.3rem; font-weight: 800; }
.modal-msg { color: var(--site-muted); margin: 0 0 24px; }
.modal-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
