:root {
  --paper: #f7f6f2;
  --panel: rgba(255, 255, 252, 0.78);
  --card: #fffefa;
  --line: rgba(71, 61, 49, 0.09);
  --ink: #2d2923;
  --muted: #81776b;
  --terracotta: #cc785c;
  --user-bubble: #dfeeda;
  --user-line: rgba(72, 108, 75, 0.12);
  --shadow: 0 24px 70px rgba(72, 61, 49, 0.11);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 1px 1px, rgba(54, 46, 38, 0.045) 1px, transparent 0) 0 0 / 13px 13px,
    var(--paper);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

button,
textarea {
  font: inherit;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  /* 锁定为视口高度：消息区在卡片内部滚动，顶部状态栏随下滑始终可见 */
  height: 100vh;
  height: 100dvh;
  padding: 28px;
  max-width: 780px;
  margin: 0 auto;
}

.chat {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 252, 0.62);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 28px 32px 22px;
}

h1,
h2,
p {
  margin: 0;
}

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

.starburst {
  color: var(--terracotta);
  font-size: 22px;
  line-height: 1;
}

h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
  font-weight: 500;
  letter-spacing: 0;
}

h2 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
}

header p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  padding: 28px 32px;
}

.messageRow {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.messageRow.user {
  flex-direction: row-reverse;
}

.avatar {
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(71, 61, 49, 0.14);
  border-radius: 12px;
  background-color: rgba(204, 120, 92, 0.12);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: var(--terracotta);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(77, 66, 55, 0.08);
  transition: border-color 0.15s ease;
}

.avatar:hover {
  border-color: rgba(204, 120, 92, 0.5);
}

.avatar.user {
  background-color: var(--user-bubble);
  border-color: var(--user-line);
  color: #486c4b;
}

.timeDivider {
  align-self: center;
  margin: 8px 0 0;
  padding: 3px 12px;
  border-radius: 999px;
  background: rgba(71, 61, 49, 0.05);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.message {
  max-width: min(680px, 76%);
  border-radius: 18px;
  padding: 13px 15px;
  line-height: 1.62;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.message.user {
  border-top-right-radius: 6px;
  border: 1px solid var(--user-line);
  background: var(--user-bubble);
  color: #263323;
  box-shadow: 0 14px 34px rgba(82, 109, 75, 0.1);
}

.message.assistant {
  border-top-left-radius: 6px;
  border: 1px solid rgba(71, 61, 49, 0.1);
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 14px 42px rgba(77, 66, 55, 0.1);
}

form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  gap: 12px;
  align-items: end;
  padding: 18px 32px 30px;
}

textarea {
  min-height: 78px;
  max-height: 190px;
  resize: vertical;
  border: 1px solid rgba(71, 61, 49, 0.11);
  border-radius: 20px;
  padding: 15px 16px;
  background: rgba(255, 255, 252, 0.82);
  color: var(--ink);
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

textarea:focus {
  border-color: rgba(204, 120, 92, 0.42);
}

button {
  cursor: pointer;
}

.sendButton {
  width: 48px;
  height: 48px;
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  padding: 0;
  background: var(--terracotta);
  color: #fffaf4;
  font-size: 22px;
  line-height: 1;
  box-shadow: 0 18px 36px rgba(147, 83, 62, 0.2);
}

.sendButton:disabled {
  cursor: default;
  opacity: 0.45;
  box-shadow: none;
}

.pillAction {
  min-height: 34px;
  border: 1px solid rgba(71, 61, 49, 0.17);
  border-radius: 999px;
  padding: 0 14px;
  background: rgba(255, 255, 252, 0.45);
  color: var(--muted);
}

.pillAction.secondary {
}

/* ── 登录页 ────────────────────────────────────────── */

.loginLayout {
  place-items: center;
}

.loginCard {
  width: 100%;
  max-width: 380px;
  padding: 44px 36px 36px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 252, 0.62);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.loginCard .brand {
  text-align: center;
  margin-bottom: 32px;
}

.loginCard .titleRow {
  justify-content: center;
}

.loginCard h1 {
  font-size: 40px;
}

.authForm {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.authForm input {
  height: 44px;
  border: 1px solid rgba(71, 61, 49, 0.17);
  border-radius: 999px;
  padding: 0 18px;
  background: rgba(255, 255, 252, 0.82);
  color: var(--ink);
  outline: none;
  font-size: 15px;
}

.authForm input:focus {
  border-color: rgba(204, 120, 92, 0.42);
}

.authForm input:disabled {
  opacity: 0.5;
}

.authError {
  margin: 0;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(204, 120, 92, 0.1);
  color: var(--terracotta);
  font-size: 13px;
}

.pillAction.primary {
  background: var(--terracotta);
  color: #fffaf4;
  border-color: var(--terracotta);
  font-weight: 500;
}

.pillAction.primary:disabled {
  opacity: 0.5;
}

.authToggle {
  margin-top: 20px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

.linkBtn {
  border: 0;
  padding: 0;
  background: none;
  color: var(--terracotta);
  font-weight: 500;
  cursor: pointer;
}

.linkBtn:disabled {
  opacity: 0.5;
}

.authReset {
  margin-top: 8px;
  text-align: center;
}

/* ── 对话界面补充 ──────────────────────────────────── */

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


pre {
  min-height: 124px;
  overflow: auto;
  margin: 0 0 20px;
  padding: 14px;
  border: 1px solid rgba(71, 61, 49, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 252, 0.62);
  color: #5e554c;
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.55;
}

@media (max-width: 900px) {
  .layout {
    padding: 16px;
  }

  header,
  .messages,
  form {
    padding-left: 20px;
    padding-right: 20px;
  }

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


/* ── 课程卡片 ──────────────────────────────────────── */

.message.hasCards {
  max-width: min(680px, 92%);
}

.messageText {
  white-space: pre-wrap;
}

.messageText + .courseCards,
.courseCards + .messageText {
  margin-top: 10px;
}

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

.courseCardsTitle {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 2px;
}

.courseCard {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: 1px solid rgba(71, 61, 49, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 252, 0.9);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

a.courseCard:hover {
  border-color: rgba(204, 120, 92, 0.5);
  box-shadow: 0 8px 22px rgba(147, 83, 62, 0.12);
}

.courseCard.placeholder {
  background: rgba(247, 246, 242, 0.7);
  border-style: dashed;
  color: var(--muted);
}

.courseIcon {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(204, 120, 92, 0.12);
  color: var(--terracotta);
  font-size: 14px;
}

.courseCard.placeholder .courseIcon {
  background: rgba(71, 61, 49, 0.07);
  color: var(--muted);
}

.courseBody {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.courseTitle {
  font-size: 14px;
  font-weight: 550;
  line-height: 1.45;
}

.courseCardNote {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.courseTag {
  flex: none;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(204, 120, 92, 0.13);
  color: var(--terracotta);
  white-space: nowrap;
}

.courseCard.placeholder .courseTag {
  background: rgba(71, 61, 49, 0.07);
  color: var(--muted);
}
