:root {
  /* Palette — cool "chalk & ink" study surface, single teal signal accent */
  --ink: #1c2541;
  --ink-soft: #3a4668;
  --surface: #f6f8fc;
  --card: #ffffff;
  --line: #e2e7f1;
  --signal: #0b8a8a;
  --signal-press: #096f6f;
  --muted: #6b748f;

  /* Semaphores — content-meaningful, the dashboard's signature */
  --green: #2e9e5b;
  --amber: #d99100;
  --grey: #9aa3b7;
  --red: #d1453b;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(28, 37, 65, .06), 0 6px 20px rgba(28, 37, 65, .06);
  --display: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--body);
  color: var(--ink);
  background: var(--surface);
  line-height: 1.5;
}
a { color: var(--signal); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.01em; line-height: 1.2; }
h1 { font-size: 1.7rem; margin: 0 0 .25rem; }
h2 { font-size: 1.25rem; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); }

/* Top bar */
.topbar {
  background: var(--ink);
  color: #fff;
}
.topbar .inner {
  max-width: 1040px; margin: 0 auto; padding: .75rem 1.25rem;
  display: flex; align-items: center; gap: 1.25rem;
}
.brand { display: inline-flex; align-items: center; gap: .5rem; font-family: var(--display); font-weight: 700; color: #fff; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand img { display: block; }
.brand-name { font-size: 1.15rem; }
.brand-name span { color: #7fe3e3; }
.topbar nav { display: flex; gap: 1rem; margin-left: auto; align-items: center; }
.topbar nav a { color: #cdd4e6; font-size: .92rem; }
.topbar nav a:hover { color: #fff; text-decoration: none; }
.lang-switch select {
  width: auto; padding: .3rem 1.6rem .3rem .55rem; font-size: .85rem;
  color: #cdd4e6; background-color: transparent; border: 1px solid #3a4668;
  border-radius: 6px; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23cdd4e6' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .5rem center;
}
.lang-switch select:hover { color: #fff; border-color: #5a6890; }
.lang-switch option { color: var(--ink); background: #fff; }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem;
}
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 720px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }

/* Buttons & forms */
.btn {
  display: inline-block; background: var(--signal); color: #fff;
  border: none; border-radius: 8px; padding: .6rem 1.05rem; font-size: .95rem;
  font-weight: 600; cursor: pointer; font-family: var(--body);
}
.btn:hover { background: var(--signal-press); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
label { font-weight: 600; font-size: .9rem; display: block; margin: .8rem 0 .25rem; }
input[type=text], input[type=password], input[type=number], input[type=email],
select, textarea {
  width: 100%; padding: .55rem .65rem; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
textarea { resize: vertical; }
.help { color: var(--muted); font-size: .82rem; margin-top: .15rem; }
.checkrow { display: flex; align-items: center; gap: .5rem; margin: .5rem 0; }
.checkrow input { width: auto; }
.checkrow label { margin: 0; }

/* Eyebrow / tags */
.eyebrow {
  font-family: var(--mono); font-size: .72rem; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted);
}
.tag {
  font-family: var(--mono); font-size: .72rem; background: #eef1f8;
  color: var(--ink-soft); padding: .15rem .45rem; border-radius: 5px;
}

/* Messages */
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .92rem; }
.flash.success { background: #e7f6ec; color: #1c5e36; }
.flash.error { background: #fbe9e7; color: #8a2a22; }
.flash.info { background: #e9f1fb; color: #234a7a; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }

/* Semaphore dots — the signature element */
.light { display: inline-block; width: 11px; height: 11px; border-radius: 50%; vertical-align: middle; }
.light.green { background: var(--green); box-shadow: 0 0 0 3px rgba(46,158,91,.18); }
.light.amber { background: var(--amber); box-shadow: 0 0 0 3px rgba(217,145,0,.18); }
.light.grey  { background: var(--grey);  box-shadow: 0 0 0 3px rgba(154,163,183,.18); }
.light.red   { background: var(--red);   box-shadow: 0 0 0 3px rgba(209,69,59,.18); }
.semaphores { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.sema { display: flex; align-items: center; gap: .5rem; }
.sema .n { font-family: var(--display); font-size: 1.6rem; font-weight: 700; }
.sema .lbl { font-size: .8rem; color: var(--muted); }

/* Aggregate bars */
.bar { background: #eef1f8; border-radius: 6px; height: 10px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--signal); }
.barrow { display: grid; grid-template-columns: 160px 1fr 60px; gap: .75rem; align-items: center; margin: .4rem 0; }

/* ── Chat room ────────────────────────────────────────────── */
.chat-shell { max-width: 760px; margin: 0 auto; }
.chat-head { display: flex; align-items: baseline; gap: .75rem; margin-bottom: 1rem; }
.thread {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1rem; min-height: 50vh;
  display: flex; flex-direction: column; gap: .75rem;
}
.bubble { max-width: 86%; padding: .7rem .9rem; border-radius: 12px; font-size: .96rem; white-space: pre-wrap; }
.bubble.assistant { background: #eef3fb; color: var(--ink); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.user { background: var(--signal); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble img { max-width: 100%; border-radius: 8px; margin-top: .5rem; display: block; }
.choices { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .9rem; }
.choices .btn.ghost { font-size: .9rem; padding: .45rem .8rem; }
.composer { display: flex; gap: .5rem; margin-top: 1rem; }
.composer textarea { flex: 1; min-height: 48px; max-height: 160px; }
.note { font-size: .8rem; color: var(--muted); margin-top: .4rem; min-height: 1.1em; }
.typing { font-style: italic; color: var(--muted); align-self: flex-start; }
.eval-card { margin-top: 1rem; border-left: 4px solid var(--green); }

/* Task images strip on join page */
.imgstrip { display: flex; gap: .6rem; flex-wrap: wrap; margin: .75rem 0; }
.imgstrip img { max-height: 130px; border-radius: 8px; border: 1px solid var(--line); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

/* ── Audio bubbles + voice recording ─────────────────────────────── */
.bubble-audio { display: block; margin-top: .5rem; width: 100%; max-width: 320px; height: 36px; }
.voice-controls { display: flex; align-items: center; gap: .75rem; margin-top: 1rem; }
.btn.record { background: #fff; color: var(--signal); border: 1.5px solid var(--signal); }
.btn.record .dot { color: var(--red); }
.btn.record.recording { background: var(--red); color: #fff; border-color: var(--red); animation: recpulse 1.4s ease-in-out infinite; }
@keyframes recpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(209,69,59,.4); } 50% { box-shadow: 0 0 0 8px rgba(209,69,59,0); } }
.rec-status { min-height: 1.1em; }

/* ── Join waiting room ───────────────────────────────────────────── */
.waiting { border-left: 4px solid var(--signal); }
.waiting-orb {
  width: 64px; height: 64px; margin: .5rem auto 0; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #7fe3e3, var(--signal));
  box-shadow: 0 0 0 0 rgba(11,138,138,.35); animation: breathe 3.2s ease-in-out infinite;
}
@keyframes breathe { 0%,100% { transform: scale(.92); box-shadow: 0 0 0 0 rgba(11,138,138,.35); } 50% { transform: scale(1.05); box-shadow: 0 0 0 18px rgba(11,138,138,0); } }

/* ── Dashboard live control bar ──────────────────────────────────── */
.livebar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .75rem; }
.livebar-actions { display: flex; gap: .5rem; align-items: center; }

/* ── Broadcast / projector view ──────────────────────────────────── */
.bcast-body {
  margin: 0; min-height: 100vh; color: #eaf0ff;
  background: radial-gradient(1200px 700px at 50% 18%, #243056 0%, #18203b 45%, #0f1528 100%);
  overflow: hidden;
}
.bcast-fx { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.bcast { position: relative; z-index: 2; display: flex; flex-direction: column; min-height: 100vh; padding: 1.4rem 2rem 1rem; }
.bcast-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.bcast-eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .72rem; color: #8ea2d6; margin: 0 0 .2rem; }
.bcast-title { font-family: var(--display); font-size: 2rem; margin: 0; color: #fff; }
.bcast-controls { display: flex; align-items: center; gap: .6rem; }
.bcast-btn { padding: .45rem .9rem; }
.bcast-controls .btn.ghost { color: #eaf0ff; border-color: #3a4668; background: rgba(255,255,255,.04); }
.bcast-live { display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; color: #cdd8f5; background: rgba(255,255,255,.05); padding: .35rem .7rem; border-radius: 999px; }

.sky { position: relative; flex: 1; margin: 1rem 0; }
.sky-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #7e8cb8; font-size: 1.1rem; }

.collective {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  text-align: center; z-index: 1; pointer-events: none;
}
.collective-glow {
  position: absolute; left: 50%; top: 50%; width: 360px; height: 360px; margin: -180px 0 0 -180px;
  border-radius: 50%; background: radial-gradient(circle, rgba(127,227,227,.5), rgba(127,227,227,0) 68%);
  transition: opacity 1.2s ease, transform 1.2s ease; opacity: .25;
}
.collective-num { position: relative; font-family: var(--display); font-size: 3.4rem; font-weight: 700; color: #fff; line-height: 1; }
.collective-lbl { position: relative; font-size: .85rem; letter-spacing: .12em; text-transform: uppercase; color: #aebbe6; }

.lanterns { position: absolute; inset: 0; }
.lantern { position: absolute; transform: translate(-50%,-50%); text-align: center; animation: drift 8s ease-in-out infinite; will-change: transform; }
@keyframes drift { 0%,100% { margin-top: 0; } 50% { margin-top: -10px; } }
.lantern-orb {
  --work: 0; display: block; width: 26px; height: 26px; margin: 0 auto; border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #fff, #9aa3b7);
  box-shadow: 0 0 12px 2px rgba(154,163,183,.5); transition: all .8s ease;
}
.lantern-name { display: block; margin-top: .35rem; font-size: .72rem; color: #c6d0ee; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lantern.st-progress .lantern-orb {
  width: calc(26px + var(--work) * 14px); height: calc(26px + var(--work) * 14px);
  background: radial-gradient(circle at 50% 38%, #fff, #e9c46a);
  box-shadow: 0 0 calc(14px + var(--work) * 22px) calc(2px + var(--work) * 6px) rgba(233,196,106,.55);
}
.lantern.st-finished .lantern-orb {
  background: radial-gradient(circle at 50% 38%, #ffffff, #2e9e5b);
  box-shadow: 0 0 22px 6px rgba(46,158,91,.6);
}
.lantern.rising { animation: rise 2.4s ease-out forwards; }
@keyframes rise { to { margin-top: -36px; } }

.bcast-foot { display: flex; gap: 1.8rem; flex-wrap: wrap; justify-content: center; padding: .6rem 0 .2rem; border-top: 1px solid rgba(255,255,255,.08); }
.tally { display: flex; align-items: center; gap: .45rem; font-size: 1rem; color: #cdd8f5; }
.tally .tnum { font-family: var(--display); font-weight: 700; font-size: 1.25rem; color: #fff; }
.tally .light { box-shadow: none; }
.dot-ink { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: #7fe3e3; }
