:root {
  --bg: #f3f6ff;
  --panel: #ffffff;
  --ink: #1a2233;
  --muted: #5c667a;
  --accent: #2b59d9;
  --ok: #1f8f52;
  --line: #dfe5f2;
  --warn: #d48b00;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
.hidden { display: none !important; }

.landing-view, .register-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.landing-card, .register-card {
  width: min(680px, 96vw);
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 16px 44px rgba(44, 73, 146, 0.14);
}
.landing-card {
  text-align: center;
  cursor: pointer;
}
.emblem {
  display: grid;
  place-items: center;
  margin-bottom: 16px;
}
.emblem-ring {
  width: 88px;
  height: 88px;
  border: 3px solid #2b59d9;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #eef3ff;
}
.emblem-ring span {
  color: #2b59d9;
  font-weight: 900;
  font-size: 32px;
  letter-spacing: 1px;
}
.landing-card h1 {
  margin: 0;
  font-size: 36px;
}
.tagline {
  margin: 10px 0 4px;
  font-size: 22px;
  color: #2b3f75;
}
.tagline-sub { margin: 0; color: var(--muted); }
.enter-hint {
  margin-top: 16px;
  color: var(--accent);
  font-weight: 700;
}
.register-card h2 { margin-top: 0; }
.register-card form { display: grid; gap: 8px; }
.register-card input {
  border: 1px solid #cfd8ea;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
}
.error-text {
  min-height: 20px;
  color: #b3261e;
}
.focus-mode .nav-panel { display: none; }
.focus-mode .layout { grid-template-columns: 1fr; }

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.topbar h1 { margin: 0 0 6px; font-size: 24px; }
.topbar p { margin: 0; color: var(--muted); }
.top-actions { display: flex; gap: 8px; }
.lang-select {
  border: 1px solid #cfd8ea;
  border-radius: 8px;
  padding: 6px 8px;
  background: #fff;
}
.learner-badge {
  display: inline-flex;
  align-items: center;
  background: #eef3ff;
  color: #2b3f75;
  border: 1px solid #d6e0fa;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
}

.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  padding: 16px;
}
.portal-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.portal-tabs .active-tab {
  background: var(--accent);
  color: #fff;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 8px 28px rgba(44, 73, 146, 0.08);
}

.search {
  width: 100%;
  border: 1px solid #cfd8ea;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
}

.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 180px);
  overflow: auto;
}

.chapter-btn {
  text-align: left;
  border: 1px solid var(--line);
  background: #fbfcff;
  color: var(--ink);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  transition: all .15s ease;
}
.chapter-btn:hover {
  transform: translateY(-1px);
  border-color: #c5d3f6;
}
.chapter-btn.complete {
  border-color: #b8ead0;
  background: #f2fff8;
}
.chapter-btn.active {
  border-color: var(--accent);
  background: #eef3ff;
  color: var(--ink);
}
.chapter-btn strong { color: inherit; }

.topic-line {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

.stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.stat-chip {
  background: #edf2ff;
  color: #2549af;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}
.progress-wrap {
  width: 100%;
  background: #e8edfb;
  border-radius: 999px;
  height: 8px;
}
.progress-bar {
  height: 8px;
  background: linear-gradient(90deg, #2b59d9, #4d77ed);
  border-radius: 999px;
  transition: width .2s ease;
}
.learning-nudge {
  border-left: 4px solid var(--accent);
  background: #f2f6ff;
  color: #2b3f75;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 6px 0 12px;
  font-size: 14px;
}

.topic-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}
.panel-lite {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 12px;
}
.audio-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.audio-panel audio {
  width: 100%;
  margin-bottom: 10px;
}
.audio-controls select {
  border: 1px solid #cfd8ea;
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

.topic-card h2 { margin: 0 0 4px; }
.topic-card .chapter-tag { color: var(--muted); font-size: 14px; }
.topic-meta {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.meta-chip {
  font-size: 12px;
  color: #3c4b70;
  background: #eef3ff;
  border: 1px solid #d6e0fa;
  border-radius: 999px;
  padding: 4px 8px;
}
.rule-note { color: var(--warn); font-size: 13px; margin-top: 8px; }

.qa-section, .exercise-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 12px;
}

.qa-item, .exercise-item { margin-bottom: 12px; }
.qa-item label { display: block; font-weight: 700; margin-bottom: 6px; }
textarea {
  width: 100%;
  border: 1px solid #cfd8ea;
  border-radius: 8px;
  padding: 8px;
  font-family: inherit;
  resize: vertical;
}

.exercise-title { font-weight: 700; margin-bottom: 4px; }
.exercise-instruction { margin: 0 0 8px; color: var(--muted); }
.checkline { display: flex; gap: 8px; align-items: center; margin-top: 6px; font-size: 14px; }

.actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}
button.ghost {
  background: #fff;
  color: var(--accent);
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.done-mark {
  color: var(--ok);
  font-size: 13px;
  margin-top: 6px;
}
.recap-section { margin-bottom: 12px; }
.recap-list {
  margin: 8px 0 0;
  padding-left: 18px;
}
.certificate-section h3 { margin-top: 0; }
.certificate-rule {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}
.certificate-ready {
  color: var(--ok);
  font-weight: 700;
}
.certificate-locked {
  color: var(--warn);
  font-weight: 700;
}
.certificate-section textarea {
  margin-top: 6px;
}
.cert-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.sharing-section form {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}
.hub-section form {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}
.recommend-section form {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}
.recommend-section input {
  border: 1px solid #cfd8ea;
  border-radius: 8px;
  padding: 9px;
}
.hub-section input, .hub-section select {
  border: 1px solid #cfd8ea;
  border-radius: 8px;
  padding: 9px;
}
.playbook-list {
  margin-top: 8px;
  padding-left: 20px;
  color: #2b3f75;
}
.sharing-section input, .sharing-section select {
  border: 1px solid #cfd8ea;
  border-radius: 8px;
  padding: 9px;
}
.story-list {
  display: grid;
  gap: 10px;
}
.story-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fbfcff;
}
.story-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.story-photo {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
}
