:root {
  --bg: #0a0e14;
  --surface: #141b26;
  --surface-2: #1c2636;
  --border: #2a3648;
  --text: #eef3fb;
  --muted: #8b9cb3;
  --accent: #4d9bff;
  --accent-press: #2f7ae0;
  --examiner: #1a2f4d;
  --learner: #243044;
  --success: #3ecf8e;
  --warn: #f0b429;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

body.mobile-app {
  width: 100%;
  max-width: none;
  margin: 0;
  position: relative;
  min-height: 100%;
  min-height: 100dvh;
}

body.sheet-open {
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* Screens */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
  width: 100%;
  max-width: 100%;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  left: 0;
  right: 0;
  margin: 0;
  transform: translateY(12px);
  min-height: 0;
}

#chat-screen {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-body .thinking {
  flex-shrink: 0;
  margin-top: auto;
}

.screen-active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.screen.dissolving {
  opacity: 0;
  transform: scale(0.98) translateY(-8px);
  transition: opacity 0.38s ease, transform 0.38s ease;
}

#chat-screen.entering {
  animation: chatEnter 0.42s ease forwards;
}

@keyframes chatEnter {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Toast */
.toast {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 12px;
  right: 12px;
  z-index: 100;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.88rem;
  background: rgba(77, 155, 255, 0.2);
  border: 1px solid var(--accent);
  backdrop-filter: blur(12px);
}

.toast.error {
  background: rgba(240, 80, 80, 0.18);
  border-color: #e85d5d;
}

/* Setup */
.setup-header {
  padding: 2.5rem 1.25rem 1rem;
  text-align: center;
}

.brand-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), #6c5ce7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
}

.setup-header h1 {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.subtitle {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
  max-width: 280px;
  margin-inline: auto;
}

.setup-form {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  -webkit-overflow-scrolling: touch;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field span {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

.field .optional {
  font-weight: 400;
  font-style: normal;
  opacity: 0.7;
}

.field select,
.field input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}

.more-options {
  font-size: 0.85rem;
  color: var(--muted);
}

.more-options summary {
  cursor: pointer;
  padding: 0.5rem 0;
  color: var(--accent);
}

.more-options[open] {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.setup-footer {
  padding: 1rem 1.25rem calc(1.25rem + var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: rgba(10, 14, 20, 0.92);
  backdrop-filter: blur(10px);
}

.btn {
  border: none;
  font: inherit;
  cursor: pointer;
  border-radius: 14px;
}

/* Link-styled actions (enable/disable via setLinkAction) */
.action-link {
  display: inline;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  text-align: left;
}

.action-link:hover:not(:disabled):not(.is-disabled) {
  color: #6eb3ff;
}

.action-link:disabled,
.action-link.is-disabled {
  color: var(--muted);
  cursor: not-allowed;
  text-decoration: none;
  opacity: 0.55;
}

.action-link.is-busy {
  cursor: wait;
  opacity: 0.75;
}

.action-link.block {
  display: block;
  width: 100%;
  text-align: center;
  padding: 0.65rem 0;
}

.action-link.small {
  font-size: 0.85rem;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 1.05rem;
  padding: 0.95rem 1.25rem;
}

.btn-primary:active {
  background: var(--accent-press);
}

.btn-block {
  width: 100%;
}

.btn-primary:disabled {
  opacity: 0.5;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.85rem 1.25rem;
  border: 1px solid var(--border);
}

.login-card {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  -webkit-overflow-scrolling: touch;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.learner-id-badge {
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  font-size: 0.78rem;
  color: var(--muted);
  word-break: break-all;
}

/* Chat header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: calc(0.75rem + env(safe-area-inset-top, 0px)) 0.75rem 0.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(20, 27, 38, 0.95);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}

.chat-header-top {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.session-timer {
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-variant-numeric: tabular-nums;
}

.session-timer.is-paused {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}

.session-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.55rem 0.75rem 0;
  width: 100%;
  flex-shrink: 0;
}

.session-controls.hidden {
  display: none;
}

.session-control-btn {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.session-control-btn.hidden {
  display: none;
}

.session-control-accent {
  margin-left: auto;
}

.session-control-primary {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-2));
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  color: var(--accent);
}

.evaluation-switcher {
  width: 100%;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  text-overflow: ellipsis;
}

.setup-evaluation-wrap {
  margin: 0 1rem 0.75rem;
}

.setup-evaluation-wrap .help {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
}

.topic-chip {
  flex: 1;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}

.btn-icon.has-update::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

/* Live dashboard (chat screen) */
.live-dashboard {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(28, 38, 54, 0.98) 0%, rgba(20, 27, 38, 0.92) 100%);
  max-height: min(42vh, 320px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.35s ease;
}

.live-dashboard.live-dashboard-active {
  box-shadow: inset 0 1px 0 rgba(77, 155, 255, 0.2);
}

.live-dashboard-collapsed {
  max-height: none;
}

.live-dashboard-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0.65rem 0;
}

.live-dashboard-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.live-dashboard-toggle {
  border: none;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0.35rem;
}

.live-dashboard-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.live-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.45rem 0.65rem 0.35rem;
}

.live-voice-stats {
  display: flex;
  flex: 1 1 100%;
  gap: 0.45rem;
}

.live-voice-stats.hidden {
  display: none;
}

.live-stat {
  flex: 1;
  min-width: 0;
  padding: 0.4rem 0.55rem;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.live-stat-muted .live-stat-value {
  color: var(--muted);
}

.live-stat-label {
  display: block;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.15rem;
}

.live-stat-value {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.live-stat-pulse {
  animation: liveStatPulse 0.55s ease;
}

@keyframes liveStatPulse {
  0% {
    transform: scale(1);
    border-color: var(--border);
  }
  40% {
    transform: scale(1.03);
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(77, 155, 255, 0.35);
  }
  100% {
    transform: scale(1);
    border-color: var(--border);
  }
}

.live-charts {
  display: flex;
  gap: 0.45rem;
  padding: 0 0.65rem 0.55rem;
  flex: 1;
  min-height: 0;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.live-charts .chart-card-compact {
  flex: 0 0 78%;
  max-width: 280px;
  scroll-snap-align: start;
}

.live-charts .chart-card-compact .chart-canvas-wrap {
  height: 100px;
}

.live-charts .chart-card-compact {
  margin: 0;
  animation: chartReveal 0.45s ease;
}

@keyframes chartReveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.live-chart-wait {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0.35rem 0;
  font-size: 0.8rem;
  text-align: center;
}

/* Examiner thinking */
.thinking {
  flex-shrink: 0;
  padding: 0 0.75rem 0.35rem;
}

.thinking-bubble {
  max-width: 92%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.thinking-bubble p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  font-style: italic;
}

.thinking-dots {
  display: inline-flex;
  gap: 4px;
}

.thinking-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: typing 1s infinite ease-in-out;
}

.thinking-dots span:nth-child(2) {
  animation-delay: 0.15s;
}
.thinking-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

/* Report sheet collapsible section */
.report-details-panel {
  padding: 0 1rem 1rem;
}

.report-details-panel summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
  padding: 0.5rem 0;
  list-style: none;
}

.report-details-panel summary::-webkit-details-marker {
  display: none;
}

.report-details-panel summary::before {
  content: "▾ ";
  color: var(--accent);
}

.report-details-panel:not([open]) summary::before {
  content: "▸ ";
}

/* Messages */
.messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 1rem 0.75rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.bubble {
  max-width: 88%;
  padding: 0.7rem 0.95rem;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.45;
  animation: bubbleIn 0.28s ease;
  overflow: visible;
  word-break: break-word;
  overflow-wrap: anywhere;
}

@keyframes bubbleIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bubble p {
  margin: 0 0 0.65rem;
}

.bubble p:last-child {
  margin-bottom: 0;
}

.bubble pre {
  margin: 0.55rem 0;
  padding: 0.65rem 0.75rem;
  border-radius: 0.55rem;
  background: rgba(15, 23, 42, 0.08);
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.45;
}

.bubble.examiner pre {
  background: rgba(255, 255, 255, 0.14);
}

.bubble pre code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble.examiner.error-bubble {
  border-color: #e85d5d;
  background: rgba(232, 93, 93, 0.08);
}

.bubble-retry-btn {
  display: inline-block;
  margin-top: 0.65rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.bubble-retry-btn:hover {
  background: rgba(77, 155, 255, 0.12);
}

.bubble.examiner {
  align-self: flex-start;
  background: var(--examiner);
  border-bottom-left-radius: 6px;
  border-left: 3px solid var(--accent);
}

.bubble.examiner em {
  font-style: italic;
  font-weight: 600;
}

.bubble.examiner strong {
  font-weight: 700;
}

.bubble.examiner strong em,
.bubble.examiner em strong {
  font-style: italic;
  font-weight: 700;
}

.bubble.learner {
  align-self: flex-end;
  background: var(--learner);
  border-bottom-right-radius: 6px;
}

.bubble.voice-transcript-muted {
  opacity: 0.82;
  font-size: 0.92em;
}

.bubble.voice-transcript-muted p {
  color: var(--muted);
  font-style: italic;
}

.bubble.voice-transcript-muted strong {
  color: var(--text);
  font-weight: 700;
}

.bubble.voice-transcript-muted em {
  font-style: italic;
  font-weight: 600;
}

.bubble.voice-audio-playing.voice-transcript-muted {
  border-left: 3px solid var(--accent);
  padding-left: 0.65rem;
}

.voice-bubble-actions {
  margin-top: 0.45rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.voice-read-aloud-btn {
  font-size: 0.78rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--text);
  cursor: pointer;
}

.voice-read-aloud-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
}

.voice-read-aloud-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.voice-speak-again-btn {
  font-size: 0.78rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}

.voice-speak-again-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.bubble.learner .voice-speak-again-btn,
.bubble.learner .voice-read-aloud-btn {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  color: var(--text);
  background: color-mix(in srgb, #fff 55%, transparent);
}

.bubble.voice-pending-review {
  border: 1px dashed var(--accent);
}

.bubble.voice-pending-review .voice-transcript-text {
  color: var(--text);
  font-style: normal;
  font-size: 1rem;
  font-weight: 650;
  margin: 0 0 0.35rem;
  line-height: 1.45;
  opacity: 1;
}

.bubble.learner.voice-pending-review .voice-transcript-text {
  color: var(--text);
}

.voice-send-transcript-btn {
  font-size: 0.78rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.voice-send-transcript-btn:hover:not(:disabled) {
  filter: brightness(1.05);
}

.bubble.learner .voice-send-transcript-btn {
  background: #fff;
  color: var(--accent);
}

.bubble.voice-capture-issue {
  border: 1px dashed var(--accent);
}

.bubble.voice-capture-issue p {
  color: var(--text);
  font-style: normal;
  margin: 0;
}

.voice-transcript-hint {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-style: normal;
}

.voice-repeat-btn {
  font-size: 0.78rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.voice-repeat-btn:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--accent);
}

.voice-repeat-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.bubble.learner .voice-repeat-btn {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--text);
  background: color-mix(in srgb, #fff 45%, transparent);
}

.bubble.learner .voice-repeat-btn:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, #fff);
}

.voice-controls-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.35rem 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.voice-persona-field {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  flex: 1 1 12rem;
}

.voice-persona-label {
  white-space: nowrap;
  font-weight: 500;
  color: var(--text);
}

.voice-persona-select {
  min-width: 10rem;
  max-width: 100%;
  flex: 1 1 auto;
  font: inherit;
  color: var(--text);
  background: var(--surface, #fff);
  border: 1px solid color-mix(in srgb, var(--muted) 35%, transparent);
  border-radius: 0.45rem;
  padding: 0.28rem 0.45rem;
}

.voice-persona-preview.hidden {
  display: none;
}

.voice-persona-preview {
  font-size: inherit;
}

.persona-setup-gate {
  display: flex;
  justify-content: center;
  padding: 1.25rem 0.75rem 0.5rem;
}

.persona-setup-gate.hidden {
  display: none;
}

.persona-setup-card {
  width: min(100%, 28rem);
  padding: 1rem 1.1rem 1.15rem;
  border-radius: 0.85rem;
  border: 1px solid color-mix(in srgb, var(--muted) 28%, transparent);
  background: color-mix(in srgb, var(--surface, #fff) 92%, transparent);
}

.persona-setup-title {
  margin: 0 0 0.45rem;
  font-size: 1.05rem;
}

.persona-setup-help {
  margin: 0 0 0.9rem;
  font-size: 0.9rem;
  line-height: 1.45;
}

.persona-setup-field {
  display: flex;
  width: 100%;
  margin-bottom: 0.75rem;
}

.persona-setup-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}

#voice-persona-confirm {
  margin-left: auto;
}

.voice-controls-wrap.hidden {
  display: none !important;
}

.realtime-conversation-wrap {
  margin: 0;
  padding: 0.85rem 0.9rem 0.75rem;
  border-radius: 1rem;
  border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--border));
  background: linear-gradient(
    165deg,
    color-mix(in srgb, var(--accent) 16%, var(--surface)) 0%,
    var(--surface) 58%
  );
  overflow: hidden;
}

.realtime-wave-stage {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 5.75rem;
  margin: 0 0 0.55rem;
  padding: 0.35rem 0.25rem 0.15rem;
}

.realtime-wave-glow {
  position: absolute;
  inset: 0.15rem 8% 0;
  border-radius: 999px;
  background: radial-gradient(
    ellipse at center bottom,
    color-mix(in srgb, var(--accent) 38%, transparent) 0%,
    transparent 72%
  );
  opacity: 0.85;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.realtime-wave-bars {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.34rem;
  width: 100%;
  max-width: 22rem;
  height: 4.75rem;
  min-height: 4.75rem;
  pointer-events: none;
}

.realtime-wave-bars .voice-wave-bar {
  flex: 1 1 0;
  max-width: 0.55rem;
  width: 0.55rem;
  min-height: 0.55rem;
  height: 20%;
  box-shadow: 0 0 16px color-mix(in srgb, var(--accent) 55%, transparent);
}

.realtime-conversation-wrap.realtime-listening .realtime-wave-glow {
  opacity: 1;
  animation: realtimeGlowPulse 1.6s ease-in-out infinite;
}

.realtime-conversation-wrap.realtime-thinking .realtime-wave-glow {
  opacity: 0.55;
  animation: none;
}

.realtime-conversation-wrap.realtime-paused .realtime-wave-bars .voice-wave-bar {
  opacity: 0.45;
}

@keyframes realtimeGlowPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.75;
  }
  50% {
    transform: scale(1.04);
    opacity: 1;
  }
}

.realtime-status-row {
  text-align: center;
}

.realtime-conversation-status {
  margin: 0;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.01em;
}

.realtime-conversation-hint {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.realtime-conversation-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.7rem;
}

.realtime-conversation-actions .session-control-btn {
  font-size: 0.82rem;
  padding: 0.4rem 0.85rem;
}

.realtime-conversation-wrap.hidden {
  display: none;
}

#chat-screen.realtime-mode .live-dashboard {
  max-height: min(46vh, 360px);
}

#chat-screen.realtime-mode .live-charts .chart-card-compact .chart-canvas-wrap {
  height: 118px;
}

#chat-screen.realtime-mode .live-charts .chart-card-compact {
  flex: 0 0 84%;
  max-width: 300px;
}

.composer-form.realtime-active .composer-input-row {
  display: none;
}

.composer-form.realtime-active .realtime-conversation-wrap {
  width: 100%;
}

.voice-slow-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  user-select: none;
}

.voice-slow-toggle input {
  accent-color: var(--accent);
}

.bubble-attachment {
  margin-top: 0.45rem;
  font-size: 0.82rem;
  opacity: 0.92;
}

.bubble-attachment a {
  color: inherit;
  text-decoration: underline;
}

/* Typing indicator */
.typing {
  display: flex;
  gap: 5px;
  padding: 0 1rem 0.5rem;
  align-self: flex-start;
}

.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing 1s infinite ease-in-out;
}

.typing span:nth-child(2) {
  animation-delay: 0.15s;
}
.typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: scale(0.85);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Composer */
.composer {
  flex-shrink: 0;
  width: 100%;
  padding: 0.5rem 0.75rem calc(0.65rem + var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: rgba(20, 27, 38, 0.98);
  backdrop-filter: blur(12px);
}

#chat-screen .chat-header,
#chat-screen .composer,
#chat-screen .session-controls,
#chat-screen .thinking,
#chat-screen .live-dashboard {
  flex-shrink: 0;
  width: 100%;
  max-width: 100%;
}

.composer-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.voice-playback-engine {
  position: fixed;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.voice-playback-waves {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.22rem;
  height: 2.35rem;
  margin: 0.35rem 0 0.1rem;
  pointer-events: none;
}

.voice-playback-waves.hidden {
  display: none;
}

.bubble.examiner .voice-playback-waves .voice-wave-bar {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--examiner) 70%, #fff) 0%,
    var(--examiner) 100%
  );
  box-shadow: 0 0 10px color-mix(in srgb, var(--examiner) 40%, transparent);
}

.bubble.learner .voice-playback-waves .voice-wave-bar {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--learner) 70%, #fff) 0%,
    var(--learner) 100%
  );
  box-shadow: 0 0 10px color-mix(in srgb, var(--learner) 40%, transparent);
}

.composer-input-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  width: 100%;
}

.voice-speak-overlay {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-end;
  gap: 0.55rem;
  min-height: 5.5rem;
  padding: 0.75rem 0.85rem 0.65rem;
  border-radius: 1rem;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  background: linear-gradient(
    165deg,
    color-mix(in srgb, var(--accent) 14%, var(--surface)) 0%,
    var(--surface) 55%
  );
  overflow: hidden;
}

.voice-speak-overlay.hidden {
  display: none;
}

.voice-speak-draft {
  position: relative;
  z-index: 1;
  margin: 0;
  min-height: 2.4rem;
  max-height: 6.5rem;
  overflow-y: auto;
  font-size: 1rem;
  line-height: 1.45;
  font-weight: 600;
  color: var(--text);
  opacity: 0.92;
  word-break: break-word;
}

.voice-speak-draft:empty::before {
  content: "Start speaking — your words will appear here.";
  color: var(--muted);
  font-weight: 500;
  font-style: italic;
}

.voice-wave-bars {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.28rem;
  height: 3.25rem;
  min-height: 3.25rem;
  margin: 0.15rem 0;
  pointer-events: none;
}

.voice-wave-bar {
  flex: 0 0 0.38rem;
  width: 0.38rem;
  min-height: 0.45rem;
  height: 22%;
  border-radius: 999px;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--accent) 85%, #fff) 0%,
    var(--accent) 100%
  );
  transform-origin: center bottom;
  transition: height 55ms linear;
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 45%, transparent);
}

.voice-speak-hint {
  position: relative;
  z-index: 2;
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}

.composer-form.voice-speak-active .composer-input-row textarea {
  opacity: 0.35;
}

.composer-form.voice-speak-active .voice-speak-overlay {
  animation: voiceOverlayIn 0.22s ease;
}

@keyframes voiceOverlayIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.btn-voice {
  flex: 0 0 auto;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-width: 4.25rem;
  min-height: 3.25rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  padding: 0.35rem 0.5rem;
}

.btn-voice.hidden {
  display: none;
}

.btn-voice.recording {
  border-color: #e25555;
  background: rgba(226, 85, 85, 0.12);
  color: #ffb4b4;
}

.btn-voice:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-voice-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.btn-voice-label {
  font-size: 0.62rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.composer-upload-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.btn-attach {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-attach:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.response-file-chip {
  font-size: 0.82rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  max-width: min(100%, 240px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-form textarea {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  padding: 0.65rem 0.9rem;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  line-height: 1.35;
}

.btn-send {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Report sheet */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  animation: fadeIn 0.25s ease;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  max-height: 85vh;
  max-height: 85dvh;
  margin: 0;
  width: 100%;
  max-width: 100%;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  display: flex;
  flex-direction: column;
  animation: sheetUp 0.32s ease;
  padding-bottom: var(--safe-bottom);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes sheetUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 0.65rem auto 0;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem 0.75rem;
}

.sheet-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.sheet-header-actions {
  gap: 0.5rem;
}

.sheet-header-btns {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-small {
  font-size: 0.72rem;
  padding: 0.35rem 0.55rem;
  white-space: nowrap;
}

.sheet-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.5rem;
}

.insights-cards {
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.insight-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
}

.insight-card h3 {
  margin: 0 0 0.2rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.insight-card p {
  margin: 0;
  font-size: 0.92rem;
}

.placeholder {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0.5rem 0;
}

.raw-toggle {
  padding: 0.5rem 1rem 1rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.insights-raw {
  margin: 0.5rem 0 0;
  padding: 0.5rem;
  background: var(--bg);
  border-radius: 8px;
  font-size: 0.65rem;
  max-height: 100px;
  overflow: auto;
}

.report-charts {
  padding: 0 1rem 1rem;
  display: grid;
  gap: 0.75rem;
}

.report-recommendations {
  padding: 0 1rem 1.25rem;
}

.rec-header h3 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

.rec-sub {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.rec-charts-grid {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

@media (min-width: 520px) {
  .rec-charts-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.rec-chart-wrap {
  position: relative;
  height: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.5rem;
}

.rec-group {
  margin-bottom: 1rem;
}

.rec-group-title {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.rec-cards {
  display: grid;
  gap: 0.65rem;
}

.rec-card {
  display: block;
  position: relative;
  padding: 0.75rem 0.85rem 0.65rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  overflow: hidden;
}

.rec-card:hover {
  border-color: var(--accent);
}

.rec-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.rec-type {
  font-size: 1rem;
}

.rec-score {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
}

.rec-title {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  line-height: 1.3;
}

.rec-desc {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

.rec-card-foot {
  display: flex;
  gap: 0.5rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.rec-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), transparent);
  max-width: 100%;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem;
}

.chart-canvas-wrap {
  position: relative;
  height: 220px;
  width: 100%;
}

.invite-curated-summary {
  margin: 0 1rem 1rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.invite-curated-summary .curated-label {
  margin: 0 0 0.5rem;
  font-weight: 600;
}

.invite-curated-summary .curated-details {
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

.invite-page .centered {
  text-align: center;
  padding: 1rem;
}

.chart-card h4 {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chart-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-bar {
  fill: var(--accent);
}

.chart-line {
  fill: none;
  stroke: var(--success);
  stroke-width: 2.5;
}

.chart-dot {
  fill: var(--success);
}

.chart-slice-strong {
  fill: var(--success);
}

.chart-slice-weak {
  fill: var(--warn);
}

.chart-slice-neutral {
  fill: var(--accent);
}

.chart-pie-wrap {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.chart-pie {
  width: 120px;
  flex-shrink: 0;
}

.chart-legend {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
}

.chart-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 0.35rem;
}

.invite-page .help {
  padding: 0 1rem 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}
