/* Palki Academy — light, clean, calm. Inspired by Linear / Notion. */

:root {
  --c-bg: #F8F9FB;
  --c-surface: #FFFFFF;
  --c-surface-2: #F1F4F8;
  --c-border: #E2E8F0;
  --c-border-strong: #CBD5E1;
  --c-text: #0F172A;
  --c-text-muted: #64748B;
  --c-text-soft: #94A3B8;
  --c-primary: #0A66C2;
  --c-primary-dark: #074E94;
  --c-primary-soft: #E6F0FB;
  --c-success: #15803D;
  --c-success-soft: #DCFCE7;
  --c-warn: #C2410C;
  --c-warn-soft: #FFEDD5;
  --c-danger: #B91C1C;
  --c-danger-soft: #FEE2E2;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 1px rgba(15, 23, 42, .03);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, .06), 0 2px 4px rgba(15, 23, 42, .04);
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-prose: "Source Serif 4", Charter, "Iowan Old Style", Georgia, serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--c-text); font-weight: 600; }
h1 { font-size: 28px; letter-spacing: -.02em; }
h2 { font-size: 20px; letter-spacing: -.01em; margin-bottom: 12px; }
h3 { font-size: 17px; }

p { margin: 0 0 12px; }

code { font-family: var(--font-mono); font-size: 13px; background: var(--c-surface-2); padding: 1px 6px; border-radius: 4px; }
pre code { display: block; padding: 12px; overflow: auto; }

.muted { color: var(--c-text-muted); }
.small { font-size: 13px; }

/* ======== Top nav ======== */
.topnav {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  position: sticky; top: 0; z-index: 50;
}
.topnav-inner {
  max-width: 1200px; margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--c-text); font-weight: 600; font-size: 15px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: linear-gradient(135deg, var(--c-primary), #1d4ed8);
  color: white; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; letter-spacing: .02em;
}
.brand-mark-lg { width: 56px; height: 56px; border-radius: 14px; font-size: 22px; }
.brand-name { display: none; }
@media (min-width: 700px) { .brand-name { display: inline; } }

.topnav-links { display: none; gap: 4px; align-items: center; flex: 1; }
.topnav-links a {
  color: var(--c-text-muted); padding: 6px 10px; border-radius: var(--r-sm);
  font-weight: 500; font-size: 14px;
}
.topnav-links a:hover { background: var(--c-surface-2); color: var(--c-text); text-decoration: none; }
.topnav-links a.active { background: var(--c-primary-soft); color: var(--c-primary-dark); }
.nav-sep { width: 1px; height: 18px; background: var(--c-border); margin: 0 6px; }
@media (min-width: 900px) { .topnav-links { display: flex; } }

.topnav-user { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.user-name { display: none; color: var(--c-text-muted); font-size: 14px; }
@media (min-width: 700px) { .user-name { display: inline; } }
.hamburger {
  background: none; border: 1px solid var(--c-border); border-radius: var(--r-sm);
  padding: 4px 10px; font-size: 18px; cursor: pointer;
}
@media (min-width: 900px) { .hamburger { display: none; } }

/* Mobile nav drawer */
.topnav-links.open {
  display: flex; flex-direction: column; align-items: stretch;
  position: absolute; top: 56px; left: 0; right: 0;
  background: var(--c-surface); padding: 12px 24px;
  border-bottom: 1px solid var(--c-border); box-shadow: var(--shadow-md);
}
.topnav-links.open a { padding: 10px 12px; border-radius: var(--r-sm); }

/* ======== Page layout ======== */
.page { min-height: calc(100vh - 56px); }
.container { max-width: 960px; margin: 0 auto; padding: 24px 20px 80px; }
.container-reading { max-width: 720px; }

.page-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.page-header h1 { margin-bottom: 4px; }

.section { margin-bottom: 32px; }

.back-link { display: inline-block; margin-bottom: 16px; color: var(--c-text-muted); font-size: 14px; }
.back-link:hover { color: var(--c-primary); }

/* ======== Buttons ======== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: var(--r-sm); border: 1px solid transparent;
  font: inherit; font-weight: 500; cursor: pointer; transition: all .12s ease;
  text-decoration: none;
}
.btn-primary { background: var(--c-primary); color: white; }
.btn-primary:hover { background: var(--c-primary-dark); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--c-text); border-color: var(--c-border); }
.btn-ghost:hover { background: var(--c-surface-2); text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ======== Cards ======== */
.card {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-md); padding: 16px 18px; margin-bottom: 8px;
  text-decoration: none; color: var(--c-text);
}
.card-link { transition: all .12s ease; }
.card-link:hover { border-color: var(--c-border-strong); background: var(--c-surface); box-shadow: var(--shadow-sm); text-decoration: none; }
.card-action { width: 100%; text-align: left; background: var(--c-primary-soft); border-color: #BEDAEF; }
.card-action:hover { background: #D9EAF7; }
.card-warn { background: var(--c-warn-soft); border-color: #F4C892; }
.card-sm { padding: 10px 14px; }
.card-form { all: unset; display: block; margin-bottom: 8px; }
.card-form button { all: unset; display: block; cursor: pointer; }
.card-title { font-weight: 600; }
.card-sub { color: var(--c-text-muted); font-size: 13px; margin-top: 4px; }
.chev { color: var(--c-text-muted); font-size: 18px; flex-shrink: 0; }

/* ======== Pills ======== */
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .03em;
  background: var(--c-surface-2); color: var(--c-text-muted);
}
.pill-open { background: var(--c-success-soft); color: var(--c-success); }
.pill-scheduled { background: var(--c-primary-soft); color: var(--c-primary-dark); }
.pill-closed { background: var(--c-surface-2); color: var(--c-text-muted); }
.pill-draft { background: var(--c-warn-soft); color: var(--c-warn); }
.pill-graded { background: var(--c-success-soft); color: var(--c-success); }
.pill-grading { background: var(--c-warn-soft); color: var(--c-warn); }
.pill-submitted { background: var(--c-primary-soft); color: var(--c-primary-dark); }
.pill-in_progress { background: var(--c-warn-soft); color: var(--c-warn); }
.pill-owner, .pill-admin { background: var(--c-primary-soft); color: var(--c-primary-dark); }
.pill-member { background: var(--c-surface-2); color: var(--c-text-muted); }
.pill-type { background: var(--c-surface-2); color: var(--c-text-muted); font-size: 10px; }

/* ======== KPI cards ======== */
.kpi-grid {
  display: grid; gap: 12px; margin-bottom: 28px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.kpi-card {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-md); padding: 18px;
}
.kpi-card.kpi-warn { background: var(--c-warn-soft); border-color: #F4C892; }
.kpi-label { font-size: 12px; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 30px; font-weight: 700; margin: 4px 0; letter-spacing: -.02em; }
.kpi-sub { font-size: 12px; color: var(--c-text-muted); }
.kpi-sub a { color: var(--c-primary); }

/* ======== Forms ======== */
.form { display: flex; flex-direction: column; gap: 12px; }
.form-inline { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.form-inline .grow { flex: 1; min-width: 200px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > label { flex: 1; min-width: 140px; }
.form label { display: flex; flex-direction: column; gap: 4px; }
.form label > span { font-size: 13px; font-weight: 500; color: var(--c-text-muted); }
.form input, .form textarea, .form select {
  font: inherit; padding: 9px 12px; border: 1px solid var(--c-border);
  border-radius: var(--r-sm); background: var(--c-surface); color: var(--c-text);
  width: 100%;
}
.form input:focus, .form textarea:focus, .form select:focus {
  outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-soft);
}
.form textarea { resize: vertical; }
.form .mono { font-family: var(--font-mono); font-size: 13px; line-height: 1.5; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.add-form { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); padding: 12px 16px; margin: 12px 0; }
.add-form summary { cursor: pointer; font-weight: 500; padding: 4px 0; color: var(--c-primary); }
.add-form[open] summary { margin-bottom: 12px; }
.qtype-block { padding: 12px; background: var(--c-surface-2); border-radius: var(--r-sm); }
.choice-row { display: flex; gap: 8px; margin-bottom: 6px; align-items: center; }
.choice-row input[type="checkbox"] { width: auto; flex-shrink: 0; }
.choice-row input[type="text"] { flex: 1; }

/* ======== Auth ======== */
.auth-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: linear-gradient(135deg, var(--c-bg), #E2E8F0);
}
.auth-card {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); padding: 32px; max-width: 400px; width: 100%;
  box-shadow: var(--shadow-md);
}
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand h1 { font-size: 24px; margin: 12px 0 4px; }
.auth-help { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--c-border); }
.alert { padding: 10px 14px; border-radius: var(--r-sm); margin-bottom: 16px; font-size: 14px; }
.alert-error { background: var(--c-danger-soft); color: var(--c-danger); border: 1px solid #FCA5A5; }

/* ======== Quiz taking ======== */
.quiz-header { align-items: center; }
.timer {
  font-family: var(--font-mono); font-size: 18px; font-weight: 600;
  background: var(--c-surface); border: 1px solid var(--c-border);
  padding: 6px 14px; border-radius: var(--r-sm);
}
.timer.warn { background: var(--c-warn-soft); border-color: #F4C892; color: var(--c-warn); }

.question-card {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-md); padding: 20px; margin-bottom: 16px;
}
.q-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.q-num {
  background: var(--c-primary); color: white; font-weight: 600; font-size: 13px;
  padding: 2px 8px; border-radius: var(--r-sm);
}
.q-points { color: var(--c-text-muted); font-size: 12px; }
.q-prompt { margin-bottom: 12px; }

.choice {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--c-border);
  border-radius: var(--r-sm); margin-bottom: 6px; cursor: pointer;
  transition: all .12s ease; background: var(--c-surface);
}
.choice:hover { border-color: var(--c-border-strong); background: var(--c-surface-2); }
.choice input { flex-shrink: 0; }
.choice-icon { width: 18px; text-align: center; flex-shrink: 0; color: var(--c-text-muted); }

.input-short { width: 100%; }
.input-long { width: 100%; min-height: 120px; }

.submit-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 0; margin-top: 16px;
  position: sticky; bottom: 0;
  background: linear-gradient(180deg, transparent, var(--c-bg) 30%);
}

/* ======== Quiz review ======== */
.review-card.rc-correct { border-left: 4px solid var(--c-success); }
.review-card.rc-wrong { border-left: 4px solid var(--c-danger); }
.review-card.rc-partial { border-left: 4px solid var(--c-warn); }
.rc-c-correct { background: var(--c-success-soft) !important; border-color: #86EFAC !important; color: var(--c-success); }
.rc-c-wrong { background: var(--c-danger-soft) !important; border-color: #FCA5A5 !important; color: var(--c-danger); }
.review-choice { cursor: default; }

.score-block { text-align: right; }
.score-num { font-size: 42px; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.badge { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; margin-top: 6px; }
.badge-pass { background: var(--c-success-soft); color: var(--c-success); }
.badge-fail { background: var(--c-danger-soft); color: var(--c-danger); }
.badge-pending { background: var(--c-warn-soft); color: var(--c-warn); }

.answer-block { background: var(--c-surface-2); padding: 12px; border-radius: var(--r-sm); margin: 8px 0; }
.answer-label { font-size: 12px; font-weight: 600; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.answer-text { white-space: pre-wrap; }
.feedback { margin-top: 8px; padding: 10px; background: var(--c-primary-soft); border-radius: var(--r-sm); font-size: 14px; }

.explanation, .ideal-answer { margin-top: 12px; }
.explanation summary, .ideal-answer summary { cursor: pointer; color: var(--c-primary); font-size: 14px; padding: 4px 0; }
.explanation[open] summary, .ideal-answer[open] summary { margin-bottom: 8px; }

/* ======== Tables ======== */
.data-table {
  width: 100%; border-collapse: collapse; background: var(--c-surface);
  border: 1px solid var(--c-border); border-radius: var(--r-md); overflow: hidden;
}
.data-table th, .data-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--c-border); font-size: 14px; }
.data-table th { background: var(--c-surface-2); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--c-text-muted); }
.data-table tbody tr:last-child td { border-bottom: none; }
.bar-cell { display: flex; align-items: center; gap: 8px; }
.bar { flex: 1; height: 6px; background: var(--c-surface-2); border-radius: 999px; overflow: hidden; min-width: 60px; }
.bar-fill { height: 100%; background: var(--c-primary); border-radius: 999px; }

/* ======== Empty / utility ======== */
.empty-state { text-align: center; padding: 80px 20px; }
.empty-state h1 { margin-bottom: 12px; }
.empty-state-sm { padding: 32px 16px; text-align: center; background: var(--c-surface); border: 1px dashed var(--c-border); border-radius: var(--r-md); }

.link-list { list-style: none; padding: 0; margin: 0; }
.link-list li { margin-bottom: 6px; }

/* ======== Prose (handbook + question prompts) ======== */
.prose { font-family: var(--font-prose); font-size: 17px; line-height: 1.7; color: var(--c-text); }
.prose h1 { font-family: var(--font-ui); font-size: 26px; margin: 24px 0 12px; }
.prose h2 { font-family: var(--font-ui); font-size: 20px; margin: 24px 0 10px; }
.prose h3 { font-family: var(--font-ui); font-size: 17px; margin: 20px 0 8px; }
.prose p { margin: 0 0 14px; }
.prose ul, .prose ol { padding-left: 22px; margin: 0 0 14px; }
.prose li { margin-bottom: 6px; }
.prose strong { font-weight: 600; color: var(--c-text); }
.prose a { color: var(--c-primary); text-decoration: underline; text-decoration-color: rgba(10, 102, 194, .3); text-underline-offset: 2px; }
.prose code { font-size: 14px; }
.prose blockquote { border-left: 3px solid var(--c-border-strong); padding-left: 16px; margin: 16px 0; color: var(--c-text-muted); }

.q-prompt { font-family: var(--font-ui); font-size: 15px; line-height: 1.55; color: var(--c-text); }
.q-prompt p:last-child { margin-bottom: 0; }

.reading-foot { padding: 32px 0; text-align: center; border-top: 1px solid var(--c-border); margin-top: 32px; }
