:root {
  --bg: #f6f3ec;
  --panel: #fffaf0;
  --ink: #22201d;
  --muted: #665f55;
  --line: #ddd3c2;
  --accent: #0b6b62;
  --accent-dark: #084f49;
  --warm: #c9793c;
  --soft: #e9f2ee;
  --shadow: 0 18px 50px rgba(34, 32, 29, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(11, 107, 98, 0.11), transparent 34%),
    linear-gradient(300deg, rgba(201, 121, 60, 0.16), transparent 36%),
    var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(320px, 1.15fr);
  gap: 24px;
  width: min(1160px, calc(100% - 32px));
  min-height: calc(100vh - 48px);
  margin: 24px auto;
}

.intro-panel,
.chat-panel,
.courses-panel {
  border: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.86);
  box-shadow: var(--shadow);
}

.intro-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  padding: 32px;
  border-radius: 8px;
}

.brand-block {
  display: grid;
  gap: 18px;
}

.eyebrow,
.section-label {
  margin: 0;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 11ch;
  font-size: clamp(2.55rem, 5vw, 4.7rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  font-size: 1.35rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.intro-copy {
  max-width: 34rem;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.55;
}

.status-box {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(11, 107, 98, 0.25);
  border-radius: 8px;
  background: var(--soft);
  color: #244d48;
  line-height: 1.45;
}

.status-dot {
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.course-note {
  padding: 14px 16px;
  border-left: 4px solid var(--warm);
  border-radius: 8px;
  background: #fff8eb;
  color: var(--muted);
  line-height: 1.45;
}

.quick-start {
  display: grid;
  gap: 10px;
}

.prompt-chip {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    transform 160ms ease,
    background 160ms ease;
}

.prompt-chip:hover {
  border-color: var(--accent);
  background: #f2fbf7;
  transform: translateY(-1px);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 640px;
  overflow: hidden;
  border-radius: 8px;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.52);
}

.memory-status {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.25;
}

.memory-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--line);
  background: #fff8eb;
}

.avatar-badge {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-width: 210px;
  padding: 8px 14px 8px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.avatar-badge img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--soft);
}

.brand-badge {
  color: var(--accent-dark);
  font-size: 1.02rem;
  font-weight: 900;
  line-height: 1.1;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  padding: 24px;
}

.message {
  max-width: 82%;
  padding: 14px 16px;
  border-radius: 8px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.message p {
  white-space: pre-line;
}

.message a {
  color: var(--accent-dark);
  font-weight: 800;
  overflow-wrap: anywhere;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  word-break: break-word;
}

.message.user a {
  color: white;
}

.message.bot {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid var(--line);
}

.message.user {
  align-self: flex-end;
  background: var(--accent);
  color: white;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 18px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.66);
}

textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--ink);
  background: #fffdf8;
  line-height: 1.45;
}

textarea:focus {
  outline: 3px solid rgba(11, 107, 98, 0.16);
  border-color: var(--accent);
}

.composer button {
  min-width: 118px;
  min-height: 48px;
  align-self: end;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  cursor: pointer;
}

.composer button:hover {
  background: var(--accent-dark);
}

.courses-panel {
  grid-column: 1 / -1;
  display: grid;
  gap: 18px;
  padding: 24px;
  border-radius: 8px;
}

.courses-header {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(280px, 1fr);
  gap: 18px;
  align-items: end;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.courses-header > p {
  color: var(--muted);
  line-height: 1.5;
}

.courses-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 16px;
}

.is-hidden {
  display: none;
}

.course-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.course-card header {
  display: grid;
  gap: 8px;
}

.course-card h3 {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.25;
}

.course-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.course-pill {
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
}

.course-description {
  color: var(--muted);
  line-height: 1.5;
}

.course-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.course-action,
.module-start,
.download-link,
.download-disabled {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 11px;
  border: 0;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: none;
}

.course-action,
.module-start,
.download-link {
  background: var(--accent);
  color: white;
  cursor: pointer;
}

.course-action:hover,
.module-start:hover,
.download-link:hover {
  background: var(--accent-dark);
}

.course-goals {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(11, 107, 98, 0.18);
  border-radius: 8px;
  background: var(--soft);
}

.course-goals p {
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.course-goals ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  color: #244d48;
  line-height: 1.42;
}

.study-mode {
  padding: 12px;
  border-left: 4px solid var(--warm);
  border-radius: 8px;
  background: #fff8eb;
  color: var(--muted);
  line-height: 1.45;
}

.download-disabled {
  border: 1px solid var(--line);
  color: var(--muted);
  background: #f8f1e8;
}

.modules-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.module-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid #eadfce;
  border-radius: 8px;
  background: #fffaf0;
}

.module-item.is-pending {
  opacity: 0.72;
}

.module-number {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--soft);
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 900;
}

.module-title {
  line-height: 1.35;
}

.module-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.module-start {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.82rem;
}

.module-status {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

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

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: min(100% - 20px, 680px);
    margin: 10px auto;
  }

  .intro-panel {
    padding: 24px;
  }

  h1 {
    max-width: 14ch;
    font-size: 2.65rem;
  }

  .chat-panel {
    min-height: 620px;
  }

  .chat-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .memory-bar {
    align-items: stretch;
    flex-direction: column;
    padding: 12px 16px;
  }

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

  .composer button {
    width: 100%;
  }

  .courses-header,
  .courses-list {
    grid-template-columns: 1fr;
  }

  .module-item {
    grid-template-columns: auto 1fr;
  }

  .module-actions {
    grid-column: 2;
    justify-content: flex-start;
  }
}
