:root { color-scheme: light; font: 16px/1.65 system-ui, -apple-system, sans-serif; color: #102039; background: #fff; --paper:#fff; --soft:#f5f7fa; --muted:#586b83; --line:#dce3ed; --navy:#082348; --on-navy:#fff; }
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; }
button, a { touch-action: manipulation; }
button, .primary { min-height: 44px; border: 1px solid var(--line); border-radius: 7px; padding: .55rem .9rem; background: var(--paper); color: inherit; cursor: pointer; }
button:hover { background: var(--soft); }
button:disabled { opacity: .6; cursor: wait; }
button:focus-visible, textarea:focus-visible, a:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 3px solid #477cbb; outline-offset: 3px; }
a { color: inherit; text-underline-offset: 3px; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.skip { position:absolute; top:-100px; left:1rem; z-index:5; background:var(--paper); padding:.7rem; }
.skip:focus { top:0; }
.chat { height:100dvh; height:var(--viewport-height, 100dvh); display:flex; flex-direction:column; overflow:hidden; }
.topbar { min-height:76px; display:flex; align-items:center; gap:14px; padding:12px 22px; border-bottom:1px solid var(--line); }
.brand { display:flex; align-items:center; gap:10px; text-decoration:none; font-weight:650; font-size:14px; }
.brand img { width:28px; height:28px; object-fit:contain; background:white; border-radius:6px; }
.role-label { margin-left:auto; color:var(--muted); font-size:12px; }
#saved { border:0; padding:10px; width:44px; height:44px; display:grid; place-items:center; }
#saved svg { width:20px; height:20px; }
.shell { flex:1; min-height:0; display:flex; }
.sidebar { flex:0 0 232px; min-width:0; display:flex; flex-direction:column; background:var(--soft); border-right:1px solid var(--line); padding:16px 12px; overflow:auto; }
.sidebar h2 { font-size:12px; color:var(--muted); font-weight:500; margin:22px 8px 8px; }
.sidebar button { text-align:left; border:0; background:transparent; width:100%; font-size:13px; overflow-wrap:anywhere; }
#conversation-list { flex:1; overflow:auto; min-height:80px; }
#conversation-list button[aria-current=true] { background:var(--paper); }
.account { border-top:1px solid var(--line); padding:16px 8px 0; font-size:13px; overflow-wrap:anywhere; }
#identity strong, #identity span { display:block; }
#identity-email { color:var(--muted); font-size:12px; }
#login { display:inline-block; padding:.6rem 0; }
.conversation { flex:1; min-width:0; min-height:0; display:flex; flex-direction:column; }
.thread-scroll { overflow:auto; overscroll-behavior:contain; flex:1; min-height:0; scroll-padding:20px; }
.thread { width:100%; max-width:760px; padding:32px 28px 16px; margin:0 auto; }
#welcome { padding:clamp(24px,9vh,110px) 0 24px; }
h1 { font-size:clamp(26px,4vw,34px); line-height:1.2; font-weight:600; letter-spacing:-.035em; margin:0 0 18px; }
#welcome p { color:var(--muted); max-width:520px; }
.message { margin:0 0 30px; overflow-wrap:anywhere; }
.message > strong { font-size:12px; color:var(--muted); font-weight:500; }
.message.user { max-width:86%; width:fit-content; margin-left:auto; padding:12px 18px; background:var(--soft); border-radius:18px; }
.message p { white-space:pre-wrap; margin:8px 0 16px; }
.message p:last-child { margin-bottom:0; }
.table-scroll { max-width:100%; overflow:auto; }
table { border-collapse:collapse; font-size:14px; min-width:420px; width:100%; }
th, td { border-bottom:1px solid var(--line); padding:12px 10px; text-align:left; vertical-align:top; white-space:pre-wrap; }
.proposal { border-top:1px solid var(--line); padding:20px 0; }
.proposal h2 { font-size:16px; font-weight:600; margin:0 0 6px; }
.proposal p, .readback-note { color:var(--muted); font-size:13px; }
.summary { margin:12px 0; }
.summary > div { display:grid; grid-template-columns:minmax(100px,1fr) minmax(0,1.5fr); gap:16px; border-bottom:1px solid var(--line); padding:10px 0; font-size:14px; }
.summary dt { color:var(--muted); }
.summary dd { margin:0; overflow-wrap:anywhere; white-space:pre-wrap; }
.summary .summary > div { display:block; }
details { margin:14px 0; }
summary { cursor:pointer; min-height:44px; padding:8px 0; }
#records:empty, #proposals:empty { display:none; }
#records { border-top:1px solid var(--line); margin-top:20px; }
#records a { display:block; padding:12px 0; }
#refresh { font-size:13px; margin:12px 0; }
.composer-wrap { width:100%; max-width:790px; margin:0 auto; padding:8px 28px max(18px,env(safe-area-inset-bottom)); flex-shrink:0; }
#status { color:var(--muted); font-size:13px; margin:0 0 8px; max-height:18dvh; overflow:auto; }
#status:empty { display:none; }
#composer { border:1px solid var(--line); border-radius:18px; padding:14px 16px 10px; background:var(--paper); }
textarea { display:block; width:100%; border:0; color:inherit; background:transparent; resize:vertical; min-height:52px; max-height:20dvh; font-size:16px; line-height:1.6; padding:0; }
.compose-bottom { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:8px; }
.compose-bottom small { color:var(--muted); font-size:11px; }
#send, .primary { background:var(--navy); color:var(--on-navy); border-color:var(--navy); }
#retry { margin-bottom:8px; }
.recovery main { max-width:580px; margin:12vh auto; padding:24px; }
.recovery p { color:var(--muted); }
.recovery .primary { display:inline-block; text-decoration:none; }
@media(max-width:640px) {
 .topbar { min-height:64px; padding:8px 12px; gap:8px; }
 .sidebar { position:absolute; z-index:3; top:64px; bottom:0; width:min(280px,85vw); box-shadow:8px 0 24px #10203920; }
 .thread { padding:24px 20px 12px; }
 .composer-wrap { padding:8px 12px max(12px,env(safe-area-inset-bottom)); }
 .message.user { max-width:95%; }
 .summary > div { grid-template-columns:1fr; gap:3px; }
 .compose-bottom small { max-width:210px; }
}
@media(prefers-color-scheme:dark) {
 :root { color-scheme:dark; color:#e9eff9; background:#101d30; --paper:#101d30; --soft:#192a40; --muted:#aabbd1; --line:#34455d; --navy:#dae8ff; --on-navy:#082348; }
}
@media(prefers-reduced-motion:reduce) { * { scroll-behavior:auto !important; } }
.order-editor { margin:1rem 0; padding:1rem; border:1px solid var(--line); border-radius:1rem; }
.order-editor label { display:block; margin:.7rem 0; }
.order-editor input,.order-editor select { display:block; width:100%; margin-top:.3rem; padding:.6rem; font:inherit; color:inherit; background:var(--paper); border:1px solid var(--line); border-radius:.4rem; }
.order-editor fieldset,.order-condition { margin:1rem 0; padding:.7rem; border:1px solid var(--line); }
.order-condition p { overflow-wrap:anywhere; }
