
:root {
  --accent: #5b5fc7;
  --accent-hover: #4b4fae;
  --accent-press: #3d4093;
  --page: #f5f5f5;
  --card: #fff;
  --text: #242424;
  --muted: #616161;
  --line: #e0e0e0;
  --banner: #f0f0fa;
  --error: #a4262c;
  color-scheme: light;
  --on-accent: #fff;
  --login-end: #fafafa;
  --header: #464775;
  --header-text: #fff;
  --header-muted: #e2e2f5;
  --header-border: #bbbce0;
  --header-hover: #ffffff15;
  --header-button: #fff;
  --header-button-hover: #ededfa;
  --header-button-text: #464775;
  --rail: #ebebf1;
  --rail-line: #dcdce5;
  --rail-active: #e0e0f2;
  --sidebar: #f0f0f0;
  --selected: #e3e3f5;
  --selected-hover: #dbdbf0;
  --selected-line: #d4d4ed;
  --meta: #51516c;
  --input-line: #858585;
  --composer-line: #bdbdbd;
  --disabled: #e0e0eb;
  --disabled-text: #56566b;
  --banner-line: #d1d1ed;
  --note-line: #d5d5dc;
  --emphasis: #46499c;
  --disclosure: #4f4f4f;
  --safety-text: #505062;
  --safety-line: #8f91d6;
  --user: #e8e8f9;
  --user-line: #d8d8ee;
  --error-bg: #fff4f4;
  --role: #464775;
  --warn: #6a4510;
  --shadow-card: #24242408;
  --shadow-message: #24242403;
  --shadow-composer: #24242405;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
/* Shared Teams-style dark palette: Scout can reuse these semantic variables. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --accent: #9299f7;
  --accent-hover: #a5aaff;
  --accent-press: #b8b5ff;
  --page: #1f1f1f;
  --card: #292929;
  --text: #f5f5f5;
  --muted: #c8c8c8;
  --line: #484848;
  --banner: #333244;
  --error: #ffb4b8;
  --on-accent: #171728;
  --login-end: #202020;
  --header: #29293d;
  --header-text: #f5f5f5;
  --header-muted: #d3d1ed;
  --header-border: #8683af;
  --header-hover: #ffffff15;
  --header-button: #3d3d5c;
  --header-button-hover: #48486b;
  --header-button-text: #eeedff;
  --rail: #202020;
  --rail-line: #404040;
  --rail-active: #3b3956;
  --sidebar: #242424;
  --selected: #37354e;
  --selected-hover: #42405e;
  --selected-line: #68648a;
  --meta: #c8c5de;
  --input-line: #8a8a8a;
  --composer-line: #8a8a8a;
  --disabled: #3d3d45;
  --disabled-text: #b6b6c6;
  --banner-line: #5f5c7f;
  --note-line: #404040;
  --emphasis: #c4bfff;
  --disclosure: #c8c8c8;
  --safety-text: #c8c8d8;
  --safety-line: #9299f7;
  --user: #34334f;
  --user-line: #68648a;
  --error-bg: #41282c;
  --role: #c4bfff;
  --warn: #f3cd87;
  --shadow-card: #00000040;
  --shadow-message: #00000026;
  --shadow-composer: #00000033;
}
*, *::before, *::after { box-sizing: border-box; }
html { width: 100%; -webkit-text-size-adjust: 100%; scroll-padding: 20px; }
body { margin: 0; min-width: 0; color: var(--text); background: var(--page); font: 15px/1.5 var(--font); }
button, input, textarea { font: inherit; }
a { color: var(--accent-press); }
a:focus-visible, input:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 3px;
}
.shell { width: 100%; min-width: 0; }
#login-screen[hidden], #chat[hidden] { display: none !important; }
#login-screen:not([hidden]) {
  display: grid; place-items: center; min-height: 100vh; min-height: 100dvh;
  padding: 28px 20px; border-top: 6px solid var(--accent);
  background: linear-gradient(135deg, var(--banner), var(--login-end) 65%);
}
.login-wrap { width: 100%; max-width: 420px; min-width: 0; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.brand-mark, .avatar {
  display: grid; place-items: center; flex-shrink: 0; width: 44px; height: 44px;
  background: var(--accent); color: var(--on-accent); border-radius: 12px; font-weight: 700;
}
h1, h2, p { margin-top: 0; }
.login-brand p { margin: 0; font-weight: 600; }
.login-brand small { color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
.auth-card { display: flex; flex-direction: column; gap: 20px; padding: 28px; box-shadow: 0 8px 24px var(--shadow-card); }
.auth-card h1 { font-size: 24px; line-height: 1.25; margin: 0; font-weight: 600; }
.auth-card .intro { margin: -10px 0 0; color: var(--muted); }
.disclosure { margin: 20px 0; color: var(--disclosure); font-size: 13px; line-height: 1.65; }
.disclosure strong { color: var(--emphasis); }
label { display: flex; flex-direction: column; gap: 8px; min-width: 0; font-weight: 600; }
input, textarea {
  width: 100%; min-width: 0; min-height: 44px; margin: 0; padding: 10px 12px;
  color: var(--text); background: var(--card); border: 1px solid var(--input-line); border-radius: 4px;
  font-size: 16px; font-weight: 400;
}
input:focus, textarea:focus { border-bottom: 2px solid var(--accent); }
textarea { resize: vertical; min-height: 94px; overflow-wrap: anywhere; }
button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
  min-width: 44px; padding: 9px 18px; margin: 0; border: 1px solid var(--accent);
  border-radius: 4px; background: var(--accent); color: var(--on-accent); font-weight: 600; cursor: pointer;
}
button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button:active { background: var(--accent-press); }
button:disabled, #logout:disabled { background: var(--disabled); border-color: var(--disabled); color: var(--disabled-text); cursor: not-allowed; }
#status, #chat-status {
  margin: 0; padding: 12px 16px; border: 1px solid var(--banner-line); border-radius: 6px;
  background: var(--banner); overflow-wrap: anywhere;
}
#status { margin-top: 16px; }
#status:empty, #chat-status:empty { display: none; }
#chat:not([hidden]) { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; min-width: 0; }
.app-bar { background: var(--header); color: var(--header-text); padding: 10px 22px; }
.app-bar-inner { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.app-brand { display: flex; align-items: center; gap: 12px; }
.app-brand .brand-mark { width: 32px; height: 32px; border-radius: 7px; background: var(--header-button); color: var(--header-button-text); font-size: 13px; }
.app-title { margin: 0; font-weight: 600; font-size: 17px; }
.app-subtitle { margin: 0; color: var(--header-muted); font-size: 12px; }
.app-bar-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; min-width: 0; }
.signed-in { margin: 0; font-size: 13px; }
#logout, #theme-toggle { background: transparent; color: var(--header-text); border-color: var(--header-border); }
#logout:hover, #theme-toggle:hover, #theme-toggle[aria-pressed="true"] { background: var(--header-hover); }
#new-conversation { background: var(--header-button); color: var(--header-button-text); border-color: var(--card); }
#new-conversation:hover { background: var(--header-button-hover); }
.workspace { display: grid; grid-template-columns: 76px 260px minmax(0, 1fr); flex: 1; min-width: 0; }
.app-rail { padding: 18px 6px; background: var(--rail); border-right: 1px solid var(--rail-line); }
.rail-link { display: flex; align-items: center; flex-direction: column; gap: 5px; padding: 12px 4px; border-radius: 5px; font-size: 12px; text-decoration: none; font-weight: 600; border-left: 3px solid var(--accent); background: var(--rail-active); }
.rail-link svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--line); padding: 26px 18px; min-width: 0; display: flex; flex-direction: column; gap: 28px; }
.sidebar h2 { font-size: 21px; margin: 0 8px; font-weight: 600; }
.section-label { text-transform: uppercase; letter-spacing: .07em; font-size: 11px; font-weight: 700; color: var(--muted); margin: 0 8px 10px; }
.conversation-link { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); background: var(--selected); border: 1px solid var(--selected-line); padding: 12px; border-radius: 6px; }
.conversation-link:hover { background: var(--selected-hover); }
.conversation-link .avatar { width: 36px; height: 36px; border-radius: 50%; font-size: 12px; }
.conversation-link strong { display: block; font-size: 14px; }
.conversation-link small { color: var(--meta); font-size: 12px; }
.sidebar-note { margin-top: auto; border-top: 1px solid var(--note-line); padding: 18px 8px 0; }
.sidebar-note p { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.sidebar-note strong { color: var(--emphasis); }
.history { min-width: 0; }
.history-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; }
.history-conversation { display: block; width: 100%; text-align: left; padding: 10px 12px; background: transparent; color: var(--text); border: 1px solid transparent; overflow-wrap: anywhere; }
.history-conversation:hover, .history-conversation[aria-current="true"] { background: var(--selected); border-color: var(--selected-line); }
.history-meta, #history-status { margin: 6px 0 0; color: var(--muted); font-size: 12px; font-weight: 400; overflow-wrap: anywhere; }
#history-status:empty { display: none; }
.msg details { margin-top: 12px; }
.msg summary { cursor: pointer; }
.msg pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; }
.conversation { min-width: 0; display: flex; flex-direction: column; }
.conversation-header { display: flex; align-items: center; gap: 14px; padding: 22px 32px; background: var(--card); border-bottom: 1px solid var(--line); }
.conversation-header .avatar { border-radius: 50%; }
.conversation-header h1 { margin: 0; font-size: 20px; font-weight: 600; }
.conversation-header p { margin: 3px 0 0; font-size: 13px; color: var(--muted); }
.test-badge { margin-left: auto; padding: 5px 10px; border-radius: 4px; background: var(--banner); color: var(--emphasis); font-size: 12px; font-weight: 600; white-space: nowrap; }
.canvas { width: 100%; max-width: 1080px; margin: 0 auto; padding: 24px 32px; display: flex; flex: 1; flex-direction: column; gap: 20px; min-width: 0; }
.safety-note { margin: 0; font-size: 13px; color: var(--safety-text); border-left: 3px solid var(--safety-line); padding-left: 12px; }
.thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 20px; min-width: 0; flex: 1; }
.thread-empty { margin: auto 0; padding: 40px 24px; color: var(--muted); text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.thread-empty::before { content: "Your desk conversation starts here"; display: block; margin-bottom: 12px; color: var(--text); font-size: 20px; font-weight: 600; }
.thread-empty[data-new-conversation]::before { content: "A fresh conversation"; }
.msg { width: min(90%, 760px); padding: 16px 20px; border: 1px solid var(--line); border-radius: 3px 12px 12px; background: var(--card); overflow-wrap: anywhere; min-width: 0; box-shadow: 0 2px 3px var(--shadow-message); }
.msg-user { align-self: flex-end; background: var(--user); border-color: var(--user-line); border-radius: 12px 3px 12px 12px; }
.msg-assistant { border-top: 3px solid var(--accent); }
.msg-error { background: var(--error-bg); border-left: 4px solid var(--error); }
.msg-role { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--role); }
.msg-error .msg-role { color: var(--error); }
.msg-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-warn { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--line); color: var(--warn); }
.visit-note { margin: 0; font-size: 12px; color: var(--muted); }
.composer { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-bottom: 3px solid var(--accent); box-shadow: 0 2px 8px var(--shadow-composer); }
.composer label { gap: 8px; font-size: 13px; }
.composer textarea { border-color: var(--composer-line); }
.composer-actions { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.composer-actions p { margin: 0; color: var(--muted); font-size: 12px; }
.composer button { min-width: 100px; }
@media (max-width: 1100px) {
  .workspace { grid-template-columns: 64px 215px minmax(0, 1fr); }
  .sidebar { padding: 24px 12px; }
  .conversation-header { padding: 20px 24px; }
  .canvas { padding: 24px; }
}
@media (max-width: 800px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .app-rail { display: none; }
  .sidebar { padding: 16px 20px; gap: 12px; border-bottom: 1px solid var(--line); }
  .sidebar h2, .sidebar-note { display: none; }
  .history-list { max-height: 180px; }
  .conversation-header { padding: 18px 20px; }
  .canvas { padding: 20px; }
  .msg { width: 95%; }
}
@media (max-width: 520px) {
  .app-bar { padding: 12px; }
  .app-bar-inner { align-items: flex-start; }
  .app-bar-actions { width: 100%; gap: 8px; }
  .signed-in { margin-right: auto; }
  .app-bar-actions button { padding: 8px 10px; font-size: 13px; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .app-rail { display: none; }
  .conversation-header { padding: 16px; gap: 10px; flex-wrap: wrap; }
  .conversation-header h1 { font-size: 18px; }
  .conversation-header .avatar { width: 36px; height: 36px; }
  .test-badge { margin-left: 46px; }
  .canvas { padding: 16px; gap: 16px; }
  .thread-empty { padding: 28px 16px; }
  .thread-empty::before { font-size: 18px; }
  .msg { width: 100%; padding: 14px; }
  .composer { padding: 12px; }
  .composer-actions { align-items: stretch; flex-direction: column; }
  .auth-card { padding: 24px; }
}
@media (forced-colors: active) {
  .rail-link, .conversation-link { border: 1px solid ButtonText; }
  .brand-mark, .avatar, .test-badge { border: 1px solid CanvasText; }
}

/* Markdown answer blocks; narrow tables scroll inside the message. */
.msg-assistant .msg-body { white-space: normal; }
.msg-assistant .msg-body > :first-child { margin-top: 0; }
.msg-assistant .msg-body > :last-child { margin-bottom: 0; }
.msg-body h1, .msg-body h2, .msg-body h3, .msg-body h4 { font-size: 1.05em; line-height: 1.4; margin: 1em 0 .4em; }
.msg-body p { margin: .5em 0; }
.msg-body ul, .msg-body ol { margin: .4em 0; padding-left: 1.5em; }
.msg-body li { margin: .2em 0; }
.msg-body table { border-collapse: collapse; display: block; width: max-content; max-width: 100%; overflow-x: auto; margin: .75em 0; font-size: .95em; }
.msg-body th, .msg-body td { padding: .4em .65em; border: 1px solid var(--line); text-align: left; }
.msg-body th { background: var(--banner); }
.msg-body pre { max-width: 100%; overflow: auto; white-space: pre; }
.msg-body code { font-family: ui-monospace, monospace; font-size: .92em; }
