*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Georgia, serif;
  background: #faf9f6;
  color: #1a1a1a;
  min-height: 100vh;
  padding: 0;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ─────────────────────────────────────────────── */

.site-header {
  border-bottom: 1px solid #e8e5df;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.site-header .logo {
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #1a1a1a;
}

.site-header nav {
  font-size: 13px;
  color: #888;
}

.breadcrumbs-bar {
  border-bottom: 1px solid #f0ede8;
  padding: 0.5rem 1.5rem;
  max-width: calc(680px + 3rem);
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
  font-size: 12px;
  color: #aaa;
}
.breadcrumb-link { color: #aaa; }
.breadcrumb-link:hover { color: #555; text-decoration: none; }
.breadcrumb-sep { margin: 0 0.35rem; color: #ccc; }
.breadcrumb-current { color: #888; }

.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

.container-wide {
  max-width: 900px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

/* ── Headings ────────────────────────────────────────────── */

h1 {
  font-size: 24px;
  font-weight: 400;
  letter-spacing: 0.02em;
  margin-bottom: 0.4rem;
}

h2 {
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #888;
  margin-bottom: 1rem;
  margin-top: 2rem;
}

h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 0.5rem;
  margin-top: 1.5rem;
}

.subtitle {
  font-size: 13px;
  color: #888;
  letter-spacing: 0.04em;
  margin-bottom: 2rem;
}

/* ── Cards ───────────────────────────────────────────────── */

.card {
  background: #fff;
  border: 1px solid #e8e5df;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

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

.card-link {
  display: block;
  background: #fff;
  border: 1px solid #e8e5df;
  border-radius: 12px;
  padding: 1.5rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.card-link:hover { border-color: #bbb; box-shadow: 0 2px 8px rgba(0,0,0,0.06); text-decoration: none; }

.card-title { font-size: 18px; font-style: italic; margin-bottom: 0.3rem; }
.card-meta  { font-size: 13px; color: #888; }

/* ── Topic index ─────────────────────────────────────────── */

.topic-card .score-badge {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 20px;
  background: #f0ede8;
  color: #555;
  margin-top: 0.5rem;
}
.topic-card .score-badge.good  { background: #edf7f0; color: #2a7a4a; }
.topic-card .score-badge.needs-work { background: #fdf0ef; color: #a03030; }

/* ── Topic show ──────────────────────────────────────────── */

.section-list { list-style: none; }
.section-list li { border-bottom: 1px solid #f0ede8; }
.section-list li:last-child { border-bottom: none; }
.section-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  font-size: 15px;
}
.section-list a:hover { text-decoration: none; color: #333; }
.section-list .item-meta { font-size: 12px; color: #aaa; }

/* ── Quiz show ───────────────────────────────────────────── */

.quiz-header { text-align: center; margin-bottom: 2rem; }
.quiz-header h1 { font-size: 22px; font-style: italic; }

.score-history { margin-top: 2rem; }
.score-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: #888;
  padding: 0.4rem 0;
  border-bottom: 1px solid #f0ede8;
}
.score-row:last-child { border-bottom: none; }
.score-row .pct { font-variant-numeric: tabular-nums; }
.score-row .pct.good { color: #2a7a4a; }
.score-row .pct.needs-work { color: #a03030; }

/* ── Quiz attempt ────────────────────────────────────────── */

.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 1.5rem;
}
.quiz-context-label {
  font-size: 12px;
  color: #aaa;
  letter-spacing: 0.04em;
  text-align: center;
  margin-bottom: 0.75rem;
}

.progress-text { font-size: 13px; color: #888; white-space: nowrap; }
.progress-bar-wrap { flex: 1; height: 3px; background: #e8e5df; border-radius: 2px; }
.progress-bar-fill { height: 3px; background: #555; border-radius: 2px; transition: width 0.3s; }

.question-card {
  background: #fff;
  border: 1px solid #e8e5df;
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  margin-bottom: 1.25rem;
}
.question-prompt { font-size: 36px; font-style: italic; margin-bottom: 0.4rem; }
.question-hint   { font-size: 13px; color: #aaa; letter-spacing: 0.04em; }

/* Multiple choice */
.options-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 1rem;
}
.opt-btn {
  padding: 12px 8px;
  font-size: 16px;
  font-family: Georgia, serif;
  border: 1px solid #d8d4cc;
  border-radius: 8px;
  background: #fff;
  color: #1a1a1a;
  cursor: pointer;
  font-style: italic;
  transition: background 0.12s;
}
.opt-btn:hover:not(:disabled) { background: #f0ede8; }
.opt-btn:disabled { cursor: default; }
.opt-btn.correct { background: #edf7f0; color: #2a7a4a; border-color: #b8e0c8; }
.opt-btn.wrong   { background: #fdf0ef; color: #a03030; border-color: #f0c0bb; }

/* Free text */
.text-input-wrap { margin-bottom: 1rem; }
.text-input {
  width: 100%;
  max-width: 320px;
  padding: 10px 14px;
  font-size: 18px;
  font-family: Georgia, serif;
  border: 1px solid #d8d4cc;
  border-radius: 8px;
  background: #fff;
  outline: none;
  text-align: center;
}
.text-input:focus { border-color: #888; }

/* Compound text (conjugation) */
.compound-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 1rem;
  text-align: left;
}
.compound-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #fff;
  border: 1px solid #e8e5df;
  border-radius: 8px;
  padding: 10px 14px;
  transition: border-color 0.15s, background 0.15s;
}
.compound-row.correct { border-color: #b8e0c8; background: #edf7f0; }
.compound-row.wrong   { border-color: #f0c0bb; background: #fdf0ef; }
.compound-label { font-size: 13px; color: #888; width: 52px; flex-shrink: 0; font-style: italic; padding-top: 2px; }
.compound-input-wrap { flex: 1; }
.compound-input {
  border: none;
  background: transparent;
  font-size: 16px;
  font-family: Georgia, serif;
  color: #1a1a1a;
  outline: none;
  width: 100%;
}
.compound-input::placeholder { color: #ccc; }
.compound-row.correct .compound-input { color: #2a7a4a; }
.compound-row.wrong   .compound-input { color: #a03030; }
.answer-reveal { font-size: 12px; color: #2a7a4a; font-style: italic; display: none; }
.answer-reveal.show { display: block; }

/* Feedback */
.feedback {
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 8px;
  margin-bottom: 1rem;
  text-align: center;
}
.feedback.correct   { background: #edf7f0; color: #2a7a4a; border: 1px solid #b8e0c8; }
.feedback.incorrect { background: #fdf0ef; color: #a03030; border: 1px solid #f0c0bb; }

/* Buttons */
.btn {
  padding: 11px 20px;
  font-size: 14px;
  font-family: Georgia, serif;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary {
  background: #1a1a1a;
  color: #faf9f6;
  border: 1px solid #1a1a1a;
  width: 100%;
}
.btn-primary:hover { background: #333; }
.btn-secondary {
  background: transparent;
  color: #888;
  border: 1px solid #d8d4cc;
}
.btn-secondary:hover { background: #f0ede8; }

.btn-row { display: flex; gap: 8px; margin-bottom: 1rem; }

/* ── Results ─────────────────────────────────────────────── */

.results-card {
  text-align: center;
  padding: 2rem 0;
}
.score-big  { font-size: 56px; font-weight: 400; font-style: italic; }
.score-sub  { font-size: 14px; color: #888; margin: 0.5rem 0 1.5rem; letter-spacing: 0.04em; }

.miss-section { text-align: left; margin-bottom: 1.5rem; }
.miss-label { font-size: 12px; color: #888; margin-bottom: 8px; letter-spacing: 0.04em; text-transform: uppercase; }
.miss-item {
  background: #f5f3ef;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 6px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.miss-item .wrong-answer { color: #a03030; }
.miss-item .correct-answer { color: #2a7a4a; }

/* ── Markdown / notes ────────────────────────────────────── */

.prose h2 { font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: #888; margin-top: 2rem; margin-bottom: 0.75rem; }
.prose h3 { font-size: 14px; font-weight: 600; margin-top: 1.5rem; margin-bottom: 0.5rem; }
.prose p  { font-size: 14px; line-height: 1.7; margin-bottom: 1rem; color: #333; }
.prose ul, .prose ol { font-size: 14px; line-height: 1.7; margin-bottom: 1rem; padding-left: 1.5rem; color: #333; }
.prose li { margin-bottom: 0.25rem; }
.prose strong { font-weight: 600; }
.prose em { font-style: italic; }
.prose code { font-family: monospace; background: #f0ede8; padding: 1px 4px; border-radius: 3px; font-size: 12px; }

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 1.5rem;
  overflow-x: auto;
  display: block;
}
.prose th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid #e8e5df;
  font-weight: 600;
  color: #555;
  white-space: nowrap;
}
.prose td {
  padding: 8px 12px;
  border-bottom: 1px solid #f0ede8;
  vertical-align: top;
}
.prose tr:last-child td { border-bottom: none; }
.prose tr:nth-child(even) { background: #faf9f6; }

/* Reference table card */
.ref-table { margin-bottom: 2rem; }
.ref-table-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: #888; margin-bottom: 0.75rem; }

/* ── Note editor ─────────────────────────────────────────── */

.note-editor {
  width: 100%;
  min-height: 400px;
  font-family: Georgia, serif;
  font-size: 14px;
  line-height: 1.7;
  border: 1px solid #e8e5df;
  border-radius: 8px;
  padding: 1rem;
  background: #fff;
  resize: vertical;
  outline: none;
}
.note-editor:focus { border-color: #888; }

/* ── Utilities ───────────────────────────────────────────── */

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-muted { color: #888; font-size: 13px; }
.text-center { text-align: center; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* ── Header user nav ─────────────────────────────────────── */

.site-header { justify-content: flex-start; }
.site-header nav:first-of-type { flex: 1; }
.site-header-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 13px;
  color: #888;
  flex: none;
}
.current-user-email { color: #aaa; font-size: 12px; }
.sign-out-btn {
  background: none;
  border: 1px solid #d8d4cc;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-family: Georgia, serif;
  color: #888;
  cursor: pointer;
}
.sign-out-btn:hover { background: #f0ede8; color: #555; }

/* ── Flash messages ──────────────────────────────────────── */

.flash-bar {
  padding: 0.6rem 2rem;
  font-size: 13px;
  border-bottom: 1px solid transparent;
}
.flash-alert  { color: #a03030; }
.flash-notice { color: #2a7a4a; }

/* ── Auth forms ──────────────────────────────────────────── */

.auth-card {
  max-width: 380px;
  margin: 4rem auto 0;
}
.auth-card h1 { margin-bottom: 0.25rem; }
.auth-card .subtitle { margin-bottom: 2rem; }

.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-form .field { display: flex; flex-direction: column; gap: 0.3rem; }
.auth-form label { font-size: 12px; color: #888; letter-spacing: 0.04em; text-transform: uppercase; }
.auth-form input[type="email"],
.auth-form input[type="password"] {
  padding: 10px 12px;
  font-size: 15px;
  font-family: Georgia, serif;
  border: 1px solid #d8d4cc;
  border-radius: 8px;
  background: #fff;
  outline: none;
}
.auth-form input:focus { border-color: #888; }
.auth-form .btn-primary { margin-top: 0.5rem; }

.auth-errors {
  background: #fdf0ef;
  border: 1px solid #f0c0bb;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 13px;
  color: #a03030;
}
.auth-errors p { margin-bottom: 0.25rem; }
.auth-errors p:last-child { margin-bottom: 0; }

.auth-links {
  text-align: center;
  font-size: 13px;
  color: #888;
  margin-top: 1.25rem;
}
