/* ============================================================
   Metaverse & Spatial AI — reflection brainstorm
   Palette, typography and spacing only; layout structure is
   unchanged so the chat / objectives / dashboard logic keeps working.
   ============================================================ */

:root {
  --ink: #1d1b31;
  --ink-soft: #3b3a52;
  --muted: #6b6a85;
  --faint: #9a99b0;
  --brand: #5b4bdb;
  --brand-strong: #4338ca;
  --brand-soft: #efedfd;
  --accent: #0d9488;
  --accent-soft: #e6f6f3;
  --line: #e7e5f2;
  --card: #ffffff;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(29, 27, 49, 0.05), 0 18px 40px -26px rgba(29, 27, 49, 0.4);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(1200px 620px at 12% -12%, #e9e6ff 0%, rgba(233, 230, 255, 0) 60%),
    radial-gradient(900px 520px at 102% -4%, #e2f5f1 0%, rgba(226, 245, 241, 0) 55%),
    #f6f5fb;
  background-attachment: fixed;
  min-height: 100vh;
  padding: 28px 20px 48px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
}

h1 {
  font-size: 1.9rem;
  line-height: 1.18;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

h2 {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 14px;
}

p {
  color: var(--muted);
}

strong {
  color: var(--ink);
  font-weight: 600;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
}

/* Header / hero */

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 18px;
  padding: 0 4px;
}

.app-header-main {
  max-width: 620px;
}

.eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--brand);
  margin-bottom: 8px;
}

.hub-url {
  font-size: 0.92rem;
  margin-top: 8px;
  color: var(--muted);
}

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

.role-badge {
  display: none;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #fff;
  background: #94a3b8;
}

.role-badge.teacher { background: var(--brand-strong); }
.role-badge.student { background: var(--accent); }
.role-badge.guest { background: #64748b; }

.conn-badge {
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #475569;
  background: #e6e5f1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.conn-badge[data-state="connecting"] { color: #92400e; background: #fef3c7; }
.conn-badge[data-state="connected"] { color: #065f46; background: #d1fae5; }
.conn-badge[data-state="closed"] { color: #991b1b; background: #fee2e2; }

/* Intro card (static) */

.intro-card {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 24px;
  background: linear-gradient(135deg, #ffffff 0%, #faf9ff 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 26px;
  margin-bottom: 18px;
}

.intro-lead p {
  font-size: 0.92rem;
}

.skill-chips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
}

.skill-chips li {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--brand-strong);
  background: var(--brand-soft);
  border: 1px solid #ddd8fb;
  padding: 3px 10px;
  border-radius: 999px;
}

.tip-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tip-list li {
  position: relative;
  padding-left: 26px;
  font-size: 0.85rem;
  color: var(--muted);
}

.tip-list li::before {
  content: '→';
  position: absolute;
  left: 0;
  top: 0;
  color: var(--accent);
  font-weight: 700;
}

/* Panels */

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-bottom: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-head h2 {
  margin-bottom: 0;
}

/* Buttons */

.btn {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 9px 18px;
  border: 1px solid #d6d3ea;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.btn:hover { background: #f4f2fe; border-color: #c3bdf0; }
.btn:active { transform: translateY(1px); }

.btn.primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
  border-color: var(--brand-strong);
  color: #fff;
  box-shadow: 0 8px 18px -10px rgba(67, 56, 202, 0.9);
}

.btn.primary:hover { background: linear-gradient(135deg, #5142d6 0%, #3730b5 100%); }

.btn.small {
  padding: 5px 11px;
  font-size: 0.74rem;
}

/* Error screen */

.error-screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(20, 18, 38, 0.92);
}

.error-box {
  max-width: 640px;
  width: 100%;
  background: #221f3a;
  color: #e2e8f0;
  border-radius: var(--radius);
  padding: 28px 32px;
}

.error-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #7f1d1d;
  color: #fecaca;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  margin-bottom: 14px;
}

.error-box h2 {
  font-size: 1.1rem;
  text-transform: none;
  letter-spacing: 0;
  color: #fecaca;
  margin-bottom: 8px;
}

.error-box p {
  color: #cbd5e1;
  font-size: 0.9rem;
}

#err-detail {
  display: none;
  margin-top: 14px;
  padding: 12px;
  max-height: 260px;
  overflow: auto;
  background: #14122a;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: #e2e8f0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.error-box .btn {
  margin-top: 18px;
  background: #37335a;
  border-color: #37335a;
  color: #fff;
}

.error-box .btn:hover { background: #47427a; }

/* Chat */

.chat-head-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-status {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.76rem;
  color: var(--muted);
}

.chat-wrap {
  margin-top: 12px;
  max-height: 420px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px;
}

.chat-empty {
  color: var(--faint);
  font-size: 0.85rem;
}

.msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 82%;
}

.msg.user {
  align-self: flex-end;
  align-items: flex-end;
}

.msg.assistant {
  align-self: flex-start;
}

.msg-who {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
}

.msg-body {
  padding: 10px 13px;
  border-radius: 13px;
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.msg.user .msg-body,
.msg.error .msg-body,
.msg-body.error {
  white-space: pre-wrap;
}

.msg.user .msg-body {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg.assistant .msg-body {
  background: #f4f2fe;
  color: var(--ink);
  border: 1px solid #e7e3fb;
  border-bottom-left-radius: 4px;
}

.msg.error .msg-body {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.msg.streaming .msg-body::after {
  content: '▋';
  margin-left: 2px;
  animation: pulse 1s steps(2) infinite;
}

/* Rendered markdown inside assistant bubbles */

.msg-body.md > :first-child { margin-top: 0; }
.msg-body.md > :last-child { margin-bottom: 0; }

.msg-body.md p {
  color: inherit;
  margin: 0 0 0.6em;
}

.msg-body.md ul,
.msg-body.md ol {
  margin: 0 0 0.6em;
  padding-left: 1.4em;
}

.msg-body.md li + li { margin-top: 0.2em; }

.msg-body.md h1,
.msg-body.md h2,
.msg-body.md h3,
.msg-body.md h4 {
  font-size: 0.95rem;
  text-transform: none;
  letter-spacing: 0;
  color: inherit;
  margin: 0.8em 0 0.4em;
}

.msg-body.md pre {
  margin: 0 0 0.6em;
  padding: 10px 12px;
  overflow-x: auto;
  background: #14122a;
  color: #e2e8f0;
  border-radius: var(--radius-sm);
}

.msg-body.md code {
  background: rgba(20, 18, 42, 0.08);
  padding: 1px 4px;
  border-radius: 4px;
}

.msg-body.md pre code {
  background: none;
  padding: 0;
  font-size: 0.8rem;
}

.msg-body.md blockquote {
  margin: 0 0 0.6em;
  padding-left: 10px;
  border-left: 3px solid #c3bdf0;
  color: var(--muted);
}

.msg-body.md a { color: var(--brand-strong); }

.msg-body.md table {
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 0 0 0.6em;
}

.msg-body.md th,
.msg-body.md td {
  border: 1px solid var(--line);
  padding: 4px 8px;
}

.chat-composer {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  align-items: flex-end;
}

.chat-composer textarea {
  flex: 1;
}

textarea {
  font-family: inherit;
  resize: vertical;
}

input,
select,
textarea {
  font: inherit;
  font-size: 0.88rem;
  color: var(--ink);
  padding: 9px 12px;
  border: 1px solid #d6d3ea;
  border-radius: var(--radius-sm);
  background: #fff;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(91, 75, 219, 0.16);
}

.chat-hint {
  font-size: 0.72rem;
  color: var(--faint);
  margin-top: 6px;
}

.app-footer {
  text-align: center;
  font-size: 0.78rem;
  color: var(--faint);
  margin-top: 6px;
  padding: 0 8px;
}

/* Tutor layout */

.tutor-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr);
  gap: 16px;
  align-items: start;
}

.objective-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.objective {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fcfcff;
}

.objective-box {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #cfcbe6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
}

.objective strong {
  display: block;
  font-size: 0.88rem;
  color: var(--ink);
}

.objective p {
  margin: 2px 0 0;
  font-size: 0.79rem;
  color: var(--muted);
}

.objective.done {
  border-color: #a7e8dd;
  background: var(--accent-soft);
}

.objective.done .objective-box {
  background: var(--accent);
  border-color: var(--accent);
}

/* Teacher dashboard */

.student-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.student-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.student-row:hover {
  background: #f7f6fe;
  border-color: #c3bdf0;
}

.student-name {
  font-weight: 600;
  font-size: 0.88rem;
}

.student-progress {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.student-progress.complete {
  color: #047857;
}

.student-meta {
  font-size: 0.75rem;
  color: var(--faint);
}

.transcript-panel {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.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;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@media (max-width: 860px) {
  .tutor-layout { grid-template-columns: 1fr; }
  .intro-card { grid-template-columns: 1fr; gap: 18px; }
}

@media (max-width: 640px) {
  body { padding: 18px 12px 36px; }
  h1 { font-size: 1.55rem; }
  .panel { padding: 16px; }
  .intro-card { padding: 18px; }
}
