/* ==========================================================================
   AI Chat — application styles
   Light/dark tokens, app shell, thread, composer, auth, modals.
   ========================================================================== */

:root {
	--accent: #10a37f;
	--accent-hover: #0e8f70;
	--accent-contrast: #ffffff;

	--bg: #ffffff;
	--bg-sunken: #f9f9f9;
	--bg-raised: #ffffff;
	--bg-sidebar: #f9f9f9;
	--bg-hover: rgba(0, 0, 0, .045);
	--bg-active: rgba(0, 0, 0, .075);
	--bg-input: #ffffff;
	--bg-code: #f6f7f8;
	--bg-user-bubble: #f0f0f0;

	--text: #0d0d0d;
	--text-muted: #5d5d5d;
	--text-faint: #8f8f8f;

	--border: rgba(0, 0, 0, .1);
	--border-strong: rgba(0, 0, 0, .18);

	--danger: #d33a3a;

	--radius-sm: 8px;
	--radius: 12px;
	--radius-lg: 26px;

	--shadow-sm: 0 1px 2px rgba(0, 0, 0, .06);
	--shadow: 0 8px 30px rgba(0, 0, 0, .12);

	--sidebar-w: 260px;
	--thread-max: 768px;

	--font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
	--font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

[data-theme="dark"] {
	--bg: #212121;
	--bg-sunken: #181818;
	--bg-raised: #2f2f2f;
	--bg-sidebar: #181818;
	--bg-hover: rgba(255, 255, 255, .06);
	--bg-active: rgba(255, 255, 255, .1);
	--bg-input: #303030;
	--bg-code: #1b1b1b;
	--bg-user-bubble: #303030;

	--text: #ececec;
	--text-muted: #b4b4b4;
	--text-faint: #8a8a8a;

	--border: rgba(255, 255, 255, .12);
	--border-strong: rgba(255, 255, 255, .22);

	--danger: #f0736f;

	--shadow: 0 8px 30px rgba(0, 0, 0, .5);
}

*, *::before, *::after { box-sizing: border-box; }

/* A display rule must never win over the hidden attribute — the app toggles
   visibility with el.hidden throughout. */
[hidden] { display: none !important; }

html, body {
	height: 100%;
	margin: 0;
	padding: 0;
}

body.aichat-body {
	font-family: var(--font);
	font-size: 16px;
	line-height: 1.6;
	color: var(--text);
	background: var(--bg);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	overflow: hidden;
}

button { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

:where(button, a, input, textarea, select):focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

/* --------------------------------------------------------------- boot ---- */

.ac-boot {
	position: fixed;
	inset: 0;
	display: grid;
	place-items: center;
	background: var(--bg);
	z-index: 200;
}

.ac-boot[hidden] { display: none; }

.ac-spinner {
	width: 26px;
	height: 26px;
	border: 2px solid var(--border-strong);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: ac-spin .7s linear infinite;
}

@keyframes ac-spin { to { transform: rotate(360deg); } }

.ac-fatal {
	display: grid;
	place-content: center;
	height: 100vh;
	text-align: center;
	padding: 24px;
	color: var(--text-muted);
}

/* ---------------------------------------------------------------- app ---- */

.ac-app {
	display: flex;
	height: 100dvh;
	overflow: hidden;
}

.ac-app[hidden] { display: none; }

/* ------------------------------------------------------------ sidebar ---- */

.ac-sidebar {
	width: var(--sidebar-w);
	flex: 0 0 var(--sidebar-w);
	background: var(--bg-sidebar);
	border-right: 1px solid var(--border);
	display: flex;
	flex-direction: column;
	min-height: 0;
	transition: margin-left .22s ease;
}

.ac-app.is-collapsed .ac-sidebar { margin-left: calc(var(--sidebar-w) * -1); }

.ac-sidebar-top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 12px 12px 4px;
}

.ac-brand {
	display: flex;
	align-items: center;
	gap: 9px;
	min-width: 0;
	font-weight: 600;
	font-size: 15px;
}

.ac-brand-logo { width: 26px; height: 26px; border-radius: 6px; object-fit: contain; }

.ac-brand-mark {
	width: 26px;
	height: 26px;
	flex: none;
	border-radius: 50%;
	background: var(--accent);
	position: relative;
}

.ac-brand-mark::after {
	content: "";
	position: absolute;
	inset: 8px;
	border-radius: 50%;
	background: var(--bg-sidebar);
}

.ac-brand-mark-lg { width: 44px; height: 44px; }
.ac-brand-mark-lg::after { inset: 13px; background: var(--bg); }

.ac-brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ac-sidebar .ac-sidebar-close { display: none; }

.ac-icon-btn {
	display: inline-grid;
	place-items: center;
	width: 34px;
	height: 34px;
	flex: none;
	padding: 0;
	border: 0;
	border-radius: var(--radius-sm);
	background: transparent;
	color: var(--text-muted);
	cursor: pointer;
	transition: background .12s ease, color .12s ease;
}

.ac-icon-btn:hover { background: var(--bg-hover); color: var(--text); }

.ac-new-chat {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 8px 12px;
	padding: 9px 11px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg-raised);
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	transition: background .12s ease;
}

.ac-new-chat:hover { background: var(--bg-hover); }
.ac-new-chat svg { width: 17px; height: 17px; }

.ac-search {
	position: relative;
	margin: 0 12px 8px;
}

.ac-search svg {
	position: absolute;
	left: 10px;
	top: 50%;
	transform: translateY(-50%);
	width: 16px;
	height: 16px;
	color: var(--text-faint);
	pointer-events: none;
}

.ac-search input {
	width: 100%;
	padding: 8px 10px 8px 32px;
	border: 1px solid transparent;
	border-radius: var(--radius-sm);
	background: var(--bg-hover);
	color: var(--text);
	font-size: 13.5px;
}

.ac-search input::placeholder { color: var(--text-faint); }
.ac-search input:focus { border-color: var(--border-strong); background: var(--bg-input); outline: none; }

.ac-conversations {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	padding: 4px 8px 12px;
	overscroll-behavior: contain;
}

.ac-group-label {
	padding: 12px 8px 5px;
	font-size: 11.5px;
	font-weight: 600;
	letter-spacing: .04em;
	text-transform: uppercase;
	color: var(--text-faint);
}

.ac-conv {
	display: flex;
	align-items: center;
	gap: 4px;
	width: 100%;
	padding: 0 2px 0 10px;
	border-radius: var(--radius-sm);
	color: var(--text);
	cursor: pointer;
	position: relative;
}

.ac-conv:hover { background: var(--bg-hover); }
.ac-conv.is-active { background: var(--bg-active); }

.ac-conv-title {
	flex: 1;
	min-width: 0;
	padding: 8px 0;
	border: 0;
	background: none;
	text-align: left;
	font-size: 14px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	cursor: pointer;
}

.ac-conv-title input {
	width: 100%;
	padding: 2px 4px;
	border: 1px solid var(--accent);
	border-radius: 5px;
	background: var(--bg-input);
	color: var(--text);
	font: inherit;
}

.ac-conv-more {
	opacity: 0;
	width: 28px;
	height: 28px;
}

.ac-conv:hover .ac-conv-more,
.ac-conv.is-active .ac-conv-more,
.ac-conv-more[aria-expanded="true"] { opacity: 1; }

.ac-conv-empty {
	padding: 24px 10px;
	text-align: center;
	font-size: 13.5px;
	color: var(--text-faint);
}

.ac-sidebar-foot {
	position: relative;
	padding: 8px;
	border-top: 1px solid var(--border);
}

.ac-user {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 8px;
	border: 0;
	border-radius: var(--radius-sm);
	background: none;
	cursor: pointer;
	text-align: left;
}

.ac-user:hover { background: var(--bg-hover); }

.ac-avatar {
	display: grid;
	place-items: center;
	width: 28px;
	height: 28px;
	flex: none;
	border-radius: 50%;
	background: var(--accent);
	color: var(--accent-contrast);
	font-size: 13px;
	font-weight: 600;
}

.ac-user-name {
	flex: 1;
	min-width: 0;
	font-size: 14px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.ac-caret { width: 16px; height: 16px; color: var(--text-faint); }

/* --------------------------------------------------------------- menu ---- */

.ac-menu {
	position: absolute;
	z-index: 60;
	min-width: 190px;
	padding: 5px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg-raised);
	box-shadow: var(--shadow);
}

.ac-menu[hidden] { display: none; }

.ac-sidebar-foot .ac-menu { bottom: calc(100% - 4px); left: 8px; right: 8px; }

.ac-menu button {
	display: block;
	width: 100%;
	padding: 8px 10px;
	border: 0;
	border-radius: var(--radius-sm);
	background: none;
	text-align: left;
	font-size: 14px;
	cursor: pointer;
}

.ac-menu button:hover { background: var(--bg-hover); }
.ac-menu button.is-danger { color: var(--danger); }

.ac-menu .ac-menu-model { display: flex; align-items: baseline; gap: 8px; }
.ac-menu .ac-menu-model small { color: var(--text-faint); font-size: 11.5px; }
.ac-menu .ac-menu-model.is-selected { background: var(--bg-active); }

/* --------------------------------------------------------------- main ---- */

.ac-main {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	position: relative;
	background: var(--bg);
}

.ac-topbar {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 8px 12px;
	min-height: 52px;
	background: var(--bg);
	position: relative;
	z-index: 20;
}

.ac-topbar-right { margin-left: auto; display: flex; gap: 4px; }

.ac-model-picker { position: relative; }

.ac-model-btn {
	display: flex;
	align-items: center;
	gap: 5px;
	padding: 7px 10px;
	border: 0;
	border-radius: var(--radius-sm);
	background: none;
	font-size: 15px;
	font-weight: 500;
	color: var(--text-muted);
	cursor: pointer;
}

.ac-model-btn:hover { background: var(--bg-hover); color: var(--text); }
.ac-model-menu { top: calc(100% + 2px); left: 0; min-width: 240px; }



/* ------------------------------------------------------------- thread ---- */

.ac-thread {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	overflow-x: hidden;
	scroll-behavior: smooth;
	overscroll-behavior: contain;
}

.ac-messages {
	max-width: var(--thread-max);
	margin: 0 auto;
	padding: 8px 20px 0;
}

.ac-thread-pad { height: 96px; }

.ac-welcome {
	display: none;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 18px;
	min-height: 46vh;
	padding: 24px;
	text-align: center;
}

.ac-app.is-empty .ac-welcome { display: flex; }
.ac-welcome h1 { margin: 0; font-size: 28px; font-weight: 600; letter-spacing: -.01em; }
.ac-welcome-logo { width: 48px; height: 48px; border-radius: 10px; object-fit: contain; }

.ac-msg { margin: 22px 0; }

.ac-msg-user { display: flex; justify-content: flex-end; }

.ac-msg-user .ac-bubble {
	max-width: 78%;
	padding: 10px 16px;
	border-radius: 20px;
	background: var(--bg-user-bubble);
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.ac-msg-assistant { display: flex; gap: 14px; }

.ac-msg-avatar {
	width: 26px;
	height: 26px;
	flex: none;
	margin-top: 2px;
	border-radius: 50%;
	background: var(--accent);
	position: relative;
}

.ac-msg-avatar::after {
	content: "";
	position: absolute;
	inset: 8px;
	border-radius: 50%;
	background: var(--bg);
}

.ac-msg-body { flex: 1; min-width: 0; }

.ac-actions {
	display: flex;
	gap: 2px;
	margin-top: 6px;
	opacity: 0;
	transition: opacity .12s ease;
}

.ac-msg:hover .ac-actions,
.ac-msg:focus-within .ac-actions { opacity: 1; }

.ac-msg-user .ac-actions { justify-content: flex-end; }

.ac-action {
	display: inline-grid;
	place-items: center;
	width: 28px;
	height: 28px;
	border: 0;
	border-radius: 6px;
	background: none;
	color: var(--text-faint);
	cursor: pointer;
}

.ac-action:hover { background: var(--bg-hover); color: var(--text); }
.ac-action svg { width: 16px; height: 16px; }

.ac-msg-files { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; justify-content: flex-end; }

.ac-file-chip {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	max-width: 230px;
	padding: 7px 11px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg-raised);
	font-size: 13px;
	text-decoration: none;
	color: var(--text);
}

.ac-file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-file-chip img { width: 42px; height: 42px; border-radius: 7px; object-fit: cover; }

.ac-edit-area {
	width: 100%;
	padding: 10px 14px;
	border: 1px solid var(--border-strong);
	border-radius: var(--radius);
	background: var(--bg-input);
	color: var(--text);
	font: inherit;
	resize: vertical;
}

.ac-edit-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

.ac-typing {
	display: inline-block;
	width: 9px;
	height: 17px;
	vertical-align: text-bottom;
	background: var(--text);
	border-radius: 1px;
	animation: ac-blink 1.1s steps(2, start) infinite;
}

@keyframes ac-blink { 50% { opacity: 0; } }

.ac-error-note {
	margin: 10px 0 0;
	padding: 11px 14px;
	border: 1px solid var(--danger);
	border-radius: var(--radius);
	background: color-mix(in srgb, var(--danger) 8%, transparent);
	color: var(--danger);
	font-size: 14px;
}

.ac-scroll-bottom {
	position: absolute;
	left: 50%;
	bottom: 128px;
	transform: translateX(-50%);
	width: 34px;
	height: 34px;
	display: grid;
	place-items: center;
	border: 1px solid var(--border);
	border-radius: 50%;
	background: var(--bg-raised);
	color: var(--text-muted);
	box-shadow: var(--shadow-sm);
	cursor: pointer;
	z-index: 15;
}

.ac-scroll-bottom[hidden] { display: none; }

/* --------------------------------------------------------- prose/markdown */

.ac-prose { overflow-wrap: anywhere; }
.ac-prose > *:first-child { margin-top: 0; }
.ac-prose > *:last-child { margin-bottom: 0; }
.ac-prose p { margin: 0 0 1em; }
.ac-prose h1, .ac-prose h2, .ac-prose h3, .ac-prose h4 { margin: 1.5em 0 .6em; line-height: 1.3; font-weight: 600; }
.ac-prose h1 { font-size: 1.5em; }
.ac-prose h2 { font-size: 1.3em; }
.ac-prose h3 { font-size: 1.12em; }
.ac-prose h4 { font-size: 1em; }
.ac-prose ul, .ac-prose ol { margin: 0 0 1em; padding-left: 1.5em; }
.ac-prose li { margin: .3em 0; }
.ac-prose li > ul, .ac-prose li > ol { margin: .3em 0; }
.ac-prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.ac-prose blockquote {
	margin: 0 0 1em;
	padding: .3em 0 .3em 1em;
	border-left: 3px solid var(--border-strong);
	color: var(--text-muted);
}
.ac-prose hr { margin: 1.5em 0; border: 0; border-top: 1px solid var(--border); }

.ac-prose code {
	padding: .15em .38em;
	border-radius: 5px;
	background: var(--bg-code);
	font-family: var(--font-mono);
	font-size: .87em;
}

.ac-code {
	margin: 0 0 1em;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	overflow: hidden;
	background: var(--bg-code);
}

.ac-code-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 6px 8px 6px 14px;
	border-bottom: 1px solid var(--border);
	font-size: 12px;
	color: var(--text-faint);
}

.ac-code-copy {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 4px 8px;
	border: 0;
	border-radius: 6px;
	background: none;
	color: var(--text-faint);
	font-size: 12px;
	cursor: pointer;
}

.ac-code-copy:hover { background: var(--bg-hover); color: var(--text); }
.ac-code-copy svg { width: 14px; height: 14px; }

.ac-code pre {
	margin: 0;
	padding: 14px;
	overflow-x: auto;
	font-family: var(--font-mono);
	font-size: 13.5px;
	line-height: 1.55;
}

.ac-code pre code { padding: 0; background: none; font-size: inherit; }

.ac-table-wrap { overflow-x: auto; margin: 0 0 1em; }

.ac-prose table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.ac-prose th, .ac-prose td { padding: 8px 12px; border: 1px solid var(--border); text-align: left; }
.ac-prose th { background: var(--bg-sunken); font-weight: 600; }

/* syntax tokens */
.tok-com { color: #7b8794; font-style: italic; }
.tok-str { color: #16794a; }
.tok-num { color: #b06000; }
.tok-key { color: #8250df; }
.tok-fn  { color: #0b6bcb; }

[data-theme="dark"] .tok-com { color: #7f8b99; }
[data-theme="dark"] .tok-str { color: #7ee2a8; }
[data-theme="dark"] .tok-num { color: #f0a868; }
[data-theme="dark"] .tok-key { color: #d0a3ff; }
[data-theme="dark"] .tok-fn  { color: #79b8ff; }

/* ----------------------------------------------------------- composer ---- */

.ac-composer-wrap {
	position: sticky;
	bottom: 0;
	padding: 0 20px 12px;
	background: linear-gradient(to bottom, transparent, var(--bg) 28%);
}

.ac-composer {
	max-width: var(--thread-max);
	margin: 0 auto;
	padding: 8px;
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	background: var(--bg-input);
	box-shadow: var(--shadow-sm);
	transition: border-color .12s ease;
}

.ac-composer:focus-within { border-color: var(--border-strong); }
.ac-composer.is-dragover { border-color: var(--accent); }

.ac-composer-row { display: flex; align-items: flex-end; gap: 6px; }

.ac-composer textarea {
	flex: 1;
	min-height: 26px;
	max-height: 45vh;
	padding: 7px 4px;
	border: 0;
	background: none;
	color: var(--text);
	font: inherit;
	line-height: 1.5;
	resize: none;
	outline: none;
}

.ac-composer textarea::placeholder { color: var(--text-faint); }

.ac-send {
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	flex: none;
	border: 0;
	border-radius: 50%;
	background: var(--text);
	color: var(--bg);
	cursor: pointer;
	transition: opacity .12s ease;
}

.ac-send:disabled { opacity: .22; cursor: default; }
.ac-send .ac-stop-icon { display: none; width: 11px; height: 11px; border-radius: 2px; background: currentColor; }
.ac-send.is-streaming .ac-send-icon { display: none; }
.ac-send.is-streaming .ac-stop-icon { display: block; }

.ac-attachments {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 4px 4px 10px;
}

.ac-attachments[hidden] { display: none; }

.ac-att {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 6px 8px 6px 10px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg-raised);
	font-size: 13px;
	max-width: 220px;
}

.ac-att span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-att.is-uploading { opacity: .6; }
.ac-att button { width: 22px; height: 22px; }
.ac-att button svg { width: 13px; height: 13px; }

.ac-disclaimer {
	max-width: var(--thread-max);
	margin: 8px auto 0;
	text-align: center;
	font-size: 11.5px;
	color: var(--text-faint);
}

/* --------------------------------------------------------------- auth ---- */

.ac-auth {
	position: fixed;
	inset: 0;
	display: grid;
	place-items: center;
	padding: 24px;
	background: var(--bg);
	overflow-y: auto;
	z-index: 120;
}

.ac-auth[hidden] { display: none; }

.ac-auth-card {
	width: 100%;
	max-width: 380px;
}

.ac-auth-brand {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
	margin-bottom: 26px;
	text-align: center;
}

.ac-auth-brand img { width: 46px; height: 46px; border-radius: 10px; object-fit: contain; }
.ac-auth-brand h1 { margin: 0; font-size: 24px; font-weight: 600; }

.ac-auth-form { display: flex; flex-direction: column; }
.ac-auth-form[hidden] { display: none; }

.ac-auth-form label,
.ac-modal-body label {
	margin: 12px 0 5px;
	font-size: 13px;
	font-weight: 500;
	color: var(--text-muted);
}

.ac-auth-form input[type="text"],
.ac-auth-form input[type="email"],
.ac-auth-form input[type="password"],
.ac-modal-body input[type="text"],
.ac-modal-body input[type="password"] {
	width: 100%;
	padding: 11px 13px;
	border: 1px solid var(--border-strong);
	border-radius: var(--radius);
	background: var(--bg-input);
	color: var(--text);
	font: inherit;
}

.ac-auth-form input:focus,
.ac-modal-body input:focus { border-color: var(--accent); outline: none; }

.ac-check {
	display: flex !important;
	align-items: center;
	gap: 8px;
	margin: 14px 0 4px !important;
	font-size: 13.5px !important;
	color: var(--text) !important;
	font-weight: 400 !important;
}

.ac-primary {
	margin-top: 18px;
	padding: 12px 16px;
	border: 0;
	border-radius: var(--radius);
	background: var(--accent);
	color: var(--accent-contrast);
	font-size: 15px;
	font-weight: 500;
	cursor: pointer;
	transition: background .12s ease;
}

.ac-primary:hover { background: var(--accent-hover); }
.ac-primary:disabled { opacity: .55; cursor: default; }
.ac-compact { margin-top: 12px; padding: 9px 14px; font-size: 14px; align-self: flex-start; }

.ac-danger {
	padding: 9px 14px;
	border: 1px solid var(--danger);
	border-radius: var(--radius);
	background: none;
	color: var(--danger);
	font-size: 14px;
	cursor: pointer;
}

.ac-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }

.ac-auth-links {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	margin-top: 16px;
}

.ac-auth-links button {
	border: 0;
	background: none;
	color: var(--accent);
	font-size: 13.5px;
	cursor: pointer;
	padding: 4px;
}

.ac-auth-links button:hover { text-decoration: underline; }

.ac-auth-error {
	margin-bottom: 14px;
	padding: 11px 13px;
	border: 1px solid var(--danger);
	border-radius: var(--radius);
	background: color-mix(in srgb, var(--danger) 8%, transparent);
	color: var(--danger);
	font-size: 13.5px;
}

.ac-auth-error[hidden] { display: none; }
.ac-auth-error.is-ok { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }

.ac-honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* -------------------------------------------------------------- modal ---- */

.ac-modal {
	position: fixed;
	inset: 0;
	display: grid;
	place-items: center;
	padding: 20px;
	background: rgba(0, 0, 0, .45);
	z-index: 140;
}

.ac-modal[hidden] { display: none; }

.ac-modal-card {
	width: 100%;
	max-width: 520px;
	max-height: 86vh;
	display: flex;
	flex-direction: column;
	border-radius: 16px;
	background: var(--bg-raised);
	box-shadow: var(--shadow);
	overflow: hidden;
}

.ac-modal-card header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 12px 16px 20px;
	border-bottom: 1px solid var(--border);
}

.ac-modal-card h2 { margin: 0; font-size: 17px; font-weight: 600; }

.ac-modal-body { padding: 6px 20px 22px; overflow-y: auto; }
.ac-modal-body section { padding: 16px 0; border-bottom: 1px solid var(--border); }
.ac-modal-body section:last-child { border-bottom: 0; }
.ac-modal-body h3 { margin: 0 0 10px; font-size: 14px; font-weight: 600; }
.ac-modal-body form { display: flex; flex-direction: column; }

.ac-form-note { margin: 10px 0 0; font-size: 13px; color: var(--text-muted); }
.ac-form-note.is-error { color: var(--danger); }

.ac-segmented {
	display: inline-flex;
	padding: 3px;
	border-radius: var(--radius);
	background: var(--bg-hover);
}

.ac-segmented button {
	padding: 7px 14px;
	border: 0;
	border-radius: 9px;
	background: none;
	font-size: 13.5px;
	cursor: pointer;
}

.ac-segmented button.is-active { background: var(--bg-raised); box-shadow: var(--shadow-sm); }

.ac-meter { height: 7px; border-radius: 4px; background: var(--bg-hover); overflow: hidden; }
.ac-meter-fill { height: 100%; width: 0; border-radius: 4px; background: var(--accent); transition: width .3s ease; }
.ac-meter-fill.is-high { background: var(--danger); }

/* -------------------------------------------------------------- toast ---- */

.ac-toast {
	position: fixed;
	left: 50%;
	bottom: 26px;
	transform: translateX(-50%);
	padding: 10px 18px;
	border-radius: 999px;
	background: var(--text);
	color: var(--bg);
	font-size: 13.5px;
	box-shadow: var(--shadow);
	z-index: 180;
}

.ac-toast[hidden] { display: none; }

/* --------------------------------------------------------------- resp ---- */

.ac-scrim { display: none; }

@media (max-width: 860px) {
	.ac-sidebar .ac-sidebar-close { display: inline-grid; }

	.ac-sidebar {
		position: fixed;
		inset: 0 auto 0 0;
		z-index: 100;
		margin-left: calc(var(--sidebar-w) * -1);
		border-right: 0;
	}

	.ac-app.is-sidebar-open .ac-sidebar {
		margin-left: 0;
		border-right: 1px solid var(--border);
		box-shadow: var(--shadow);
	}

	.ac-app.is-collapsed .ac-sidebar { margin-left: calc(var(--sidebar-w) * -1); }

	.ac-scrim {
		display: block;
		position: fixed;
		inset: 0;
		z-index: 90;
		background: rgba(0, 0, 0, .4);
	}

	.ac-scrim[hidden] { display: none; }

	.ac-messages { padding: 8px 14px 0; }
	.ac-composer-wrap { padding: 0 12px 10px; }
	.ac-msg-user .ac-bubble { max-width: 88%; }
	.ac-welcome h1 { font-size: 23px; }
}

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