body {
  --bg: var(--bg-color); --side: var(--glass-bg); --text: var(--text-color); --muted: color-mix(in srgb, var(--text-color) 65%, transparent);
  --line: var(--input-border); --bubble: var(--glass-bg); --code: var(--glass-bg); --card: var(--glass-bg);
  --accent: var(--primary-color); --accent-text: #ffffff; --tint: var(--glass-bg);
  --danger: #ff7675; --danger-tint: rgba(255, 118, 117, 0.1); --warn: var(--secondary-color); --warn-tint: var(--glass-bg);
}
body.dark-mode { --accent-text: #10102a; }
input, textarea { caret-color: auto; cursor: text; }
a, button, select, label, summary { cursor: pointer; }
h1, h2, h3, h4 { font-family: var(--font-heading); }
.login-card { width: 100%; max-width: 480px; margin: 18vh auto 0; text-align: center; }
.login-card:hover, .card:hover { transform: none; }
.login-card h2 { margin-bottom: 14px; }
.login-card p { margin-bottom: 20px; opacity: .85; }
.login-card .neon-button { width: 100%; justify-content: center; }
.login-status { margin: 14px 0 6px !important; color: var(--danger); }
.login-status:empty { display: none; }
.plain-link { color: var(--muted); font-size: .875rem; text-decoration: none; }
.plain-link:hover { text-decoration: underline; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
#login-view { margin-left: auto; margin-right: auto; }
.top-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.nav-logout { padding: 4px 12px; font-size: .85rem; border-color: #ff7675; color: #ff7675; }
[hidden] { display: none !important; }
button, select, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.primary { padding: 10px 16px; font-weight: 600; color: var(--accent-text); background: var(--accent); border: 0; border-radius: 8px; cursor: pointer; }
.plain-link { color: var(--muted); font-size: .875rem; text-decoration: none; }
.plain-link:hover { text-decoration: underline; }


.app { display: flex; height: 100dvh; }
.sidebar { display: flex; flex-direction: column; flex: 0 0 260px; width: 260px; min-width: 0; overflow: hidden; gap: 10px; padding: 12px; background: var(--side); border-right: 1px solid var(--line); }
.new-chat { padding: 9px 12px; text-align: left; font-weight: 600; background: transparent; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.new-chat:hover, .chat-item:hover { background: var(--bubble); }
.chat-list { flex: 1; min-height: 0; overflow-y: auto; }
.chat-item { display: flex; align-items: center; border-radius: 8px; }
.chat-item.active { background: var(--bubble); }
.chat-open { flex: 1; min-width: 0; padding: 7px 8px; overflow: hidden; text-align: left; font-size: .9rem; white-space: nowrap; text-overflow: ellipsis; background: none; border: 0; cursor: pointer; }
.chat-delete { padding: 4px 8px; color: var(--muted); background: none; border: 0; cursor: pointer; }
.side-foot p { margin: 6px 0 0; color: var(--muted); font-size: .75rem; }
.scrim { display: none; }

.main { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.picker { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: .85rem; color: var(--muted); }
.picker select { max-width: 200px; padding: 4px 6px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
.icon-button { flex: none; width: 38px; height: 38px; padding: 0; background: none; border: 0; border-radius: 8px; cursor: pointer; }
.icon-button:hover { background: var(--bubble); }
.menu { display: none; }

.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 16px; }
.generated, .attachment-thumb { background: #fff; }
.message { max-width: 760px; margin: 0 auto 22px; overflow-wrap: anywhere; }
.message.user { display: flex; flex-direction: column; align-items: flex-end; }
.user .bubble { max-width: 85%; padding: 8px 14px; white-space: pre-wrap; background: var(--bubble); border-radius: 16px; }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100%; text-align: center; }
.empty h1 { margin: 0 0 18px; font-size: 1.7rem; }
.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.suggestions button { padding: 8px 12px; font-size: .9rem; background: none; border: 1px solid var(--line); border-radius: 18px; cursor: pointer; }
.suggestions button:hover { background: var(--bubble); }

.status { color: var(--muted); font-size: .9rem; }
.error { color: var(--danger); }
.body > :first-child { margin-top: 0; }
.body > :last-child { margin-bottom: 0; }
.body h1, .body h2, .body h3, .body h4 { margin: 1.1em 0 .4em; line-height: 1.3; }
.body h1 { font-size: 1.4rem; } .body h2 { font-size: 1.25rem; } .body h3 { font-size: 1.1rem; } .body h4 { font-size: 1rem; }
.body p { margin: .6em 0; }
.body ul, .body ol { margin: .6em 0; padding-left: 1.5em; }
.body a { color: var(--accent); }
.body blockquote { margin: .6em 0; padding-left: 12px; color: var(--muted); border-left: 3px solid var(--line); }
.body hr { border: 0; border-top: 1px solid var(--line); }
.body code { padding: 1px 4px; font: .9em ui-monospace, Menlo, Consolas, monospace; background: var(--code); border-radius: 4px; }
.codeblock { position: relative; margin: .7em 0; }
.codeblock pre { margin: 0; padding: 12px; overflow-x: auto; background: var(--code); border: 1px solid var(--line); border-radius: 8px; }
.codeblock code { padding: 0; background: none; }
.copy-code { position: absolute; top: 6px; right: 6px; padding: 2px 8px; font-size: .75rem; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.table-wrap { margin: .7em 0; overflow-x: auto; }
.body table { border-collapse: collapse; }
.body th, .body td { padding: 5px 10px; text-align: left; border: 1px solid var(--line); }

.generated { display: block; max-width: min(100%, 512px); margin: 10px 0 4px; border-radius: 10px; }
.generating { opacity: .6; }
.files, .chips, .sources { display: flex; flex-wrap: wrap; gap: 6px; }
.files { margin-top: 10px; }
.file-chip, .chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 6px 10px; font-size: .85rem; color: inherit; text-decoration: none; background: var(--bubble); border: 1px solid var(--line); border-radius: 8px; }
a.file-chip { font-weight: 600; }
.chip button { padding: 0 2px; background: none; border: 0; cursor: pointer; }
.attachment-thumb { max-width: 180px; max-height: 180px; margin-bottom: 6px; border-radius: 10px; }
.sources { margin-top: 8px; font-size: .8rem; }
.sources a { color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 6px; color: var(--muted); font-size: .78rem; }
.actions button { padding: 0; color: inherit; background: none; border: 0; text-decoration: underline; cursor: pointer; }

.composer { padding: 8px 16px 10px; }
.composer > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.chips { margin-bottom: 6px; }
.chips:empty { display: none; }
.composer-row { display: flex; align-items: flex-end; gap: 2px; padding: 5px; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; }
.composer-row textarea { flex: 1; min-width: 0; max-height: 200px; padding: 7px 6px; resize: none; background: none; border: 0; outline: none; }
.send { flex: none; width: 38px; height: 38px; font-weight: 700; color: var(--accent-text); background: var(--accent); border: 0; border-radius: 10px; cursor: pointer; }
.send:disabled { opacity: .45; cursor: default; }
.fineprint { margin: 5px auto 0; color: var(--muted); font-size: .72rem; text-align: center; }

@media (max-width: 760px) {
  .sidebar { position: fixed; z-index: 20; top: 0; bottom: 0; left: 0; width: 270px; transform: translateX(-100%); transition: transform .18s; }
  .sidebar.open { transform: none; }
  .scrim { position: fixed; z-index: 10; inset: 0; display: block; background: rgba(0, 0, 0, .4); border: 0; }
  .menu { display: block; }
  .topbar { padding: 6px 8px; gap: 4px 8px; }
  .picker span { display: none; }
  .picker select { max-width: 120px; }
  .messages { padding: 14px 12px; }
  .composer { padding: 6px 8px 8px; }
  .composer-row textarea { font-size: 16px; }
}
