:root {
  --bg: #eef3fb;
  --card: #ffffff;
  --line: #d5dfec;
  --ink: #12284c;
  --muted: #567;
  --blue: #0067d8;
  --blue-2: #0a7ea3;
  --warn: #bb2b3f;
  --ok: #0b8a44;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  min-height: 100vh;
  background:
    radial-gradient(circle at 0 0, #dbe8ff 0, transparent 28%),
    radial-gradient(circle at 100% 100%, #fddfca 0, transparent 23%),
    var(--bg);
}

.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background-image: url("/assets/security-robot-splash.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.splash-overlay {
  position: absolute;
  inset: 0;
  background: rgba(19, 27, 58, 0.22);
}
.splash-login {
  position: absolute;
  top: 24px;
  left: 24px;
  width: min(420px, calc(100vw - 48px));
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(4px);
}
.splash-login h2 {
  margin-top: 0;
  color: #0b2a57;
  font-weight: 900;
  letter-spacing: -0.02em;
}
.splash-login .hint {
  color: #355277;
}
.splash-login label {
  color: #1f3c63;
  font-weight: 800;
}
.splash-screen.hidden {
  display: none;
}

.hidden { display: none !important; }

.site-footer {
  margin: 18px auto 10px;
  text-align: center;
  color: #355277;
  font-weight: 700;
  font-size: 0.92rem;
}
.site-footer a {
  color: inherit;
  font-weight: 800;
}

.shell {
  max-width: 1220px;
  margin: 0 auto;
  padding: 18px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 8px 30px rgba(14, 45, 80, 0.07);
  margin-bottom: 14px;
}
.login-screen {
  max-width: 820px;
  margin: 36px auto;
}

.recaptcha-slot {
  margin: 12px 0 10px;
  min-height: 78px;
}
.recaptcha-slot.hidden {
  display: none;
  min-height: 0;
  margin: 0;
}

.splash-log-note {
  color: #164e63 !important;
  font-weight: 700;
  background: rgba(13, 148, 136, 0.08);
  border: 1px solid rgba(13, 148, 136, 0.2);
  border-radius: 10px;
  padding: 8px 10px;
  margin-top: 8px;
}

.recaptcha-slot iframe {
  max-width: 100%;
}

.hero {
  background: linear-gradient(120deg, #08407d 0%, #0a8da4 58%, #1ea7cf 100%);
  color: #fff;
}
.hero .ghost {
  background: rgba(255,255,255,.2);
  color: #fff;
  border: 1px solid rgba(255,255,255,.35);
}
.hero h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
}
.hero-major {
  font: inherit;
  letter-spacing: inherit;
}
.subtitle {
  margin: 4px 0 0;
  opacity: .92;
  font-weight: 600;
}
.hero p {
  margin: 8px 0 14px;
  max-width: 820px;
  opacity: .95;
}
.hero .hint {
  color: rgba(255,255,255,.92);
}
.hero-top {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}
.hero-badges {
  display: flex;
  gap: 8px;
  align-items: center;
}
.version-badge {
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.45);
  background: rgba(255,255,255,.16);
  color: #fff;
  font-weight: 800;
  font-size: .86rem;
  padding: 8px 12px;
  white-space: nowrap;
}
.ai-badge {
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.4);
  background: rgba(255,255,255,.12);
  color: #fff;
  font-weight: 900;
  font-size: .82rem;
  padding: 8px 12px;
  white-space: nowrap;
  min-width: 110px;
  text-align: center;
}
.ai-badge.ok {
  background: rgba(34, 197, 94, 0.24);
  border-color: rgba(34, 197, 94, 0.55);
}
.ai-badge.bad {
  background: rgba(239, 68, 68, 0.24);
  border-color: rgba(239, 68, 68, 0.55);
}
.dev-badge {
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.5);
  background: rgba(185, 28, 28, 0.88);
  color: #fff;
  font-weight: 800;
  font-size: .78rem;
  padding: 8px 12px;
  white-space: nowrap;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(100px, 1fr));
  gap: 8px;
}
.stat {
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.28);
  background: rgba(255,255,255,.11);
  padding: 10px;
}
.stat .label {
  font-size: .76rem;
  opacity: .82;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.stat .value {
  margin-top: 4px;
  font-size: 1.08rem;
  font-weight: 800;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 8px;
}
.tab {
  border: 1px solid var(--line);
  background: #f3f7fd;
  color: #173b6b;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}
.tab.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(110deg, var(--blue), var(--blue-2));
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.chooser-grid {
  grid-template-columns: 1fr;
}
@media (min-width: 980px) {
  .grid { grid-template-columns: .9fr 1.1fr; }
  .admin-grid { grid-template-columns: 1fr 1fr; }
  .chooser-grid { grid-template-columns: 1fr 1fr; }
}

.robot-showcase {
  position: relative;
  padding: 0;
  overflow: hidden;
  border-radius: 24px;
  min-height: 520px;
  background: linear-gradient(140deg, #4c3f7e 0%, #6c62a4 45%, #8c84be 100%);
}
.robot-showcase img {
  display: block;
  width: 100%;
  height: clamp(420px, 60vh, 720px);
  object-fit: cover;
  object-position: 62% 88%;
}
@media (max-width: 900px) {
  .robot-showcase {
    min-height: 340px;
  }
  .robot-showcase img {
    height: clamp(280px, 42vh, 500px);
    object-position: 64% 90%;
  }
}

.robot-health-joke {
  position: absolute;
  left: clamp(18px, 4vw, 52px);
  top: 50%;
  transform: translateY(-50%);
  width: min(50%, 620px);
  z-index: 3;
  color: #f4f8ff;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: 0.01em;
  font-size: clamp(1.22rem, 2.5vw, 2.3rem);
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  text-shadow:
    0 2px 8px rgba(10, 16, 40, 0.62),
    0 1px 1px rgba(10, 16, 40, 0.8);
  overflow-wrap: anywhere;
}
@media (max-width: 900px) {
  .robot-health-joke {
    left: 16px;
    right: 16px;
    width: auto;
    top: auto;
    bottom: 18px;
    transform: none;
    font-size: clamp(1.02rem, 4.8vw, 1.4rem);
    line-height: 1.24;
  }
}

/* Workspace layout: top row (tools + test lab), then full-width classrooms/chats. */
.workspace-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.workspace-top {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 980px) {
  .workspace-top { grid-template-columns: 0.85fr 1.15fr; }
}

.classrooms-full {
  margin-bottom: 0;
}
.classrooms-split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: start;
}

.classrooms-left .classrooms-list {
  max-height: 240px;
}

.seat-chat-viewer {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  padding: 12px;
}
.seat-chat-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.seat-chat-title {
  font-weight: 900;
  color: #0f2f55;
  font-size: 1.1rem;
}
.seat-chat-actions {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.seat-chat-empty {
  border: 1px dashed #cfe0f6;
  border-radius: 14px;
  background: #f8fbff;
  padding: 14px;
}

.seat-chat-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1300;
}
.seat-chat-modal.open {
  display: block;
}
.seat-chat-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 18, 40, 0.56);
}
.seat-chat-modal-panel {
  position: absolute;
  inset: clamp(14px, 3vw, 32px);
  margin: 0 auto;
  max-width: 1080px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.seat-chat-modal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.seat-chat-modal-top h3 {
  margin: 0;
}
.seat-chat-modal .seat-chat-viewer,
.seat-chat-modal .seat-chat-empty {
  flex: 1 1 auto;
}
.seat-chat-modal .chat-box {
  min-height: 50vh;
  max-height: 68vh;
}
body.modal-open {
  overflow: hidden;
}

h2 {
  margin: 0 0 8px;
  font-size: clamp(1.3rem, 2.3vw, 2rem);
}
label {
  display: block;
  margin: 8px 0 6px;
  color: var(--muted);
  font-weight: 600;
}
.auth-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
@media (min-width: 780px) {
  .auth-grid { grid-template-columns: 1fr 1fr; }
}
.auth-grid.single-col {
  grid-template-columns: 1fr !important;
}

.student-form {
  max-width: 560px;
  margin: 0 auto;
}
.student-form .row {
  justify-content: center;
}
.manual-row {
  margin-top: 8px;
}
#reset-row input {
  min-width: 220px;
  flex: 1;
}
#dev-login-row input {
  min-width: 220px;
  flex: 1;
}
.diag-token {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #f8fbff;
}
.diag-token summary {
  cursor: pointer;
  font-weight: 700;
  color: #1f487a;
}
textarea,
select,
input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 10px;
  font: inherit;
  background: #fff;
}
select { min-height: 46px; }
input[type="checkbox"],
input[type="radio"] {
  width: auto;
}

.row {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
button {
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 800;
  color: #fff;
  background: var(--blue);
  cursor: pointer;
}
button.secondary { background: #2f6fb2; }
button.warn { background: var(--warn); }
button.ghost {
  background: #e9eff8;
  color: #173b6b;
}
button:disabled { opacity: .6; cursor: not-allowed; }

.status {
  margin: 10px 0 0;
  color: var(--muted);
  font-weight: 700;
}
.status:empty { display: none; }
.status.ok { color: var(--ok); }
.status.error { color: var(--warn); }

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  font-weight: 800;
  color: #173b6b;
}
.checkbox-line input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.json {
  margin-top: 10px;
  background: #f6f9fd;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 290px;
  overflow: auto;
}

/* Classroom list should feel like a normal table container, not a JSON blob. */
.classrooms-list {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  padding: 10px;
  max-height: 290px;
  overflow: auto;
}
.chat-box {
  min-height: 170px;
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fbff;
  padding: 10px;
}
/* Student chat should be much taller to balance the large figure/learn-more column. */
#student-chat-box {
  min-height: 420px;
  max-height: 620px;
}
.msg {
  padding: 9px 10px;
  border-radius: 10px;
  margin-bottom: 8px;
  line-height: 1.42;
}
.msg.user { background: #dcecff; }
.msg.assistant { background: #e8fff0; }
.msg.system { background: #fff3df; }
.msg-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.msg-actions { flex: 0 0 auto; }
.msg-body { margin-top: 4px; }
.tts-btn {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  cursor: pointer;
}
.tts-btn:hover { background: #f3f7ff; }

.hint {
  margin: 0 0 6px;
  color: var(--muted);
}
.feature-card ul {
  margin: 10px 0 0 18px;
  padding: 0;
}
.feature-card li { margin: 6px 0; }
.tool-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.classrooms-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fbff;
  padding: 12px;
}
.classrooms-panel h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}
.classroom-seats-block {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  padding: 12px;
}
.seat-block-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.seat-block-title {
  font-size: 1.15rem;
  font-weight: 900;
  color: #0f2f55;
}
.inline-copy-link {
  margin-left: 8px;
  font-size: 0.82rem;
  font-weight: 800;
  vertical-align: middle;
}
.tool-btn {
  text-align: left;
  background: #f3f8ff;
  color: #184072;
  border: 1px solid #d8e6fb;
}
.tool-btn:hover {
  background: #eaf3ff;
}
.character-preview {
  margin: 10px 0;
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #f8fbff;
}

/* Student chat: character panel + chat on desktop (closer to WP feel). */
.student-chat-layout{
  display:grid;
  /* Intentionally large character panel (selling point / classroom vibe). */
  grid-template-columns: 520px minmax(0, 1fr);
  gap: 14px;
  align-items:start;
}
@media (max-width: 980px){
  .student-chat-layout{ grid-template-columns: 1fr; }
}
.student-figure-card{
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f8fbff;
  padding: 12px;
}
.student-figure-card img{
  width: 100%;
  height: 520px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid #cfe0f6;
  background: #fff;
  box-shadow: 0 12px 30px rgba(16, 62, 112, 0.14);
}
.student-figure-meta{ margin-top: 10px; }
#character-image {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid #cfe0f6;
  background: #fff;
}

.student-chat-header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.student-chat-head-left{ min-width: 260px; }
.student-chat-actions{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:flex-end;
}
@media (max-width: 640px){
  .student-chat-actions{ width:100%; }
}

#student-figure-image {
  /* IMPORTANT: id selector beats .student-figure-card img, so keep this aligned. */
  width: 100%;
  height: 520px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid #cfe0f6;
  background: #fff;
  box-shadow: 0 12px 30px rgba(16, 62, 112, 0.14);
}
.starter-questions {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.starter-q-btn {
  border: 1px solid #bdd6f3;
  background: #eef6ff;
  color: #173b6b;
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 700;
  font-size: 0.86rem;
  cursor: pointer;
}
.starter-q-btn:hover {
  background: #dcecff;
}
#student-learn-more-text {
  white-space: pre-line;
}
.student-enter-send-line {
  margin-top: 8px;
  margin-bottom: 0;
}
.student-enter-send-line .hint {
  margin: 0;
}
.student-compose-actions {
  margin-top: 8px;
}
.character-name {
  font-weight: 800;
}
.character-era {
  color: #3e5f86;
  font-size: 0.9rem;
  margin-top: 2px;
}
.character-blurb {
  color: #415875;
  font-size: 0.9rem;
  margin-top: 6px;
}

.rooms-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 12px;
}

.rooms-table th,
.rooms-table td {
  text-align: left;
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.rooms-table thead th {
  background: #f3f8ff;
  color: #173a62;
  font-weight: 800;
  font-size: 0.9rem;
}

.rooms-table tbody tr:hover td {
  background: #fbfdff;
}

.room-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #103b6a;
  font-weight: 800;
  cursor: pointer;
  text-align: left;
}
.room-name:focus-visible {
  outline: 2px solid rgba(0, 103, 216, 0.35);
  outline-offset: 3px;
  border-radius: 10px;
}

.room-row.selected td {
  background: #eff7ff;
}

.room-details td {
  background: #fbfdff;
  padding: 0;
}
.room-details-inner {
  padding: 12px 10px;
}
.room-details-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  align-items: center;
  justify-content: space-between;
}
.room-actions {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-left: auto;
}
button.mini {
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 0.86rem;
  font-weight: 800;
}
button.mini.danger {
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #9f1239;
}
.chip {
  background: #eef6ff;
  border: 1px solid #d8e6fb;
  border-radius: 999px;
  padding: 6px 10px;
  color: #173a62;
  font-size: 0.88rem;
}
.seat-actions {
  white-space: nowrap;
}
.seat-actions .sep {
  opacity: 0.35;
  margin: 0 6px;
}
button.linkish {
  padding: 0;
  border: 0;
  background: transparent;
  color: #1d4ed8;
  font-weight: 800;
  cursor: pointer;
}
button.linkish:hover {
  text-decoration: underline;
}
button.linkish.danger {
  color: #b91c1c;
}
.seat-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.seat-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  background: #ffffff;
  border: 1px solid #d8e6fb;
  border-radius: 10px;
  padding: 6px 10px;
  color: #173a62;
}
.room-details-title {
  font-weight: 800;
  color: #173a62;
  margin-bottom: 6px;
}

.seats-table {
  width: 100%;
  border-collapse: collapse;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
}
.seats-table th,
.seats-table td {
  text-align: left;
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
}
.seats-table thead th {
  background: #f3f8ff;
  color: #173a62;
  font-weight: 800;
  font-size: 0.9rem;
}
.seats-table td:first-child {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

#admin-card { display: none; }
#admin-card.visible { display: block; }
.smtp-alert {
  border-color: #f5c2c7;
  background: #fff4f5;
  color: #8b1f2d;
  font-weight: 600;
}

@media (max-width: 780px) {
  .shell { padding: 12px; }
  .stats { grid-template-columns: repeat(2, minmax(100px, 1fr)); }
  .hero-top { align-items: flex-start; flex-direction: column; }
  .hero-badges { width: 100%; justify-content: flex-start; }
  .version-badge { align-self: flex-start; }
  .row.stack-mobile button { width: 100%; }
  .splash-login {
    top: 12px;
    left: 12px;
    width: calc(100vw - 24px);
  }
  .recaptcha-slot {
    transform: scale(0.92);
    transform-origin: 0 0;
  }
}
