:root {
  color-scheme: dark;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #eff0f7;
  background: #11131a;
  --panel: #181b25;
  --border: #30354a;
  --muted: #b0b5c9;
  --accent: #c3b9ff;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, input, textarea, select { color: inherit; font: inherit; }
button { cursor: pointer; border-radius: 8px; border: 1px solid transparent; padding: 8px 11px; }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.primary { background: var(--accent); color: #222040; font-weight: 700; }
.subtle { background: transparent; border-color: var(--border); }
a { color: var(--accent); }
.mark { display: grid; width: 35px; height: 35px; flex: none; place-items: center; border-radius: 9px; background: #2c2845; color: var(--accent); font-weight: 750; }
.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(100%, 420px); border: 1px solid var(--border); border-radius: 17px; background: var(--panel); padding: 23px; }
h1 { font-size: 1.6rem; margin: .7em 0 .38em; letter-spacing: -.035em; }
p { color: var(--muted); line-height: 1.5; }
.login-card form { display: grid; gap: 8px; }
.login-card input, select { background: #10121a; border: 1px solid var(--border); border-radius: 8px; padding: 7px; }
.login-card input { width: 100%; padding: 10px; font-size: 1rem; }
.login-card .hint { font-size: .82rem; margin-bottom: 0; }
.chat-page { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.topbar { flex: none; background: var(--panel); display: flex; align-items: center; padding: 10px 12px; gap: 8px; border-bottom: 1px solid var(--border); }
.heading { flex: 1; min-width: 0; }
.heading strong, .heading small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.heading small { color: var(--muted); font-size: .77rem; margin-top: 2px; }
.topbar button { font-size: .77rem; min-height: 36px; }
.back-link { color: inherit; text-decoration: none; padding: 7px; border: 1px solid var(--border); border-radius: 8px; font-size: .77rem; white-space: nowrap; }
.threads { display: flex; align-items: center; gap: 8px; width: min(100%, 760px); margin: 0 auto; padding: 7px 12px; font-size: .77rem; color: var(--muted); }
.threads select { flex: 1; min-width: 0; }
.threads small { white-space: nowrap; }
.history-actions { text-align: center; padding-top: 5px; }
.history-actions:has(button[hidden]) { display: none; }
.profile-summary { display: block; color: var(--muted); font-size: .72rem; margin-top: 6px; }
.phone-profile-dialog { width: min(820px,94vw); max-height: 90dvh; color: inherit; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 15px; }
.phone-profile-dialog::backdrop { background: #060710b5; }
.phone-profile-top, .phone-profile-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.phone-profile-top h2 { margin: 0 auto 0 0; font-size: 1.15rem; }
.phone-profile-actions { margin-top: 12px; }
.profile-fieldset { display: grid; grid-template-columns: repeat(auto-fit,minmax(145px,1fr)); gap: 9px; margin: 9px 0; }
.phone-profile-dialog details { margin: 9px 0; border-top: 1px solid var(--border); padding-top: 8px; }
.phone-profile-dialog summary { cursor: pointer; font-weight: 650; }
.profile-field { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: .79rem; min-width: 0; }
.profile-field input:not([type=checkbox]), .profile-field textarea, .profile-field select { width: 100%; background: #10121a; border: 1px solid var(--border); border-radius: 7px; padding: 7px; }
.profile-field.check { flex-direction: row; align-items: center; }
.profile-wide { grid-column: 1 / -1; }
.profile-error { color: #ffbdd1; }
.engine-action { padding: 9px 12px 0; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.conversation { flex: 1; min-height: 0; overflow: auto; }
.empty { min-height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 20px; }
#messages, .composer { width: min(100%, 760px); margin: 0 auto; }
#messages { display: grid; gap: 20px; padding: 18px 12px; }
.message { min-width: 0; overflow-wrap: anywhere; }
.message.user { background: #292642; border: 1px solid #3c355d; border-radius: 13px 13px 3px 13px; padding: 10px 12px; justify-self: end; max-width: 90%; }
.message strong { display: block; font-size: .78rem; color: #b9c0d7; margin-bottom: 5px; }
.message-text, .thought { white-space: pre-wrap; line-height: 1.52; }
.trace { border-left: 2px solid #544b71; padding: 1px 0 1px 8px; margin: 8px 0; }
.trace summary { cursor: pointer; color: var(--muted); font-size: .8rem; }
.trace p, .trace a { margin: 5px 0; font-size: .8rem; display: block; }
.composer { flex: none; padding: 0 9px max(7px, env(safe-area-inset-bottom)); }
.composer form { background: var(--panel); border: 1px solid var(--border); border-radius: 13px; padding: 8px; }
.options { display: flex; gap: 6px 10px; align-items: center; flex-wrap: wrap; }
.options label { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: .74rem; }
.options select { padding: 4px 5px; }
.mode-options { margin-bottom: 6px; }
.options input[type=number] { border: 1px solid var(--border); border-radius: 7px; background: #10121a; padding: 4px; width: 7em; }
#image-steps { width: 4.2em; }
.generated-image { margin: 9px 0 0; }
.generated-image img { display: block; width: min(100%, 620px); height: auto; border-radius: 10px; background: var(--panel); }
.generated-image figcaption { color: var(--muted); font-size: .8rem; padding-top: 5px; }
.generated-image a { margin-left: 12px; }
.web input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
textarea { width: 100%; border: 0; min-height: 49px; max-height: 23dvh; resize: vertical; background: transparent; padding: 6px 2px 2px; font-size: 1rem; }
.controls { display: flex; justify-content: flex-end; align-items: center; gap: 7px; }
.controls small { min-width: 0; margin-right: auto; color: var(--muted); font-size: .75rem; }
.notice { padding: 7px 9px; border: 1px solid #704452; background: #32222d; border-radius: 7px; color: #ffbdd1; font-size: .81rem; margin-bottom: 5px; overflow-wrap: anywhere; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.diag-body { display: grid; gap: 10px; margin-top: 10px; }
.diag-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 9px; }
.diag-card { border: 1px solid var(--border); border-radius: 10px; background: #10121a; padding: 10px; display: grid; gap: 4px; }
.diag-card strong { font-size: .85rem; }
.diag-card small { color: var(--muted); font-size: .77rem; overflow-wrap: anywhere; }
.diag-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.diag-log { margin: 0; background: #10121a; border: 1px solid var(--border); border-radius: 8px; padding: 9px; max-height: 220px; overflow: auto; font-family: Consolas, monospace; font-size: .74rem; white-space: pre-wrap; overflow-wrap: anywhere; }
