:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --paper: #ffffff;
  --paper-soft: #f9fafc;
  --ink: #242833;
  --muted: #747c8d;
  --line: #e2e6ef;
  --line-strong: #cfd6e4;
  --blue: #2f6fed;
  --blue-soft: #edf3ff;
  --green: #22995c;
  --green-soft: #eaf8f0;
  --yellow: #b58400;
  --yellow-soft: #fff6da;
  --red: #d84b4b;
  --red-soft: #fff0f0;
  --shadow: 0 12px 30px rgba(28, 35, 50, .08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, textarea, input, select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 8px 13px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}

button:hover { transform: translateY(-1px); border-color: #b9c4d6; }
button:disabled { cursor: not-allowed; opacity: .48; transform: none; }
button.primary { background: #1f7a4d; border-color: #1f7a4d; color: #fff; }
button.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
button.ghost { background: var(--paper-soft); }
button.full { width: 100%; justify-content: center; }

textarea, input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 14px;
  background: var(--paper-soft);
  color: var(--ink);
  outline: none;
  line-height: 1.35;
}

textarea {
  min-height: 104px;
  resize: vertical;
}

select {
  width: auto;
  min-width: 154px;
  min-height: 42px;
  padding: 9px 12px;
  border-radius: 12px;
  font-weight: 760;
}

textarea:focus, input:focus, select:focus { border-color: #aab8d0; background: #fff; }

.app {
  display: grid;
  grid-template-columns: minmax(360px, 1.08fr) minmax(360px, .96fr) minmax(320px, .78fr);
  gap: 16px;
  height: 100vh;
  padding: 16px;
  overflow: hidden;
}

.app[hidden] { display: none; }

.admin-app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
  height: 100vh;
  padding: 16px;
  overflow: hidden;
}

.admin-app[hidden] { display: none; }

.admin-grid,
.admin-sessions-grid {
  min-width: 0;
  min-height: 0;
  display: grid;
  gap: 16px;
}

.admin-grid {
  grid-template-columns: minmax(280px, .36fr) minmax(0, 1fr);
}

.admin-sessions-grid {
  grid-template-columns: minmax(520px, .8fr) minmax(420px, .55fr);
}

.admin-grid[hidden],
.admin-sessions-grid[hidden] {
  display: none;
}

.column {
  min-width: 0;
  min-height: 0;
  display: grid;
  gap: 14px;
}

.dialog-col { grid-template-rows: auto minmax(0, 1fr) auto; }
.reply-col { grid-template-rows: auto minmax(0, 1fr); }
.assist-col { grid-template-rows: auto minmax(260px, .9fr) minmax(260px, .9fr); }

.personal-app {
  grid-template-columns: minmax(360px, 1.08fr) minmax(360px, .96fr) minmax(320px, .78fr);
}

.personal-transcript-col {
  grid-template-rows: auto minmax(0, 1fr);
}

.personal-prompter-col,
.personal-help-col {
  grid-template-rows: auto minmax(0, 1fr);
}

.personal-pane-header .eyebrow,
.personal-question-block .eyebrow {
  margin: 0 0 5px;
}

.personal-pane-title {
  font-size: 20px;
}

.personal-answer-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 16px;
  overflow: hidden;
}

.personal-question-block {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.personal-question {
  color: var(--ink);
  font-size: 15px;
  font-weight: 760;
  line-height: 1.45;
}

.personal-answer-text {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding-right: 5px;
  color: var(--ink);
  font-size: clamp(20px, 1.55vw, 27px);
  font-weight: 650;
  line-height: 1.52;
  white-space: pre-wrap;
  scrollbar-gutter: stable;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.personal-help-card .personal-answer-text {
  font-size: clamp(17px, 1.18vw, 21px);
}

.personal-answer-text.waiting {
  color: var(--muted);
  font-weight: 600;
}

.personal-answer-meta,
.personal-answer-footer {
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
}

.personal-answer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.personal-transcript-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  overflow: hidden;
}

.personal-transcript-head,
.personal-transcript-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.personal-transcript-head {
  justify-content: space-between;
}

.personal-transcript-head .eyebrow {
  margin: 0;
}

.personal-readonly-badge {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--muted);
  background: var(--paper-soft);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.personal-transcript-list {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding-right: 3px;
  scrollbar-gutter: stable;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.personal-transcript-item {
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 12px 13px;
  background: var(--paper-soft);
}

.personal-transcript-item.system {
  border-color: #cbdaf8;
  background: #f4f7ff;
}

.personal-transcript-item.microphone {
  border-color: #c9ead8;
  background: #f1faf5;
}

.personal-transcript-item.partial {
  opacity: .68;
}

.personal-transcript-item-head {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.personal-transcript-item-head time {
  margin-left: auto;
}

.personal-source-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
}

.personal-transcript-item.microphone .personal-source-dot {
  background: var(--green);
}

.personal-source-label {
  color: var(--ink);
  font-weight: 850;
}

.personal-transcript-text {
  font-size: 15px;
  line-height: 1.48;
  white-space: pre-wrap;
}

.card {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.92);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.header-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 18px;
}

.audio-card {
  display: grid;
  gap: 12px;
  padding: 17px 18px;
}

.audio-row {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.audio-row + .audio-row {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.title {
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
  font-weight: 850;
  letter-spacing: -.01em;
}

.sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.section {
  padding: 18px;
  overflow: auto;
}

.section.personal-transcript-card {
  overflow: hidden;
}

.admin-list-card {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
}

.admin-mode-tabs {
  display: flex;
  gap: 8px;
}

.admin-mode-tabs button {
  min-width: 0;
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--paper-soft);
}

.admin-mode-tabs button.active {
  border-color: #bfd1f8;
  background: var(--blue-soft);
  color: var(--blue);
}

.admin-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.admin-tabs button {
  min-width: 0;
  border-radius: 12px;
  background: var(--paper-soft);
}

.admin-tabs button.active {
  border-color: #bfd1f8;
  background: var(--blue-soft);
  color: var(--blue);
}

.admin-create-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.admin-create-row button {
  min-width: 0;
  padding-inline: 9px;
}

.admin-prompt-list {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
  overflow: auto;
  padding-right: 2px;
}

.admin-prompt-item {
  width: 100%;
  min-height: 78px;
  display: grid;
  gap: 5px;
  justify-items: start;
  align-content: center;
  border-radius: 14px;
  padding: 12px;
  text-align: left;
  background: var(--paper-soft);
  font-weight: 700;
}

.admin-prompt-item.active {
  border-color: #bfd1f8;
  background: #f4f7ff;
}

.admin-prompt-title {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-size: 15px;
  font-weight: 850;
}

.admin-prompt-key,
.admin-prompt-meta {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.admin-editor-card {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(280px, 1fr) auto auto;
  gap: 13px;
}

.admin-editor-head,
.admin-editor-actions,
.admin-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-editor-head .eyebrow {
  margin: 0;
}

.admin-field {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.admin-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.admin-meta-row .admin-field {
  flex: 1 1 auto;
}

.admin-updated {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
  white-space: nowrap;
}

.admin-content-field {
  min-height: 0;
}

#adminPromptContent {
  min-height: 280px;
  height: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.46;
}

.admin-editor-actions {
  justify-content: flex-end;
}

.admin-note {
  min-height: 20px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.admin-sessions-card,
.admin-session-detail-card {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 13px;
}

.admin-session-detail-card {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.admin-session-table {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper-soft);
}

.admin-session-row {
  width: 100%;
  min-width: 720px;
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) 100px 128px 86px 78px 92px;
  gap: 12px;
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 12px 14px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.admin-session-row:last-child {
  border-bottom: 0;
}

.admin-session-row:hover,
.admin-session-row.active {
  background: #f4f7ff;
}

.admin-session-cell {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 760;
}

.admin-session-cell.primary {
  display: grid;
  gap: 3px;
}

.admin-session-email {
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
  font-weight: 850;
}

.admin-session-id {
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.admin-session-head {
  color: var(--muted);
  background: #fff;
  cursor: default;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.admin-session-title {
  margin-top: 5px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 850;
}

.admin-detail-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.admin-detail-tabs button {
  min-width: 0;
  border-radius: 12px;
  background: var(--paper-soft);
}

.admin-detail-tabs button.active {
  border-color: #bfd1f8;
  background: var(--blue-soft);
  color: var(--blue);
}

.admin-session-detail {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 2px;
}

.admin-event-item,
.admin-transcript-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
  background: var(--paper-soft);
}

.admin-event-item pre {
  margin: 8px 0 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: #495163;
  font-size: 12px;
  line-height: 1.45;
}

.admin-detail-meta {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 12px;
  color: #8a92a4;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.dialog {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100%;
  padding-bottom: 4px;
}

.empty {
  color: var(--muted);
  line-height: 1.45;
  padding: 4px 0;
}

.bubble {
  width: fit-content;
  max-width: min(82%, 560px);
  border: 1px solid transparent;
  border-radius: 19px;
  padding: 12px 14px;
  line-height: 1.34;
  font-size: 16px;
  word-break: break-word;
}

.bubble .role {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.bubble .meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.bubble .speaker {
  color: var(--ink);
  font-weight: 850;
}

.bubble.client {
  align-self: flex-start;
  background: var(--green-soft);
  border-color: #c8ecd8;
}

.bubble.seller {
  align-self: flex-end;
  background: var(--blue-soft);
  border-color: #c9dafb;
}

.bubble.partial {
  align-self: flex-start;
  background: var(--yellow-soft);
  border-color: #f1d98a;
}

.bubble.partial.seller {
  align-self: flex-end;
}

.bubble.speaker {
  align-self: flex-start;
  background: var(--paper-soft);
  border-color: var(--line-strong);
}

.capture-row, .action-row {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.switch-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
  user-select: none;
}

.switch-label input {
  width: 17px;
  height: 17px;
  accent-color: var(--green);
}

.audio-debug-panel {
  display: grid;
  gap: 10px;
  padding: 10px 0 4px;
  border-top: 1px solid var(--line);
}

.audio-debug-panel[hidden] {
  display: none;
}

.audio-debug-metrics {
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
  line-height: 1.35;
  white-space: pre-wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--paper-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.status-pill.on { color: var(--green); background: var(--green-soft); border-color: #c8ecd8; }
.status-pill.warn { color: var(--yellow); background: var(--yellow-soft); border-color: #f1d98a; }
.status-pill.err { color: var(--red); background: var(--red-soft); border-color: #ffd0d0; }

.reply-main {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.reply-auto-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.reply-panel-title {
  padding: 18px 18px 0;
  margin: 0;
}

.reply-text {
  align-self: stretch;
  display: block;
  width: 100%;
  min-height: 0;
  padding: clamp(18px, 2.3vw, 28px);
  font-size: clamp(19px, 1.45vw, 26px);
  line-height: 1.24;
  font-weight: 720;
  letter-spacing: 0;
  word-break: break-word;
  cursor: pointer;
  overflow: auto;
}

.reply-text .rich-text {
  min-height: 100%;
  align-content: center;
  gap: 10px;
}

.reply-text .rich-text p {
  margin: 0;
}

.reply-text .rich-text ul,
.reply-text .rich-text ol {
  margin: 0;
  padding-left: 1.25em;
}

.reply-text .rich-text li + li {
  margin-top: 6px;
}

.reply-text.muted {
  color: #9aa3b5;
  font-weight: 650;
}

.reply-manual-panel {
  min-height: 0;
  display: grid;
  gap: 12px;
  padding: 16px 18px;
  border-top: 1px solid var(--line);
  background: var(--paper-soft);
}

.manual-reply-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, .42fr);
  align-items: center;
  gap: 12px;
}

.manual-reply-head .eyebrow {
  margin: 0 0 5px;
}

.manual-reply-meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.reply-immediate-text {
  min-height: 118px;
  max-height: 210px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.82);
  padding: 16px 18px;
  color: var(--ink);
  font-size: clamp(16px, 1.05vw, 19px);
  line-height: 1.32;
  font-weight: 720;
  cursor: pointer;
}

.reply-immediate-text .rich-text {
  gap: 8px;
}

.reply-immediate-text .rich-text p {
  margin: 0;
}

.reply-immediate-text .rich-text ul,
.reply-immediate-text .rich-text ol {
  margin: 0;
  padding-left: 1.25em;
}

.reply-immediate-text .rich-text li + li {
  margin-top: 5px;
}

.reply-immediate-text.muted {
  color: #9aa3b5;
  font-weight: 650;
}

.manual-status {
  min-width: 0;
}

.reply-generate {
  width: 100%;
  min-height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  border-color: #1f7a4d;
  background: #1f7a4d;
  color: #fff;
  border-radius: 16px;
  font-size: clamp(18px, 1.5vw, 24px);
  font-weight: 850;
}

.reply-generate:hover {
  border-color: #17613c;
  background: #17613c;
}

.reply-generate:disabled {
  opacity: 1;
  border-color: #7fc8a1;
  background: #2f9a66;
  color: #eefbf3;
}

.button-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 3px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 999px;
  animation: spin .8s linear infinite;
}

.reply-generate.loading .button-spinner {
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.pipeline-panel {
  border-top: 1px solid var(--line);
  background: #fbfcff;
  padding: 12px 18px;
}

.pipeline-empty {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.pipeline-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-bottom: 9px;
}

.pipeline-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.manual-status .pipeline-grid {
  grid-template-columns: 1fr;
}

.pipeline-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  padding: 10px 11px;
}

.pipeline-card.wait { border-color: #f1d98a; background: var(--yellow-soft); }
.pipeline-card.ok { border-color: #c8ecd8; background: var(--green-soft); }
.pipeline-card.skip { border-color: #d5dbe8; background: #f3f5f9; }
.pipeline-card.bad { border-color: #ffd0d0; background: var(--red-soft); }

.pipeline-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.pipeline-primary {
  min-height: 32px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 820;
  line-height: 1.2;
}

.pipeline-detail {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-grid {
  display: grid;
  gap: 10px;
}

.stage-section {
  min-height: 0;
}

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

.metric {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  background: var(--paper-soft);
}

.metric.green { color: var(--green); background: var(--green-soft); border-color: #c8ecd8; }
.metric.yellow { color: var(--yellow); background: var(--yellow-soft); border-color: #f1d98a; }
.metric.red { color: var(--red); background: var(--red-soft); border-color: #ffd0d0; }

.stage-title {
  font-size: 20px;
  font-weight: 850;
  margin-bottom: 6px;
}

.stage-body {
  color: #4c5464;
  line-height: 1.42;
}

.stage-clock {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.chat {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.chat-log {
  flex: 0 0 auto;
  min-height: 120px;
  max-height: 220px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 2px;
}

.student-app {
  grid-template-columns: minmax(320px, .88fr) minmax(420px, 1fr) minmax(340px, .78fr);
  column-gap: 12px;
}

.student-app .assist-col {
  grid-template-rows: auto minmax(0, 1fr);
}

.student-pane {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.student-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100%;
}

.student-assist-section {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 14px;
}

.student-assist-chat,
.student-chat {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.student-chat {
  flex: 1 1 auto;
}

.student-app #studentAssistLog {
  flex: 1 1 auto;
  max-height: none;
}

.student-manual-block {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.student-item {
  border: 1px solid var(--line);
  border-radius: 17px;
  padding: 12px 13px;
  background: var(--paper-soft);
  line-height: 1.38;
  font-size: 16px;
}

.student-item .meta {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.assist-msg {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 13px;
  background: var(--paper-soft);
  line-height: 1.36;
}

.assist-msg.fast {
  border-color: #c8ecd8;
  background: var(--green-soft);
  font-weight: 750;
}

.student-answer-bubble {
  width: fit-content;
  max-width: 92%;
  border: 1px solid var(--line);
  border-radius: 17px;
  padding: 12px 13px;
  background: var(--paper-soft);
  line-height: 1.38;
  font-size: 15px;
  word-break: break-word;
}

.student-answer-bubble.user {
  align-self: flex-end;
  border-color: #cfe0ff;
  background: #eef4ff;
}

.student-answer-bubble.assistant {
  align-self: flex-start;
}

.student-answer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.student-answer-bubble .meta {
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.answer-switch {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  background: #fff;
  color: var(--ink);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .06em;
  line-height: 1.2;
  text-transform: uppercase;
  cursor: pointer;
}

.answer-switch:hover:not(:disabled) {
  border-color: #9bb8ef;
  background: #eef4ff;
}

.answer-switch:disabled {
  cursor: default;
  opacity: .55;
}

.plain-text {
  white-space: pre-wrap;
}

.rich-text {
  display: grid;
  gap: 8px;
}

.rich-text p {
  margin: 0;
}

.rich-text ul,
.rich-text ol {
  margin: 0;
  padding-left: 20px;
}

.rich-text li + li {
  margin-top: 5px;
}

.rich-text code {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 5px;
  background: #eef1f6;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: .92em;
}

.manual-controls {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

#assistQuestion { min-height: 82px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(16px);
  opacity: 0;
  pointer-events: none;
  background: #202633;
  color: #fff;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 14px;
  box-shadow: 0 12px 28px rgba(0,0,0,.16);
  transition: opacity .18s ease, transform .18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%);
}

.auth-panel {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(246,247,251,.78);
  backdrop-filter: blur(16px);
}

.auth-panel[hidden] {
  display: none;
}

body.auth-locked .app,
body.auth-locked .admin-app {
  filter: blur(4px);
  pointer-events: none;
  user-select: none;
}

.auth-card {
  width: min(440px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 24px 70px rgba(28,35,50,.18);
}

.auth-card h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.08;
  letter-spacing: -.02em;
}

.auth-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.42;
}

.auth-error {
  min-height: 20px;
  color: var(--red);
  font-size: 14px;
  font-weight: 750;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  flex-wrap: wrap;
}

.user-chip {
  max-width: 190px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1180px) {
  .app, .admin-app {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }
  .admin-app {
    grid-template-columns: 1fr;
  }
  .admin-sessions-grid {
    grid-template-columns: 1fr;
  }
  .assist-col { grid-column: 1 / -1; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto minmax(300px, auto); }
  .assist-col > header { grid-column: 1 / -1; }
  .column { min-height: 520px; }
  .reply-text { min-height: 280px; }
  .pipeline-grid { grid-template-columns: 1fr; }
  .manual-reply-head { grid-template-columns: 1fr; }
  .personal-app {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: visible;
    align-content: start;
  }
  .personal-transcript-col,
  .personal-prompter-col,
  .personal-help-col { min-height: 520px; }
}

@media (max-width: 760px) {
  .app, .admin-app {
    grid-template-columns: 1fr;
    padding: 10px;
  }
  .admin-grid {
    grid-template-columns: 1fr;
  }
  .admin-sessions-grid {
    grid-template-columns: 1fr;
  }
  .admin-mode-tabs {
    width: 100%;
  }
  .admin-mode-tabs button {
    flex: 1 1 0;
  }
  .assist-col { grid-template-columns: 1fr; }
  .assist-col > header { grid-column: auto; }
  .column { min-height: auto; }
  .header-card, .audio-row { align-items: stretch; flex-direction: column; }
  .header-card button, .audio-row button { width: 100%; }
  .admin-editor-card {
    grid-template-rows: auto;
  }
  .admin-editor-head,
  .admin-meta-row,
  .admin-editor-actions {
    align-items: stretch;
    flex-direction: column;
  }
  .admin-editor-actions button {
    width: 100%;
  }
  .admin-updated {
    white-space: normal;
  }
  .bubble { max-width: 94%; }
  .personal-app {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    padding: 10px;
  }
  .personal-transcript-col {
    align-content: start;
    grid-template-rows: auto auto;
  }
  .personal-prompter-col,
  .personal-help-col {
    min-height: 0;
    grid-template-rows: auto auto;
  }
  .personal-header {
    gap: 10px;
    padding: 14px;
  }
  .personal-header .header-actions {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    width: 100%;
    justify-content: stretch;
    flex-wrap: nowrap;
  }
  .personal-header .user-chip {
    min-width: 0;
    max-width: none;
  }
  .personal-header button {
    width: auto;
    min-height: 34px;
    padding: 6px 11px;
  }
  .personal-transcript-card {
    width: 100%;
    height: clamp(240px, 56dvh, 520px);
    gap: 10px;
    padding: 14px;
  }
  .personal-transcript-head {
    align-items: flex-start;
  }
  .personal-transcript-head .sub {
    max-width: none;
    white-space: normal;
  }
  .personal-transcript-list {
    gap: 8px;
    padding-right: 5px;
  }
  .personal-transcript-item {
    flex: 0 0 auto;
    border-radius: 13px;
    padding: 10px 11px;
  }
  .personal-transcript-item-head {
    margin-bottom: 5px;
  }
  .personal-transcript-text {
    font-size: 14px;
    line-height: 1.4;
  }
  .personal-readonly-badge {
    display: none;
  }
  .personal-pane-header {
    align-items: center;
    flex-direction: row;
  }
  .personal-answer-card {
    height: clamp(280px, 50dvh, 480px);
    padding: 14px;
  }
  .personal-answer-text,
  .personal-help-card .personal-answer-text {
    font-size: 17px;
    line-height: 1.48;
  }
  .personal-answer-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}
