:root {
  color-scheme: dark;
  --bg: #100e16;
  --panel: #1a1722;
  --inset: #14111b;
  --ink: #f4efe8;
  --muted: #bbb1c3;
  --accent: #ff694c;
  --accent-faint: #ff826e;
  --success: #a5e9be;
  --line: #3c3449;
  --mono: 'IBM Plex Mono', Consolas, monospace;
  font-family: 'Inter', 'Segoe UI', sans-serif;
  font-size: 16px;
  background: var(--bg);
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 0; min-height: 100svh; }
a { color: var(--ink); text-underline-offset: .22em; }
button, input, select, textarea { font: inherit; }
button, summary { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent-faint); outline-offset: 4px; }

.sr-only, .skip:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip:focus { position: absolute; z-index: 5; inset: .75rem auto auto .75rem; padding: 1rem; background: var(--bg); }
.frame { width: min(78rem, calc(100% - 2 * clamp(1rem, 4vw, 3rem))); margin-inline: auto; }
.header { border-bottom: 1px solid var(--line); }
.header-row { min-height: 4.4rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.brand, .back { min-height: 2.75rem; display: inline-flex; align-items: center; text-decoration: none; }
.brand { gap: .5rem; font-weight: 760; letter-spacing: -.02em; }
.brand span { color: var(--muted); font-weight: 450; margin-inline-start: -.27rem; }
.back { gap: .48rem; color: var(--muted); font-size: .85rem; }
.back span, .footer a span { color: var(--accent-faint); }
.back:hover, .footer a:hover { color: var(--ink); }

.intro {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 2rem;
  margin-block: 0 2.2rem;
  padding-block-start: clamp(2.5rem, 6vw, 5.5rem);
  position: relative;
  isolation: isolate;
}
.intro::before {
  content: '';
  position: absolute;
  inset: 0 0 -2.2rem;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(ellipse at 62% 72%, #49252b79, transparent 57%);
  opacity: .6;
}
.kicker {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin-block-end: .9rem;
  color: var(--muted);
  font: 600 .68rem/1.3 var(--mono);
  letter-spacing: .12em;
}
.kicker span { width: 1.65rem; height: 1px; background: var(--accent); }
h1 { margin: 0; font-size: clamp(2.8rem, 7.3vw, 6.1rem); letter-spacing: -.075em; line-height: .98; font-weight: 780; }
h1 em { color: var(--accent); font-style: normal; }
.intro p { color: var(--muted); max-width: 30rem; margin: 0; font-size: clamp(.92rem, 1.5vw, 1.09rem); line-height: 1.65; }
.intro-copy p + p { margin-top: .65rem; }
.intro-copy a { color: var(--accent); text-decoration: underline; text-underline-offset: .18em; }

.workspace { display: grid; grid-template-columns: minmax(14.5rem, 18rem) minmax(0, 1fr); gap: .9rem; align-items: start; }
.settings { display: grid; gap: .9rem; min-width: 0; }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: .85rem; background: var(--panel); }
.settings .panel { padding: clamp(.96rem, 2vw, 1.25rem); }
.panel-header h2 { margin: 0; font-weight: 700; font-size: .98rem; letter-spacing: -.015em; }
.connection-state { display: flex; align-items: center; gap: .55rem; margin: 1rem 0 .4rem; font-size: .88rem; font-weight: 670; }
.connection-state::before, #composer-hint span { content: ''; flex: none; width: .5rem; height: .5rem; border-radius: 50%; background: #9488a0; }
.connection-state[data-state='working']::before, .connection-state[data-state='error']::before { background: var(--accent-faint); }
.connection-state[data-state='ready']::before, #composer-hint span { background: var(--success); }
.support { margin: .55rem 0 0; color: var(--muted); font-size: .81rem; line-height: 1.54; overflow-wrap: anywhere; }
.endpoint { display: block; margin-block-start: .8rem; color: var(--accent-faint); font: .77rem/1.3 var(--mono); }
.button { min-height: 2.75rem; padding: .64rem .92rem; border: 1px solid transparent; border-radius: .5rem; font-size: .82rem; font-weight: 720; line-height: 1.15; }
.primary { background: var(--accent); color: #211617; }
.primary:not(:disabled):hover { background: #ff8a75; }
.secondary { background: transparent; color: var(--ink); border-color: var(--line); }
.secondary:not(:disabled):hover { background: #2c2538; }
.button:disabled { opacity: .58; }
.connect { display: flex; align-items: center; justify-content: space-between; gap: .4rem; width: 100%; margin-top: .95rem; text-align: left; }
.connect span, #send span { font-size: 1rem; }
select { margin-top: .85rem; width: 100%; max-width: 100%; min-height: 2.8rem; border: 1px solid var(--line); padding: .43rem .55rem; background: var(--inset); border-radius: .45rem; color: var(--ink); font-size: .88rem; }
select:disabled { opacity: .68; }

.settings .setup { padding-block: 0; }
summary { display: list-item; padding-block: .8rem; min-height: 2.75rem; font-size: .85rem; font-weight: 650; }
summary::marker { color: var(--accent-faint); }
.setup-copy { padding-block: 0 1rem; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.setup-copy ol { margin: 0; padding-inline-start: 1.15rem; }
.setup-copy li + li { margin-top: .62rem; }
.setup-copy code { color: var(--accent-faint); font: .76rem/1.5 var(--mono); overflow-wrap: anywhere; }
.setup-origin { display: block; }

.conversation { overflow: hidden; }
.transcript-header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .65rem 1rem; border-bottom: 1px solid var(--line); }
.chat-scroll { min-height: 22rem; max-height: clamp(22rem, 53vh, 42rem); overflow-y: auto; overscroll-behavior-y: contain; background: var(--inset); }
.chat-scroll:focus-visible { outline-offset: -3px; }
.chat-empty { min-height: 22rem; display: grid; justify-items: center; align-content: center; padding: 1.65rem; text-align: center; background: radial-gradient(ellipse at 50% 50%, #261920, transparent 56%); }
.chat-empty h3 { margin: 1rem 0 .45rem; font-size: 1.12rem; font-weight: 690; letter-spacing: -.025em; }
.chat-empty p { margin: 0; max-width: 24rem; color: var(--muted); font-size: .9rem; line-height: 1.55; }
.chat-symbol { display: grid; place-items: center; width: 3.7rem; aspect-ratio: 1; border: 1px solid #7b433e; border-radius: .86rem; background: #342029; color: var(--accent-faint); font: 600 1.43rem/1 var(--mono); box-shadow: 0 0 42px #f6674120; }
.messages { list-style: none; display: grid; gap: 1rem; padding: 1.2rem; margin: 0; }
.messages:empty { display: none; }
.message { min-width: 0; padding: .95rem 1rem; border: 1px solid var(--line); border-radius: .6rem; }
.message.user { margin-left: min(6vw, 3rem); background: #282032; }
.message.assistant { margin-right: min(6vw, 3rem); background: #1d1926; }
.message-heading { margin: 0 0 .5rem; color: var(--muted); font: 700 .72rem/1.35 var(--mono); overflow-wrap: anywhere; }
.message.assistant .message-heading { color: var(--accent-faint); }
.message-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .93rem; line-height: 1.64; }

.composer { border-top: 1px solid var(--line); display: grid; gap: .55rem; padding: .82rem 1rem 1rem; }
textarea { resize: vertical; width: 100%; min-height: 4rem; max-height: 16rem; border: 1px solid var(--line); border-radius: .52rem; background: var(--inset); padding: .7rem .8rem; color: var(--ink); line-height: 1.45; }
textarea:disabled { opacity: .65; }
textarea::placeholder { color: var(--muted); }
.composer-end { display: flex; align-items: center; justify-content: end; gap: .5rem; }
#composer-hint { flex: 1; display: flex; align-items: baseline; gap: .55rem; margin: 0; color: var(--muted); font-size: .74rem; line-height: 1.45; }
#composer-hint span { align-self: center; width: .42rem; height: .42rem; }
#send { min-width: 5.1rem; }
.chat-status { margin: 0; color: var(--muted); font-size: .78rem; line-height: 1.45; }
.chat-status:empty { display: none; }
.chat-status[data-error='true'] { color: #ff9c8f; }
.noscript { margin: 0; padding: 1rem; color: var(--accent-faint); }
.footer { min-height: 5rem; display: flex; justify-content: space-between; align-items: center; gap: .65rem; color: var(--muted); font-size: .8rem; padding-bottom: env(safe-area-inset-bottom); }
.footer a { display: inline-flex; align-items: center; min-height: 2.75rem; gap: .35rem; color: var(--muted); }

@media (max-width: 54rem) {
  .intro { align-items: start; flex-direction: column; gap: 1rem; }
}
@media (max-width: 42rem) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .settings { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings .setup { grid-column: 1 / -1; }
}
@media (max-width: 30rem) {
  .brand span { display: none; }
  .settings { grid-template-columns: minmax(0, 1fr); }
  .intro { margin-bottom: 1.45rem; }
  .chat-scroll, .chat-empty { min-height: 16.5rem; }
  .messages { padding: .8rem; }
  .message.user { margin-left: .75rem; }
  .message.assistant { margin-right: .75rem; }
  .conversation textarea { font-size: 1rem; }
}
