:root {
  color-scheme: light;
  --ink: #142118;
  --muted: #607067;
  --paper: #f7faf5;
  --surface: #ffffff;
  --line: #dce6dd;
  --green: #167347;
  --green-dark: #0e5534;
  --green-soft: #e6f3eb;
  --amber: #d6a33a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
[hidden] { display: none !important; }
button, textarea, input { font: inherit; }
button { cursor: pointer; }
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(145deg, #edf6ef, #f9fbf8 55%, #e3f1e8); }
.login-card { width: min(100%, 420px); padding: 38px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: 0 22px 60px #10271b1f; display: grid; gap: 10px; }
.login-avatar { width: 96px; height: 96px; object-fit: contain; margin-bottom: 8px; }
.login-card h1 { color: var(--ink); }
.login-copy { margin: 2px 0 14px; color: var(--muted); line-height: 1.5; }
.login-card label { margin-top: 6px; color: var(--ink); font-size: .88rem; font-weight: 750; }
.login-card input { width: 100%; padding: 12px 13px; border: 1px solid #bdcabe; border-radius: 10px; background: white; color: var(--ink); outline: none; }
.login-card input:focus { border-color: var(--green); box-shadow: 0 0 0 3px #16734718; }
.login-error { min-height: 1.25rem; margin: 4px 0 0; color: #a7322d; font-size: .86rem; }
.primary-button { border: 0; border-radius: 10px; padding: 12px 16px; background: var(--green); color: white; font-weight: 800; }
.primary-button:hover { background: var(--green-dark); }
.primary-button:disabled { opacity: .6; cursor: wait; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 310px minmax(0, 1fr); }
.course-panel { padding: 42px 32px; background: #10271b; color: #f4faf5; display: flex; flex-direction: column; gap: 24px; }
.brand-mark { width: 112px; height: 112px; display: block; object-fit: contain; }
.eyebrow { margin: 0 0 8px; font-size: .75rem; font-weight: 800; letter-spacing: .13em; color: #89b99c; }
h1 { margin: 0; font-family: Georgia, serif; font-size: 2rem; line-height: 1.08; font-weight: 500; }
.status-card { margin-top: auto; display: grid; grid-template-columns: 12px 1fr; gap: 12px; align-items: start; padding: 16px; border: 1px solid #365343; border-radius: 14px; background: #173523; }
.status-card strong { display: block; font-size: .95rem; }
.status-card p { margin: 5px 0 0; color: #b6c8bc; font-size: .82rem; line-height: 1.4; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: #e2b651; margin-top: 4px; box-shadow: 0 0 0 4px #e2b65122; }
.status-dot.ready { background: #5bd08c; box-shadow: 0 0 0 4px #5bd08c22; }
.status-dot.error { background: #f17872; box-shadow: 0 0 0 4px #f1787222; }
.secondary-button { border: 1px solid #557565; background: transparent; color: white; border-radius: 10px; padding: 12px 14px; font-weight: 700; }
.secondary-button:hover { background: #ffffff0c; }
.secondary-button:disabled { cursor: wait; opacity: .65; }
.privacy-note { margin: 0; color: #91a99a; font-size: .78rem; line-height: 1.5; }
.chat-panel { min-width: 0; height: 100vh; display: grid; grid-template-rows: auto 1fr auto; background: var(--surface); }
.chat-header { padding: 24px 34px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.chat-header h2 { margin: 0; font-family: Georgia, serif; font-size: 1.6rem; font-weight: 500; }
.account-actions { display: flex; align-items: center; gap: 7px; }
.account-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .82rem; }
.text-button { border: 0; background: transparent; color: var(--green); font-weight: 750; padding: 10px; }
.logout-button { color: #7a3733; }
.messages { overflow-y: auto; padding: 34px max(34px, calc((100% - 850px) / 2)); }
.message { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 16px; margin-bottom: 28px; }
.message.user { grid-template-columns: minmax(0, 1fr); justify-items: end; }
.avatar { width: 64px; height: 64px; display: block; object-fit: contain; align-self: start; }
.message-body { max-width: 760px; line-height: 1.65; }
.message-body > p { margin: 4px 0 10px; white-space: pre-wrap; }
.user .message-body { background: var(--green-soft); padding: 12px 16px; border-radius: 16px 16px 3px 16px; }
.sources { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.source { margin: 7px 0; }
.source summary { cursor: pointer; color: var(--green-dark); font-weight: 750; font-size: .88rem; }
.source p { margin: 8px 0 12px; padding: 10px 12px; background: var(--paper); color: var(--muted); border-radius: 8px; font-size: .84rem; line-height: 1.55; }
.composer { margin: 18px max(24px, calc((100% - 850px) / 2)) 24px; padding: 9px 9px 9px 16px; border: 1px solid #bdcabe; border-radius: 17px; display: flex; gap: 10px; align-items: end; box-shadow: 0 8px 30px #17352312; }
.composer:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px #16734718; }
textarea { min-height: 42px; max-height: 140px; flex: 1; resize: none; border: 0; outline: 0; padding: 10px 0; color: var(--ink); background: transparent; }
.composer button { border: 0; border-radius: 10px; padding: 11px 18px; background: var(--green); color: white; font-weight: 800; }
.composer button:hover { background: var(--green-dark); }
.composer button:disabled { opacity: .55; cursor: wait; }
.typing { color: var(--muted); font-style: italic; }
.error-text { color: #a7322d; }
.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; }

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .course-panel { padding: 18px 20px; gap: 12px; }
  .course-panel h1, .privacy-note { display: none; }
  .brand-mark { width: 76px; height: 76px; }
  .status-card { margin-top: 0; }
  .chat-panel { height: calc(100vh - 180px); }
  .chat-header { padding: 16px 18px; }
  .account-name { display: none; }
  .account-actions { gap: 0; }
  .text-button { padding: 8px 6px; font-size: .82rem; }
  .messages { padding: 24px 18px; }
  .message { grid-template-columns: 54px minmax(0, 1fr); gap: 12px; }
  .avatar { width: 54px; height: 54px; }
  .composer { margin: 12px 14px 16px; }
  .login-card { padding: 28px 24px; }
}
