:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #f3f5f8;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.shell { max-width: 1280px; min-height: 100vh; margin: 0 auto; padding: 0 28px; display: flex; flex-direction: column; }
.topbar { height: 76px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e0e5ed; }
.brand { color: inherit; display: inline-flex; gap: 11px; align-items: center; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: white; background: #176b58; font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand small { margin-top: 2px; color: #687386; font-size: 12px; }
.account-bar { display: flex; align-items: center; gap: 14px; color: #536074; font-size: 14px; }
.login-view { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 390px; align-items: center; gap: 70px; padding: 72px 8%; }
.login-copy { max-width: 560px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 14px; font-size: clamp(32px, 5vw, 48px); letter-spacing: -0.04em; }
h2 { font-size: 22px; }
h3 { margin: 22px 0 8px; font-size: 15px; }
.login-copy > p:not(.eyebrow) { color: #596579; font-size: 18px; line-height: 1.65; }
.eyebrow { margin-bottom: 10px; color: #176b58; font-size: 12px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.privacy-note { margin-top: 28px; padding-left: 14px; border-left: 3px solid #83b9aa; font-size: 14px !important; }
.panel { border: 1px solid #e1e6ee; border-radius: 16px; background: white; box-shadow: 0 12px 32px rgb(22 34 52 / 5%); }
.login-panel { padding: 30px; }
.login-panel label, .stack-form label { display: block; margin: 15px 0 7px; color: #485469; font-size: 13px; font-weight: 650; }
input, textarea, select { width: 100%; padding: 11px 12px; border: 1px solid #d5dce6; border-radius: 8px; outline: none; background: white; color: #172033; }
input:focus, textarea:focus, select:focus { border-color: #318b74; box-shadow: 0 0 0 3px rgb(49 139 116 / 12%); }
.button { min-height: 40px; padding: 9px 16px; border: 0; border-radius: 8px; font-weight: 700; }
.button-primary { background: #176b58; color: white; }
.button-primary:hover { background: #105544; }
.button-secondary { border: 1px solid #cbd6e1; background: #f5f8fb; color: #263248; }
.button-quiet { background: transparent; color: #435168; }
.full-width { width: 100%; margin-top: 22px; }
.small { font-size: 12px; }
.muted { color: #768195; }
.error-message { min-height: 18px; margin: 8px 0 0; color: #b33434; font-size: 13px; }
.app-view { flex: 1; padding: 42px 0 30px; }
.welcome-row { display: flex; justify-content: space-between; align-items: end; margin-bottom: 22px; }
.welcome-row h1 { margin: 0; font-size: 34px; }
.knowledge-count { padding: 8px 12px; border-radius: 20px; background: #e7f2ef; color: #176b58; font-size: 12px; font-weight: 700; }
.password-panel { margin-bottom: 18px; padding: 14px 18px; }
.password-form { max-width: 430px; padding-top: 6px; }
.password-form label { display: block; margin: 12px 0 6px; color: #485469; font-size: 13px; font-weight: 650; }
.password-form .button { margin-top: 12px; }
.success-message { min-height: 18px; margin: 8px 0 0; color: #176b58; font-size: 13px; }
.chat-layout { display: grid; grid-template-columns: minmax(0, 1fr) 350px; align-items: start; gap: 20px; }
.chat-panel { min-height: 540px; padding: 22px; display: flex; flex-direction: column; }
.messages { flex: 1; max-height: 60vh; min-height: 330px; overflow-y: auto; padding: 2px 3px 16px; }
.message { width: fit-content; max-width: min(820px, 95%); margin-bottom: 15px; padding: 14px 16px; border-radius: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.message p { margin: 4px 0 0; white-space: pre-wrap; }
.assistant-message { background: #f1f5f5; }
.user-message { margin-left: auto; background: #176b58; color: white; }
.message-label { font-size: 11px; font-weight: 750; opacity: .7; }
.message-sources { margin-top: 10px; padding-top: 8px; border-top: 1px solid #dce5e2; color: #657369; font-size: 12px; }
.chat-form { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 10px; border-top: 1px solid #e7ebf0; padding-top: 15px; }
.chat-form textarea { resize: vertical; min-height: 48px; max-height: 160px; }
.chat-error { margin: 4px 0 0; }
.admin-panel { padding: 20px; }
.admin-heading h2 { margin: 0 0 14px; }
.admin-heading .eyebrow { margin: 0; }
details { padding: 13px 0; border-top: 1px solid #e8ebf0; }
summary { color: #28354a; cursor: pointer; font-size: 14px; font-weight: 700; }
.stack-form { padding-top: 4px; }
.stack-form input[type="file"] { padding: 8px; font-size: 12px; }
.stack-form textarea { resize: vertical; }
.knowledge-list { margin: 0; padding: 0; list-style: none; }
.knowledge-list li { display: flex; justify-content: space-between; align-items: start; gap: 8px; padding: 10px 0; border-top: 1px solid #eef0f4; font-size: 12px; }
.knowledge-list strong, .knowledge-list span { display: block; }
.knowledge-list span { margin-top: 4px; color: #798397; }
.delete-button { border: 0; background: none; color: #a33737; font-size: 12px; }
.footer { padding: 18px 0; border-top: 1px solid #e0e5ed; color: #8992a1; font-size: 12px; text-align: center; }
.hidden { display: none !important; }
.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: 850px) {
  .login-view { grid-template-columns: 1fr; gap: 26px; padding: 44px 4%; }
  .login-panel { max-width: 500px; width: 100%; }
  .chat-layout { grid-template-columns: 1fr; }
  .admin-panel { order: 2; }
}
@media (max-width: 520px) {
  .shell { padding: 0 16px; }
  .topbar { height: 66px; }
  .account-bar { gap: 6px; font-size: 12px; }
  .login-view { padding: 36px 0; }
  .login-panel { padding: 22px; }
  .app-view { padding-top: 30px; }
  .welcome-row { align-items: start; gap: 12px; }
  .welcome-row h1 { font-size: 27px; }
  .chat-panel { min-height: 70vh; padding: 14px; }
  .messages { min-height: 40vh; }
  .chat-form { grid-template-columns: 1fr; }
  .chat-form .button { width: 100%; }
}
