:root {
  --bg: #fbfaf6;
  --surface: #fffdf8;
  --rail: #f2f5ef;
  --ink: #24312b;
  --body: #37443b;
  --muted: #607165;
  --line: #dce5da;
  --accent: #285b4c;
  --accent-strong: #214a3e;
  --user: #eaf2e9;
  --focus: #b16d3e;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; color: var(--body); background: var(--bg); font: 16px/1.55 Lato, sans-serif; caret-color: var(--accent); }
button, textarea { font: inherit; }
a { color: var(--accent); text-underline-offset: .18em; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
::selection { color: var(--ink); background: #c8dfc8; }
* { scrollbar-color: var(--line) transparent; scrollbar-width: thin; }
.visuallyHidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skipLink { position: fixed; top: -60px; left: 12px; z-index: 100; padding: .6rem 1rem; background: var(--surface); }
.skipLink:focus { top: 10px; }
.chatApp { display: grid; grid-template-columns: 248px minmax(0,1fr); width: 100%; height: 100dvh; min-height: 420px; }
.chatRail { display: flex; flex-direction: column; min-width: 0; padding: 20px 14px 18px; border-right: 1px solid var(--line); background: var(--rail); }
.railTop { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 24px; }
.railBrand { display: flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font: 700 .96rem/1.1 var(--font-body); }
.railBrand img { object-fit: contain; image-rendering: pixelated; }
.railBrand small { display: block; margin-top: 4px; color: var(--muted); font-size: .69rem; font-weight: 500; }
.railClose { display: none; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); }
.railClose svg { width: 20px; height: 20px; }
.newChat { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); text-align: left; font: 700 .89rem var(--font-body); }
.newChat:hover, .railNav a:hover { background: #e5ede3; }
.mySharesButton { margin-top: 8px; }
.newChat svg { width: 20px; height: 20px; }
.railNav { display: grid; gap: 2px; margin-top: 28px; }
.railLabel { padding: 0 .75rem .55rem; color: var(--muted); font: 700 .72rem var(--font-body); }
.railNav a { display: flex; align-items: center; min-height: 42px; padding: .55rem .75rem; border-radius: 8px; color: var(--body); text-decoration: none; font: 500 .88rem var(--font-body); }
.railBottom { margin-top: auto; padding: 0 .75rem; }
.railBottom p { margin: 0 0 .85rem; color: var(--muted); font-size: .76rem; line-height: 1.5; }
.railBottom a { font: 700 .8rem var(--font-body); }
.railShade { display: none; }
.chatMain { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.glyphField { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.chatHeader { position: relative; z-index: 2; display: flex; align-items: center; gap: 12px; min-height: 66px; padding: 0 clamp(18px,3vw,42px); border-bottom: 1px solid var(--line); background: var(--bg); }
.headerTitle { display: flex; flex-direction: column; min-width: 0; }
.headerTitle strong { color: var(--ink); font: 700 .97rem var(--font-body); }
.headerTitle span { color: var(--muted); font: .74rem var(--font-body); }
.headerActions { display: flex; align-items: center; gap: 15px; margin-left: auto; }
.headerActions a { font: 700 .84rem var(--font-body); text-decoration: none; }
.headerActions a:hover { text-decoration: underline; }
.headerActions button, .menuButton { display: grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 9px; background: transparent; color: var(--ink); }
.headerActions button:hover, .menuButton:hover, .railClose:hover { background: var(--user); }
.headerActions .shareChatButton { width: auto; min-width: 92px; padding: 0 .7rem; border: 1px solid var(--line); font: 700 .78rem var(--font-body); }
.headerActions .shareChatButton:disabled { opacity: .45; cursor: not-allowed; }
.menuButton { display: none; }
.chatScroll { position: relative; z-index: 1; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; }
.chatEmpty { display: flex; flex-direction: column; justify-content: center; width: min(100%,760px); min-height: 100%; margin: 0 auto; padding: 38px 30px 54px; }
.chatEmpty[hidden] { display: none; }
.welcomeMascotStage { position: relative; width: 154px; height: 83px; margin-bottom: 13px; }
.welcomeMascot { position: absolute; bottom: 0; left: 0; display: grid; place-items: center; width: 56px; height: 56px; padding: 0; border: 0; border-radius: 8px; background: transparent; transform-origin: center bottom; }
.welcomeMascot img { display: block; width: 56px; height: 56px; image-rendering: pixelated; }
.welcomeMascot:hover img { filter: drop-shadow(0 3px 4px rgba(40,91,76,.25)); }
.welcomeMascot[data-action="jump"] { animation: mascot-jump 650ms ease-in-out; }
.welcomeMascot[data-action="move"] { animation: mascot-move 850ms ease-in-out; }
.welcomeMascot[data-action="run"] { animation: mascot-run 1000ms linear; }
@keyframes mascot-jump { 0%,100% { transform: translateY(0) scale(1); } 18% { transform: translateY(0) scale(1.1,.88); } 45% { transform: translateY(-27px) scale(.95,1.05); } 75% { transform: translateY(0) scale(1.07,.9); } }
@keyframes mascot-move { 0%,100% { transform: translateX(0); } 35%,60% { transform: translateX(38px); } }
@keyframes mascot-run { 0%,100% { transform: translate(0,0) scaleX(1); } 15% { transform: translate(18px,-4px) scaleX(1); } 30% { transform: translate(36px,0) scaleX(1); } 45% { transform: translate(56px,-4px) scaleX(1); } 58% { transform: translate(76px,0) scaleX(-1); } 72% { transform: translate(55px,-4px) scaleX(-1); } 86% { transform: translate(27px,0) scaleX(-1); } 99% { transform: translate(0,-3px) scaleX(-1); } }
.chatEmpty h1 { max-width: 670px; margin: 0; color: var(--ink); font: 700 clamp(2.15rem,4vw,3.4rem)/1.1 var(--font-body); letter-spacing: -.03em; }
.chatEmpty > p { max-width: 620px; margin: 16px 0 32px; color: var(--muted); font-size: 1rem; line-height: 1.65; }
.promptStarts { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
.promptStarts button { display: flex; flex-direction: column; gap: 7px; min-height: 115px; padding: 14px 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--body); text-align: left; }
.promptStarts button:hover { border-color: #a4c2aa; background: #f6faf4; }
.promptStarts strong { color: var(--ink); font: 700 .89rem var(--font-body); }
.promptStarts span { color: var(--muted); font-size: .81rem; line-height: 1.4; }
.chatTurns { max-width: 790px; margin: 0 auto; padding: 30px 30px 42px; }
.chatTurn { display: flex; align-items: flex-start; gap: 14px; margin: 0 0 28px; }
.chatTurn--user { justify-content: flex-end; }
.chatTurn--user .turnBody { max-width: min(85%,600px); padding: 12px 16px; border-radius: 14px; background: var(--user); }
.chatTurn--assistant .turnBody { flex: 1; min-width: 0; padding-top: 2px; }
.turnAvatar { flex: 0 0 34px; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); object-fit: contain; image-rendering: pixelated; }
.turnText { margin: 0; color: var(--ink); line-height: 1.72; white-space: pre-wrap; overflow-wrap: anywhere; }
.turnStatus { display: block; margin: 0 0 7px; color: var(--muted); font: 700 .72rem var(--font-body); }
.turnStatus--inference { color: #8a572e; }
.turnStatus--unknown, .turnStatus--error { color: #97533c; }
.turnSources { display: flex; flex-wrap: wrap; gap: 7px; margin: 13px 0 0; padding: 0; list-style: none; }
.turnSources a { display: inline-block; padding: .35rem .6rem; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--accent); font: 700 .73rem/1.35 var(--font-body); text-decoration: none; }
.turnSources a:hover { border-color: var(--accent); text-decoration: underline; }
.answerVisual { margin: 18px 0 0; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.answerVisual > img { display: block; width: 100%; max-height: 320px; object-fit: contain; background: #fff; border-radius: 8px; }
.answerVisual figcaption { margin-top: 10px; color: var(--muted); font-size: .79rem; line-height: 1.5; }
.answerVisual figcaption strong { color: var(--ink); font-weight: 700; }
.answerVisual figcaption a { overflow-wrap: anywhere; }
.figureEnlarge, .searchCurrentDocs { min-height: 38px; margin-top: 11px; padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--accent); font: 700 .8rem var(--font-body); }
.figureEnlarge:hover, .searchCurrentDocs:hover { border-color: var(--accent); }
.figureDialog { width: min(1000px,calc(100vw - 24px)); max-height: 90dvh; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); overflow: auto; }
.figureDialog::backdrop { background: rgba(8,12,16,.78); }
.figureDialogClose { display: block; margin-left: auto; padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }
.figureDialog img { display: block; max-width: 100%; max-height: 72dvh; margin: 12px auto; object-fit: contain; background: #fff; }
.figureDialog p { margin: 8px 0 0; font-size: .85rem; }
.visualKind { color: var(--muted); font: 700 .68rem var(--font-body); letter-spacing: .08em; text-transform: uppercase; }
.answerVisual h3 { margin: 5px 0 12px; color: var(--ink); font: 700 1rem var(--font-body); }
.designDiagramViewport { max-width: 100%; overflow-x: auto; }
.designDiagramViewport svg { display: block; max-width: none; color: var(--accent); }
.designEdge { stroke: var(--accent); stroke-width: 1.8; opacity: .55; }
.designNodeBox { fill: var(--bg); stroke: var(--line); stroke-width: 1.5; }
.designNodeLabel { fill: var(--ink); font: 700 15px var(--font-body); }
.comparisonViewport { max-width: 100%; overflow-x: auto; }
.comparisonViewport table { width: 100%; min-width: 480px; border-collapse: collapse; font-size: .83rem; }
.comparisonViewport th, .comparisonViewport td { padding: .65rem .7rem; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.comparisonViewport th { background: var(--bg); color: var(--ink); font: 700 .76rem var(--font-body); }
.comparisonViewport td:first-child { color: var(--ink); font-weight: 700; }
.designConnections { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line); color: var(--body); font-size: .78rem; overflow-wrap: anywhere; }
.answerNextStep, .answerLimits { margin-top: 15px; padding-left: 12px; border-left: 3px solid var(--accent); }
.answerLimits { border-color: var(--line); }
.answerNextStep strong, .answerLimits strong { display: block; color: var(--ink); font: 700 .77rem var(--font-body); }
.answerNextStep p, .answerLimits p { margin: 4px 0 0; font-size: .86rem; line-height: 1.5; }
.turnActions { display: flex; gap: 12px; margin-top: 13px; }
.turnActions button { min-height: 34px; padding: .3rem .15rem; border: 0; background: none; color: var(--muted); font: 700 .75rem var(--font-body); }
.turnActions button:hover { color: var(--accent); text-decoration: underline; }
.feedbackForm { display: grid; gap: 8px; max-width: 400px; margin-top: 9px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.feedbackForm label { color: var(--muted); font: 700 .75rem var(--font-body); }
.feedbackComment { width: 100%; min-height: 66px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); color: var(--ink); resize: vertical; font-size: .84rem; }
.feedbackForm button { justify-self: start; padding: .45rem .8rem; border: 1px solid var(--line); border-radius: 7px; background: var(--user); color: var(--ink); font: 700 .75rem var(--font-body); }
.feedbackThanks { margin: 9px 0 0; color: var(--muted); font-size: .75rem; }
.shareDialog { width: min(560px,calc(100vw - 28px)); max-height: min(84dvh,780px); padding: 25px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); color: var(--body); box-shadow: 0 24px 80px rgba(0,0,0,.24); overflow-y: auto; }
.shareDialog::backdrop { background: rgba(10,15,19,.68); }
.shareDialogHead { display: flex; justify-content: space-between; gap: 12px; }
.shareEyebrow { color: var(--muted); font: 700 .67rem var(--font-body); letter-spacing: .12em; }
.shareDialog h2 { margin: 3px 0 0; color: var(--ink); font: 700 1.5rem var(--font-body); }
.shareDialog p { margin: 13px 0 17px; color: var(--muted); font-size: .89rem; }
.shareDialogHead button { align-self: flex-start; width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); font-size: 1.8rem; line-height: 1; }
.shareDialogHead button:hover { background: var(--user); }
.shareDialog fieldset { display: grid; gap: 9px; max-height: 290px; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; overflow-y: auto; }
.shareDialog legend { padding: 0 5px; color: var(--ink); font: 700 .8rem var(--font-body); }
.sharePair { display: flex; align-items: flex-start; gap: 10px; padding: 9px; border-radius: 8px; background: var(--bg); }
.sharePair input { margin-top: 4px; accent-color: var(--accent); }
.sharePair span { min-width: 0; overflow-wrap: anywhere; font-size: .82rem; }
.sharePair strong { display: block; color: var(--ink); font: 700 .81rem var(--font-body); }
.sharePreviewQuestion,.sharePreviewAnswer { display: block; margin-top: 5px; white-space: pre-wrap; }
.sharePreviewAnswer { color: var(--muted); }
.shareAcknowledgement { display: flex; align-items: flex-start; gap: 9px; margin-top: 16px; color: var(--ink); font-size: .83rem; }
.shareAcknowledgement input { margin-top: 4px; accent-color: var(--accent); }
.shareDialogActions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 13px; }
.shareDialogActions button,.shareLinkRow button { min-height: 38px; padding: 7px 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--user); color: var(--ink); font: 700 .8rem var(--font-body); }
.shareDialogActions button[type=submit] { background: var(--accent); color: var(--bg); }
.shareDialogActions button:disabled { opacity: .45; cursor: not-allowed; }
.shareDialog .shareStatus { min-height: 1.3em; margin: 8px 0; color: var(--ink); }
.shareResult { margin-top: 15px; padding-top: 14px; border-top: 1px solid var(--line); }
.shareResult[hidden] { display: none; }
.shareResult label { color: var(--ink); font: 700 .82rem var(--font-body); }
.shareLinkRow { display: flex; gap: 7px; margin-top: 7px; }
.shareLinkRow input { flex: 1; min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); color: var(--ink); font-size: .78rem; }
.shareResult #shareRevoke { padding: 0; border: 0; background: none; color: var(--muted); text-decoration: underline; font: 700 .75rem var(--font-body); }
.manageList { display: grid; gap: 10px; }
.manageItem { padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); }
.manageItem a { display: block; overflow-wrap: anywhere; font: 700 .78rem var(--font-body); }
.manageItem p { margin: 6px 0; font-size: .76rem; }
.manageItem button { padding: 0; border: 0; background: none; color: var(--muted); font: 700 .76rem var(--font-body); text-decoration: underline; }
.composerDock { position: relative; z-index: 2; flex: 0 0 auto; padding: 15px max(24px,calc((100% - 760px)/2)) max(14px,env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg); }
.chatComposer { display: flex; align-items: flex-end; gap: 11px; min-height: 62px; padding: 9px 10px 9px 17px; border: 1px solid #b9cdbb; border-radius: 16px; background: var(--surface); box-shadow: 0 7px 24px rgba(39,58,45,.07); }
.chatComposer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(40,91,76,.11); }
.chatComposer textarea { flex: 1; max-height: 160px; min-height: 40px; padding: 8px 0; border: 0; outline: 0; resize: none; background: transparent; color: var(--ink); line-height: 1.5; overflow-y: auto; }
.chatComposer textarea::placeholder { color: #697a6e; opacity: 1; }
.chatComposer button { display: grid; place-items: center; flex: 0 0 42px; width: 42px; height: 42px; border: 0; border-radius: 11px; background: var(--accent); color: #fff; }
.chatComposer button:hover { background: var(--accent-strong); }
.chatComposer button:disabled { background: #b5c5b7; cursor: not-allowed; }
.chatComposer button[hidden] { display: none; }
.composerNote { margin: 9px 3px 0; color: var(--muted); font-size: .72rem; text-align: center; }
body.dark-mode { --bg:#161514;--surface:#201f1d;--rail:#201f1d;--ink:#f4f6f7;--body:#d5dbe0;--muted:#a8a29a;--line:#3a3733;--accent:#cf9265;--accent-strong:#fff;--user:#32302d;--focus:#e0a878; }
.dark-mode .newChat:hover, .dark-mode .railNav a:hover, .dark-mode .headerActions button:hover, .dark-mode .menuButton:hover { background: #32302d; }
.dark-mode .promptStarts button:hover { border-color: #9a948c; background: #32302d; }
.dark-mode .chatComposer button { background: #cf9265; color: #161514; }
.dark-mode .chatComposer button:hover { background: #fff; }
.dark-mode .chatComposer button:disabled { background: #3a3733; color: #d5dbe0; }
.dark-mode .chatComposer textarea::placeholder { color: #a8a29a; }
.dark-mode .turnStatus--inference { color: #efc297; }
.dark-mode .turnStatus--unknown, .dark-mode .turnStatus--error { color: #efb3a2; }
@media (max-width: 850px) {
  .chatApp { grid-template-columns: 1fr; }
  .chatRail { position: fixed; inset: 0 auto 0 0; z-index: 31; width: min(290px,82vw); transform: translateX(-105%); transition: transform 190ms ease-out; box-shadow: 12px 0 28px rgba(20,39,26,.13); }
  .chatRail.isOpen { transform: translateX(0); }
  .railClose, .menuButton { display: grid; }
  .railShade:not([hidden]) { position: fixed; inset: 0; z-index: 30; display: block; border: 0; background: rgba(12,30,18,.48); }
  .chatHeader { padding-inline: 14px; }
}
@media (max-width: 600px) {
  .chatHeader { min-height: 60px; }
  .headerTitle span { display: none; }
  .headerActions { gap: 3px; }
  .headerActions a { font-size: .78rem; }
  .chatEmpty { justify-content: flex-start; padding: clamp(55px,11vh,100px) 21px 30px; }
  .welcomeMascotStage { height: 78px; margin-bottom: 10px; }
  .welcomeMascot, .welcomeMascot img { width: 50px; height: 50px; }
  .chatEmpty h1 { font-size: 2.15rem; }
  .chatEmpty > p { margin: 14px 0 24px; font-size: .93rem; }
  .promptStarts { grid-template-columns: 1fr; gap: 0; border-top: 1px solid var(--line); }
  .promptStarts button { min-height: 65px; padding: 11px 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; }
  .promptStarts button:hover { border-color: var(--line); background: transparent; }
  .promptStarts span { font-size: .77rem; }
  .chatTurns { padding: 25px 18px 28px; }
  .chatTurn { gap: 10px; margin-bottom: 24px; }
  .chatTurn--user .turnBody { max-width: 88%; }
  .composerDock { padding: 10px 12px max(10px,env(safe-area-inset-bottom)); }
  .composerNote { font-size: .72rem; line-height: 1.35; }
}
@media (max-width: 360px) { .headerActions a { display: none; } }
@media (max-width: 360px) { .headerActions .shareChatButton { min-width: 82px; padding-inline: .4rem; } .shareDialog { padding: 18px; } }
@media (max-height: 700px) { .chatEmpty { justify-content: flex-start; } }
@media (prefers-reduced-motion: reduce) { .chatScroll { scroll-behavior: auto; } .chatRail { transition: none; } .welcomeMascot[data-action] { animation: none; } }

/* Embedded chat keeps the reading page visible behind the dialog. */
body.embedded .chatApp{grid-template-columns:minmax(0,1fr)}
body.embedded .chatRail,body.embedded .chatHeader{display:none}
body.embedded .chatMain{min-width:0}
body.dark-mode .chatComposer{border-color:#3a3733;box-shadow:0 7px 24px rgba(0,0,0,.16)}
body.dark-mode .chatComposer:focus-within{box-shadow:0 0 0 3px rgba(165,192,210,.22)}
body.dark-mode::selection{background:#3a3733;color:#fff}
