:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #5f6f69;
  --line: #dbe5df;
  --paper: #fbfcfa;
  --panel: #ffffff;
  --mint: #2f8f74;
  --mint-dark: #1e6654;
  --coral: #d95d39;
  --gold: #d9a441;
  --blue: #3867b7;
  --shadow: 0 16px 40px rgba(23, 33, 31, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

.hidden {
  display: none !important;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(244, 248, 245, 0.94);
}

.login-box {
  display: grid;
  gap: 14px;
  width: min(380px, 100%);
  padding: 26px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-box h2 {
  margin: 0;
}

.login-box p {
  color: var(--muted);
}

.login-box input {
  min-height: 46px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.login-box input:focus {
  border-color: var(--mint);
}

.login-box button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  background: var(--mint);
  color: #fff;
  font-weight: 800;
}

.login-error {
  min-height: 20px;
  color: var(--coral);
  font-size: 14px;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: #f4f8f5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  background: var(--mint);
  color: #fff;
  font-weight: 800;
  border-radius: 8px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  margin-top: 4px;
  font-size: 28px;
  line-height: 1.15;
}

.brand p,
.label,
.topic-button small,
.progress-meta,
.ai-status {
  color: var(--muted);
}

.label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  margin-bottom: 4px;
}

.student-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.student-panel > div,
.metric {
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sidebar-actions,
.quick-actions {
  display: grid;
  gap: 10px;
}

.secondary-button,
.ghost-button,
.quick-actions button,
.composer button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  font-weight: 700;
}

.secondary-button,
.composer button {
  background: var(--mint);
  color: #fff;
}

.secondary-button:hover,
.composer button:hover {
  background: var(--mint-dark);
}

.ghost-button,
.quick-actions button {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.section-title,
.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-weight: 700;
}

.topic-list {
  display: grid;
  gap: 8px;
}

.topic-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 74px;
  padding: 12px;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
}

.topic-button strong,
.topic-button small {
  display: block;
}

.topic-button strong {
  line-height: 1.2;
}

.topic-button small {
  margin-top: 4px;
}

.topic-button em {
  min-width: 42px;
  text-align: center;
  font-style: normal;
  font-weight: 800;
  color: var(--mint-dark);
}

.topic-button.active {
  border-color: var(--mint);
  box-shadow: inset 4px 0 0 var(--mint);
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 24px;
  gap: 18px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.ai-status {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  white-space: nowrap;
}

.ai-status.ready {
  color: var(--mint-dark);
  border-color: #a9d8ca;
}

.progress-band {
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.progress-track {
  height: 12px;
  overflow: hidden;
  background: #edf2ef;
  border-radius: 999px;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--mint), var(--gold), var(--coral));
  transition: width 180ms ease;
}

.lesson-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 18px;
  min-height: 0;
  flex: 1;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 520px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  padding: 18px;
  overflow-y: auto;
}

.message {
  max-width: 82%;
  padding: 13px 15px;
  border-radius: 8px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.message.assistant {
  align-self: flex-start;
  background: #edf7f2;
  border: 1px solid #cbe7da;
}

.message.user {
  align-self: flex-end;
  background: #eef3fb;
  border: 1px solid #cbd9ef;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 130px;
  gap: 12px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.composer textarea {
  width: 100%;
  resize: vertical;
  min-height: 48px;
  max-height: 150px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.composer textarea:focus {
  border-color: var(--mint);
}

.composer button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.insight-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.metric strong {
  font-size: 22px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .insight-panel {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .quick-actions {
    grid-column: 1 / -1;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .sidebar,
  .workspace {
    padding: 16px;
  }

  .topbar,
  .progress-meta {
    flex-direction: column;
  }

  h2 {
    font-size: 22px;
  }

  .student-panel,
  .composer,
  .insight-panel,
  .quick-actions {
    grid-template-columns: 1fr;
  }

  .message {
    max-width: 100%;
  }
}
