:root {
  font-family: Inter, system-ui, sans-serif;
  color: #14213d;
  background: #f8fafc;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
}
button, input, select {
  font: inherit;
  border-radius: 12px;
  border: 1px solid #cfd7e6;
  padding: 0.8rem 1rem;
}
button {
  background: #2563eb;
  color: white;
  border: none;
  cursor: pointer;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }
.secondary-button {
  background: #e2e8f0;
  color: #14213d;
}

.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  height: 100vh;
  gap: 1rem;
  padding: 1rem;
  overflow: hidden;
}
.card {
  background: white;
  border-radius: 24px;
  box-shadow: 0 10px 30px rgba(20,33,61,0.08);
  padding: 1rem;
}
.sidebar, .main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
  overflow: hidden;
}
.sidebar {
  overflow-y: auto;
}
.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.small-gap { gap: 0.5rem; }
.hero { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.session-summary {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 0.75rem;
  background: #f8fafc;
}
.student-layout .sidebar > button,
.student-layout .sidebar > h3,
.student-layout .sidebar > .stack.small-gap {
  display: none;
}
.admin-layout .sidebar > button:nth-of-type(2) {
  display: none;
}
.today-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.today-card {
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 0.85rem;
  background: #f8fafc;
}
.today-card-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.today-card-head span {
  color: #2563eb;
  font-weight: 700;
}
.today-card p {
  margin: 0 0 0.75rem;
}
.admin-program-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border: 1px solid #dbeafe;
  border-radius: 16px;
  background: #f8fbff;
  padding: 0.85rem;
}
.admin-program-panel h3,
.admin-program-panel p {
  margin: 0;
}
.program-diagnostic {
  color: #b45309;
  font-size: 0.9rem;
  line-height: 1.4;
}
.admin-main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
  overflow-y: auto;
}
.admin-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 1rem;
}
.admin-header h1,
.admin-header p,
.admin-detail h2,
.admin-detail p,
.admin-empty h2,
.admin-empty p,
.admin-preview h2 {
  margin: 0;
}
.admin-header span {
  color: #64748b;
  white-space: nowrap;
}
.admin-detail {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.admin-student-card,
.admin-empty {
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  background: #f8fafc;
  padding: 1rem;
}
.admin-start-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.9rem;
}
.admin-start-controls label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  font-weight: 700;
}
.admin-preview {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.admin-asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.admin-asset-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  background: #f8fafc;
  padding: 0.75rem;
}
.admin-asset-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  border-radius: 12px;
  background: white;
}
.admin-log-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.admin-log-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #f8fafc;
  padding: 0.75rem;
}
.admin-log-card div {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.admin-log-card span {
  color: #64748b;
  font-size: 0.9rem;
}
.admin-log-actions {
  display: flex;
  gap: 0.5rem;
}
.admin-log-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.admin-log-detail {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #f8fafc;
  padding: 1rem;
}
.admin-log-detail h3 {
  margin: 0.6rem 0 0;
}
.admin-log-detail h3:first-child {
  margin-top: 0;
}
.admin-log-message {
  margin: 0;
  line-height: 1.45;
}
.session-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #64748b;
  font-size: 0.95rem;
}
.instruction-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.75rem;
  background: #eef6ff;
  border: 1px solid #cfe4ff;
  border-radius: 20px;
  padding: 1.25rem;
}
.messages,
.voice-note,
.main > .voice-status {
  display: none;
}
.instruction-stage p {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 100%;
  overflow: auto;
}
.stage-label {
  color: #2563eb;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
}
.messages { display: none; }
.student-transmission {
  flex: 0 0 auto;
  border: 1px solid #dbeafe;
  border-radius: 14px;
  background: #f8fbff;
  padding: 0.7rem 0.85rem;
}
.student-transmission span {
  display: block;
  color: #2563eb;
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
}
.student-transmission p {
  margin: 0;
  color: #14213d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.message {
  max-width: 92%;
  margin-bottom: 0.45rem;
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  font-size: 0.92rem;
}
.message.user {
  margin-left: auto;
  background: #dbeafe;
}
.message.assistant {
  background: #eaf7e7;
}
.message p {
  margin: 0.25rem 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.composer {
  display: grid;
  grid-template-columns: 1fr 190px 36px 130px 130px;
  gap: 0.75rem;
  flex: 0 0 auto;
}
.voice-tooltip {
  display: grid;
  place-items: center;
  width: 36px;
  height: 100%;
  min-height: 46px;
  border-radius: 12px;
  background: #e2e8f0;
  color: #14213d;
  font-weight: 700;
  cursor: help;
}
.assessment {
  display: none;
  flex: 0 0 auto;
  background: #fff7ed;
  padding: 1rem;
  border-radius: 18px;
}
.progress-card {
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 0.75rem;
}
.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.4rem;
}
.progress-bar {
  height: 10px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.35rem;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #60a5fa, #2563eb);
}
.muted { color: #64748b; }
.voice-note {
  margin: 0;
  font-size: 0.95rem;
}
.avatar-shell { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; }
.avatar {
  width: 144px;
  height: 144px;
  border-radius: 0;
  overflow: hidden;
  background: #f8fafc;
  box-shadow: none;
}
.avatar.speaking { animation: pulse 0.7s infinite alternate; }
.avatar-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  mix-blend-mode: multiply;
}
.avatar-caption { font-weight: 700; }
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.login-panel {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.login-copy {
  text-align: center;
}
.login-copy h1 {
  margin: 0;
}
.login-form {
  width: 100%;
}

.student-screen {
  height: 100vh;
  background: #f8fafc;
}
.student-home {
  width: min(1040px, 100%);
  min-height: 100%;
  margin: 0 auto;
  padding: 1rem;
  overflow-y: auto;
}
.student-home-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.student-home-hero h1,
.student-info-card h2,
.lesson-topbar h1,
.progress-panel h2 {
  margin: 0;
}
.eyebrow {
  margin: 0 0 0.25rem;
  color: #2563eb;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}
.student-home-actions,
.lesson-actions {
  display: flex;
  gap: 0.75rem;
}
.icon-button {
  width: 44px;
  min-width: 44px;
  padding: 0.8rem 0;
  background: #e2e8f0;
  color: #14213d;
  font-weight: 800;
}
.student-home-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.student-info-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 180px;
}
.student-info-card p {
  margin: 0;
  line-height: 1.5;
}
.advice-card {
  background: #eef6ff;
  border: 1px solid #cfe4ff;
}
.visible-status {
  display: block;
  margin: 1rem 0 0;
}
.student-lesson {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 0.75rem;
  padding: 0.75rem;
  overflow: hidden;
}
.lesson-topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  min-height: 0;
}
.lesson-topbar .avatar {
  width: 92px;
  height: 92px;
  border-radius: 0;
}
.lesson-topbar .avatar-caption {
  display: none;
}
.lesson-topbar h1 {
  font-size: 1.35rem;
}
.lesson-display {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  overflow: hidden;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 1rem;
}
.lesson-display p {
  margin: 0;
  white-space: pre-wrap;
}
.lesson-display-head,
.lesson-asset-toolbar,
.lesson-asset-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.asset-counter {
  color: #64748b;
  font-size: 0.9rem;
  font-weight: 700;
}
.teacher-transcript {
  min-height: calc(1.35em * 3);
  max-height: none;
  overflow: visible;
  color: #14213d;
  font-size: clamp(0.95rem, 1.5vw, 1.08rem);
  line-height: 1.35;
}
.lesson-asset-view {
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow: hidden;
}
.lesson-asset-toolbar {
  flex: 0 0 auto;
  justify-content: flex-end;
}
.lesson-asset-toolbar strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lesson-asset-actions button {
  padding: 0.45rem 0.65rem;
  font-size: 0.9rem;
}
.lesson-asset-open {
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0;
  background: #f8fafc;
  color: #14213d;
  border: none;
}
.lesson-asset-open img {
  width: 100%;
  min-height: 0;
  flex: 1 1 auto;
  object-fit: contain;
  border: 0;
  border-radius: 30px;
  background: #f8fafc;
}
.lesson-bubble {
  min-height: 68px;
}
.lesson-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 110px;
  gap: 0.6rem;
}
.lesson-status {
  margin: 0;
  color: #64748b;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.progress-panel-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: flex-end;
  background: rgba(15, 23, 42, 0.28);
  padding: 1rem;
  z-index: 10;
}
.progress-panel {
  width: min(420px, 100%);
  overflow-y: auto;
}
.progress-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.settings-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.settings-field span {
  font-weight: 700;
}

@keyframes pulse {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

@media (max-width: 920px) {
  body {
    overflow: auto;
  }

  .layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
    padding: 0.75rem;
  }

  .sidebar,
  .main {
    min-height: auto;
    overflow: visible;
  }

  .student-layout .sidebar {
    order: 1;
  }

  .student-layout .main {
    order: 2;
  }

  .card {
    border-radius: 18px;
  }

  .composer { grid-template-columns: 1fr; }
  .hero { align-items: flex-start; }
  .session-user {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }

  .admin-header,
  .admin-detail {
    grid-template-columns: 1fr;
  }

  .admin-header {
    flex-direction: column;
  }

  .instruction-stage {
    flex: 0 0 auto;
    justify-content: flex-start;
    min-height: 220px;
  }

  .instruction-stage p {
    max-height: none;
    overflow: visible;
    font-size: 1.1rem;
  }

  .student-home-grid {
    grid-template-columns: 1fr;
  }

  .lesson-composer {
    grid-template-columns: 1fr 1fr;
  }

  .lesson-composer input {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .layout {
    gap: 0.75rem;
    padding: 0.5rem;
  }

  .card {
    padding: 0.85rem;
    border-radius: 16px;
  }

  .sidebar,
  .main,
  .today-panel {
    gap: 0.85rem;
  }

  .sidebar h2,
  .main h1 {
    margin: 0;
  }

  .main h1 {
    font-size: 1.85rem;
  }

  .hero {
    gap: 0.75rem;
  }

  .avatar {
    width: 112px;
    height: 112px;
    border-radius: 22px;
  }

  .session-user {
    align-items: stretch;
    flex-direction: column;
    gap: 0.5rem;
  }

  .today-card-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.25rem;
  }

  .student-transmission p {
    white-space: normal;
  }

  button,
  input,
  select {
    width: 100%;
  }

  .icon-button {
    width: 44px;
    min-width: 44px;
  }

  .student-home {
    padding: 0.5rem;
  }

  .student-home-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .student-home-actions {
    flex-direction: column;
  }

  .student-info-card {
    min-height: 150px;
  }

  .student-lesson {
    gap: 0.45rem;
    padding: 0.45rem 0;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
  }

  .lesson-topbar {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.75rem;
  }

  .lesson-topbar .avatar {
    width: 72px;
    height: 72px;
    border-radius: 0;
  }

  .lesson-topbar h1 {
    font-size: 1.05rem;
  }

  .lesson-actions {
    grid-column: 1 / -1;
  }

  .lesson-display {
    padding: 0.65rem 0;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .teacher-transcript {
    min-height: calc(1.35em * 3);
    max-height: none;
    font-size: 0.9rem;
    padding: 0 0.65rem;
  }

  .lesson-display-head,
  .lesson-asset-toolbar {
    align-items: center;
    flex-direction: row;
    gap: 0.5rem;
    padding: 0 0.65rem;
  }

  .lesson-asset-actions {
    display: flex;
    gap: 0.5rem;
  }

  .lesson-asset-actions button {
    padding: 0.35rem 0.55rem;
    font-size: 0.82rem;
    border-radius: 10px;
  }

  .lesson-asset-open img {
    max-height: none;
    border-left: 0;
    border-right: 0;
    border-radius: 24px;
  }

  .lesson-composer {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    padding: 0 0.45rem;
  }

  .lesson-composer input {
    grid-column: 1 / -1;
  }

  .progress-panel-backdrop {
    align-items: flex-end;
    padding: 0.5rem;
  }

  .progress-panel {
    max-height: 82dvh;
    width: 100%;
  }
}
