:root {
  --bg: #f7f7fb;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --accent: #5b3df5;
  --accent-dark: #4229d1;
  --border: #e5e7eb;
  --success: #1a9c62;
}

* { box-sizing: border-box; }

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

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.topbar .brand {
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  font-size: 1.1rem;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar nav a { color: var(--text); text-decoration: none; }
.topbar nav a:hover { color: var(--accent); }
.topbar .user { color: var(--muted); }

.link-button {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.link-button:hover { color: var(--accent); }

.inline-form { display: inline; }

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

h1 { margin-top: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

.card a.title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}
.card a.title:hover { color: var(--accent); }
.card.highlight { border-color: var(--accent); background: #f3f0ff; }
.card.review { border-color: #e8b84b; background: #fdf6e8; }

.status-zone {
  padding-bottom: 1.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 2px dashed var(--border);
}
.status-zone .card:last-child { margin-bottom: 0; }

.section-divider {
  margin-top: 0;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.progress {
  height: 10px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-top: 0.5rem;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
}

.module-list { list-style: none; padding: 0; }
.module-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  background: var(--card);
}
.module-list a { color: var(--text); text-decoration: none; font-weight: 500; }
.module-list a:hover { color: var(--accent); }

.badge {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--border);
  color: var(--muted);
}
.badge.done { background: #d5f2e3; color: var(--success); }
.badge.review { background: #fde9c8; color: #9a6a00; }

.module-body {
  line-height: 1.6;
  margin: 1rem 0;
}
.module-body img { max-width: 100%; height: auto; border-radius: 6px; }
.module-body h2, .module-body h3, .module-body h4 { margin-top: 1.5rem; }
.module-body blockquote {
  border-left: 3px solid var(--accent);
  margin: 1rem 0;
  padding: 0.25rem 1rem;
  color: var(--muted);
}

.embed-wrapper {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: 10px;
  margin: 1rem 0;
  background: #000;
}
.embed-wrapper iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: 0;
}

.attachments { list-style: none; padding: 0; }
.attachments li { margin-bottom: 0.4rem; }
.attachments a { color: var(--accent); }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.6rem 1.1rem;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--accent-dark); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #d8dae0; }
.complete-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
}

form.stack p { margin: 0.75rem 0; }
form.stack label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
form.stack input[type=text], form.stack input[type=email], form.stack input[type=password] {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.card.stat { text-align: center; margin-bottom: 0; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--accent); margin: 0; }
.stat-label { color: var(--muted); margin: 0.25rem 0 0; font-size: 0.85rem; }

.table-wrapper { overflow-x: auto; margin-bottom: 1.5rem; }
table { width: 100%; border-collapse: collapse; background: var(--card); }
table th, table td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.9rem;
}
table th { color: var(--muted); font-weight: 600; }

.messages { list-style: none; padding: 0; }
.messages .message {
  padding: 0.6rem 1rem;
  border-radius: 6px;
  margin-bottom: 0.75rem;
  background: #eef2ff;
}
.messages .message.success { background: #d5f2e3; }
.messages .message.error { background: #fde2e1; }
