*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-2: #252836;
  --border: #2e3242;
  --text: #e4e4e7;
  --text-muted: #9ca3af;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --user-bubble: #6366f1;
  --tutor-bubble: #1e2030;
  --error: #ef4444;
  --radius: 12px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.screen { height: 100%; }
.hidden { display: none !important; }

/* ── Auth ── */

.auth-container {
  max-width: 380px;
  margin: 0 auto;
  padding: 60px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.auth-logo {
  margin-bottom: 12px;
}

.auth-container h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-muted);
  margin-bottom: 32px;
  font-size: 0.95rem;
}

#auth-tabs {
  display: flex;
  gap: 0;
  width: 100%;
  margin-bottom: 24px;
  border-radius: var(--radius);
  background: var(--surface);
  padding: 4px;
}

.tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
}

.tab.active {
  background: var(--surface-2);
  color: var(--text);
}

.auth-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-form input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.auth-form input:focus {
  border-color: var(--accent);
}

.auth-form input::placeholder {
  color: var(--text-muted);
}

.auth-form button {
  padding: 12px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 4px;
}

.auth-form button:hover { background: var(--accent-hover); }
.auth-form button:disabled { opacity: 0.6; cursor: not-allowed; }

.error {
  color: var(--error);
  font-size: 0.85rem;
  text-align: center;
  margin-top: 12px;
}

/* ── Verify ── */

.verify-info {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.verify-info strong {
  color: var(--text);
}

.verify-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 4px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-btn:hover {
  color: var(--accent-hover);
}

.link-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Profile Modal ── */

.profile-modal-content {
  max-width: 380px;
  padding: 24px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

#profile-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#profile-form label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: -8px;
}

#profile-form input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

#profile-form input:focus {
  border-color: var(--accent);
}

#profile-form input::placeholder {
  color: var(--text-muted);
}

#profile-form button[type="submit"] {
  padding: 12px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 4px;
}

#profile-form button[type="submit"]:hover { background: var(--accent-hover); }
#profile-form button[type="submit"]:disabled { opacity: 0.6; cursor: not-allowed; }

.profile-msg-success {
  color: #22c55e;
  font-size: 0.85rem;
  text-align: center;
  margin: 0;
}

/* ── Dashboard ── */

#dashboard-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.dash-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.dash-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.dash-search {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
}

.dash-search:focus { border-color: var(--accent); }
.dash-search::placeholder { color: var(--text-muted); }

.dash-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.dash-table-wrap {
  overflow-x: auto;
}

.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.dash-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.dash-table th.sorted-asc::after { content: ' \25B4'; }
.dash-table th.sorted-desc::after { content: ' \25BE'; }

.dash-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.dash-row {
  cursor: pointer;
  transition: background 0.15s;
}

.dash-row:hover {
  background: var(--surface-2);
}

.dash-name-cell {
  display: flex;
  flex-direction: column;
}

.dash-email {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.dash-warn {
  color: var(--error);
}

.dash-muted {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.dash-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 12px;
}

.online-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}

.online-dot.online {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34,197,94,0.5);
}

.dash-grade {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dash-grade.HD { background: rgba(168,85,247,0.15); color: #a855f7; }
.dash-grade.D { background: rgba(59,130,246,0.15); color: #3b82f6; }
.dash-grade.C { background: rgba(34,197,94,0.15); color: #22c55e; }
.dash-grade.P { background: rgba(249,115,22,0.15); color: #f97316; }
.dash-grade.F { background: rgba(239,68,68,0.15); color: #ef4444; }

/* ── Dashboard Detail ── */

.dash-back-btn {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border: none;
  color: var(--accent);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 10px 0;
  margin-bottom: 8px;
  display: block;
  width: 100%;
  text-align: left;
}

.dash-back-btn:hover { text-decoration: underline; }

.dash-profile-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

.dash-profile-card h2 {
  font-size: 1.2rem;
  margin-bottom: 4px;
}

.dash-profile-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.dash-section-title {
  font-size: 0.9rem;
  font-weight: 700;
  margin: 20px 0 10px;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── Feedback Cards ── */

.feedback-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.feedback-card-header {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.feedback-status {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: auto;
}

.feedback-status.new { background: rgba(99,102,241,0.15); color: var(--accent); }
.feedback-status.reviewed { background: rgba(34,197,94,0.15); color: #22c55e; }
.feedback-status.resolved { background: rgba(156,163,175,0.1); color: #6b7280; }

.feedback-card-body {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text);
}

.dash-feedback-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--error);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0 4px;
  margin-left: 4px;
}

/* ── Wellbeing Alerts ── */

.wellbeing-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.wellbeing-card.tier1 {
  border-left: 4px solid #ef4444;
}

.wellbeing-card.tier2 {
  border-left: 4px solid #eab308;
}

.wellbeing-card-header {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.wellbeing-student {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.wellbeing-student-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.wellbeing-student-link:hover {
  color: var(--accent-hover, var(--accent));
}

.wellbeing-student-school {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.wellbeing-student-school::before {
  content: '·';
  margin-right: 8px;
}

.wellbeing-signal {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  text-transform: capitalize;
}

.wellbeing-quote {
  font-style: italic;
  color: var(--text);
  font-size: 0.85rem;
  padding: 8px 12px;
  margin: 6px 0 10px;
  border-left: 3px solid var(--text-muted);
  background: var(--bg);
  border-radius: 0 6px 6px 0;
}

/* ── Prompt proposals ────────────────────────────────────────────── */

.proposal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
}

.proposal-card.status-pending    { border-left: 4px solid #6366f1; }
.proposal-card.status-approved   { border-left: 4px solid #4ade80; }
.proposal-card.status-applied    { border-left: 4px solid #22c55e; }
.proposal-card.status-rejected   { border-left: 4px solid #6b7280; opacity: 0.75; }
.proposal-card.status-reverted   { border-left: 4px solid #ef4444; opacity: 0.75; }

.proposal-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.proposal-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.proposal-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.proposal-rationale {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 10px;
}

.proposal-metric {
  font-size: 0.8rem;
  color: var(--accent);
  margin-bottom: 10px;
}

.proposal-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 12px;
  margin-bottom: 6px;
}

.proposal-patch {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
  max-height: 260px;
  overflow-y: auto;
}

.proposal-quote {
  font-style: italic;
  color: var(--text);
  font-size: 0.82rem;
  padding: 6px 10px;
  margin: 4px 0;
  border-left: 3px solid var(--text-muted);
  background: var(--bg);
  border-radius: 0 4px 4px 0;
}

.proposal-kill {
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.proposal-segment-warn {
  margin-top: 8px;
  padding: 6px 10px;
  background: #3b3620;
  color: #fbbf24;
  font-size: 0.75rem;
  border-radius: 4px;
}

.proposal-audit {
  margin-top: 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
}

.proposal-verification {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.proposal-verification.verdict-agree {
  background: rgba(74, 222, 128, 0.08);
  border-color: #4ade80;
}

.proposal-verification.verdict-refine {
  background: rgba(251, 191, 36, 0.08);
  border-color: #fbbf24;
}

.proposal-verification.verdict-reject {
  background: rgba(239, 68, 68, 0.08);
  border-color: #ef4444;
}

.proposal-verification.verdict-in_progress {
  background: var(--bg);
  border-color: var(--border);
  border-style: dashed;
}

.proposal-verification-header {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.verdict-agree    .proposal-verification-header { color: #4ade80; }
.verdict-refine   .proposal-verification-header { color: #fbbf24; }
.verdict-reject   .proposal-verification-header { color: #ef4444; }
.verdict-in_progress .proposal-verification-header { color: var(--text-muted); }

.proposal-verification-rationale {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 8px;
}

.feedback-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.feedback-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.feedback-toolbar-actions .btn-primary {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.feedback-toolbar-actions .btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.feedback-context-link {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 8px 12px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: 6px;
  color: var(--accent);
  font: inherit;
  font-size: 0.8rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.feedback-context-link:hover {
  border-color: var(--accent);
  background: var(--surface-2);
}

.feedback-context-content {
  max-width: 760px;
  width: 92vw;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
}

.feedback-context-body {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 60vh;
}

.feedback-context-msg {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.5;
}

.feedback-context-msg.user {
  background: rgba(99, 102, 241, 0.1);
  border-left: 3px solid #6366f1;
}

.feedback-context-msg.assistant {
  background: var(--surface);
  border-left: 3px solid var(--text-muted);
}

.feedback-context-msg.before-feedback {
  opacity: 1;
}

.feedback-context-msg-meta {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
  letter-spacing: 0.04em;
}

.feedback-context-msg-text {
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.feedback-context-marker {
  margin-top: 6px;
  padding: 10px 12px;
  background: rgba(245, 166, 35, 0.12);
  border: 1px dashed #f5a623;
  border-radius: 6px;
  font-size: 0.8rem;
  color: #f5a623;
  font-style: italic;
}

.delete-student-content {
  max-width: 500px;
  width: 92vw;
}

.delete-student-content .modal-footer {
  margin-top: 16px;
}

.proposal-patch-editor {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.45;
  resize: vertical;
}

.proposal-patch-editor:focus {
  outline: none;
  border-color: var(--accent);
}

.proposal-actions {
  margin-top: 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.proposal-actions button {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover, var(--accent));
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

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

.btn-danger {
  background: #3b1a1a;
  color: #ef4444;
  border: 1px solid #7f1d1d;
}

.btn-danger:hover:not(:disabled) {
  background: #521e1e;
}

.proposal-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Settings card */

.proposals-settings {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}

.proposals-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}

.proposals-settings-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.proposals-settings-grid select,
.proposals-settings-grid input[type='number'] {
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
}

.proposals-settings-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.proposals-settings-actions .btn-primary {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.proposals-usage {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* Preview modal */

.proposal-preview-content {
  max-width: 800px;
  width: 92vw;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
}

.proposal-preview-body {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  max-height: 60vh;
  margin: 12px 0;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.modal-footer button {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}

.wellbeing-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* ── Audit Log ── */

.audit-entry {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
}

.audit-entry:last-child { border-bottom: none; }

/* ── Admin Note Form ── */

.admin-note-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.admin-note-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  resize: none;
  outline: none;
}

.admin-note-input:focus { border-color: var(--accent); }

.admin-note-btn {
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.admin-note-btn:hover { background: var(--accent-hover); }
.admin-note-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Chat History Viewer ── */

.dash-chat-view {
  max-height: 600px;
  overflow-y: auto;
  padding: 8px 0;
}

.dash-chat-session {
  margin-bottom: 20px;
}

.dash-chat-session-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

/* Clickable short session ID — 8-char UUID prefix, copy full UUID on click */
.dash-chat-session-slug {
  display: inline-block;
  font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--surface, #1a1d27);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
}

.dash-chat-session-slug:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.dash-chat-session-slug.copied {
  background: #059669;
  color: #fff;
  border-color: #059669;
}

/* Per-session cost summary — subtle pill right of the session header text */
.dash-chat-session-cost {
  margin-left: auto;
  font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--surface, #1a1d27);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  cursor: help;
}

.dash-chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  line-height: 1.6;
  margin-bottom: 6px;
  word-wrap: break-word;
}

.dash-chat-msg.user {
  margin-left: auto;
  background: var(--user-bubble);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.dash-chat-msg.assistant {
  background: var(--tutor-bubble);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.dash-chat-img {
  max-width: 200px;
  max-height: 250px;
  border-radius: 8px;
  margin-bottom: 6px;
  display: block;
  cursor: pointer;
  transition: opacity 0.15s;
}

.dash-chat-img:hover { opacity: 0.8; }

.dash-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  cursor: pointer;
  padding: 24px;
}

.dash-lightbox img {
  max-width: 95vw;
  max-height: 95vh;
  border-radius: 8px;
  object-fit: contain;
}

@media (max-width: 600px) {
  .dash-content { padding: 8px 12px; }
  .dash-table { font-size: 0.8rem; }
  .dash-chat-msg { max-width: 95%; }
}

/* ── Chat ── */

#chat-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#chat-screen.hidden { display: none; }

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo {
  flex-shrink: 0;
}

.student-school {
  color: var(--text-muted);
  font-size: 0.8rem;
  opacity: 0.6;
}

header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.student-name {
  color: var(--text-muted);
  font-size: 0.85rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.2s;
}

.student-name:hover {
  color: var(--text);
  background: var(--surface-2);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn-header {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  transition: all 0.2s;
}

.icon-btn-header:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.logout-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.logout-btn:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

/* ── Unit Menu Panel ── */

.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 50;
  transition: opacity 0.2s;
}

.menu-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 320px;
  max-width: 85vw;
  height: 100%;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 51;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
}

.menu-panel.open {
  transform: translateX(0);
}

.menu-panel-right {
  left: auto;
  right: 0;
  border-right: none;
  border-left: 1px solid var(--border);
  transform: translateX(100%);
}

.menu-panel-right.open {
  transform: translateX(0);
}

.menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.menu-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.menu-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0 4px;
}

.menu-close:hover { color: var(--text); }

.menu-units {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.menu-loading {
  color: var(--text-muted);
  text-align: center;
  padding: 20px;
  font-size: 0.85rem;
}

/* ── Term Sections ── */

.menu-term-section {
  margin-bottom: 4px;
}

.menu-term-header {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  gap: 8px;
  text-align: left;
}

.menu-term-header:hover {
  background: var(--border);
}

.menu-term-count {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  padding: 1px 7px;
  border-radius: 10px;
}

.menu-term-chevron {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.menu-term-section.collapsed .menu-term-chevron {
  transform: rotate(-90deg);
}

.menu-term-list {
  padding: 4px 0 4px 0;
  overflow: hidden;
  max-height: 2000px;
  transition: max-height 0.25s ease, opacity 0.2s;
  opacity: 1;
}

.menu-term-section.collapsed .menu-term-list {
  max-height: 0;
  opacity: 0;
  padding: 0;
}

/* ── Compact Unit Rows ── */

.menu-unit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s;
  text-align: left;
  gap: 10px;
}

.menu-unit-row:hover {
  background: var(--surface-2);
}

.menu-unit-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.menu-unit-code {
  font-size: 0.65rem;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1;
}

.menu-unit-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-unit-status {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.mini-progress {
  width: 36px;
  height: 4px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
}

.mini-progress-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.3s;
}

.mini-progress-fill.HD { background: #a855f7; }
.mini-progress-fill.D { background: #3b82f6; }
.mini-progress-fill.C { background: #22c55e; }
.mini-progress-fill.P { background: #f97316; }
.mini-progress-fill.F { background: #ef4444; }

.menu-unit-pct {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 24px;
  text-align: right;
}

.topic-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 20px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--accent);
}

.topic-bar button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0 4px;
}

.topic-bar button:hover { color: var(--text); }

.topic-progress {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent);
}

.topic-progress.HD { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.topic-progress.D { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.topic-progress.C { background: rgba(99, 102, 241, 0.15); color: #6366f1; }
.topic-progress.P { background: rgba(234, 179, 8, 0.15); color: #eab308; }
.topic-progress.F { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

.messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.messages::before {
  content: '';
  flex: 1;
}

.chat-welcome {
  align-self: center;
  max-width: 520px;
  width: 100%;
  text-align: center;
  padding: 32px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: welcome-fade 0.35s ease-out;
}

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

.welcome-greeting {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.welcome-hint {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0;
}

.welcome-jumpback {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.jumpback-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
}

.jumpback-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s, background 0.15s;
}

.jumpback-card:hover,
.jumpback-card:focus-visible {
  border-color: var(--accent);
  background: var(--surface-2);
  outline: none;
}

.jumpback-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.jumpback-unit {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  color: var(--text);
}

.jumpback-unit:empty {
  display: none;
}

.jumpback-preview {
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.jumpback-action {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: 4px;
}

.message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  line-height: 1.7;
  word-wrap: break-word;
}

.message.user {
  align-self: flex-end;
  background: var(--user-bubble);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message.assistant {
  align-self: flex-start;
  background: var(--tutor-bubble);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.message.assistant p { margin-bottom: 8px; }
.message.assistant p:last-child { margin-bottom: 0; }
.message.assistant strong { color: #fff; font-weight: 600; }
.message.assistant ol, .message.assistant ul { padding-left: 20px; margin-bottom: 8px; }
.message.assistant li { margin-bottom: 4px; }
.message.assistant code {
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

.message .katex-display {
  margin: 12px 0;
  overflow-x: auto;
}

.typing-indicator {
  align-self: flex-start;
  padding: 12px 16px;
  background: var(--tutor-bubble);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-bottom-left-radius: 4px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.typing-label {
  animation: blink 1.4s infinite;
}

.typing-timer {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
}

@keyframes blink {
  0%, 60%, 100% { opacity: 0.3; }
  30% { opacity: 1; }
}

/* ── Image Preview ── */

.image-preview {
  padding: 8px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.image-preview-inner {
  display: flex;
  gap: 8px;
}

.image-thumb {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border: none;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
  cursor: pointer;
  padding: 0;
}

.message .user-image {
  max-width: 240px;
  max-height: 300px;
  border-radius: 8px;
  margin-top: 8px;
  display: block;
}

/* ── Webcam Modal ── */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  width: 90%;
  max-width: 480px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.modal-content video {
  width: 100%;
  display: block;
  background: #000;
}

.webcam-controls {
  display: flex;
  gap: 8px;
  padding: 12px;
  justify-content: center;
}

.webcam-controls button {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

#webcam-capture {
  background: var(--accent);
  color: #fff;
}

#webcam-cancel {
  background: var(--surface-2);
  color: var(--text);
}

/* ── Chat Input ── */

.chat-input {
  display: flex;
  gap: 8px;
  padding: 12px 20px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  align-items: flex-end;
  position: relative;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
  padding: 0;
}

.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#mic-btn.recording {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  animation: mic-pulse 1.5s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  50%      { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.camera-tooltip {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 6px;
  padding: 6px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  animation: fadeInOut 3s ease;
  pointer-events: none;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translateY(4px); }
  15% { opacity: 1; transform: translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

.chat-input textarea {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: 120px;
  transition: border-color 0.2s;
}

.chat-input textarea:focus {
  border-color: var(--accent);
}

.chat-input textarea::placeholder {
  color: var(--text-muted);
}

.chat-input button[type="submit"] {
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.chat-input button[type="submit"]:hover { background: var(--accent-hover); }
.chat-input button[type="submit"]:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Feedback Button ── */

.feedback-btn {
  position: fixed;
  bottom: 80px;
  left: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  z-index: 40;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.feedback-btn svg {
  width: 24px;
  height: 24px;
}

.feedback-btn .feedback-plus {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg);
}

.feedback-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--surface-2);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%) translateY(8px);
  max-width: min(92vw, 420px);
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1.4;
  text-align: center;
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.app-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#feedback-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#feedback-form textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  outline: none;
}

#feedback-form textarea:focus { border-color: var(--accent); }

#feedback-form button[type="submit"] {
  padding: 12px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

#feedback-form button[type="submit"]:hover { background: var(--accent-hover); }
#feedback-form button[type="submit"]:disabled { opacity: 0.6; cursor: not-allowed; }

.feedback-attach-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.feedback-image-label {
  font-size: 0.8rem;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.feedback-image-label:hover { color: var(--accent-hover); }

.feedback-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
}

.feedback-icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.feedback-icon-btn.recording {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239,68,68,0.1);
  animation: pulse-record 1.2s infinite;
}

@keyframes pulse-record {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.3); }
  50% { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

.feedback-paste-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.feedback-recording-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius);
}

.recording-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  animation: pulse-record 1s infinite;
  flex-shrink: 0;
}

.recording-timer {
  font-size: 0.9rem;
  font-weight: 600;
  color: #ef4444;
  font-variant-numeric: tabular-nums;
  min-width: 36px;
}

.feedback-rec-cancel {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 8px;
}

.feedback-rec-cancel:hover { color: var(--text); }

.feedback-rec-done {
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

/* ── Student History Panel ── */

#history-panel {
  border-right: none;
  border-left: 1px solid var(--border);
}

#history-panel.open {
  transform: translateX(0);
}

.history-session-card {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 4px;
  transition: background 0.15s;
  background: none;
  border: 1px solid transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.history-session-card:hover,
.history-session-card:focus-visible {
  background: var(--surface-2);
  border-color: var(--border);
  outline: none;
}

.history-session-header {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.history-preview {
  font-size: 0.8rem;
  color: var(--text);
  line-height: 1.4;
}

/* ── Idle Overlay ── */

.idle-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,17,23,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.idle-box {
  text-align: center;
  max-width: 380px;
  padding: 40px;
}

.idle-box p {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 24px;
}

.idle-resume-btn {
  padding: 12px 36px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.idle-resume-btn:hover { background: var(--accent-hover); }

/* ── Mobile ── */

@media (max-width: 600px) {
  .auth-container { padding: 40px 20px; }
  .messages { padding: 12px; }
  .message { max-width: 92%; font-size: 0.9rem; }
  .chat-input { padding: 8px 12px 12px; }
  .chat-input button[type="submit"] { padding: 12px 16px; }
  .image-preview { padding: 8px 12px; }
}

/* ── Inline video recommendation card (find_video tool) ───────────────── */

.video-rec-card {
  margin-top: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  max-width: 100%;
}

.video-rec-collapsed {
  display: flex;
  gap: 12px;
  padding: 12px;
  align-items: flex-start;
}

.video-rec-thumb {
  position: relative;
  flex-shrink: 0;
  width: 160px;
  height: 90px;
  border: none;
  padding: 0;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  background: #000;
  transition: transform 0.15s;
}

.video-rec-thumb:hover {
  transform: translateY(-1px);
}

.video-rec-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-rec-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  background: rgba(0, 0, 0, 0.25);
  transition: background 0.15s;
}

.video-rec-thumb:hover .video-rec-play {
  background: rgba(0, 0, 0, 0.4);
}

.video-rec-ts {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
}

.video-rec-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.video-rec-title {
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.video-rec-sub {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.video-rec-snippet {
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.45;
  margin-top: 4px;
  font-style: italic;
  opacity: 0.85;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.video-rec-feedback {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
}

.video-rec-fb-label {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-right: 4px;
}

.video-rec-fb-btn {
  background: var(--surface-2, #252836);
  border: 1px solid var(--border);
  color: #fff;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
  transition: all 0.15s;
}

.video-rec-fb-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.video-rec-player {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
  background: #000;
}

.video-rec-player iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.video-rec-close {
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  padding: 10px;
  font-size: 0.82rem;
  cursor: pointer;
  text-align: center;
}

.video-rec-close:hover {
  background: var(--surface-2, #252836);
  color: #fff;
}

.video-rec-card .video-rec-feedback:not(:first-child) {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--border);
  margin-top: 0;
}

.hidden { display: none !important; }

@media (max-width: 560px) {
  .video-rec-collapsed {
    flex-direction: column;
  }
  .video-rec-thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }
}

/* ── First-time onboarding pulse on the hamburger menu ──────────────────── */
/*
 * Shown only on the very first session (until the student either opens the
 * menu or sends their first message, tracked in localStorage). Subtle glow
 * so they notice it's tappable without feeling harassed.
 */

.menu-hint-pulse {
  position: relative;
  animation: menu-hint-pulse 1.6s ease-in-out infinite;
}

.menu-hint-pulse::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 8px;
  border: 2px solid var(--accent);
  opacity: 0;
  pointer-events: none;
  animation: menu-hint-ring 1.6s ease-out infinite;
}

@keyframes menu-hint-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08); }
}

@keyframes menu-hint-ring {
  0%   { opacity: 0.7; transform: scale(1); }
  70%  { opacity: 0; transform: scale(1.35); }
  100% { opacity: 0; transform: scale(1.35); }
}

.welcome-hint-icon {
  display: inline-block;
  padding: 1px 6px;
  margin: 0 2px;
  background: var(--surface-2, #252836);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.95em;
  color: var(--accent);
}

/* ── Admin session expired toast ────────────────────────────────────── */
.session-expired-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #dc2626;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  z-index: 10000;
  max-width: 90%;
  text-align: center;
  animation: session-toast-in 0.25s ease-out;
}

@keyframes session-toast-in {
  from { opacity: 0; transform: translate(-50%, -20px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ── Student progress panel ─────────────────────────────────────────── */

.progress-summary {
  padding: 12px 14px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.progress-summary-target {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 10px;
}

.progress-summary-target strong {
  color: #fff;
  font-weight: 600;
}

.progress-summary-hint {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.8rem;
  margin-left: 4px;
}

.progress-summary-hint:hover {
  text-decoration: underline;
}

.progress-summary-bar {
  width: 100%;
  height: 10px;
  background: var(--surface-2, #252836);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-summary-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover, #818cf8));
  border-radius: 5px;
  transition: width 0.3s ease;
}

.progress-summary-pct {
  color: var(--text-muted);
  font-size: 0.82rem;
  text-align: right;
}

#progress-chart-slot {
  padding: 0 14px;
  margin-bottom: 12px;
}

.progress-unit-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 14px 20px;
}

.progress-unit-card {
  background: var(--surface, #1a1d27);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.progress-unit-title {
  color: #fff;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 6px;
}

.progress-unit-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.progress-unit-grade {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--surface-2, #252836);
  color: var(--text-muted);
}

.progress-unit-grade.grade-HD { background: rgba(34, 197, 94, 0.18); color: #4ade80; }
.progress-unit-grade.grade-D  { background: rgba(59, 130, 246, 0.18); color: #60a5fa; }
.progress-unit-grade.grade-C  { background: rgba(99, 102, 241, 0.18); color: #818cf8; }
.progress-unit-grade.grade-P  { background: rgba(245, 158, 11, 0.18); color: #fbbf24; }
.progress-unit-grade.grade-F  { background: rgba(239, 68, 68, 0.18); color: #fca5a5; }

.progress-unit-ref {
  font-size: 0.72rem;
  color: var(--text-muted);
  opacity: 0.8;
}

.progress-unit-label {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-bottom: 5px;
}

.progress-unit-bar {
  width: 100%;
  height: 8px;
  background: var(--surface-2, #252836);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-unit-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-unit-sublabel {
  color: var(--text-muted);
  font-size: 0.72rem;
  opacity: 0.75;
}

/* ── Progress chart ─────────────────────────────────────────────────── */
.progress-chart {
  width: 100%;
  max-width: 320px;
  display: block;
  margin: 0 auto;
  font-family: inherit;
}

.progress-chart-grid {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 2 3;
  opacity: 0.5;
}

.progress-chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.progress-chart-axis-label {
  fill: var(--text-muted);
  font-size: 9px;
}

.progress-chart-hint {
  color: var(--text-muted);
  font-size: 0.78rem;
  text-align: center;
  padding: 10px 0;
  font-style: italic;
}

/* ── Hours-to-target additions to the progress panel ────────────────── */

.progress-summary-hours {
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.progress-unit-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.progress-unit-hours {
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}

.progress-unit-hours.on-target {
  color: #4ade80;
}

/* ── Trusted-device checkbox on the MFA challenge form ───────────────── */

.trust-device-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--surface, #1a1d27);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.trust-device-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 2px;
  accent-color: var(--accent);
  cursor: pointer;
}

.trust-device-option span {
  flex: 1;
}

.trust-device-option em {
  color: #f59e0b;
  font-style: normal;
  font-size: 0.75rem;
}

.trust-device-option:hover {
  border-color: var(--accent);
}

/* ── Admin cost summary dashboard ─────────────────────────── */
.cost-total-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.cost-total-big {
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.cost-total-sub {
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.cost-section {
  margin-top: 1.75rem;
}

.cost-section .dash-section-subtitle {
  margin-bottom: 0.75rem;
}

.cost-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 0.9rem;
}

.cost-table th {
  text-align: left;
  padding: 0.6rem 0.8rem;
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.cost-table td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.cost-table tbody tr:last-child td {
  border-bottom: none;
}

.cost-table tbody tr:hover {
  background: rgba(99, 102, 241, 0.05);
}

.cost-table-cost {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.cost-table-sub {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 0.15rem;
}

.cost-table-models {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
}

.cost-chart {
  width: 100%;
  max-width: 600px;
  height: auto;
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
}

.cost-chart-grid {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}

.cost-chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.cost-chart-area {
  fill: var(--accent);
  fill-opacity: 0.12;
  stroke: none;
}

.cost-chart-dot {
  fill: var(--accent);
  stroke: var(--surface);
  stroke-width: 1.5;
}

.cost-chart-dot:hover {
  r: 5;
  fill: var(--accent-hover);
}

.cost-chart-axis {
  fill: var(--text-muted);
  font-size: 10px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
}

/* ── Idle warning overlay ─────────────────────────────────── */
#idle-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.idle-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  max-width: 360px;
}

.idle-dialog p {
  margin-bottom: 1rem;
  font-size: 1rem;
  color: var(--text);
}

.idle-dialog button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.5rem;
  font-size: 1rem;
  cursor: pointer;
}

.idle-dialog button:hover {
  background: var(--accent-hover);
}

/* ── Google sign-in button ────────────────────────────────── */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--border);
}

.google-signin-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.google-signin-btn:hover {
  border-color: var(--accent);
  background: var(--surface-2);
}
