:root {
  --bg: #1b1d23;
  --bg-panel: #23262e;
  --bg-panel-raised: #2b2f39;
  --border: #383c47;
  --text: #e6e5e2;
  --text-dim: #9a9ea8;
  --accent: #5fb3a3;
  --accent-dim: #3d7a70;
  --warn: #d98c5f;
  --error: #d9705f;
  --font-ui: -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); }

button {
  font-family: var(--font-ui);
  background: var(--accent);
  color: #10231f;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}
button:hover { background: #74c2b3; }
button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
button.secondary:hover { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input, textarea, select {
  font-family: var(--font-ui);
  background: var(--bg-panel-raised);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent-dim);
  border-color: var(--accent);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}
.topbar .brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar .brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
}
.topbar .user-info {
  display: flex; align-items: center; gap: 12px;
  color: var(--text-dim); font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 53px);
}
.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}
.main {
  padding: 20px;
  overflow-y: auto;
}

.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 14px;
}

.assignment-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 4px;
  border: 1px solid transparent;
}
.assignment-item:hover { background: var(--bg-panel-raised); }
.assignment-item.active {
  background: var(--bg-panel-raised);
  border-color: var(--accent-dim);
}
.assignment-item .title { font-weight: 600; font-size: 14px; }
.assignment-item .meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-panel-raised);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.badge.submitted { color: var(--accent); border-color: var(--accent-dim); }
.badge.draft { color: var(--warn); }

.editor-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  height: 420px;
}

.output-panel {
  background: #14161b;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  white-space: pre-wrap;
  max-height: 240px;
  overflow-y: auto;
}
.output-panel.error { color: var(--error); }
.output-panel .status-line { color: var(--text-dim); margin-bottom: 6px; }

.toolbar {
  display: flex; gap: 8px; margin: 12px 0;
}

.discussion {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
  padding: 4px;
}
.message {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-panel-raised);
  border: 1px solid var(--border);
  max-width: 85%;
}
.message.teacher { align-self: flex-start; border-left: 3px solid var(--accent); }
.message.student { align-self: flex-end; border-left: 3px solid var(--warn); }
.message .meta { font-size: 11px; color: var(--text-dim); margin-bottom: 4px; }
.message .body { font-size: 14px; white-space: pre-wrap; }
.message .linked-version {
  display: inline-block; margin-top: 6px; font-size: 11px;
  color: var(--accent); cursor: pointer;
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-card {
  width: 340px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
}
.login-card h1 {
  font-size: 20px;
  margin: 0 0 4px 0;
}
.login-card p.sub { color: var(--text-dim); font-size: 13px; margin-top: 0; margin-bottom: 20px; }
.login-card label {
  display: block; font-size: 12px; color: var(--text-dim);
  margin-bottom: 4px; margin-top: 12px;
}
.login-card input { width: 100%; }
.login-card button { width: 100%; margin-top: 18px; }
.login-error { color: var(--error); font-size: 13px; margin-top: 10px; }

.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.form-row input, .form-row textarea { width: 100%; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 600; font-size: 12px; }
tr.student-row { cursor: pointer; }
tr.student-row:hover { background: var(--bg-panel-raised); }

.version-list { display: flex; flex-direction: column; gap: 4px; }
.version-item {
  padding: 6px 10px; border-radius: 6px; font-size: 12px; cursor: pointer;
  border: 1px solid transparent; color: var(--text-dim);
}
.version-item:hover { background: var(--bg-panel-raised); }
.version-item.active { border-color: var(--accent-dim); color: var(--text); }

h2 { font-size: 18px; margin: 0 0 4px 0; }
h3 { font-size: 14px; margin: 0 0 10px 0; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.muted { color: var(--text-dim); font-size: 13px; }
.grade-box { display: flex; gap: 10px; align-items: center; }
.grade-box input[type=number] { width: 80px; }

/* --- Single-column pages (e.g. new student form) --- */
.layout.single { grid-template-columns: 1fr; }
.layout.single .main { max-width: 640px; margin: 0 auto; width: 100%; }

.back-link {
  display: inline-block;
  margin-bottom: 12px;
  font-size: 13px;
  text-decoration: none;
}
.back-link:hover { text-decoration: underline; }

/* Anchors that should look like buttons */
.button-link {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  background: var(--accent);
  color: #10231f;
}
.button-link.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.button-link.secondary:hover { border-color: var(--accent); color: var(--accent); }

.form-message {
  margin-top: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
}
.form-message.success { border: 1px solid var(--accent-dim); color: var(--accent); }
.form-message.error { border: 1px solid var(--error); color: var(--error); }

/* --- Study group headings in the student sidebar --- */
.group-heading {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 12px 0 4px;
}
.group-heading:first-child { margin-top: 0; }

/* --- Student profile --- */
.profile-table { width: 100%; }
.profile-table td { padding: 4px 0; font-size: 14px; }
.profile-table td.muted { width: 140px; }

/* --- Assignment handouts --- */
.file-list { margin: 12px 0; }
.file-list h4 { margin: 0 0 6px; font-size: 13px; color: var(--text-dim); font-weight: 600; }
.file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 13px;
}
.file-item a { text-decoration: none; }
.file-item a:hover { text-decoration: underline; }

/* --- Delete button on discussion messages --- */
.message .meta { display: flex; align-items: center; gap: 8px; }
.delete-message {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
  border-radius: 4px;
}
.delete-message:hover { background: transparent; color: var(--error); }

/* --- "Needs grading" indicator in the teacher sidebar --- */
.needs-review {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--warn);
  color: #241505;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  cursor: help;
}

/* --- Project tree beside the code editor --- */
.editor-layout {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.editor-layout .editor-wrap { flex: 1; min-width: 0; }

.file-tree {
  width: 190px;
  flex: 0 0 190px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  overflow-y: auto;
  height: 420px;
}
/* The starter-project tree carries an extra "set main" button per row, so it
   needs more room before names start getting cut off. */
.file-tree.wide { width: 240px; flex: 0 0 240px; }
.file-tree-header {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
/* Only the "+ New file" button at the bottom of the tree - the direct-child
   selector keeps this away from the small buttons inside a .file-node, which
   it would otherwise stretch across the whole row. */
.file-tree > button { width: 100%; margin-top: auto; }

.file-node {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-dim);
}
.file-node:hover { background: var(--bg-panel-raised); color: var(--text); }
.file-node.active {
  background: var(--bg-panel-raised);
  border-color: var(--accent-dim);
  color: var(--text);
}
/* The name takes the leftover space; min-width:0 lets it actually shrink and
   ellipsize instead of forcing the row wider. */
.file-node-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Badges and per-row buttons keep their natural width, whatever else a
   broader button rule might say. */
.file-node .entry-badge,
.file-node .delete-file,
.file-node .set-entry { flex: 0 0 auto; }

.entry-badge {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #10231f;
  background: var(--accent);
  border-radius: 4px;
  padding: 1px 5px;
}

.delete-file {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1;
  padding: 0 3px;
  cursor: pointer;
  border-radius: 4px;
  width: auto;
  margin-top: 0;
}
.delete-file:hover { background: transparent; color: var(--error); }

#entry-hint { font-size: 12px; margin-top: 8px; }

/* "set main" action in the starter-project tree */
.set-entry {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  cursor: pointer;
  width: auto;
  margin-top: 0;
}
.set-entry:hover { background: transparent; border-color: var(--accent); color: var(--accent); }

/* --- Deadline warnings in a student's profile --- */
.deadline-flag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--warn);
  color: #241505;
  cursor: help;
}
.deadline-flag.overdue { background: var(--error); color: #2a0f0c; }

.warning-banner {
  border: 1px solid var(--warn);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 13px;
}
.warning-banner ul { margin: 6px 0 0; padding-left: 18px; }
.warning-banner li { margin-bottom: 2px; }

/* Import results table */
#import-result table { margin-top: 8px; }
#import-result h3 { margin: 16px 0 4px; font-size: 14px; }
#import-result code { font-size: 12.5px; }

/* A deadline that has already passed reads as an error, not a caution */
.warning-banner.overdue { border-color: var(--error); }

/* Destructive action button */
button.secondary.danger { color: var(--error); border-color: var(--border); }
button.secondary.danger:hover { border-color: var(--error); color: var(--error); }

/* --- Assignment type tag --- */
.type-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: middle;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.type-badge.type-code { color: var(--accent); border-color: var(--accent-dim); }
.type-badge.type-text { color: #8ba7d9; border-color: #4a5b7d; }
.type-badge.type-freeform { color: var(--warn); border-color: #7d5a44; }

/* --- Text assignments --- */
.text-editor {
  width: 100%;
  min-height: 320px;
  resize: vertical;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.6;
}
.text-view {
  background: var(--bg-panel-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  max-height: 420px;
  overflow-y: auto;
}
