:root {
  --bg: #f7f1ee;
  --card: #ffffff;
  --text: #2b2323;
  --muted: #7a6b68;
  --accent: #b5566e;
  --accent-text: #ffffff;
  --track: #eadcd7;
  --done: #2e7d5b;
  --ready: #b5566e;
  --locked: #9a8f8c;
  --border: #eee3df;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(80, 40, 40, 0.07);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1718;
    --card: #282223;
    --text: #f3ecea;
    --muted: #b3a5a2;
    --accent: #e0879c;
    --accent-text: #1c1718;
    --track: #3a3132;
    --done: #6fcf9f;
    --ready: #e0879c;
    --locked: #8d8280;
    --border: #3a3132;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
  font-size: 15px;
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 96px;
}

h1 { font-size: 24px; line-height: 1.25; margin: 8px 0 4px; }
h2 { font-size: 18px; margin: 28px 0 12px; }

.muted { color: var(--muted); }
.center { text-align: center; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.progress-card { margin-top: 16px; }
.progress-label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.progress-count { font-size: 20px; font-weight: 700; }

.progress {
  height: 12px;
  margin: 12px 0 4px;
  background: var(--track);
  border-radius: 999px;
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  margin-top: 16px;
  padding: 12px 16px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 17px;
  font-weight: 600;
  text-decoration: none;
}

.button[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }

.modules { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.module {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 12px 14px;
  text-decoration: none;
}

.module-order {
  flex: 0 0 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: var(--track);
}

.module-body { flex: 1; min-width: 0; }
.module-title { font-weight: 600; overflow-wrap: anywhere; }
.module-status { font-size: 14px; }
.module.locked { opacity: 0.75; }
.status-completed { color: var(--done); }
.status-available { color: var(--ready); }
.status-locked { color: var(--locked); }
.status-pending { color: var(--muted); }
.chevron { color: var(--muted); font-size: 22px; }

.small { font-size: 14px; }
.module-meta { font-size: 13px; }
.current { margin-top: 12px; display: grid; gap: 4px; }
.card + .card { margin-top: 12px; }
.card-title { margin: 0 0 8px; font-size: 16px; }

.attempts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.attempts li { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; font-size: 14px; }
.attempts li.voided span:first-child { text-decoration: line-through; color: var(--muted); }

.facts { margin: 0; display: grid; gap: 12px; }
.facts div { display: grid; gap: 2px; }
.facts dt { font-size: 13px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

.back { display: inline-block; min-height: 44px; padding: 10px 0; text-decoration: none; color: var(--muted); }

.notice { margin-top: 16px; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar a {
  flex: 1;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
}

.tabbar a[aria-current="page"] { color: var(--accent); }

@media (min-width: 720px) {
  .page { padding-top: 32px; }
  h1 { font-size: 28px; }
}
