:root {
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #252c28;
  background: #fff;
  font-synthesis: none;
  --accent: #dc2616;
  --accent-hover: #bd2012;
  --accent-soft: #fcece9;
  --line: #e8e6e3;
  --muted: #747e78;
  --content-width: 1280px;
  --gutter: clamp(20px, 4vw, 64px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; }
button, textarea, select { font: inherit; }
button, summary, select { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
button, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, summary:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 24px; min-height: 92px; padding: 16px 32px; border-bottom: 1px solid var(--line); }
.brand { margin: 0; font-size: 18px; font-weight: 450; line-height: 1.4; letter-spacing: -.55px; }
.brand-name { white-space: nowrap; }
.brand-name strong { color: var(--accent); font-size: 25px; font-weight: 800; letter-spacing: -.8px; }
.brand-client { display: block; font-size: 13px; font-weight: 400; letter-spacing: 0; }
.corridor { text-align: center; }
.corridor label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; }
.route { max-width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; background: #fafaf9; color: #414a44; font-size: 13px; }
.new-chat { justify-self: end; display: flex; align-items: center; gap: 9px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 9px; color: #535e57; background: #fff; font-size: 12px; }
.new-chat svg { width: 17px; height: 17px; }
.new-chat:hover:not(:disabled) { border-color: #e7b9b1; color: var(--accent); background: #fffaf9; }
.workspace { min-height: 0; min-width: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.chat-scroll { position: relative; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; overflow-anchor: none; scrollbar-width: thin; scrollbar-color: #d7d9d6 transparent; padding: 0 max(var(--gutter), calc((100% - var(--content-width)) / 2)); }
.chat-scroll:focus-visible { outline-offset: -3px; }
.welcome { min-height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 23px; padding: 36px 0 50px; text-align: center; }
.welcome-mark { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); }
.welcome-mark svg { width: 27px; height: 27px; }
.welcome h2 { max-width: 720px; margin: 0; font-size: clamp(28px, 3.2vw, 44px); font-weight: 600; line-height: 1.22; letter-spacing: -1.6px; text-wrap: balance; }
.welcome h2 span { color: var(--accent); }
.compose-wrap { width: 100%; max-width: calc(var(--content-width) + 2 * var(--gutter)); margin: 0 auto; padding: 12px var(--gutter) 14px; background: #fff; }
.examples-wrap { display: grid; grid-template-rows: 1fr; opacity: 1; transition: grid-template-rows 160ms ease, opacity 120ms ease, transform 160ms ease; }
.examples-wrap.is-hidden { grid-template-rows: 0fr; opacity: 0; transform: translateY(5px); pointer-events: none; }
.examples-inner { min-height: 0; overflow: hidden; }
.examples-label { margin: 0 0 10px 2px; font-size: 12px; color: var(--muted); }
.examples { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 3px 3px 17px; }
.examples button { min-width: 0; text-align: left; padding: 15px 18px; background: #fcfcfb; color: #444d47; border: 1px solid var(--line); border-radius: 13px; transition: background 120ms, border-color 120ms; }
.examples button:hover { background: #fff8f6; border-color: #e6b6ae; }
.examples button:focus-visible { outline-offset: 1px; }
.example-label { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 10px; font-weight: 600; color: var(--muted); letter-spacing: .4px; }
.example-label span { color: var(--accent); font-size: 17px; line-height: 1; }
.example-prompt { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: 14px; line-height: 1.55; }
#chat-form { position: relative; display: flex; align-items: flex-end; gap: 12px; border: 1px solid #dbdfda; border-radius: 17px; padding: 10px 10px 32px; background: #fff; box-shadow: 0 3px 16px #242c2806; transition: border-color 120ms, box-shadow 120ms; }
#chat-form:focus-within { border-color: #dc8277; box-shadow: 0 0 0 3px #dc26160a; }
.draft-editor { flex: 1; min-width: 0; position: relative; }
textarea, .draft-overlay { font: inherit; font-size: 16px; line-height: 24px; padding: 10px 12px; white-space: pre-wrap; overflow-wrap: break-word; }
.draft-overlay { position: absolute; inset: 0; overflow: hidden; pointer-events: none; color: transparent; }
.rule-mention { color: var(--accent); background: #dc261610; border-radius: 3px; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.draft-overlay .rule-mention { pointer-events: auto; }
.rule-card.referenced { outline: 2px solid var(--accent); }
textarea { display: block; width: 100%; min-width: 0; height: 44px; min-height: 44px; max-height: min(360px, 40dvh); resize: none; border: 0; outline: 0; background: transparent; color: #303932; scrollbar-width: thin; }
textarea::placeholder { color: #929994; }
.send { flex: 0 0 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 11px; background: var(--accent); color: #fff; transition: background 120ms, opacity 120ms; }
.send:hover:not(:disabled) { background: var(--accent-hover); }
.send[aria-label="Assessing your message"] svg { animation: pulse 1.4s ease-in-out infinite; }
.input-footer { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin: 10px 3px 0; font-size: 10px; line-height: 1.5; color: var(--muted); }
#input-hint { flex-shrink: 0; }
.error { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-height: 95px; overflow: auto; margin-bottom: 10px; padding: 10px 14px; border: 1px solid #efc7c1; border-radius: 10px; background: #fff6f4; color: #a22c20; font-size: 13px; line-height: 1.5; }
.error button { flex-shrink: 0; border: 1px solid #e7b9b1; border-radius: 6px; padding: 5px 10px; background: #fff; color: inherit; font-size: 12px; }
.exchange { padding: 28px 0 40px; }
/* Leave enough room to align every new user message at the top, even while loading. */
.exchange:last-child { min-height: 100%; }
.user-message { width: fit-content; max-width: min(86%, 900px); margin: 0 0 26px auto; padding: 14px 20px; border: 1px solid #f2ded9; border-radius: 17px 5px 17px 17px; background: #fcf0ed; }
.user-message p { margin: 0; font-size: 14px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.assistant-reply { margin: 0 0 16px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.assessment { min-width: 0; }
.assistant-avatar { flex-shrink: 0; display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid #f3d4ce; border-radius: 11px; background: var(--accent-soft); color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: -.3px; }
.pending, .failed { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.pending .assistant-avatar { animation: pulse 1.5s ease-in-out infinite; }
.failed { color: #a22c20; }
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.column { min-width: 0; padding: 15px 12px 7px; border: 1px solid #e0e8e2; border-radius: 13px; background: #f5f8f5; }
.column.problematic { border-color: #efdfdb; background: #fdf5f3; }
.column.needs_info { border-color: #ebe5d6; background: #faf8f1; }
.column-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 3px; }
.column-heading h3 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; font-weight: 600; }
.status-icon { display: grid; place-items: center; width: 21px; height: 21px; border-radius: 50%; background: #e0ede3; color: #39734b; font-size: 12px; }
.problematic .status-icon { background: #fbe1dc; color: #bc3020; }
.needs_info .status-icon { background: #f0e8d0; color: #866923; }
.count { padding: 3px 7px; border-radius: 5px; background: #ffffffa6; color: #667269; font-size: 11px; }
.column-note { margin: 9px 3px 14px; color: #737c75; font-size: 11px; line-height: 1.5; }
.rule-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; margin-bottom: 8px; padding: 13px 12px; border: 1px solid #e3e6df; border-radius: 8px; background: #fff; color: #3c473f; text-align: left; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.rule-card::after { content: ''; flex: none; width: 6px; height: 6px; border: solid #89938c; border-width: 1.5px 1.5px 0 0; transform: rotate(45deg); }
.rule-card:hover { background: #fffaf9; border-color: #e7b9b1; }
#rule-dialog { width: min(780px, calc(100% - 32px)); max-height: min(84dvh, 860px); padding: 0; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 24px 80px #18231c33; color: inherit; }
#rule-dialog[open] { display: flex; flex-direction: column; }
#rule-dialog::backdrop { background: rgb(26 32 29 / 55%); }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: clamp(16px, 3vw, 30px); border-bottom: 1px solid var(--line); }
.dialog-heading h2 { margin: 5px 0 0; font-size: clamp(19px, 3vw, 26px); line-height: 1.25; }
.dialog-actions { display: flex; gap: 8px; flex-shrink: 0; }
#chat-rule { background: var(--accent); border: 0; border-radius: 8px; color: white; padding: 9px 14px; }
@media (max-width: 700px) { .dialog-heading { flex-direction: column; } }
.dialog-close { border: 1px solid var(--line); border-radius: 8px; background: white; color: inherit; padding: 9px 14px; }
.card-body { padding: 0 clamp(16px, 3vw, 30px) 24px; overflow-y: auto; overscroll-behavior: contain; font-size: 15px; line-height: 1.65; overflow-wrap: anywhere; }
.rule-meta { color: var(--muted); font-size: 12px; }
.card-body h3 { margin: 20px 0 6px; font-size: 14px; }
.card-body p { margin: 0; }
.card-body blockquote { margin: 6px 0; padding: 8px 12px; border-left: 2px solid #d3dcd3; background: #f7f8f5; }
.question { padding: 12px; margin-top: 16px; border-radius: 6px; background: #faf6e9; }
.question h3 { margin-top: 0; color: #80682e; }
.rule-content { margin: 0; padding: 12px; border-radius: 6px; background: #f7f8f5; font: inherit; font-size: 14px; white-space: pre-wrap; }
.empty-column { padding: 28px 12px; margin: 0 0 8px; color: #7a837b; font-size: 12px; line-height: 1.7; text-align: center; }
.disclaimer { display: flex; justify-content: center; gap: 7px; padding: 10px 20px; color: #7e8680; background: #fafbf9; border-top: 1px solid #f0efec; font-size: 10px; line-height: 1.4; text-align: center; }
.disclaimer strong { font-weight: 500; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
@keyframes pulse { 50% { opacity: .4; } }
@media (max-width: 1000px) {
  .topbar { grid-template-columns: minmax(0, 1fr) auto auto; gap: 20px; padding-inline: 24px; }
  .brand { font-size: 16px; }
  .brand-name strong { font-size: 22px; }
  .board { gap: 10px; }
  .column { padding-inline: 9px; }
  .column-heading h3 { gap: 5px; font-size: 12px; }
  #input-hint { display: none; }
}
@media (max-width: 700px) {
  :root { --gutter: 18px; }
  .topbar { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 14px 18px 12px; }
  .brand { font-size: 15px; letter-spacing: -.6px; }
  .brand-name strong { font-size: 21px; }
  .brand-client { font-size: 11px; }
  .new-chat { grid-column: 2; grid-row: 1; padding: 9px; }
  .new-chat span { display: none; }
  .corridor { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 12px; }
  .corridor label { margin: 0; font-size: 9px; }
  .route { padding: 6px 8px; font-size: 12px; }
  .welcome { gap: 16px; padding-block: 28px; }
  .welcome h2 { max-width: 480px; font-size: 30px; letter-spacing: -1px; }
  .welcome-mark { width: 42px; height: 42px; border-radius: 12px; }
  .welcome-mark svg { width: 22px; height: 22px; }
  .examples { gap: 8px; }
  .examples-label { font-size: 11px; }
  .examples button { padding: 12px; border-radius: 10px; }
  .example-label { font-size: 9px; letter-spacing: 0; }
  .example-prompt { font-size: 12px; -webkit-line-clamp: 3; }
  .compose-wrap { padding-top: 8px; padding-bottom: 10px; }
  .input-footer { margin-top: 7px; font-size: 9px; }
  .exchange { padding-top: 20px; }
  .user-message { max-width: 94%; padding: 12px 15px; }
  .user-message p { font-size: 13px; }
  .board { grid-template-columns: 1fr; }
  .column { padding: 14px 12px 6px; }
  .column-heading h3 { font-size: 14px; }
  .column-note { margin-bottom: 10px; }
  .empty-column { padding: 15px 10px; }
  .disclaimer { padding: 8px 12px; font-size: 9px; }
  .disclaimer > span { display: none; }
}
@media (max-width: 440px) {
  .examples { grid-template-columns: 1fr; gap: 7px; padding-bottom: 12px; }
  .examples button { padding: 9px 12px; }
  .example-label { margin-bottom: 3px; font-size: 8px; }
  .example-label span { font-size: 12px; }
  .example-prompt { -webkit-line-clamp: 1; }
  .welcome h2 { font-size: 27px; }
  #chat-form { gap: 4px; padding-inline: 7px; padding-top: 7px; }
  textarea, .draft-overlay { padding-inline: 8px; }
}
@media (max-height: 650px) {
  .topbar { min-height: 70px; padding-block: 10px; }
  .welcome { padding-block: 20px; gap: 12px; }
  .welcome-mark { display: none; }
  .welcome h2 { font-size: 28px; }
  .examples-label { display: none; }
  .examples button { padding-block: 9px; }
  .example-prompt { -webkit-line-clamp: 1; }
  textarea { max-height: 30dvh; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

#message-count { position: absolute; right: 12px; bottom: 8px; font-size: 11px; color: var(--muted); }
#message-count.over-limit, #message-limit-error { color: #a22c20; }
#message-limit-error { margin: 6px 3px 0; font-size: 12px; }
