/* ==========================================================================
   LMS UIII — design system
   Tokens → base → layout (app shell) → components → page-specific blocks
   ========================================================================== */

:root {
  --brand-950: #03241c;
  --brand-900: #063a2e;
  --brand-800: #0a4d3d;
  --brand-700: #0d634e;
  --brand-600: #12795f;
  --brand-500: #1a9474;
  --brand-100: #d7efe6;
  --brand-50: #edf7f3;

  --gold-600: #b7861b;
  --gold-500: #d4a12a;
  --gold-400: #e6bc52;
  --gold-100: #faf0d4;
  --gold-50: #fdf8ea;

  --ink-900: #111a17;
  --ink-800: #1f2a26;
  --ink-700: #36433e;
  --ink-600: #4f5d57;
  --ink-500: #6b7872;
  --ink-400: #949f9a;
  --ink-300: #c3cbc7;
  --ink-200: #dfe5e2;
  --ink-100: #edf1ef;
  --ink-50: #f6f8f7;

  --red-600: #c2362c;
  --red-50: #fdf0ee;
  --amber-600: #b26a00;
  --amber-50: #fff6e6;
  --blue-600: #2861c9;
  --blue-50: #eef3fd;
  --violet-600: #6d4bd1;
  --violet-50: #f3effd;

  --bg: #f4f6f4;
  --surface: #ffffff;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(17, 26, 23, 0.05);
  --shadow: 0 1px 2px rgba(17, 26, 23, 0.04), 0 4px 16px rgba(17, 26, 23, 0.06);
  --shadow-lg: 0 10px 40px rgba(6, 58, 46, 0.18);
  --sidebar-w: 264px;
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-800);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1,
h2,
h3,
h4 {
  margin: 0;
  color: var(--ink-900);
  line-height: 1.25;
  letter-spacing: -0.01em;
}
h1 {
  font-size: 26px;
  font-weight: 800;
}
h2 {
  font-size: 17px;
  font-weight: 700;
}
h3 {
  font-size: 15px;
  font-weight: 700;
}
p {
  margin: 0;
}
a {
  color: var(--brand-700);
  text-decoration: none;
}
a:hover {
  color: var(--brand-900);
}
img {
  max-width: 100%;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.icon-sm {
  width: 15px;
  height: 15px;
}
.icon-lg {
  width: 22px;
  height: 22px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
:focus-visible {
  outline: 2px solid var(--gold-500);
  outline-offset: 2px;
}

/* ---------- App shell ---------- */
.shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  color: #d9ebe4;
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(212, 161, 42, 0.16), transparent 60%),
    linear-gradient(180deg, var(--brand-900) 0%, var(--brand-950) 100%);
  z-index: 40;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px 22px;
  color: #fff;
}
.brand:hover {
  color: #fff;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(140deg, var(--gold-400), var(--gold-600));
  color: var(--brand-950);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.04em;
  box-shadow: 0 6px 18px rgba(212, 161, 42, 0.35);
}
.brand-name {
  font-weight: 800;
  font-size: 16px;
  line-height: 1.1;
}
.brand-sub {
  font-size: 11px;
  color: #9cc5b6;
}
.nav-label {
  padding: 14px 12px 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7fae9d;
}
.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 10px;
  color: #cfe3dc;
  font-weight: 600;
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
}
.nav a:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}
.nav a.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--gold-400);
}
.nav a .icon {
  opacity: 0.85;
}
.nav-ai {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 800;
  color: var(--brand-950);
  background: var(--gold-400);
}
.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-footer .who {
  min-width: 0;
  flex: 1;
}
.sidebar-footer .who strong {
  display: block;
  color: #fff;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-footer .who span {
  font-size: 11px;
  color: #9cc5b6;
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}
.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}
.topbar {
  display: none;
}
.content {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 36px 56px;
}
.footer {
  margin-top: auto;
  padding: 18px 36px;
  font-size: 12px;
  color: var(--ink-500);
  border-top: 1px solid var(--ink-200);
}
.backdrop {
  display: none;
}

@media (max-width: 960px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  body.nav-open .sidebar {
    transform: none;
  }
  body.nav-open .backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(3, 36, 28, 0.45);
    z-index: 30;
  }
  .main {
    margin-left: 0;
  }
  .topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 10px 16px;
    color: #fff;
    background: var(--brand-900);
  }
  .content {
    padding: 22px 16px 40px;
  }
  .footer {
    padding: 16px;
  }
}

/* ---------- Page header ---------- */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-header p {
  margin-top: 6px;
  color: var(--ink-500);
  max-width: 680px;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--brand-700);
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-500);
}
.back-link:hover {
  color: var(--brand-700);
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  padding: 28px 30px;
  margin-bottom: 24px;
  border-radius: var(--radius-lg);
  color: #e5f3ee;
  background:
    radial-gradient(70% 120% at 100% 0%, rgba(212, 161, 42, 0.28), transparent 60%),
    linear-gradient(120deg, var(--brand-800), var(--brand-950));
  box-shadow: var(--shadow-lg);
}
.hero::after {
  content: '';
  position: absolute;
  right: -40px;
  bottom: -60px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  border: 36px solid rgba(255, 255, 255, 0.04);
}
.hero h1 {
  color: #fff;
}
.hero p {
  margin-top: 8px;
  max-width: 620px;
  color: #bfdcd2;
}
.hero .actions {
  position: relative;
  z-index: 1;
  margin-top: 20px;
}
.hero-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--gold-400);
  background: rgba(255, 255, 255, 0.08);
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-body {
  padding: 22px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--ink-100);
}
.card-header p {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--ink-500);
}
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  border-top: 1px solid var(--ink-100);
  background: var(--ink-50);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.card-link {
  display: block;
  color: inherit;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.card-link:hover {
  color: inherit;
  border-color: var(--brand-100);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.section {
  margin-bottom: 28px;
}
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.section-title p {
  font-size: 12.5px;
  color: var(--ink-500);
}

/* ---------- Grid & utilities ---------- */
.grid {
  display: grid;
  gap: 16px;
}
.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.split {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 20px;
  align-items: start;
}
.split-wide {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
@media (max-width: 1100px) {
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .split,
  .split-wide {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 720px) {
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.wrap {
  flex-wrap: wrap;
}
.muted {
  color: var(--ink-500);
}
.small {
  font-size: 12.5px;
}
.tiny {
  font-size: 11.5px;
}
.strong {
  font-weight: 700;
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mt-1 {
  margin-top: 4px;
}
.mt-2 {
  margin-top: 8px;
}
.mt-3 {
  margin-top: 14px;
}
.mt-4 {
  margin-top: 22px;
}
.hidden {
  display: none !important;
}
.right {
  text-align: right;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 700;
  font-size: 13.5px;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.05s;
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled,
.btn[aria-busy='true'] {
  opacity: 0.65;
  cursor: progress;
}
.btn-primary {
  color: #fff;
  background: var(--brand-700);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15) inset, 0 4px 12px rgba(13, 99, 78, 0.25);
}
.btn-primary:hover {
  color: #fff;
  background: var(--brand-800);
}
.btn-gold {
  color: var(--brand-950);
  background: linear-gradient(180deg, var(--gold-400), var(--gold-500));
  box-shadow: 0 4px 14px rgba(212, 161, 42, 0.35);
}
.btn-gold:hover {
  color: var(--brand-950);
  background: var(--gold-500);
}
.btn-secondary {
  color: var(--ink-800);
  background: var(--surface);
  border-color: var(--ink-200);
}
.btn-secondary:hover {
  color: var(--ink-900);
  border-color: var(--ink-300);
  background: var(--ink-50);
}
.btn-ghost {
  color: var(--ink-600);
  background: transparent;
}
.btn-ghost:hover {
  color: var(--ink-900);
  background: var(--ink-100);
}
.btn-light {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.18);
}
.btn-light:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.2);
}
.btn-danger {
  color: var(--red-600);
  background: var(--red-50);
}
.btn-danger:hover {
  color: #fff;
  background: var(--red-600);
}
.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 12.5px;
  border-radius: 8px;
}
.btn-lg {
  height: 46px;
  padding: 0 22px;
  font-size: 14.5px;
}
.btn-block {
  width: 100%;
}
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--ink-600);
  background: var(--ink-100);
}
.badge .icon {
  width: 13px;
  height: 13px;
}
.badge-green {
  color: var(--brand-700);
  background: var(--brand-50);
}
.badge-amber {
  color: var(--amber-600);
  background: var(--amber-50);
}
.badge-red {
  color: var(--red-600);
  background: var(--red-50);
}
.badge-blue {
  color: var(--blue-600);
  background: var(--blue-50);
}
.badge-violet {
  color: var(--violet-600);
  background: var(--violet-50);
}
.badge-gold {
  color: var(--gold-600);
  background: var(--gold-50);
}
.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.code-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--brand-800);
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
}

/* ---------- Avatar ---------- */
.avatar {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  background: var(--brand-600);
}
.avatar-sm {
  width: 30px;
  height: 30px;
  font-size: 11.5px;
}
.avatar-admin {
  background: var(--violet-600);
}
.avatar-dosen {
  color: var(--brand-950);
  background: var(--gold-400);
}
.avatar-mahasiswa {
  background: var(--brand-600);
}

/* ---------- Stats ---------- */
.stat {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
}
.stat-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: var(--brand-700);
  background: var(--brand-50);
}
.stat-icon.gold {
  color: var(--gold-600);
  background: var(--gold-50);
}
.stat-icon.blue {
  color: var(--blue-600);
  background: var(--blue-50);
}
.stat-icon.violet {
  color: var(--violet-600);
  background: var(--violet-50);
}
.stat-value {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--ink-900);
}
.stat-label {
  font-size: 12.5px;
  color: var(--ink-500);
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table th {
  padding: 11px 22px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-500);
  background: var(--ink-50);
  border-bottom: 1px solid var(--ink-100);
}
.table td {
  padding: 14px 22px;
  border-bottom: 1px solid var(--ink-100);
  vertical-align: middle;
}
.table tr:last-child td {
  border-bottom: 0;
}
.table tbody tr:hover {
  background: #fafcfb;
}
.cell-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.cell-user strong {
  display: block;
  color: var(--ink-900);
}
.cell-user span {
  font-size: 12px;
  color: var(--ink-500);
}

/* ---------- List items ---------- */
.list {
  display: flex;
  flex-direction: column;
}
.list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--ink-100);
  color: inherit;
}
.list-item:last-child {
  border-bottom: 0;
}
a.list-item:hover {
  color: inherit;
  background: #fafcfb;
}
.list-item .grow {
  flex: 1;
  min-width: 0;
}
.list-item .title {
  font-weight: 700;
  color: var(--ink-900);
}
.list-item .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--ink-500);
}

/* ---------- Forms ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-700);
}
.label .req {
  color: var(--red-600);
}
.hint {
  font-size: 12px;
  color: var(--ink-500);
}
.input,
.select,
.textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--ink-200);
  border-radius: 10px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input,
.select {
  height: 42px;
}
.textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.6;
}
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(26, 148, 116, 0.15);
}
.input-icon {
  position: relative;
}
.input-icon .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-400);
}
.input-icon .input {
  padding-left: 38px;
}
.input-score {
  width: 84px;
  height: 40px;
  text-align: right;
  font-weight: 800;
  font-size: 15px;
  color: var(--brand-800);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.form-grid .full {
  grid-column: 1 / -1;
}
@media (max-width: 720px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Alerts ---------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 20px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13.5px;
}
.alert-success {
  color: var(--brand-800);
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
}
.alert-error {
  color: var(--red-600);
  background: var(--red-50);
  border: 1px solid #f6d3cf;
}
.alert-info {
  color: var(--blue-600);
  background: var(--blue-50);
  border: 1px solid #d6e2f8;
}

/* ---------- Empty state ---------- */
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--ink-500);
}
.empty .empty-icon {
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 12px;
  border-radius: 50%;
  color: var(--brand-600);
  background: var(--brand-50);
}
.empty h3 {
  margin-bottom: 4px;
}

/* ---------- Progress & score ---------- */
.progress {
  height: 8px;
  border-radius: 99px;
  background: var(--ink-100);
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-500), var(--brand-700));
}
.progress.warn > span {
  background: linear-gradient(90deg, var(--gold-400), var(--gold-600));
}
.score-ring {
  --pct: 0;
  position: relative;
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: conic-gradient(var(--gold-400) calc(var(--pct) * 1%), rgba(255, 255, 255, 0.12) 0);
}
.score-ring::before {
  content: '';
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: var(--brand-900);
}
.score-ring > div {
  position: relative;
  text-align: center;
  color: #fff;
}
.score-ring strong {
  display: block;
  font-size: 28px;
  line-height: 1;
}
.score-ring span {
  font-size: 11px;
  color: #a9cfc1;
}
.score-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  padding: 4px 10px;
  border-radius: 99px;
  font-weight: 800;
  color: var(--brand-800);
  background: var(--brand-50);
}
.score-pill small {
  font-weight: 600;
  color: var(--ink-500);
}

/* ---------- Reading / prose ---------- */
.prose {
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.8;
  color: var(--ink-800);
  white-space: pre-line;
}
.reader {
  max-height: 640px;
  overflow-y: auto;
  padding: 20px 22px;
}
.md p + p,
.md ul,
.md ol {
  margin-top: 8px;
}
.md ul,
.md ol {
  padding-left: 20px;
  margin-bottom: 0;
}
.md li + li {
  margin-top: 3px;
}
.md h4 {
  margin: 12px 0 4px;
  font-size: 14px;
}
.md code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--ink-100);
  font-size: 12.5px;
}

/* ---------- Rubric blocks ---------- */
.rubric {
  display: flex;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius);
  background: #fff;
}
.rubric-num {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 8px;
  font-weight: 800;
  font-size: 12.5px;
  color: #fff;
  background: var(--brand-700);
}
.rubric-body {
  flex: 1;
  min-width: 0;
}
.rubric-body p {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--ink-500);
}
.rubric-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 110px 36px;
  gap: 10px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius);
  background: var(--ink-50);
}
@media (max-width: 720px) {
  .rubric-row {
    grid-template-columns: 28px minmax(0, 1fr);
  }
}
.points-total {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 99px;
  font-weight: 800;
  color: var(--brand-800);
  background: var(--brand-50);
}
.points-total.off {
  color: var(--amber-600);
  background: var(--amber-50);
}

/* ---------- AI panel ---------- */
.ai-panel {
  position: relative;
  overflow: hidden;
  padding: 22px;
  border-radius: var(--radius-lg);
  color: #d8ece5;
  background:
    radial-gradient(80% 140% at 100% 0%, rgba(212, 161, 42, 0.25), transparent 55%),
    linear-gradient(135deg, var(--brand-800), var(--brand-950));
  box-shadow: var(--shadow-lg);
}
.ai-panel h2,
.ai-panel h3 {
  color: #fff;
}
.ai-panel .label {
  color: var(--gold-400);
}
.ai-panel .textarea {
  color: #fff;
  background: rgba(0, 0, 0, 0.22);
  border-color: rgba(255, 255, 255, 0.16);
}
.ai-panel .textarea::placeholder {
  color: rgba(216, 236, 229, 0.5);
}
.ai-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: var(--brand-950);
  background: var(--gold-400);
}
.ai-status {
  display: none;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
}
.ai-status.show {
  display: flex;
}
.ai-status.ok {
  color: #c9f0df;
}
.ai-status.err {
  color: #ffd2cc;
  background: rgba(194, 54, 44, 0.25);
}
.flash-fill {
  animation: flashFill 1.6s ease;
}
@keyframes flashFill {
  0% {
    background: var(--gold-100);
    border-color: var(--gold-500);
  }
  100% {
    background: #fff;
  }
}

/* ---------- Chat ---------- */
.chat {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 210px);
  min-height: 520px;
}
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: linear-gradient(180deg, #fbfcfb, var(--ink-50));
}
.msg {
  display: flex;
  gap: 12px;
  max-width: 820px;
}
.msg.me {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.msg-bubble {
  padding: 13px 16px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--ink-200);
  box-shadow: var(--shadow-sm);
}
.msg.me .msg-bubble {
  color: #fff;
  background: var(--brand-700);
  border-color: var(--brand-700);
  border-top-right-radius: 4px;
}
.msg.bot .msg-bubble {
  border-top-left-radius: 4px;
}
.msg-bubble img {
  display: block;
  max-height: 220px;
  margin-bottom: 8px;
  border-radius: 10px;
}
.msg-meta {
  margin-top: 6px;
  font-size: 11px;
  color: var(--ink-400);
}
.bot-avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 11px;
  color: var(--gold-400);
  background: linear-gradient(140deg, var(--brand-700), var(--brand-950));
}
.typing span {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 3px;
  border-radius: 50%;
  background: var(--ink-400);
  animation: blink 1.2s infinite;
}
.typing span:nth-child(2) {
  animation-delay: 0.2s;
}
.typing span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
  }
  40% {
    opacity: 1;
  }
}
.chat-compose {
  padding: 14px 16px;
  border-top: 1px solid var(--ink-200);
  background: #fff;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.compose-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.compose-row .textarea {
  min-height: 46px;
  max-height: 180px;
  resize: none;
}
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.suggestion {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--ink-200);
  border-radius: 99px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-700);
  background: #fff;
  cursor: pointer;
}
.suggestion:hover {
  border-color: var(--brand-500);
  color: var(--brand-800);
}

/* ---------- Login ---------- */
.auth {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  min-height: 100vh;
}
.auth-art {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 44px;
  color: #d8ece5;
  background:
    radial-gradient(60% 60% at 90% 10%, rgba(212, 161, 42, 0.3), transparent 60%),
    radial-gradient(50% 50% at 10% 100%, rgba(26, 148, 116, 0.35), transparent 60%),
    linear-gradient(150deg, var(--brand-800), var(--brand-950));
}
.auth-art h1 {
  max-width: 460px;
  font-size: 36px;
  color: #fff;
}
.auth-art p {
  max-width: 440px;
  margin-top: 14px;
  font-size: 15px;
  color: #bcdcd0;
}
.feature-list {
  display: grid;
  gap: 14px;
  margin-top: 30px;
}
.feature {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.feature .stat-icon {
  width: 38px;
  height: 38px;
  color: var(--gold-400);
  background: rgba(255, 255, 255, 0.08);
}
.feature strong {
  display: block;
  color: #fff;
}
.feature span {
  font-size: 13px;
  color: #a9cfc1;
}
.auth-form {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}
.auth-box {
  width: 100%;
  max-width: 400px;
}
.demo-accounts {
  display: grid;
  gap: 8px;
}
.demo-account {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--ink-200);
  border-radius: 12px;
  background: #fff;
  text-align: left;
  cursor: pointer;
}
.demo-account:hover {
  border-color: var(--brand-500);
  background: var(--brand-50);
}
.demo-account .grow {
  flex: 1;
  min-width: 0;
}
@media (max-width: 900px) {
  .auth {
    grid-template-columns: 1fr;
  }
  .auth-art {
    display: none;
  }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  max-width: 380px;
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 600;
  color: #fff;
  background: var(--ink-900);
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.2s ease;
}
.toast.error {
  background: var(--red-600);
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

details.disclosure > summary {
  list-style: none;
  cursor: pointer;
}
details.disclosure > summary::-webkit-details-marker {
  display: none;
}

/* ---------- Grading, report card, admin, tutor, 404 ---------- */
.grow {
  flex: 1;
  min-width: 0;
}
.pre-line {
  white-space: pre-line;
}
.cell-user .avatar {
  font-size: 13px;
  color: #fff;
}
.cell-user .avatar-sm {
  font-size: 11.5px;
}
.actions-center {
  justify-content: center;
}
.actions-end {
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 6px;
}
.inline-form {
  display: inline;
}
.danger-text {
  color: var(--red-600);
}
.danger-text:hover {
  color: var(--red-600);
  background: var(--red-50);
}
.btn-icon {
  width: 40px;
  padding: 0;
  flex-shrink: 0;
}
.btn-icon.is-active {
  color: var(--brand-700);
  background: var(--brand-50);
  border-color: var(--brand-500);
}
details.disclosure > summary .chev {
  flex-shrink: 0;
  transition: transform 0.15s;
}
details.disclosure[open] > summary .chev {
  transform: rotate(90deg);
}
details.disclosure:not([open]) > summary {
  border-bottom: 0;
}
.attachment {
  display: block;
  padding: 18px 22px 0;
  color: inherit;
}
.attachment img {
  display: block;
  max-height: 320px;
  margin-bottom: 6px;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius);
}
.note {
  padding: 12px 14px;
  border-left: 3px solid var(--gold-500);
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--ink-700);
  background: var(--ink-50);
  white-space: pre-line;
}
.facts {
  display: grid;
  gap: 12px;
  margin: 0;
}
.facts > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.facts dt {
  font-size: 12.5px;
  color: var(--ink-500);
}
.facts dd {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  text-align: right;
  color: var(--ink-900);
}
.stat-of {
  margin-left: 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-400);
}

/* Grading sheet */
@media (min-width: 1101px) {
  .sticky-col {
    position: sticky;
    top: 24px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    border-radius: var(--radius-lg);
  }
}
.rubric-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.rubric-head label {
  cursor: pointer;
}
.score-pill {
  flex-shrink: 0;
  white-space: nowrap;
}
.table .right {
  text-align: right;
}
.score-field {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.grade-dock {
  position: sticky;
  bottom: 0;
  z-index: 5;
  background: #fff;
  box-shadow: 0 -8px 24px rgba(17, 26, 23, 0.07);
}
.grade-total strong {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--brand-800);
}
.grade-total span {
  margin-left: 4px;
  font-weight: 700;
  color: var(--ink-500);
}
.ai-panel .suggestion {
  color: #e5f3ee;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}
.ai-panel .suggestion:hover {
  color: var(--brand-950);
  background: var(--gold-400);
  border-color: var(--gold-400);
}
.ai-status .icon {
  flex-shrink: 0;
}

/* Report card */
.report-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 28px;
}
.report-summary {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 240px;
}
.grade-letter {
  position: relative;
  z-index: 1;
  padding: 14px 24px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  text-align: center;
  background: rgba(255, 255, 255, 0.08);
}
.grade-letter span {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #a9cfc1;
}
.grade-letter strong {
  display: block;
  margin-top: 4px;
  font-family: var(--font-serif);
  font-size: 46px;
  line-height: 1;
  color: var(--gold-400);
}

/* Tutor chat */
.chat > .card-header {
  flex-shrink: 0;
}
.chat-full {
  height: calc(100vh - 140px);
}
.chat-empty {
  max-width: 600px;
  margin: auto;
  padding: 20px 0;
  text-align: center;
}
.chat-empty .suggestions {
  justify-content: center;
}
.bot-avatar-lg {
  width: 56px;
  height: 56px;
  margin: 0 auto;
  border-radius: 16px;
}
.msg > div {
  min-width: 0;
}
.msg-bubble {
  overflow-wrap: anywhere;
}
.msg-error {
  color: var(--red-600);
  background: var(--red-50);
  border-color: #f6d3cf;
}
.msg-error .icon {
  vertical-align: -3px;
}
.image-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.compose-row .btn {
  height: 46px;
}
.compose-row .btn-icon {
  width: 46px;
}

/* 404 */
.not-found {
  max-width: 640px;
  margin: 40px auto;
}
.not-found .empty {
  padding: 56px 28px;
}
.md blockquote {
  margin: 8px 0 0;
  padding: 6px 12px;
  border-left: 3px solid var(--gold-400);
  color: var(--ink-600);
  background: var(--gold-50);
  border-radius: 0 8px 8px 0;
}
