:root {
  color-scheme: dark;
  --bg: #0e1116;
  --sidebar: #131820;
  --surface: #171d26;
  --surface-strong: #1d2530;
  --surface-hover: #252e3a;
  --text: #f4f6f8;
  --muted: #96a0ae;
  --faint: #657080;
  --line: rgba(255, 255, 255, 0.09);
  --accent: #59d0b0;
  --accent-strong: #7de2c5;
  --accent-soft: rgba(89, 208, 176, 0.13);
  --danger: #ff817c;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  --code: #0a0d11;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f7f8;
  --sidebar: #edf1f2;
  --surface: #ffffff;
  --surface-strong: #f3f6f6;
  --surface-hover: #e7ecec;
  --text: #17201f;
  --muted: #5e6d6b;
  --faint: #7a8987;
  --line: rgba(23, 32, 31, 0.11);
  --accent: #087f69;
  --accent-strong: #056552;
  --accent-soft: rgba(8, 127, 105, 0.1);
  --danger: #bf3834;
  --shadow: 0 24px 70px rgba(40, 55, 52, 0.15);
  --code: #18201f;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button, input, textarea, select { font: inherit; }
button, select, label[for] { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.app-shell { display: grid; grid-template-columns: 292px minmax(0, 1fr); height: 100dvh; }

.sidebar {
  display: flex;
  min-height: 0;
  flex-direction: column;
  padding: 20px 14px 14px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}

.brand-row { display: flex; align-items: center; gap: 11px; padding: 0 8px 21px; }
.brand-mark, .welcome-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid color-mix(in srgb, var(--accent), transparent 45%);
  background: linear-gradient(145deg, var(--accent-soft), transparent), var(--surface);
  color: var(--accent-strong);
  font-family: Georgia, serif;
  font-weight: 700;
}
.brand-mark { width: 38px; height: 38px; border-radius: 12px; font-size: 20px; }
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: 0.01em; }
.brand-subtitle { margin-top: 2px; color: var(--muted); font-size: 11px; }
.sidebar-close { display: none; margin-left: auto; }

.new-chat-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 45px;
  border: 1px solid color-mix(in srgb, var(--accent), transparent 50%);
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 680;
  transition: 160ms ease;
}
.new-chat-button:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft), var(--accent) 7%); }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 2px 8px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: color-mix(in srgb, var(--surface), transparent 25%);
  color: var(--muted);
}
.search-box:focus-within { border-color: color-mix(in srgb, var(--accent), transparent 35%); }
.search-box input { width: 100%; height: 38px; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13px; }
.search-box input::placeholder { color: var(--faint); }

.chat-list { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 1px; scrollbar-width: thin; }
.chat-empty { padding: 24px 14px; color: var(--faint); font-size: 12px; line-height: 1.5; text-align: center; }
.chat-item { position: relative; margin: 3px 0; }
.chat-item-main {
  display: block;
  width: 100%;
  overflow: hidden;
  padding: 11px 39px 11px 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-item:hover .chat-item-main { background: var(--surface); color: var(--text); }
.chat-item.active .chat-item-main { border-color: var(--line); background: var(--surface-strong); color: var(--text); }
.chat-delete {
  position: absolute;
  top: 50%; right: 6px;
  display: grid;
  width: 29px; height: 29px;
  place-items: center;
  translate: 0 -50%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  opacity: 0;
}
.chat-item:hover .chat-delete, .chat-item.active .chat-delete, .chat-delete:focus-visible { opacity: 1; }
.chat-delete:hover { background: color-mix(in srgb, var(--danger), transparent 87%); color: var(--danger); }

.sidebar-footer { display: grid; gap: 2px; padding-top: 10px; border-top: 1px solid var(--line); }
.account-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-bottom: 5px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.account-card:hover { border-color: color-mix(in srgb, var(--accent), var(--line) 55%); }
.account-avatar, .user-avatar { display: grid; place-items: center; border-radius: 10px; background: var(--accent-soft); color: var(--accent-strong); font-size: 11px; font-weight: 800; }
.account-avatar { width: 34px; height: 34px; }
.account-copy { display: grid; min-width: 0; gap: 2px; }
.account-copy strong, .account-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-copy strong { font-size: 12px; }
.account-copy small { color: var(--muted); font-size: 10px; }
.sidebar-action {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  text-align: left;
}
.sidebar-action:hover { background: var(--surface); color: var(--text); }
.file-action input { display: none; }

.main-panel { display: grid; min-width: 0; min-height: 0; grid-template-rows: 64px minmax(0, 1fr) auto; }
.topbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 23px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg), transparent 5%);
}
.icon-button {
  display: grid;
  width: 38px; height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-size: 19px;
}
.icon-button:hover { border-color: var(--line); background: var(--surface); color: var(--text); }
.menu-button { display: none; }
.settings-button { margin-left: auto; }

.model-control { display: flex; align-items: center; gap: 9px; }
.model-control label { color: var(--faint); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.model-control select {
  max-width: 240px;
  padding: 7px 30px 7px 9px;
  border: 1px solid transparent;
  border-radius: 9px;
  outline: 0;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}
.model-control select:focus { border-color: var(--accent); }
.connection-state { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #d6a848; box-shadow: 0 0 0 4px rgba(214,168,72,.1); }
.connection-state.online .status-dot { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.connection-state.offline .status-dot { background: var(--danger); box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger), transparent 88%); }

.conversation { min-height: 0; overflow-y: auto; scroll-behavior: smooth; scrollbar-width: thin; }
.welcome { display: flex; min-height: 100%; align-items: center; flex-direction: column; justify-content: center; padding: 48px 28px 36px; text-align: center; }
.welcome-mark { width: 60px; height: 60px; border-radius: 19px; box-shadow: 0 12px 40px var(--accent-soft); font-size: 31px; }
.eyebrow { margin: 18px 0 6px; color: var(--accent-strong); font-size: 11px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.welcome h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(31px, 4vw, 48px); font-weight: 500; letter-spacing: -.025em; }
.welcome-copy { max-width: 570px; margin: 14px 0 31px; color: var(--muted); font-size: 14px; line-height: 1.65; }
.prompt-grid { display: grid; width: min(100%, 790px); grid-template-columns: repeat(3, 1fr); gap: 12px; }
.prompt-card {
  display: flex;
  min-height: 139px;
  flex-direction: column;
  align-items: flex-start;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: 170ms ease;
}
.prompt-card:hover { translate: 0 -2px; border-color: color-mix(in srgb, var(--accent), transparent 50%); box-shadow: 0 14px 35px rgba(0,0,0,.09); }
.prompt-card strong { margin: auto 0 5px; font-size: 14px; }
.prompt-card > span:last-child { color: var(--muted); font-size: 12px; line-height: 1.4; }
.prompt-icon { color: var(--accent-strong); font-size: 23px; }

.messages { width: min(100%, 900px); margin: 0 auto; padding: 34px 28px 12px; }
.message { display: grid; grid-template-columns: 36px minmax(0,1fr); gap: 14px; margin: 0 0 29px; }
.message-avatar {
  display: grid;
  width: 34px; height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.message.assistant .message-avatar { border-color: color-mix(in srgb, var(--accent), transparent 55%); background: var(--accent-soft); color: var(--accent-strong); font-family: Georgia, serif; font-size: 17px; }
.message-main { min-width: 0; }
.message-meta { display: flex; align-items: center; gap: 7px; min-height: 28px; margin-bottom: 4px; }
.message-author { font-size: 13px; font-weight: 750; }
.message-actions { display: flex; gap: 2px; margin-left: auto; }
.message-action {
  min-width: 28px; height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  opacity: 0;
}
.message:hover .message-action, .message-action:focus-visible { opacity: 1; }
.message-action:hover { background: var(--surface); color: var(--text); }
.message-content { color: var(--text); font-size: 15px; line-height: 1.72; overflow-wrap: anywhere; }
.message-content > :first-child { margin-top: 0; }
.message-content > :last-child { margin-bottom: 0; }
.message-content p { margin: 0 0 1em; }
.message-content h1, .message-content h2, .message-content h3 { margin: 1.25em 0 .55em; line-height: 1.25; }
.message-content h1 { font-size: 1.45em; }
.message-content h2 { font-size: 1.25em; }
.message-content h3 { font-size: 1.08em; }
.message-content ul, .message-content ol { margin: .5em 0 1em; padding-left: 1.5em; }
.message-content blockquote { margin: 1em 0; padding: .2em 0 .2em 1em; border-left: 3px solid var(--accent); color: var(--muted); }
.message-content a { color: var(--accent-strong); text-underline-offset: 3px; }
.message-content code { padding: .13em .38em; border-radius: 5px; background: var(--surface-strong); font: .9em/1.5 "Cascadia Code", Consolas, monospace; }
.code-block { position: relative; margin: 1em 0; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--code); }
.code-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 10px 7px 14px; border-bottom: 1px solid rgba(255,255,255,.08); color: #9da8aa; font-size: 11px; }
.code-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.copy-code, .preview-code, .download-code { border: 0; border-radius: 6px; padding: 4px 7px; background: rgba(255,255,255,.07); color: #c7cdcf; cursor: pointer; font-size: 11px; }
.copy-code:hover, .preview-code:hover, .download-code:hover { background: rgba(255,255,255,.14); color: white; }
.code-block pre { margin: 0; overflow-x: auto; padding: 15px; color: #e9eeee; }
.code-block pre code { padding: 0; background: none; color: inherit; font-size: 12.5px; }
.message-images { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.image-preview, .markdown-image-button { padding: 0; border: 0; border-radius: 12px; background: transparent; cursor: zoom-in; }
.message-images img { display: block; width: min(180px, 40vw); height: 135px; border: 1px solid var(--line); border-radius: 12px; object-fit: cover; }
.markdown-image-button { display: block; max-width: 100%; margin: 1em 0; }
.markdown-image { display: block; max-width: min(100%, 720px); max-height: 540px; border: 1px solid var(--line); border-radius: 14px; object-fit: contain; }
.message-files { display: grid; gap: 7px; margin: 0 0 12px; }
.file-card { display: grid; grid-template-columns: 38px minmax(0,1fr) auto auto; align-items: center; gap: 9px; max-width: 620px; padding: 9px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.file-icon { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 9px; background: var(--accent-soft); color: var(--accent-strong); font-size: 9px; font-weight: 850; }
.file-copy { display: grid; min-width: 0; gap: 3px; }
.file-copy strong, .file-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-copy strong { font-size: 12px; }
.file-copy small { color: var(--faint); font-size: 10px; }
.file-card-action { min-height: 30px; padding: 0 9px; border: 0; border-radius: 8px; background: var(--surface-hover); color: var(--muted); cursor: pointer; font-size: 11px; line-height: 30px; text-decoration: none; }
.file-card-action:hover { color: var(--text); }
.variant-nav { display: flex; align-items: center; gap: 7px; width: max-content; margin-top: 8px; color: var(--faint); font-size: 11px; }
.variant-button { display: grid; width: 25px; height: 25px; place-items: center; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; }
.variant-button:hover { background: var(--surface); color: var(--text); }
.typing-cursor { display: inline-block; width: 8px; height: 1.15em; margin-left: 3px; vertical-align: -.18em; border-radius: 2px; background: var(--accent); animation: blink .85s infinite; }
@keyframes blink { 50% { opacity: .15; } }

.composer-wrap { position: relative; z-index: 4; padding: 8px 28px max(12px, env(safe-area-inset-bottom)); background: linear-gradient(0deg, var(--bg) 75%, transparent); }
.composer, .attachment-strip { width: min(100%, 900px); margin: 0 auto; }
.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-height: 58px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(0,0,0,.13);
}
.composer:focus-within { border-color: color-mix(in srgb, var(--accent), transparent 35%); box-shadow: 0 0 0 3px var(--accent-soft), 0 12px 34px rgba(0,0,0,.13); }
.attach-button, .send-button {
  display: grid;
  width: 42px; height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 13px;
  cursor: pointer;
}
.attach-button { background: transparent; color: var(--muted); font-size: 21px; }
.attach-button:hover { background: var(--surface-hover); color: var(--text); }
.attach-button input { display: none; }
.composer textarea { min-height: 42px; max-height: 180px; flex: 1; resize: none; border: 0; outline: 0; padding: 10px 4px 7px; background: transparent; color: var(--text); line-height: 1.5; }
.composer textarea::placeholder { color: var(--faint); }
.send-button { background: var(--accent); color: #071814; font-size: 23px; font-weight: 800; transition: 150ms ease; }
.send-button:hover { background: var(--accent-strong); transform: scale(1.03); }
.send-button:disabled { background: var(--surface-hover); color: var(--faint); cursor: default; transform: none; }
.send-button.generating { border-radius: 50%; background: var(--danger); color: white; font-size: 15px; }
.composer-note { margin: 7px auto 0; color: var(--faint); font-size: 10px; text-align: center; }
.attachment-strip { display: flex; gap: 9px; padding: 0 3px 9px; overflow-x: auto; }
.attachment { position: relative; display: grid; width: 86px; min-height: 82px; flex: 0 0 auto; justify-items: center; gap: 4px; padding: 7px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.attachment.uploading { opacity: .58; }
.attachment img { display: block; width: 66px; height: 66px; border: 1px solid var(--line); border-radius: 12px; object-fit: cover; }
.attachment-file-icon { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 10px; background: var(--accent-soft); color: var(--accent-strong); font-size: 10px; font-weight: 850; }
.attachment-name { width: 100%; overflow: hidden; color: var(--muted); font-size: 9px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.remove-attachment { position: absolute; top: -5px; right: -5px; display: grid; width: 21px; height: 21px; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--surface-strong); color: var(--text); cursor: pointer; font-size: 13px; }

.canvas-dialog { width: min(96vw, 1180px); height: min(92vh, 900px); padding: 0; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.canvas-dialog::backdrop { background: rgba(4,7,10,.78); backdrop-filter: blur(7px); }
.canvas-card { display: grid; height: 100%; grid-template-rows: auto minmax(0,1fr); }
.canvas-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.canvas-header .eyebrow { margin: 0 0 2px; }
.canvas-header h2 { max-width: min(60vw, 760px); margin: 0; overflow: hidden; font: 500 22px/1.2 Georgia, serif; text-overflow: ellipsis; white-space: nowrap; }
.canvas-actions { display: flex; align-items: center; gap: 7px; }
.canvas-stage { min-height: 0; overflow: auto; background: #f4f5f6; }
.canvas-frame { display: block; width: 100%; height: 100%; min-height: 60vh; border: 0; background: white; }
.canvas-image { display: block; max-width: 100%; max-height: 100%; margin: auto; padding: 20px; object-fit: contain; }
.canvas-text { min-height: 100%; margin: 0; padding: 24px; overflow: auto; background: #11161d; color: #edf1f2; font: 13px/1.65 "Cascadia Code", Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.canvas-loading, .canvas-error { display: grid; min-height: 55vh; place-items: center; padding: 30px; color: #58656b; text-align: center; }
.canvas-error { color: #9c3a43; }

.settings-dialog { width: min(92vw, 590px); padding: 0; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.settings-dialog::backdrop { background: rgba(4, 7, 10, .68); backdrop-filter: blur(5px); }
.settings-card { padding: 25px; }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 23px; }
.dialog-header .eyebrow { margin: 0 0 4px; }
.dialog-header h2 { margin: 0; font-family: Georgia, serif; font-size: 27px; font-weight: 500; }
.field { display: grid; gap: 8px; margin: 18px 0; }
.field > span { font-size: 13px; font-weight: 700; }
.field textarea { width: 100%; resize: vertical; border: 1px solid var(--line); border-radius: 12px; outline: 0; padding: 11px 12px; background: var(--bg); color: var(--text); line-height: 1.5; }
.field input { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 12px; outline: 0; padding: 0 12px; background: var(--bg); color: var(--text); }
.field input:focus { border-color: var(--accent); }
.field textarea:focus { border-color: var(--accent); }
.field small { color: var(--faint); line-height: 1.4; }
.range-field > span { display: flex; justify-content: space-between; }
.range-field output { color: var(--accent-strong); }
.range-field input { accent-color: var(--accent); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 25px; }
.primary-button, .secondary-button { min-height: 41px; padding: 0 16px; border-radius: 11px; cursor: pointer; font-weight: 700; }
.primary-button { border: 1px solid var(--accent); background: var(--accent); color: #071814; }
.secondary-button { border: 1px solid var(--line); background: transparent; color: var(--muted); }
.logout-button { margin-right: auto; color: var(--danger); }
.account-section { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 22px 0 2px; padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--bg); }
.account-section > div { display: grid; gap: 3px; min-width: 0; }
.account-section strong, .account-section small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-section small { color: var(--muted); }

.admin-dialog { width: min(94vw, 850px); max-height: min(90vh, 760px); padding: 0; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.admin-dialog::backdrop { background: rgba(4, 7, 10, .72); backdrop-filter: blur(6px); }
.admin-card { padding: 25px; }
.admin-create { display: grid; grid-template-columns: 1fr 1.35fr 1fr .8fr auto; align-items: end; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); }
.admin-create .field { margin: 0; }
.admin-create select, .user-role { min-height: 44px; border: 1px solid var(--line); border-radius: 11px; padding: 0 10px; background: var(--surface); color: var(--text); }
.admin-create .primary-button { min-height: 44px; }
.user-list { display: grid; gap: 7px; margin-top: 18px; }
.user-row { display: grid; grid-template-columns: 38px minmax(0, 1fr) 145px 36px; align-items: center; gap: 11px; padding: 10px; border: 1px solid var(--line); border-radius: 13px; background: var(--bg); }
.user-avatar { width: 38px; height: 38px; }
.user-identity { display: grid; min-width: 0; gap: 3px; }
.user-identity strong, .user-identity small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-identity small, .admin-loading { color: var(--muted); font-size: 11px; }
.delete-user { color: var(--danger); }
.delete-user:disabled { opacity: .25; cursor: not-allowed; }

.login-dialog { width: min(92vw, 440px); padding: 0; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.login-dialog::backdrop { background: rgba(4, 7, 10, .78); backdrop-filter: blur(7px); }
.login-card { padding: 32px; text-align: center; }
.login-mark { display: grid; width: 58px; height: 58px; margin: 0 auto; place-items: center; border: 1px solid color-mix(in srgb, var(--accent), transparent 45%); border-radius: 18px; background: var(--accent-soft); color: var(--accent-strong); font: 700 30px Georgia, serif; }
.login-card .eyebrow { margin-top: 19px; }
.login-card h2 { margin: 0; font: 500 28px/1.2 Georgia, serif; }
.login-copy { margin: 11px 0 24px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.login-copy code { color: var(--text); }
.login-card .field { text-align: left; }
.login-error { margin: 12px 0; color: var(--danger); font-size: 12px; line-height: 1.45; }
.login-button { width: 100%; margin-top: 7px; }
.login-button:disabled { opacity: .55; cursor: wait; }
.login-note { margin: 13px 0 0; color: var(--faint); font-size: 10px; }

.toast-region { position: fixed; z-index: 100; right: 18px; bottom: 18px; display: grid; gap: 9px; width: min(360px, calc(100vw - 36px)); }
.toast { padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-strong); color: var(--text); box-shadow: var(--shadow); font-size: 13px; animation: toast-in 180ms ease-out; }
.toast.error { border-color: color-mix(in srgb, var(--danger), transparent 50%); }
@keyframes toast-in { from { opacity: 0; translate: 0 8px; } }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 840px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; width: min(86vw, 310px); transform: translateX(-102%); box-shadow: var(--shadow); transition: transform 190ms ease-out; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim { position: fixed; z-index: 29; inset: 0; background: rgba(0,0,0,.54); }
  .sidebar-close, .menu-button { display: grid; }
  .main-panel { height: 100dvh; }
  .topbar { padding: 0 12px; gap: 8px; }
  .model-control label, .connection-state span:last-child { display: none; }
  .model-control select { max-width: min(45vw, 215px); }
  .prompt-grid { grid-template-columns: 1fr; }
  .prompt-card { min-height: 94px; }
  .welcome { justify-content: flex-start; padding-top: 58px; }
  .messages { padding: 25px 16px 8px; }
  .composer-wrap { padding-inline: 12px; }
  .admin-create { grid-template-columns: 1fr 1fr; }
  .admin-create .primary-button { grid-column: 1 / -1; }
}

@media (max-width: 520px) {
  .welcome { padding-inline: 17px; }
  .welcome-copy { margin-bottom: 22px; }
  .message { grid-template-columns: 29px minmax(0,1fr); gap: 10px; }
  .message-avatar { width: 29px; height: 29px; border-radius: 9px; }
  .message-content { font-size: 14px; }
  .composer-note { display: none; }
  .composer-wrap { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .account-section { align-items: stretch; flex-direction: column; }
  .admin-create { grid-template-columns: 1fr; }
  .admin-create .primary-button { grid-column: auto; }
  .user-row { grid-template-columns: 34px minmax(0, 1fr) 36px; }
  .user-role { grid-column: 2 / -1; grid-row: 2; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
