:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #17203a;
  --muted: #5d6b8a;
  --line: #e3e8f4;
  --primary: #2456f0;
  --primary-ink: #ffffff;
  --primary-soft: #e8eeff;
  --green: #0f9d58;
  --green-soft: #e3f5ec;
  --amber: #b7791f;
  --amber-soft: #fdf1dc;
  --red: #d64545;
  --red-soft: #fde9e9;
  --blue-soft: #e5efff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(23, 32, 58, .06), 0 8px 24px rgba(23, 32, 58, .07);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
h1 { font-size: 26px; margin: 0 0 6px; }
h2 { font-size: 19px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 0 0 8px; }
p { margin: 8px 0; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 18px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand em { color: var(--primary); font-style: normal; }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav-link {
  padding: 7px 12px; border-radius: 9px; color: var(--muted); font-weight: 500;
}
.nav-link:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.nav-link.active { background: var(--primary-soft); color: var(--primary); }
.userbox { display: flex; align-items: center; gap: 10px; }
.userbox-name { font-weight: 600; }
.userbox-role { color: var(--muted); font-size: 12px; background: var(--bg); border: 1px solid var(--line); padding: 2px 8px; border-radius: 999px; }

/* ---------- Layout ---------- */
.container { max-width: 900px; margin: 26px auto 60px; padding: 0 20px; }
.container-wide { max-width: 1240px; }
.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 26px 16px 40px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { color: var(--muted); font-size: 13px; margin: 0 0 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.center-card { max-width: 460px; margin: 60px auto; text-align: center; }

.grid { display: grid; gap: 14px; margin: 14px 0; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; margin: 14px 0;
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.mini-card { display: block; color: inherit; margin: 0; transition: transform .08s ease; }
.mini-card:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--primary); }
.mini-title { font-weight: 700; margin-bottom: 4px; }
.mini-meta { display: flex; gap: 12px; color: var(--muted); font-size: 13px; margin-top: 8px; }
.stat { text-align: center; padding: 16px; }
.stat-num { font-size: 30px; font-weight: 800; color: var(--primary); }
.stat-warn .stat-num { color: var(--amber); }
.feature { text-align: left; }
.feature-ico { font-size: 26px; margin-bottom: 6px; }
.demo-card { margin-top: 22px; }
.demo-creds { list-style: none; padding: 0; margin: 8px 0; }
.demo-creds li { padding: 3px 0; }
.chip { display: inline-block; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; margin: 2px; }
.objectives-card { border-left: 4px solid var(--primary); }
.graded-box { background: var(--green-soft); border-radius: 10px; padding: 10px 14px; margin-top: 10px; }

/* ---------- Flash ---------- */
.flash { padding: 10px 14px; border-radius: 10px; margin: 0 0 14px; font-weight: 500; }
.flash-ok { background: var(--green-soft); color: var(--green); }
.flash-err { background: var(--red-soft); color: var(--red); }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line);
}
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table-scroll { overflow-x: auto; }
.ktp-table td, .ktp-table th { font-size: 14px; }
.journal th.rot a { writing-mode: horizontal-tb; }
.cell { text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.cell-graded { background: var(--green-soft); color: var(--green); }
.cell-pending { background: var(--amber-soft); color: var(--amber); }
.cell-returned { background: var(--red-soft); color: var(--red); }
.legend span { padding: 1px 6px; border-radius: 6px; }
.feedback-cell { max-width: 260px; }
.row-edit { display: inline-block; position: relative; }
.ktp-edit-form { min-width: 560px; padding: 12px; background: var(--bg); border-radius: 10px; margin-top: 8px; }
details.collapsible summary { cursor: pointer; padding: 4px 0; }
details.row-edit summary { list-style: none; }
details.row-edit summary::-webkit-details-marker { display: none; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; font-size: 12px; font-weight: 700; line-height: 1;
  padding: 5px 9px; border-radius: 999px; white-space: nowrap;
}
.badge-gray { background: #eceff5; color: var(--muted); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-blue { background: var(--blue-soft); color: var(--primary); }
.join-code { background: var(--primary-soft); color: var(--primary); padding: 2px 8px; border-radius: 8px; font-weight: 700; }
.join-code-big code { font-size: 30px; letter-spacing: 4px; background: var(--primary-soft); color: var(--primary); padding: 8px 18px; border-radius: 12px; display: inline-block; }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 10px; cursor: pointer;
  font: inherit; font-weight: 600; padding: 9px 16px;
  background: #eef1f8; color: var(--ink);
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-outline { background: #fff; border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-ghost:hover { color: var(--ink); }
.btn-danger { color: var(--red); }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 12px 26px; font-size: 16px; }
.btn-block { width: 100%; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 5px;
  font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary-soft); border-color: var(--primary);
}
textarea { resize: vertical; }
.stack > * { margin-bottom: 4px; }
.row-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row-form label { flex: 1; min-width: 120px; }
.inline-form { display: inline-block; }
.grade-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.grade-form input[type=number] { width: 90px; margin-top: 0; }
.grade-form input[type=text] { flex: 1; min-width: 160px; margin-top: 0; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }

/* ---------- Auth & hero ---------- */
.auth-wrap { display: flex; justify-content: center; padding: 40px 16px; }
.auth-card { width: 100%; max-width: 420px; }
.hero { display: grid; grid-template-columns: 1.15fr .85fr; gap: 30px; align-items: center; padding: 30px 0 10px; }
.hero-kicker { color: var(--primary); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: 12px; }
.hero h1 { font-size: 40px; line-height: 1.15; margin: 10px 0; }
.hero .accent { color: var(--primary); }
.hero-lead { color: var(--muted); font-size: 17px; }
.hero-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.hero-slide {
  background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  padding: 18px; max-width: 360px; margin-left: auto;
}
.hero-slide-head { height: 10px; width: 60%; background: var(--primary-soft); border-radius: 6px; margin-bottom: 12px; }
.hero-slide-line { height: 8px; background: var(--bg); border-radius: 6px; margin-bottom: 8px; }
.hero-slide-line.w80 { width: 80%; }
.hero-slide-line.w60 { width: 60%; }
.hero-quiz { border-top: 1px dashed var(--line); margin-top: 12px; padding-top: 12px; }
.hero-quiz-q { font-weight: 700; margin-bottom: 8px; font-size: 14px; }
.hero-quiz-opt { border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; margin-bottom: 6px; font-size: 14px; }
.hero-quiz-opt.ok { border-color: var(--green); background: var(--green-soft); color: var(--green); font-weight: 700; }

/* ---------- Presentation player ---------- */
.player-card { padding: 0; overflow: hidden; }
.player-head {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.player-head h2 { margin: 0; font-size: 16px; }
.player-progress { display: flex; align-items: center; gap: 10px; }
.progress-bar { width: 180px; height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--green); border-radius: 999px; transition: width .25s ease; }
.slide-stage { min-height: 320px; padding: 26px 30px; }
.slide { animation: slidein .18s ease; }
@keyframes slidein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.s-title { text-align: center; padding: 60px 20px; }
.s-title h1 { font-size: 34px; }
.s-title .sub { color: var(--muted); font-size: 17px; margin-top: 8px; }
.s-text h2, .s-quote h2 { margin-top: 0; }
.slide-stage ul { margin: 10px 0 0; padding-left: 22px; }
.slide-stage li { margin: 6px 0; }
.s-quote { border-left: 4px solid var(--primary); padding-left: 18px; color: var(--muted); font-size: 18px; font-style: italic; }
.s-quote .author { margin-top: 10px; font-size: 14px; font-weight: 700; }
.s-image img { max-width: 100%; border-radius: 12px; }
.s-image .caption { color: var(--muted); font-size: 13px; margin-top: 6px; text-align: center; }
.s-code pre {
  background: #10162c; color: #dce6ff; padding: 16px 18px; border-radius: 12px;
  overflow-x: auto; font-size: 14px; line-height: 1.5; margin: 0;
}
.s-code .caption { color: var(--muted); font-size: 13px; margin-top: 8px; }
.md pre { background: #10162c; color: #dce6ff; padding: 14px 16px; border-radius: 10px; overflow-x: auto; font-size: 13.5px; }
.md code { background: var(--primary-soft); color: var(--primary); padding: 1px 6px; border-radius: 6px; }
.md pre code { background: transparent; color: inherit; padding: 0; }

/* tasks */
.s-task { background: var(--primary-soft); border: 1px solid #d5e2ff; border-radius: 12px; padding: 16px 18px; }
.s-task .task-q { font-weight: 700; font-size: 16px; margin-bottom: 12px; }
.task-opts { display: flex; flex-direction: column; gap: 8px; }
.task-opt {
  display: flex; align-items: center; gap: 10px; text-align: left;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; cursor: pointer; font: inherit; width: 100%;
}
.task-opt:hover { border-color: var(--primary); }
.task-opt.sel { border-color: var(--primary); background: #fff; box-shadow: inset 0 0 0 1px var(--primary); }
.task-opt.correct { border-color: var(--green); background: var(--green-soft); }
.task-opt.wrong { border-color: var(--red); background: var(--red-soft); }
.task-opt .opt-mark { font-weight: 800; color: var(--muted); }
.task-input-row { display: flex; gap: 8px; }
.task-input-row input { margin-top: 0; flex: 1; }
.task-actions { margin-top: 12px; display: flex; gap: 10px; align-items: center; }
.task-result { margin-top: 12px; border-radius: 10px; padding: 10px 14px; font-weight: 500; }
.task-result.ok { background: var(--green-soft); color: var(--green); }
.task-result.err { background: var(--red-soft); color: var(--red); }
.task-result .hint { display: block; color: var(--muted); font-weight: 400; font-size: 13px; margin-top: 4px; }
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.match-grid select { margin-top: 0; }
.player-nav { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); gap: 10px; }
.dots { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); cursor: pointer; border: none; padding: 0; }
.dot.active { background: var(--primary); transform: scale(1.25); }
.dot.done { background: var(--green); }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .hero { grid-template-columns: 1fr; }
  .hero-art { display: none; }
}
@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .topbar-inner { flex-wrap: wrap; }
  .nav { order: 3; width: 100%; }
  .match-grid { grid-template-columns: 1fr; }
  .ktp-edit-form { min-width: 0; }
  h1 { font-size: 22px; }
  .hero h1 { font-size: 30px; }
}
