:root {
  --bg: #f7f7f5;
  --card: #ffffff;
  --border: #e3e3df;
  --text: #1a1a1a;
  --muted: #666;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --danger: #dc2626;
  --success: #16a34a;
  --warn-bg: #fef9c3;
  --warn-border: #fde68a;
  --warn-fg: #854d0e;
  --ok-bg: #dcfce7;
  --ok-border: #bbf7d0;
  --ok-fg: #166534;
  --err-bg: #fee2e2;
  --err-border: #fecaca;
  --err-fg: #991b1b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}
.container.wide { max-width: 1000px; }

h1 { font-size: 1.6rem; margin: 0 0 8px; }
h2 { font-size: 1.2rem; margin: 24px 0 12px; }
.muted { color: var(--muted); }

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

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

label { display: block; font-weight: 600; margin: 16px 0 6px; }
label:first-child { margin-top: 0; }

input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: white;
}
textarea { min-height: 100px; resize: vertical; }
.hint { font-weight: 400; font-size: 0.85rem; color: var(--muted); margin: 4px 0 0; }

button, .btn {
  display: inline-block;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.secondary, .btn.secondary { background: #e5e5e2; color: var(--text); }
button.danger, .btn.danger { background: var(--danger); }
.btn.small { padding: 8px 14px; font-size: 0.9rem; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.flash { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.flash.error { background: var(--err-bg); border-color: var(--err-border); color: var(--err-fg); }
.flash.success { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-fg); }

.code-pill {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.3rem;
  letter-spacing: 2px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 8px;
  padding: 6px 14px;
  font-weight: 700;
}

/* roster name buttons */
.name-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.name-grid button, .name-btn { background: white; color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.name-grid button:hover, .name-btn:hover { border-color: var(--accent); color: var(--accent); }
.name-btn { display: block; text-align: center; text-decoration: none; font-weight: 600; cursor: pointer; }

/* lists */
.list { list-style: none; padding: 0; margin: 0; }
.list li { border-bottom: 1px solid var(--border); padding: 12px 0; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.list li:last-child { border-bottom: 0; }

/* chat */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 120px); }
.messages { flex: 1; overflow-y: auto; padding: 4px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 80%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: white; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.user { align-self: flex-end; background: var(--accent); color: white; border-bottom-right-radius: 4px; }
.composer { display: flex; gap: 8px; margin-top: 12px; align-items: flex-end; }
.composer textarea { min-height: 48px; max-height: 160px; }
.turns { font-size: 0.85rem; color: var(--muted); margin: 8px 0 0; text-align: center; }
.closed-banner { background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn-fg); border-radius: 8px; padding: 12px; text-align: center; margin-top: 12px; }
.typing { font-style: italic; color: var(--muted); }

.transcript .msg { max-width: 100%; }

/* status badges (assignment open vs draft) */
.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid;
  vertical-align: middle;
  white-space: nowrap;
}
.badge.open { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-fg); }
.badge.draft { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-fg); }

/* student activity chooser */
.activity-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  text-decoration: none;
  color: var(--text);
}
.activity-card:hover { border-color: var(--accent); }
.activity-card strong { font-size: 1.05rem; }

/* minimum-response-length progress bar (student chat) */
.lenbar { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.lenbar-track { flex: 1; height: 8px; background: #e5e5e2; border-radius: 999px; overflow: hidden; }
.lenbar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .15s ease; }
.lenbar.full .lenbar-fill { background: var(--success); }
.lenbar-text { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.lenbar.full .lenbar-text { color: var(--success); font-weight: 600; }

/* thermometer (AI-judged dimension, student chat + teacher transcript) */
.thermo { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.thermo-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.thermo-label { font-weight: 600; font-size: 0.9rem; }
.thermo-val { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
.thermo-track { height: 10px; background: #e5e5e2; border-radius: 999px; overflow: hidden; }
.thermo-fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .4s ease; }

/* vertical animated thermometer fixed to the left of the student chat */
.container.has-thermo { padding-left: 104px; }
.thermometer {
  position: fixed;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 40;
}
.thermometer-readout { font-weight: 800; font-size: 1.25rem; color: #dc2626; line-height: 1; }
.thermometer-readout small { font-size: .7rem; color: var(--muted); font-weight: 600; }
.thermometer-stem { position: relative; display: flex; flex-direction: column; align-items: center; }
.thermometer-tube {
  position: relative;
  width: 18px;
  height: 190px;
  background: #f1f1ee;
  border: 2px solid #cfcfca;
  border-bottom: 0;
  border-radius: 999px 999px 0 0;
  overflow: hidden;
  box-shadow: inset 0 0 5px rgba(0, 0, 0, .08);
}
.thermometer-liquid {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 0;
  background: linear-gradient(to top, #dc2626, #fb7185);
  /* slight overshoot so the liquid settles like a fluid */
  transition: height .75s cubic-bezier(.34, 1.4, .5, 1);
}
.thermometer-bulb {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #dc2626;
  border: 2px solid #cfcfca;
  margin-top: -10px;                 /* overlap the tube so liquid + bulb connect */
  z-index: 1;
  box-shadow: inset -2px -2px 5px rgba(0, 0, 0, .18);
}
.thermometer-label { font-size: .72rem; color: var(--muted); text-align: center; max-width: 86px; line-height: 1.25; }

@media (max-width: 760px) {
  .container.has-thermo { padding-left: 62px; }
  .thermometer { left: 6px; width: 50px; gap: 5px; }
  .thermometer-readout { font-size: 1rem; }
  .thermometer-tube { height: 140px; width: 16px; }
  .thermometer-bulb { width: 28px; height: 28px; }
  .thermometer-label { display: none; }   /* too tight beside a phone chat */
}
