:root { color-scheme: dark; font: 16px/1.6 var(--cc-sans); color: var(--cc-ivory); background: var(--cc-midnight); --teal: var(--cc-copper); --muted: var(--cc-muted); --line: var(--cc-line); }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, textarea, select { font: inherit; }
button { min-height: 44px; padding: .65rem 1.15rem; color: #170e07; background: var(--teal); border: 1px solid var(--teal); border-radius: .65rem; cursor: pointer; font-weight: 600; }
button:hover:enabled { background: #e9ae85; }
button:disabled { opacity: .5; cursor: default; }
button span { margin-left: .65rem; }
.secondary { color: var(--teal); background: #101b2a; border-color: #8d674f; }
.secondary:hover:enabled { background: #152436; }
:focus-visible { outline: 3px solid #e9ae85; outline-offset: 4px; }
h1, h2, h3, p { margin: 0; }
.app { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem clamp(1rem, 4vw, 3.5rem); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .7rem; font-size: 1.2rem; font-weight: 700; letter-spacing: -.04em; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 2.35rem; height: 2.35rem; color: var(--teal); background: #e2e9df; border: 1px solid #bdcbbf; border-radius: .75rem; font-family: Georgia, serif; font-weight: 400; }
.trademark { font-size: .65rem; vertical-align: top; margin-left: .1rem; }
.engine-status { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; color: var(--muted); font-size: .8rem; }
.status-dot { width: .45rem; height: .45rem; flex-shrink: 0; border-radius: 50%; background: #9fa9b4; }
body[data-state="ready"] .status-dot { background: var(--teal); }
body[data-state="generating"] .status-dot, body[data-state="loading"] .status-dot { background: #e9ae85; }
body[data-state="error"] .status-dot, body[data-state="load-error"] .status-dot, body[data-state="unsupported"] .status-dot { background: #e9a594; }
.main { position: relative; min-height: 0; }
.scroll-area { height: 100%; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.conversation-width { width: min(100% - 2rem, 48rem); margin-inline: auto; }
.welcome { padding: clamp(2rem, 7vh, 4.5rem) 0 2rem; }
.eyebrow { margin-bottom: 1.25rem; color: #e9ae85; font-size: .7rem; text-transform: uppercase; letter-spacing: .16em; font-weight: 650; }
h1 { font-family: var(--cc-serif); font-size: clamp(2.1rem, 5.5vw, 3.65rem); line-height: 1.12; letter-spacing: -.045em; font-weight: 400; }
h1 em { color: var(--teal); font-weight: 400; }
.claim { margin-top: 1.2rem; font-size: .85rem; font-weight: 600; }
.claim span { display: block; color: var(--muted); font-size: .7rem; font-weight: 400; }
.welcome-copy { margin-top: 1.3rem; color: var(--muted); font-size: .95rem; }
.model-panel { padding: 1.5rem; margin: 0 0 2rem; border: 1px solid #344354; border-radius: 1rem; background: #101b2a; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.panel-heading h2 { font-size: 1rem; font-weight: 650; }
.badge { color: var(--teal); border: 1px solid #8d674f; border-radius: 2rem; font-size: .65rem; padding: .15rem .6rem; white-space: nowrap; }
.model-panel p, .device-details { font-size: .85rem; color: #b5bdc6; }
.model-label { display: block; font-size: .8rem; font-weight: 600; margin-top: 1rem; }
select { width: 100%; padding: .65rem; margin: .4rem 0 .7rem; border: 1px solid #536170; border-radius: .5rem; color: #f2e9d8; background: #101b2a; }
#model-resources { margin-bottom: .4rem; }
#model-choice-help { margin-bottom: .85rem; }
.device-details { margin: .85rem 0 1.2rem; }
summary { cursor: pointer; width: fit-content; }
.device-details p { margin-top: .5rem; }
#loading-progress { margin-top: 1rem; }
progress { width: 100%; accent-color: var(--teal); height: .6rem; }
#progress-detail { overflow-wrap: anywhere; }
.hint { color: var(--muted); font-size: .75rem; }
.messages { list-style: none; margin: 0; padding: .5rem 0 2rem; }
.messages:empty { padding: 0; }
.message { margin: 1rem 0 1.75rem; overflow-wrap: anywhere; }
.message-heading { display: flex; align-items: baseline; gap: .65rem; margin-bottom: .5rem; }
.message-heading h3 { font-size: .8rem; font-weight: 650; }
.message-heading time { font-size: .65rem; color: var(--muted); }
.message-body { white-space: pre-wrap; font-size: .95rem; line-height: 1.75; }
.message--user { margin-left: min(12%, 4rem); padding: 1rem 1.2rem; background: #152436; border: 1px solid #344354; border-radius: 1rem 1rem .2rem 1rem; }
.message--assistant { padding: .5rem 1.2rem; border-left: 2px solid #c97a4a; }
.message-state { font-size: .75rem; color: var(--muted); margin-top: .6rem; }
.message--error .message-state { color: #e9a594; }
.latest { position: absolute; bottom: .65rem; left: 50%; transform: translateX(-50%); box-shadow: 0 3px 12px #f2e9d815; white-space: nowrap; font-size: .8rem; }
.composer-area { padding: .85rem 0 max(.8rem, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #0b1220; }
.composer { border: 1px solid #536170; border-radius: 1rem; background: #101b2a; padding: .7rem; }
.composer:focus-within { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal); }
textarea { display: block; width: 100%; min-height: 3.5rem; max-height: 22vh; resize: vertical; padding: .35rem .4rem; border: 0; border-radius: .25rem; color: inherit; background: transparent; line-height: 1.5; }
textarea::placeholder { color: #9fa9b4; opacity: 1; }
textarea:focus-visible { outline-offset: 0; }
.composer-bottom { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding-top: .4rem; }
#prompt-help { color: var(--muted); font-size: .68rem; margin-left: .4rem; }
#send { min-width: 5.5rem; font-size: .85rem; }
.chat-notice { text-align: center; font-size: .7rem; color: var(--muted); margin-top: .55rem; }
.metrics { text-align: center; font-size: .65rem; color: var(--muted); }
.metrics:empty { display: none; }
footer { display: flex; justify-content: space-between; gap: .5rem; color: var(--muted); font-size: .65rem; margin-top: .8rem; }
.error-panel { padding: .8rem 1rem; margin-bottom: .75rem; border: 1px solid #a66b51; background: #291d1b; border-radius: .65rem; color: #f1b3a2; font-size: .85rem; max-height: 25vh; overflow-y: auto; }
.error-panel button { margin-top: .65rem; font-size: .8rem; }
#context-notice { margin-bottom: .5rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.noscript { position: fixed; inset: auto 1rem 1rem; padding: 1rem; background: #170e07; border: 1px solid #f1b3a2; }
@media (max-width: 540px) {
  .topbar { padding: .7rem 1rem; gap: .65rem; }
  .engine-status { font-size: .7rem; max-width: 50%; text-align: right; }
  .welcome { padding-top: 2rem; }
  .model-panel { padding: 1rem; }
  .message--user { margin-left: 1rem; }
  .message--assistant { padding-left: .85rem; }
  footer { flex-direction: column; align-items: center; gap: 0; margin-top: .45rem; }
  #prompt-help { max-width: 12rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }

/* Shared landing identity, with a quieter conversation surface. */
.brand { color: var(--cc-ivory); text-decoration: none; letter-spacing: normal; }
.message--assistant .message-heading::before { content: ""; width: 1.65rem; height: 1.65rem; align-self: center; flex: 0 0 auto; border-radius: 50%; background: url("../assets/chatchap-avatar.png") 50% 15% / 240%; }
.message-heading { align-items: center; }
.claim span { font-size: .8rem; }
.hint, .chat-notice, #prompt-help { font-size: .8rem; }
.metrics, footer, .message-heading time { font-size: .75rem; }
.model-panel a { color: var(--cc-copper-hi); text-underline-offset: .2em; }
@media (max-width: 540px) {
  .topbar { padding: .65rem .8rem; }
  .brand { gap: .5rem; }
  .wordmark { font-size: 1.35rem; }
  .brand-avatar { width: 2rem; height: 2rem; }
  .engine-status { font-size: .75rem; max-width: 45%; }
  .composer-area { padding-top: .6rem; }
  footer { font-size: .7rem; }
}

.welcome { padding: clamp(1.5rem, 3vh, 2rem) 0 1.5rem; }
h1 { font-size: clamp(2.1rem, 4.5vw, 3.25rem); }

/* Markdown is rendered only in assistant messages; user input stays literal. */
.message--assistant .message-body { white-space: normal; }
.message-body p { white-space: pre-wrap; margin: 0 0 .8rem; }
.message-body > :last-child { margin-bottom: 0; }
.message-body ul, .message-body ol { margin: .5rem 0 .8rem; padding-left: 1.5rem; }
.message-body li { margin: .25rem 0; white-space: pre-wrap; }
.message-body h4 { margin: .8rem 0 .4rem; font-size: 1rem; }
.message-body a { color: #e5af82; text-decoration: underline; text-underline-offset: .15em; }
.message-body code { font-family: ui-monospace, monospace; font-size: .88em; background: #ffffff0c; padding: .12em .3em; border-radius: .25rem; }
.message-body pre { max-width: 100%; overflow-x: auto; white-space: pre; padding: .85rem; margin: .7rem 0; background: #080d16; border: 1px solid var(--line); border-radius: .5rem; }
.message-body pre code { padding: 0; background: none; }
.message-body blockquote { margin: .7rem 0; padding-left: 1rem; border-left: 2px solid var(--muted); color: var(--muted); white-space: pre-wrap; }
