/* HXARK interface: shared visual identity, no remote fonts or trackers. */
:root {
 --bg:#090b0c; --surface:#111416; --surface-2:#191d20; --border:#2a3033;
 --text:#f2f4f3; --muted:#a0a9ad; --primary:#dcf7e9; --primary-text:#101a15;
 --primary-hover:#bdeed5; --accent:#a7efce; --danger:#f58383; --danger-text:#260909;
 --warn-bg:#282415; --warn-text:#eee0a2; --info-bg:#16221d; --user-bubble:#1d2624;
 --code-bg:#090c0e; --code-text:#e3f2ef; --focus:#a7efce; --radius:10px;
 --shadow:0 18px 80px #0004;
 font-family:Inter,Arial,Helvetica,sans-serif; color-scheme:dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pad { padding: 0 12px; }
.noscript { padding: 24px; }
.boot { padding: 40px; text-align: center; color: var(--muted); }

button { cursor: pointer; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); padding: 8px 14px; }
button:disabled { cursor: not-allowed; opacity: .55; }
button.primary { background: var(--primary); color: var(--primary-text); border-color: transparent; font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--primary-hover); }
button.danger { background: var(--danger); color: var(--danger-text); border-color: transparent; font-weight: 600; }
button.ghost { background: transparent; }
button.ghost:hover { background: var(--surface-2); }
button.icon { border: none; background: transparent; font-size: 18px; padding: 6px 10px; }
button.wide { width: 100%; }
input, textarea { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; background: var(--surface); }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-name { font-weight: 800; letter-spacing: .14em; }
.brand-large h1 { margin: 0; letter-spacing: .14em; }
.brand-large p { margin: 0; }
.tag { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: 2px 6px; border-radius: 6px; background: var(--info-bg); color: var(--primary); font-weight: 700; }
.badge { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.sim { background: var(--warn-bg); color: var(--warn-text); }

/* ---------------- authentication */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 28px; box-shadow: var(--shadow); }
.tabs { display: flex; gap: 6px; margin: 18px 0 14px; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.tabs button { flex: 1; border: none; background: transparent; }
.tabs button[aria-selected="true"] { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 14px; }

/* ---------------- layout */
.app { display: grid; grid-template-columns: 290px 1fr; height: 100vh; height: 100dvh; }
.sidebar { display: flex; flex-direction: column; gap: 12px; padding: 14px 12px; border-right: 1px solid var(--border); background: var(--surface); min-height: 0; }
.history { flex: 1; overflow-y: auto; min-height: 0; margin: 0 -4px; padding: 0 4px; }
.conversation-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.conversation-list li { display: flex; align-items: stretch; border-radius: 10px; }
.conversation-list li:hover, .conversation-list li.active { background: var(--surface-2); }
.conversation-list .open { flex: 1; min-width: 0; text-align: left; border: none; background: transparent; padding: 8px 10px; }
.conversation-list .open .name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-list .open .match { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-list .tools { display: flex; opacity: 0; }
.conversation-list li:hover .tools, .conversation-list li.active .tools, .conversation-list li:focus-within .tools { opacity: 1; }
.conversation-list .tools button { border: none; background: transparent; padding: 4px 7px; color: var(--muted); }
.conversation-list .tools button:hover { color: var(--text); }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--surface); }
.title { flex: 1; margin: 0; font-size: 16px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.banner { background: var(--warn-bg); color: var(--warn-text); padding: 8px 20px; font-size: 13px; }
.notice { margin: 10px 20px 0; padding: 10px 14px; border-radius: 10px; background: var(--info-bg); font-size: 14px; }
.notice.error { background: var(--warn-bg); color: var(--warn-text); }
.messages { flex: 1; overflow-y: auto; padding: 22px max(20px, calc((100% - 820px) / 2)); display: flex; flex-direction: column; gap: 18px; }
.empty { margin: auto; text-align: center; max-width: 420px; }
.empty h3 { margin: 12px 0 4px; }

.msg { display: flex; flex-direction: column; gap: 4px; max-width: 100%; }
.msg .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.msg .body { overflow-wrap: anywhere; }
.msg.user { align-items: flex-end; }
.msg.user .body { background: var(--user-bubble); padding: 10px 14px; border-radius: 16px 16px 4px 16px; max-width: min(640px, 90%); white-space: pre-wrap; }
.msg.assistant .body { padding: 2px 0; }
.msg .body p { margin: 0 0 10px; }
.msg .body p:last-child { margin-bottom: 0; }
.msg .body ul, .msg .body ol { margin: 0 0 10px; padding-left: 24px; }
.msg .body h3, .msg .body h4, .msg .body h5 { margin: 14px 0 6px; }
.msg .body blockquote { margin: 0 0 10px; padding-left: 12px; border-left: 3px solid var(--border); color: var(--muted); }
.msg .body code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 13px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.code { margin: 0 0 10px; border-radius: 10px; overflow: hidden; background: var(--code-bg); color: var(--code-text); }
.code-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 10px; font-size: 12px; opacity: .85; }
.code-head button { border: none; background: transparent; color: inherit; font-size: 12px; padding: 2px 6px; }
.code pre { margin: 0; padding: 10px 14px 14px; overflow-x: auto; }
.code pre code { background: transparent; padding: 0; color: inherit; }
.status-line { font-size: 13px; color: var(--muted); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.status-line.warn { color: var(--warn-text); background: var(--warn-bg); padding: 6px 10px; border-radius: 8px; }
.status-line button { padding: 3px 10px; font-size: 13px; }
.typing::after { content: "▍"; animation: blink 1s steps(1) infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .typing::after { animation: none; } }
.tool-card { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--surface); font-size: 13px; }

.composer { padding: 12px max(20px, calc((100% - 820px) / 2)) 18px; display: flex; flex-direction: column; gap: 8px; }
.composer textarea { resize: none; max-height: 220px; min-height: 48px; padding: 12px 14px; border-radius: 14px; box-shadow: var(--shadow); }
.composer-row { display: flex; align-items: center; gap: 10px; }
.file-card { border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 12px; padding: 16px; background: var(--surface); overflow-wrap: anywhere; }
.file-card h3 { margin: 0 0 8px; font-size: 16px; }
.file-card p { margin: 8px 0; }
.file-card .file-download { display: inline-block; margin-top: 8px; font-weight: 600; }
.file-card { font-size: 1rem; }
.file-card .small, #file-dialog .small { font-size: .875rem; }
.file-card .ghost { display: block; margin-top: 12px; }
#file-input { max-width: 100%; }
#file-status { min-height: 1.5em; }
@media (max-width: 600px) { .composer-row { flex-wrap: wrap; } .composer-row .quota { flex-basis: 100%; order: 2; } }
.quota { flex: 1; }
.quota.out { color: var(--danger); font-weight: 600; }

dialog { border: 1px solid var(--border); border-radius: 16px; padding: 0; background: var(--surface); color: var(--text); width: min(560px, calc(100% - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(5, 20, 18, .45); }
.dialog-body { padding: 22px; display: flex; flex-direction: column; gap: 12px; max-height: 85vh; overflow-y: auto; }
.dialog-body h2 { margin: 0; font-size: 18px; }
.dialog-body h3 { margin: 6px 0 4px; font-size: 15px; }
.dialog-body label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.options { display: flex; flex-direction: column; gap: 8px; }
.option { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1px solid var(--border); border-radius: 10px; font-weight: 400 !important; flex-direction: row !important; }
.option input { width: auto; margin-top: 4px; }
.capabilities { margin: 0; padding-left: 18px; }
.usage-table { width: 100%; border-collapse: collapse; }
.usage-table th, .usage-table td { text-align: left; padding: 3px 6px; border-bottom: 1px solid var(--border); }

.only-mobile { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(5, 20, 18, .45); z-index: 9; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .only-mobile { display: inline-block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 10; transform: translateX(-105%); transition: transform .2s ease; }
  .sidebar.open { transform: none; }
  .topbar { padding: 10px 12px; }
  .messages { padding: 16px 14px; }
  .composer { padding: 10px 12px 14px; }
  .conversation-list .tools { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

.auth { background:radial-gradient(ellipse at 50% 0%,#19251f 0,transparent 65%),var(--bg); }
.auth-card { width:min(460px,100%); padding:36px; border-radius:16px; }
.brand-large { margin-bottom:32px; gap:18px; }
.brand-large h1 { font-size:26px; letter-spacing:.11em; }
.brand-large p { margin-top:6px; font-size:12px; }
.stack { gap:20px; }.stack label { font-size:13px; font-weight:400; gap:9px; }
.stack button.primary { margin-top:6px; min-height:44px; }
.sidebar { background:#101315; }.topbar { background:var(--bg); }
.empty h3 { font-size:clamp(24px,4vw,34px); font-weight:500; letter-spacing:-.04em; }
.empty img { margin-bottom:18px; }.empty p { max-width:470px; line-height:1.7; }
#tools-banner { background:transparent; border-bottom:1px solid var(--border); color:var(--muted); font-size:12px; }
#input:disabled { opacity:.65; cursor:not-allowed; }#send:disabled { opacity:.4; }
.admin-row { display:flex; align-items:center; justify-content:space-between; gap:20px; padding:15px 0; margin:0; border-bottom:1px solid var(--border); }
.language-switch { display:flex; align-items:center; justify-content:space-between; gap:20px; margin-bottom:24px; font-size:12px; }
.language-switch a { color:var(--muted); text-decoration:none; }.language-switch a:hover { color:var(--text); }
.language-switch nav { display:flex; gap:16px; }.language-switch a[aria-current] { color:var(--accent); }
@media(max-width:480px) { .auth-card { padding:25px; }.auth { padding:16px; } }
