:root {
  --bg: #f6efe0;
  --surface: #ffffff;
  --ink: #2c1e4a;
  --primary: #4c1d95;
  --primary-light: #7c3aed;
  --accent: #f59e0b;
  --success: #16a34a;
  --error: #dc2626;
  --muted: #6b7280;
  --border: #e2d9c3;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0;
}

header.app-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

nav a {
  color: #fff;
  margin-left: 1rem;
  text-decoration: none;
  font-weight: 600;
}
nav a:hover { text-decoration: underline; }

main {
  max-width: 720px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.stat-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.stat {
  flex: 1;
  min-width: 130px;
  background: var(--surface);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  border: 1px solid var(--border);
}
.stat .value { font-size: 1.75rem; font-weight: 700; color: var(--primary); }
.stat .label { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }

.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}
.badge-card {
  text-align: center;
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fffdf7;
}
.badge-icon { font-size: 2rem; display: block; margin-bottom: 0.25rem; }
.badge-card p { color: var(--muted); font-size: 0.85rem; margin: 0.25rem 0 0; }

button, .button {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0.7rem 1.4rem;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  font-size: 1rem;
}
button:hover { background: var(--primary-light); }
button:disabled { opacity: 0.6; cursor: not-allowed; }

input[type="text"],
input[type="number"],
input[type="password"],
input[type="file"],
textarea,
select {
  width: 100%;
  padding: 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 1rem;
  margin-top: 0.25rem;
  font-family: inherit;
}
label { display: block; margin-bottom: 1rem; font-weight: 600; }

.error { color: var(--error); font-weight: 600; min-height: 1.2em; }
.muted { color: var(--muted); }

.feedback { padding: 1rem; border-radius: 8px; margin-top: 1rem; font-weight: 600; }
.feedback.correct { background: #dcfce7; color: #166534; }
.feedback.incorrect { background: #fee2e2; color: #991b1b; }

.topic-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.topic-include { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; }
.topic-include input { width: auto; margin-top: 0; }

#preview-list, #recent-list { list-style: none; padding: 0; margin: 0.5rem 0; }
#preview-list li { color: var(--muted); font-size: 0.9rem; }
#recent-list li { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.login-card { max-width: 360px; width: 100%; text-align: center; }
.login-card h1 { margin-bottom: 0.25rem; }
