:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #dce2ec;
  --text: #162032;
  --muted: #5b677d;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --success: #15803d;
  --warning-bg: #fef9c3;
  --warning-border: #eab308;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.topbar {
  background: #0f172a;
  color: #f8fafc;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: #ffffff;
  text-decoration: none;
}
.topbar-back {
  color: #93c5fd;
  text-decoration: none;
  font-size: 0.9rem;
  border: 1px solid #334155;
  padding: 4px 10px;
  border-radius: 6px;
}
.topbar-back:hover { background: #1e293b; color: #ffffff; }
.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
}

.container {
  max-width: 1360px;
  margin: 24px auto;
  padding: 0 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--primary); color: #ffffff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #ffffff; border-color: var(--success); }
.btn-danger { background: var(--danger); color: #ffffff; border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 0.82rem; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: #e2e8f0;
  color: #334155;
}
.badge-ok { background: #dcfce7; color: #166534; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-err { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.flex-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.space-between { justify-content: space-between; }

label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; color: var(--muted); }
input[type="text"], input[type="number"], input[type="datetime-local"], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-size: 0.9rem;
  background: #ffffff;
}
textarea { resize: vertical; }

table.grading-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.grading-table th, table.grading-table td {
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  vertical-align: top;
  text-align: left;
}
table.grading-table th {
  background: #f8fafc;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.teacher-warning {
  margin-top: 6px;
  padding: 6px 10px;
  background: var(--warning-bg);
  border-left: 3px solid var(--warning-border);
  border-radius: 4px;
  font-size: 0.82rem;
  color: #713f12;
}

.notice-box {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  font-size: 0.9rem;
  margin-bottom: 14px;
}
.notice-warn {
  border-color: #fde68a;
  background: #fffbeb;
  color: #78350f;
}
.notice-err {
  border-color: #fecaca;
  background: var(--danger-bg);
  color: #7f1d1d;
}

.progress-wrap {
  width: 100%;
  height: 12px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.25s ease;
}

.side-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(640px, 95vw);
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(15, 23, 42, 0.16);
  z-index: 1000;
  display: flex;
  flex-direction: column;
}
.side-drawer[hidden] { display: none; }
.drawer-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.drawer-body {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
}
.code-preview {
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px;
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  white-space: pre-wrap;
  overflow-x: auto;
}
.preview-img {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 8px;
}

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 560px;
  width: 92vw;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.2);
}
dialog::backdrop { background: rgba(15, 23, 42, 0.45); }

.status-toast {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #e2e8f0;
  font-size: 0.9rem;
}
.status-toast[hidden] { display: none; }
.inline-form { display: inline; }
.mt-12 { margin-top: 12px; }
.mb-12 { margin-bottom: 12px; }
.w-90 { width: 90px; }
