/* IO Augment — MVP styling. The IO brand: Signal blue, paper, ink.
   Light-committed by brand rule (the IO has no dark mode). Neo-grotesk
   system stack stands in for the licensed Scto Grotesk A, which a desktop
   font licence does not permit us to serve on the web. */

:root {
  --signal: #1b4dff;
  --signal-ink: #1230a8;
  --paper: #f1f0eb;
  --paper-2: #e7e5dd;
  --card: #ffffff;
  --ink: #121210;
  --ink-2: #43423d;
  --slate: #3b5266;
  --on-signal: #f1f0eb;
  --line: #d7d5cc;
  --line-2: #c9c7bd;
  --good: #147a4b;

  --grot: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Roboto Mono', Menlo, monospace;

  --r: 6px;
  --rail-w: 244px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--grot);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }

.app {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  min-height: 100vh;
}
/* the hidden attribute must win over the display rules above/below */
.app[hidden], .gate[hidden] { display: none; }

/* ---------- rail ---------- */
.rail {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
  background: var(--signal);
  color: var(--on-signal);
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; flex-direction: column; gap: 12px; }
.lockup {
  display: inline-flex; align-items: center; gap: 6px;
  align-self: flex-start;
  font-weight: 800; letter-spacing: -0.02em;
  background: var(--paper); color: var(--signal);
  padding: 4px 8px; border-radius: var(--r);
  font-size: 15px;
}
.lockup .the { font-weight: 500; }
.wordmark { font-weight: 800; font-size: 30px; letter-spacing: -0.05em; }
.wordmark sup { font-size: 0.32em; font-weight: 500; vertical-align: super; margin-left: 2px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  text-align: left; width: 100%;
  padding: 10px 12px;
  background: transparent; border: 0; border-radius: var(--r);
  color: color-mix(in srgb, var(--on-signal) 82%, transparent);
  font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
  cursor: pointer;
}
.nav-item:hover { background: color-mix(in srgb, var(--paper) 14%, transparent); color: var(--on-signal); }
.nav-item.is-active { background: var(--paper); color: var(--signal); }
.nav-k { font-family: var(--mono); font-size: 11px; opacity: 0.7; }
.nav-item.is-active .nav-k { opacity: 0.55; }

.rail-foot { margin-top: auto; }
.cohort { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.cohort-sub { margin: 2px 0 0; font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em;
  color: color-mix(in srgb, var(--on-signal) 70%, transparent); }

/* ---------- main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 80%, #fff);
  position: sticky; top: 0; z-index: 5;
}
.crumb { margin: 0; font-weight: 700; letter-spacing: -0.015em; }
.crumb-sub { margin: 2px 0 0; font-size: 13px; color: var(--ink-2); }
.who { display: flex; align-items: center; gap: 10px; }
.who-name { font-size: 13px; color: var(--ink-2); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--signal); color: var(--on-signal);
  font-size: 13px; font-weight: 700;
}

.panel { display: none; flex: 1; min-height: 0; }
.panel.is-active { display: flex; flex-direction: column; }
.pad { padding: 32px 28px 56px; max-width: 760px; }
.h { margin: 0 0 6px; font-size: clamp(1.5rem, 3vw, 2.1rem); letter-spacing: -0.03em; text-wrap: balance; }
.lede { margin: 0 0 24px; color: var(--ink-2); font-size: 1.02rem; max-width: 54ch; }

/* ---------- companion / chat ---------- */
.chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-scroll {
  flex: 1; overflow-y: auto;
  padding: 28px; display: flex; flex-direction: column; gap: 16px;
}
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.bubble {
  max-width: 62ch; padding: 14px 16px; border-radius: 14px;
  line-height: 1.5; font-size: 0.98rem;
}
.msg.assistant .bubble { background: var(--card); border: 1px solid var(--line); border-top-left-radius: 4px; }
.msg.user .bubble { background: var(--signal); color: var(--on-signal); border-top-right-radius: 4px; }
.bubble p { margin: 0 0 8px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble .hint { font-size: 0.86rem; color: var(--ink-2); }
.msg.user .bubble .hint { color: color-mix(in srgb, var(--on-signal) 80%, transparent); }
.bubble.thinking { color: var(--ink-2); font-style: italic; }

.composer {
  display: flex; gap: 10px; padding: 16px 28px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 80%, #fff);
}
.composer-input {
  flex: 1; padding: 12px 14px; border: 1px solid var(--line-2);
  border-radius: var(--r); background: var(--card);
}
.composer-input:focus { outline: 2px solid var(--signal); outline-offset: 1px; border-color: var(--signal); }
.grounding {
  margin: 0; padding: 6px 28px 14px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.03em; color: var(--ink-2);
  background: color-mix(in srgb, var(--paper) 80%, #fff);
}

.btn {
  padding: 12px 18px; border: 1px solid var(--ink); border-radius: var(--r);
  background: var(--ink); color: var(--paper); font-weight: 650; cursor: pointer;
}
.btn:hover { background: #000; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--paper-2); }
.btn-signal { background: var(--signal); border-color: var(--signal); color: var(--on-signal); }
.btn-signal:hover { background: var(--signal-ink); }

/* ---------- sessions ---------- */
.sessions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.sessions li {
  display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 14px;
  padding: 16px 0; border-top: 1px solid var(--line);
}
.sessions li.clickable { cursor: pointer; }
.sessions li.clickable:hover .st { color: var(--signal); }

/* ---------- class modal + voice feedback ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(18, 18, 16, 0.5); padding: 20px; }
.modal[hidden] { display: none; }
.modal-card { position: relative; width: min(640px, 100%); max-height: 88vh; overflow-y: auto;
  background: var(--card); border-radius: 12px; padding: 26px; }
.modal-x { position: absolute; top: 12px; right: 14px; border: 0; background: transparent;
  font-size: 17px; cursor: pointer; color: var(--ink-2); }
.modal-x:hover { color: var(--ink); }
.modal-k { margin: 0 0 4px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--signal); }
.modal-h { margin: 0 0 16px; font-size: 1.4rem; letter-spacing: -0.03em; text-wrap: balance; }
.video { height: 200px; border-radius: 8px; background: var(--signal); color: var(--on-signal);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; margin-bottom: 22px; }
.video-play { width: 54px; height: 54px; border-radius: 50%; background: rgba(241, 240, 235, 0.16);
  display: grid; place-items: center; font-size: 18px; }
.video-meta { font-family: var(--mono); font-size: 12px; color: color-mix(in srgb, var(--on-signal) 82%, transparent); }
.fb-head { margin: 0 0 12px; font-weight: 700; letter-spacing: -0.01em; }
.fb-list { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.fb-empty { color: var(--ink-2); font-size: 0.92rem; }
.fb-item { border-left: 3px solid var(--line-2); padding-left: 12px; }
.fb-by { display: flex; align-items: center; gap: 8px; }
.fb-name { font-weight: 650; font-size: 0.92rem; }
.fb-role { font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 4px; }
.fb-role.instructor { background: var(--signal); color: var(--on-signal); }
.fb-role.student { background: var(--paper-2); color: var(--ink-2); }
.fb-text { margin: 5px 0 0; font-size: 0.95rem; line-height: 1.45; }
.fb-input { width: 100%; min-height: 70px; resize: vertical; padding: 12px;
  border: 1px solid var(--line-2); border-radius: var(--r); background: var(--card); line-height: 1.5; }
.fb-input:focus { outline: 2px solid var(--signal); outline-offset: 1px; border-color: var(--signal); }
.fb-actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.mic { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px;
  border: 1px solid var(--line-2); border-radius: var(--r); background: var(--card); cursor: pointer; font-weight: 600; }
.mic:hover { border-color: var(--signal); }
.mic:disabled { opacity: 0.5; cursor: default; }
.mic-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-2); }
.mic.rec { border-color: #a13a50; color: #a13a50; }
.mic.rec .mic-dot { background: #d34; animation: micpulse 1s infinite; }
@keyframes micpulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .mic.rec .mic-dot { animation: none; } }
.fb-note { margin: 8px 0 0; font-size: 13px; }
.sessions .wk { font-family: var(--mono); font-size: 12px; color: var(--signal); }
.sessions .st { font-weight: 650; letter-spacing: -0.01em; }
.sessions .sd { font-size: 13px; color: var(--ink-2); }
.tag { font-family: var(--mono); font-size: 11px; padding: 3px 8px; border-radius: 999px; }
.tag.rec { background: #e7f2ec; color: var(--good); }
.tag.up { background: var(--paper-2); color: var(--ink-2); }

/* ---------- build ---------- */
.field-label { display: block; font-size: 13px; font-weight: 650; margin: 0 0 8px; }
.project {
  width: 100%; min-height: 140px; resize: vertical;
  padding: 14px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--card);
  line-height: 1.5;
}
.project:focus { outline: 2px solid var(--signal); outline-offset: 1px; border-color: var(--signal); }
.build-row { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.save-note { font-size: 13px; color: var(--good); }

/* ---------- progress ---------- */
.arc { list-style: none; margin: 0; padding: 0; }
.arc li {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 0; border-top: 1px solid var(--line); cursor: pointer;
}
.arc .box {
  width: 22px; height: 22px; border: 1.5px solid var(--line-2); border-radius: 5px;
  display: grid; place-items: center; flex: 0 0 auto; color: transparent; font-size: 14px; font-weight: 800;
}
.arc li.done .box { background: var(--signal); border-color: var(--signal); color: var(--on-signal); }
.arc .wk { font-family: var(--mono); font-size: 12px; color: var(--ink-2); width: 58px; flex: 0 0 auto; }
.arc .nm { font-weight: 600; letter-spacing: -0.01em; }

/* ---------- credential ---------- */
.cred-empty { color: var(--ink-2); }
.credential {
  background: var(--signal); color: var(--on-signal);
  border-radius: 10px; padding: 26px; max-width: 560px; margin: 8px 0 22px;
}
.credential .badge { font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: color-mix(in srgb, var(--on-signal) 75%, transparent); margin: 0 0 12px; }
.credential .ctitle { margin: 0 0 6px; font-size: 1.7rem; letter-spacing: -0.03em; }
.credential .cmeta { margin: 0; font-size: 0.9rem; color: color-mix(in srgb, var(--on-signal) 82%, transparent); }
.credential .cid { font-family: var(--mono); font-size: 11px; margin-top: 14px; word-break: break-all;
  color: color-mix(in srgb, var(--on-signal) 70%, transparent); }
.demo-flag {
  display: inline-block; margin: 0 0 16px; padding: 4px 9px; border-radius: 4px;
  background: #fff3d6; color: #7a5200; font-size: 12px; font-weight: 650;
}
.loop { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-direction: column; gap: 0; max-width: 560px; }
.loop li { display: grid; grid-template-columns: 26px 1fr; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.loop .n { font-family: var(--mono); font-size: 12px; color: var(--signal); }
.loop .lt { display: block; font-weight: 650; letter-spacing: -0.01em; }
.loop .ld { display: block; font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.cred-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 8px; }

/* ---------- sign-in gate ---------- */
.gate { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: var(--paper); padding: 24px; }
.gate-card {
  width: min(420px, 100%); background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 30px; display: flex; flex-direction: column; gap: 12px;
}
.gate-card .brand { flex-direction: row; align-items: center; gap: 10px; margin-bottom: 4px; }
.gate-card .lockup { background: var(--signal); color: var(--paper); }
.gate-card .wordmark { color: var(--ink); font-size: 24px; }
.gate-h { margin: 8px 0 0; font-size: 1.5rem; letter-spacing: -0.03em; }
.gate-sub { margin: 0 0 6px; color: var(--ink-2); font-size: 0.95rem; }
.gate-input {
  padding: 12px 14px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--card);
}
.gate-input:focus { outline: 2px solid var(--signal); outline-offset: 1px; border-color: var(--signal); }
.role-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.role {
  padding: 10px; border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--card); cursor: pointer; font-weight: 600; color: var(--ink-2);
}
.role.is-on { border-color: var(--signal); background: color-mix(in srgb, var(--signal) 8%, #fff); color: var(--signal); }
.gate-go { margin-top: 4px; text-align: center; justify-content: center; }
.gate-note { margin: 6px 0 0; font-size: 12px; color: var(--ink-2); }
.gsi { display: flex; justify-content: center; margin: 2px 0; min-height: 40px; }
.gate-err { margin: 0; color: #a13a50; font-size: 13px; min-height: 0; }
.gate-err:empty { display: none; }
.gate-or { display: flex; align-items: center; gap: 10px; margin: 4px 0; color: var(--ink-2); font-size: 11px; letter-spacing: 0.02em; text-transform: uppercase; }
.gate-or::before, .gate-or::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.who-name, .avatar { cursor: pointer; }

/* ---------- profile ---------- */
.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 26px; }
.profile-av {
  width: 56px; height: 56px; border-radius: 50%; flex: 0 0 auto;
  background: var(--signal); color: var(--on-signal);
  display: grid; place-items: center; font-size: 22px; font-weight: 800;
}
.profile-head .h { margin: 0; }
.profile-role { margin: 4px 0 0; color: var(--ink-2); font-size: 0.95rem; }
.profile-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 30px; align-items: start; }
.profile-form { display: flex; flex-direction: column; gap: 8px; }
.profile-form .field-label { margin-top: 6px; }
.profile-form .project { min-height: 90px; }
.profile-cards { display: flex; flex-direction: column; gap: 10px; }
.pcard {
  text-align: left; display: flex; flex-direction: column; gap: 4px;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); cursor: pointer;
}
.pcard:hover { border-color: var(--signal); }
.pc-k { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--signal); }
.pc-v { font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
@media (max-width: 820px) { .profile-grid { grid-template-columns: 1fr; } }

/* ---------- files ---------- */
.files-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.upload-btn { cursor: pointer; }
.file-list { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-direction: column; }
.file-empty { color: var(--ink-2); font-size: 0.92rem; padding: 16px 0; }
.file-item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px;
  padding: 14px 0; border-top: 1px solid var(--line); }
.file-ic { font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--signal);
  background: color-mix(in srgb, var(--signal) 8%, #fff); border: 1px solid var(--line);
  border-radius: 6px; padding: 8px 10px; min-width: 50px; text-align: center; }
.file-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.file-name { font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: 13px; color: var(--ink-2); }
.file-actions { display: flex; align-items: center; gap: 14px; }
.file-dl { font-weight: 600; color: var(--signal); text-decoration: none; font-size: 0.9rem; }
.file-dl:hover { text-decoration: underline; }
.file-rm { border: 0; background: transparent; color: var(--ink-2); cursor: pointer; font-size: 14px; }
.file-rm:hover { color: #a13a50; }

/* ---------- admin roster ---------- */
body:not(.role-instructor) .nav-admin { display: none; }
.enrol-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.enrol-form .gate-input { flex: 1 1 160px; min-width: 0; }
.enrol-form #en-role { flex: 0 0 140px; }
.enrol-form #en-add { flex: 0 0 auto; }
.roster { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-direction: column; }
.roster-row { display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: 16px; padding: 13px 0; border-top: 1px solid var(--line); }
.ros-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ros-name { font-weight: 600; letter-spacing: -0.01em; }
.ros-email { font-size: 13px; color: var(--ink-2); }
.ros-cohort { font-size: 13px; color: var(--ink-2); }

.role-badge {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 4px; background: var(--signal); color: var(--on-signal);
}
.signout {
  background: transparent; border: 1px solid var(--line-2); border-radius: var(--r);
  padding: 5px 10px; font-size: 12px; color: var(--ink-2); cursor: pointer;
}
.signout:hover { background: var(--paper-2); color: var(--ink); }

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 16px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .rail-foot { margin: 0; }
}
