:root {
	--bg: #0a1634;
	--bg-deep: #07102a;
	--topbar: #0c1b3f;
	--surface: #11244f;
	--surface-2: #173063;
	--border: rgba(125, 165, 255, 0.16);
	--border-strong: rgba(125, 165, 255, 0.32);
	--text: #e8efff;
	--text-soft: #b9c9ee;
	--muted: #7f95c4;
	--accent: #3b82f6;
	--accent-bright: #60a5fa;
	--accent-deep: #1d4ed8;
	--danger: #f87171;
	--radius: 14px;
	--font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
	--mono: "Cascadia Code", "Cascadia Mono", Consolas, ui-monospace, monospace;
	--titlebar-controls: 0px;
}

* { box-sizing: border-box; }

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

/* Solid colour on html + body (not just gradients): iOS 26 tints the status-bar / home-indicator
   strips of an installed web app from body's background-color, and the sign-in page shows there too. */
html { background: var(--bg-deep); color-scheme: dark; }

body {
	display: flex;
	flex-direction: column;
	background-color: var(--bg-deep);
	background-image:
		radial-gradient(1200px 600px at 85% -10%, rgba(59, 130, 246, 0.18), transparent 60%),
		radial-gradient(900px 500px at -10% 110%, rgba(37, 99, 235, 0.16), transparent 60%),
		linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
	color: var(--text);
	font-family: var(--font);
	font-size: 15px;
	line-height: 1.6;
	overflow: hidden;
	-webkit-font-smoothing: antialiased;
}

::selection { background: rgba(96, 165, 250, 0.4); }

/* ------------------------------------------------------------ top bar */

.topbar {
	flex: none;
	height: 52px;
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 0 calc(var(--titlebar-controls) + 8px) 0 14px;
	background: var(--topbar);
	border-bottom: 1px solid var(--border);
	user-select: none;
}


.brand {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-right: 8px;
}
.brand-mark { width: 24px; height: 24px; border-radius: 7px; }
.brand-name { font-weight: 650; letter-spacing: 0.2px; font-size: 14px; color: #dbe6ff; }

.btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	white-space: nowrap;
	flex: none;
	height: 34px;
	padding: 0 14px;
	border-radius: 10px;
	border: 1px solid var(--border-strong);
	background: linear-gradient(180deg, #1a3775, #142c61);
	color: var(--text);
	font: 600 13px var(--font);
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: linear-gradient(180deg, #21438c, #193572); border-color: rgba(125, 165, 255, 0.5); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }

.select-wrap {
	position: relative;
	display: inline-flex;
	align-items: center;
	flex: none;
}
.select-wrap select {
	appearance: none;
	height: 34px;
	padding: 0 34px 0 14px;
	border-radius: 10px;
	border: 1px solid var(--border-strong);
	background: #10245a;
	color: var(--text);
	font: 600 13px var(--font);
	cursor: pointer;
	outline: none;
}
.select-wrap select:hover { border-color: rgba(125, 165, 255, 0.5); }
.select-wrap select:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }
.select-wrap select option { background: #10245a; color: var(--text); }
.select-wrap .chev {
	position: absolute;
	right: 12px;
	pointer-events: none;
	color: var(--accent-bright);
}

.badge {
	margin-left: auto;
	overflow: hidden;
	text-overflow: ellipsis;
	font-size: 11.5px;
	font-weight: 600;
	color: var(--text-soft);
	padding: 4px 10px;
	border-radius: 999px;
	border: 1px solid var(--border);
	background: rgba(59, 130, 246, 0.1);
	white-space: nowrap;
}

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

.scroller {
	flex: 1;
	overflow-y: auto;
	position: relative;
	scroll-behavior: auto;
}
.scroller::-webkit-scrollbar { width: 10px; }
.scroller::-webkit-scrollbar-thumb {
	background: rgba(125, 165, 255, 0.2);
	border-radius: 10px;
	border: 3px solid transparent;
	background-clip: padding-box;
}
.scroller::-webkit-scrollbar-thumb:hover { background-color: rgba(125, 165, 255, 0.35); }

.thread {
	max-width: 820px;
	margin: 0 auto;
	padding: 24px 22px 12px;
	display: flex;
	flex-direction: column;
	gap: 18px;
}

.msg { display: flex; flex-direction: column; animation: rise 0.18s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.msg.user { align-items: flex-end; }
.msg.user .bubble {
	max-width: 78%;
	padding: 10px 15px;
	border-radius: 18px 18px 6px 18px;
	background: linear-gradient(135deg, #2563eb, #3b82f6);
	color: #fff;
	white-space: pre-wrap;
	word-wrap: break-word;
	box-shadow: 0 6px 20px -8px rgba(37, 99, 235, 0.7);
}

.msg.assistant .meta {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0 0 6px 2px;
	font-size: 12px;
	color: var(--muted);
}
.model-tag {
	font-weight: 650;
	color: var(--accent-bright);
	letter-spacing: 0.2px;
}
.model-tag.sol { color: #fbbf24; }
.model-tag.astra { color: #c4b5fd; }
.model-tag.image { color: #f9a8d4; }
.model-tag.or { color: #fdba74; }

/* ------------------------------------------------------------ OpenRouter panel */

.or-panel {
	flex: none;
	padding: 10px 22px 8px;
	background: rgba(12, 27, 63, 0.75);
	border-bottom: 1px solid var(--border);
}
.or-panel[hidden] { display: none; }
.or-row {
	max-width: 820px;
	margin: 0 auto;
	display: flex;
	gap: 10px;
	align-items: center;
}
.or-search-wrap {
	flex: 1;
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 0 12px;
	height: 36px;
	border-radius: 10px;
	background: #10245a;
	border: 1px solid var(--border-strong);
	color: var(--muted);
}
.or-search-wrap:focus-within { border-color: rgba(96, 165, 250, 0.7); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2); }
.or-search-wrap input {
	flex: 1;
	border: 0;
	outline: none;
	background: transparent;
	color: var(--text);
	font: 14px var(--font);
}
.or-search-wrap input::placeholder { color: var(--muted); }
.or-selected {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	max-width: 50%;
	padding: 6px 12px;
	border-radius: 10px;
	font-size: 13px;
	font-weight: 600;
	color: #fde68a;
	background: rgba(251, 191, 36, 0.1);
	border: 1px solid rgba(251, 191, 36, 0.35);
	cursor: pointer;
	white-space: nowrap;
	overflow: hidden;
}
.or-selected[hidden] { display: none; }
.or-selected .or-using { font-weight: 500; color: var(--muted); }
.or-selected code { font: 11.5px var(--mono); color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; }
.or-tabs { display: inline-flex; gap: 4px; flex: none; }
.or-tab {
	height: 36px;
	padding: 0 14px;
	border-radius: 10px;
	border: 1px solid var(--border-strong);
	background: #10245a;
	color: var(--text-soft);
	font: 600 13px var(--font);
	cursor: pointer;
}
.or-tab:hover:not(:disabled) { border-color: rgba(125, 165, 255, 0.5); color: var(--text); }
.or-tab.active { background: linear-gradient(180deg, #21438c, #193572); color: var(--text); }
.or-tab:disabled { opacity: 0.45; cursor: default; }
.or-chips { margin-top: 8px; flex-wrap: wrap; }
.or-chips:empty, .or-chips:not(:has(:not([hidden]))) { display: none; }
.or-selected.or-provider { color: #a5f3fc; background: rgba(34, 211, 238, 0.08); border-color: rgba(34, 211, 238, 0.35); }
.or-selected .or-clear {
	border: 0;
	background: transparent;
	color: inherit;
	font: 600 15px/1 var(--font);
	cursor: pointer;
	padding: 0 2px;
	opacity: 0.7;
}
.or-selected .or-clear:hover { opacity: 1; }
.or-results li.or-auto .or-name { color: var(--text-soft); }
.or-results .or-meta .out-price { color: #86efac; font-weight: 650; }
.or-results .or-meta .uptime-low { color: #fca5a5; }
.or-results .or-row-actions { grid-column: 1 / -1; display: flex; gap: 6px; margin-top: 4px; }
.or-results .or-mini {
	padding: 2px 9px;
	border-radius: 7px;
	border: 1px solid var(--border-strong);
	background: rgba(59, 130, 246, 0.12);
	color: var(--text-soft);
	font: 600 11px var(--font);
	cursor: pointer;
}
.or-results .or-mini:hover { color: var(--text); border-color: rgba(125, 165, 255, 0.6); }
.or-results li.selected .or-mini.primary, .or-results li.backup .or-mini.backup { background: rgba(251, 191, 36, 0.18); color: #fde68a; }

.or-privacy-wrap select { height: 36px; }
.or-privacy-wrap select.strict { border-color: rgba(34, 197, 94, 0.55); color: #86efac; }
.or-results .or-meta .zdr { color: #86efac; border-color: rgba(34, 197, 94, 0.4); }
.or-results .or-meta .logs { color: #fca5a5; border-color: rgba(248, 113, 113, 0.4); }
.or-results li.not-private { opacity: 0.7; }
.or-status button.link {
	border: 0;
	background: transparent;
	color: var(--accent-bright);
	font: inherit;
	cursor: pointer;
	padding: 0;
	text-decoration: underline;
}

.or-status {
	max-width: 820px;
	margin: 6px auto 0;
	font-size: 12px;
	color: var(--muted);
}
.or-status[hidden] { display: none; }
.or-status.error { color: #fca5a5; }
.or-results {
	max-width: 820px;
	margin: 8px auto 0;
	padding: 0;
	list-style: none;
	max-height: 42vh;
	overflow-y: auto;
	border-radius: 12px;
	border: 1px solid var(--border);
	background: rgba(8, 18, 48, 0.8);
}
.or-results[hidden] { display: none; }
.or-results li {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 2px 14px;
	padding: 9px 14px;
	border-bottom: 1px solid var(--border);
	cursor: pointer;
	outline: none;
}
.or-results li:last-child { border-bottom: 0; }
.or-results li:hover, .or-results li:focus { background: rgba(59, 130, 246, 0.16); }
.or-results li.selected { background: rgba(251, 191, 36, 0.1); }
.or-results .or-name { font-weight: 600; font-size: 13.5px; }
.or-results .or-id { grid-column: 1; font: 11.5px var(--mono); color: var(--text-soft); }
.or-results .or-meta {
	grid-column: 2;
	grid-row: 1 / span 2;
	align-self: center;
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	gap: 4px;
	font-size: 11px;
	color: var(--muted);
}
.or-results .or-meta span {
	padding: 1px 7px;
	border-radius: 999px;
	border: 1px solid var(--border);
	background: rgba(59, 130, 246, 0.08);
}
.or-results .or-meta .price { color: #86efac; }
.or-results .or-meta .tps { color: #fde68a; font-weight: 650; border-color: rgba(251, 191, 36, 0.35); }
.or-results .or-meta .kind { color: #f9a8d4; }
.or-results .or-meta span:empty { display: none; }
.or-results li.kbd { background: rgba(59, 130, 246, 0.16); }
.or-results li.or-auto .or-id { color: var(--muted); font-family: var(--font); }
.or-panel .or-status { margin-top: 8px; }
.or-selected .or-using + span { overflow: hidden; text-overflow: ellipsis; }
.or-results .or-desc {
	grid-column: 1 / -1;
	font-size: 12px;
	color: var(--muted);
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}
.or-results::-webkit-scrollbar { width: 10px; }
.or-results::-webkit-scrollbar-thumb { background: rgba(125, 165, 255, 0.2); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }

.web-tag {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 1px 7px;
	border-radius: 999px;
	font-size: 11px;
	font-weight: 600;
	color: #86efac;
	background: rgba(34, 197, 94, 0.12);
	border: 1px solid rgba(34, 197, 94, 0.3);
}

.status {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	color: var(--text-soft);
	font-size: 14px;
}

.sources-toggle {
	display: inline-block;
	align-self: flex-start;
	margin: 6px 0 0 2px;
	padding: 2px 8px;
	border: 1px solid transparent;
	border-radius: 7px;
	background: transparent;
	color: var(--muted);
	font: 500 11.5px var(--font);
	cursor: pointer;
}
.sources-toggle:hover { color: var(--text); background: rgba(125, 165, 255, 0.12); border-color: var(--border); }
.sources-toggle:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }
.sources[hidden] { display: none; }
.sources {
	margin: 6px 0 0 2px;
	padding: 10px 14px;
	border-radius: 12px;
	background: rgba(17, 36, 79, 0.5);
	border: 1px solid var(--border);
	font-size: 12.5px;
}
.sources-head {
	font-weight: 650;
	font-size: 11px;
	letter-spacing: 0.4px;
	text-transform: uppercase;
	color: var(--muted);
	margin-bottom: 4px;
}
.sources ol { margin: 0; padding-left: 1.4em; }
.sources li { margin: 2px 0; overflow-wrap: anywhere; }
.sources li::marker { color: var(--muted); }
.sources a { color: var(--accent-bright); text-decoration: none; }
.sources a:hover { text-decoration: underline; }
.sources .host { margin-left: 6px; color: var(--muted); }

.hint-web { font-style: italic; }

/* generated images */
.msg.assistant .bubble.image-bubble { padding: 10px; align-self: flex-start; max-width: 100%; }
.gen-image {
	display: block;
	max-width: 100%;
	max-height: 70vh;
	border-radius: 10px;
	background: #081230;
}
.gen-caption { margin: 8px 6px 2px; font-size: 12px; color: var(--muted); }
.select-wrap select.web-on { border-color: rgba(34, 197, 94, 0.55); color: #86efac; }
.hint-web[hidden] { display: none; }

.msg.assistant .bubble {
	padding: 14px 18px;
	border-radius: 6px 18px 18px 18px;
	background: rgba(17, 36, 79, 0.85);
	border: 1px solid var(--border);
	word-wrap: break-word;
	overflow-wrap: anywhere;
}
.msg.assistant.error .bubble {
	border-color: rgba(248, 113, 113, 0.45);
	background: rgba(127, 29, 29, 0.25);
	color: #fecaca;
}
.msg.assistant .recover { margin-top: 8px; color: #fde68a; border-color: rgba(251, 191, 36, 0.45); background: rgba(251, 191, 36, 0.08); }

.notice {
	font-size: 12px;
	color: var(--muted);
	margin: 6px 0 0 2px;
}

.actions {
	display: flex;
	gap: 4px;
	margin: 6px 0 0 2px;
	opacity: 0;
	transition: opacity 0.15s;
}
.msg:hover .actions, .actions:focus-within { opacity: 1; }
.icon-btn {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 3px 8px;
	border-radius: 7px;
	border: 1px solid transparent;
	background: transparent;
	color: var(--muted);
	font: 500 12px var(--font);
	cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: rgba(125, 165, 255, 0.12); border-color: var(--border); }

/* typing indicator */
.typing { display: inline-flex; gap: 5px; padding: 4px 0; }
.typing i {
	width: 7px; height: 7px; border-radius: 50%;
	background: var(--accent-bright);
	opacity: 0.35;
	animation: blink 1.1s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); } 40% { opacity: 1; transform: scale(1); } }

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

.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 0.8em; }
.md h1, .md h2, .md h3, .md h4 { margin: 1.1em 0 0.5em; line-height: 1.3; color: #f1f5ff; }
.md h1 { font-size: 1.35em; }
.md h2 { font-size: 1.2em; }
.md h3 { font-size: 1.07em; }
.md ul, .md ol { margin: 0 0 0.8em; padding-left: 1.4em; }
.md li { margin: 0.2em 0; }
.md li::marker { color: var(--accent-bright); }
.md a { color: var(--accent-bright); text-decoration: none; border-bottom: 1px solid rgba(96, 165, 250, 0.4); }
.md a:hover { border-bottom-color: var(--accent-bright); }
.md blockquote {
	margin: 0 0 0.8em;
	padding: 2px 14px;
	border-left: 3px solid var(--accent);
	color: var(--text-soft);
	background: rgba(59, 130, 246, 0.07);
	border-radius: 0 8px 8px 0;
}
.md hr { border: 0; border-top: 1px solid var(--border); margin: 1.2em 0; }
.md table { border-collapse: collapse; margin: 0 0 0.9em; font-size: 0.94em; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.md th { background: rgba(59, 130, 246, 0.12); }
.md :not(pre) > code {
	font-family: var(--mono);
	font-size: 0.88em;
	padding: 1px 6px;
	border-radius: 6px;
	background: rgba(96, 165, 250, 0.14);
	color: #cfe0ff;
}
.md pre {
	position: relative;
	margin: 0 0 0.9em;
	border-radius: 10px;
	border: 1px solid var(--border);
	background: #081230;
	overflow: hidden;
}
.md pre code {
	display: block;
	padding: 14px 16px;
	overflow-x: auto;
	font-family: var(--mono);
	font-size: 13px;
	line-height: 1.55;
	background: transparent !important;
}
.code-head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 5px 8px 5px 14px;
	font-size: 11.5px;
	color: var(--muted);
	background: rgba(59, 130, 246, 0.08);
	border-bottom: 1px solid var(--border);
}

/* ------------------------------------------------------------ empty state */

.empty {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	pointer-events: none;
	padding: 20px;
	text-align: center;
}
.empty[hidden] { display: none; }
.empty-mark {
	width: 64px;
	height: 64px;
	border-radius: 18px;
	box-shadow: 0 18px 50px -12px rgba(59, 130, 246, 0.65);
}
.empty h1 {
	margin: 4px 0 2px;
	font-size: 24px;
	font-weight: 650;
	background: linear-gradient(90deg, #e8efff, #93c5fd);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
}
.hints {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px 16px;
	font-size: 12.5px;
	color: var(--muted);
}

.version {
	position: absolute;
	bottom: 10px;
	right: 16px;
	font-size: 11px;
	color: var(--muted);
	opacity: 0.7;
}

kbd {
	font-family: var(--font);
	font-size: 11px;
	font-weight: 600;
	padding: 1px 6px;
	border-radius: 5px;
	border: 1px solid var(--border-strong);
	border-bottom-width: 2px;
	background: rgba(59, 130, 246, 0.1);
	color: var(--text-soft);
}

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

.composer-wrap {
	flex: none;
	padding: 10px 22px 12px;
	background: linear-gradient(180deg, transparent, rgba(7, 16, 42, 0.8) 30%);
}

.key-warning {
	max-width: 820px;
	margin: 0 auto 8px;
	padding: 8px 12px;
	border-radius: 10px;
	font-size: 13px;
	color: #fecaca;
	background: rgba(127, 29, 29, 0.3);
	border: 1px solid rgba(248, 113, 113, 0.4);
}

.composer {
	max-width: 820px;
	margin: 0 auto;
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 8px 8px 8px 16px;
	border-radius: 18px;
	background: var(--surface);
	border: 1px solid var(--border-strong);
	box-shadow: 0 10px 40px -14px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.04);
	transition: border-color 0.15s, box-shadow 0.15s;
}
.composer:focus-within {
	border-color: rgba(96, 165, 250, 0.7);
	box-shadow: 0 10px 40px -14px rgba(0, 0, 0, 0.6), 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.composer textarea {
	flex: 1;
	min-height: 24px;
	max-height: 40vh;
	padding: 7px 0;
	resize: none;
	border: 0;
	outline: none;
	background: transparent;
	color: var(--text);
	font: 15px/1.5 var(--font);
}
.composer textarea::placeholder { color: var(--muted); }

.send {
	flex: none;
	width: 38px;
	height: 38px;
	display: grid;
	place-items: center;
	border: 0;
	border-radius: 12px;
	background: linear-gradient(135deg, var(--accent-deep), var(--accent-bright));
	color: #fff;
	cursor: pointer;
	transition: filter 0.15s, transform 0.05s, opacity 0.15s;
}
.send:hover { filter: brightness(1.12); }
.send:active { transform: scale(0.96); }
.send:disabled { opacity: 0.35; cursor: default; filter: none; }
.send.stop { background: #1e3a8a; border: 1px solid var(--border-strong); }
.send[hidden] { display: none; }

.composer-hint {
	max-width: 820px;
	margin: 7px auto 0;
	text-align: center;
	font-size: 11.5px;
	color: var(--muted);
}
.composer-hint kbd { font-size: 10.5px; padding: 0 5px; }

/* ------------------------------------------------------------ web additions */

.topbar { flex-wrap: wrap; height: auto; min-height: 52px; padding: 8px 14px; }
.btn-ghost { background: transparent; }
.btn-small { height: 30px; padding: 0 10px; font-size: 12px; }
.topbar .badge { margin-left: 0; }
.user-menu { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; }
.user-name { font-size: 13px; color: var(--text-soft); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Options dropdown: effort badge, History, Privacy, Phone view */
.options { position: relative; display: inline-flex; }
.options-btn { gap: 6px; }
.options-btn[aria-expanded="true"] { background: linear-gradient(180deg, #1a3775, #142c61); border-color: rgba(125, 165, 255, 0.5); }
.options-lock { display: none; font-size: 11px; line-height: 1; }
.options-btn.privacy-on .options-lock { display: inline; }
.options-btn.privacy-on { border-color: rgba(34, 197, 94, 0.55); color: #86efac; }
.options-menu {
	position: absolute;
	top: calc(100% + 6px);
	right: 0;
	min-width: 220px;
	padding: 6px;
	display: flex;
	flex-direction: column;
	gap: 2px;
	border-radius: 12px;
	border: 1px solid var(--border-strong);
	background: var(--topbar);
	box-shadow: 0 18px 50px -12px rgba(0, 0, 0, 0.75);
	z-index: 15;
	animation: drop 0.12s ease-out;
}
@keyframes drop { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }
.options-menu[hidden] { display: none; }
.options-row {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	height: 36px;
	padding: 0 12px;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: var(--text);
	font: 600 13px var(--font);
	text-align: left;
	text-decoration: none;
	cursor: pointer;
	white-space: nowrap;
	user-select: none;
}
.options-row:hover, .options-row:focus-visible { background: rgba(59, 130, 246, 0.14); outline: none; }
.options-row svg { color: var(--accent-bright); flex: none; }
.options-static { cursor: default; justify-content: space-between; color: var(--text-soft); }
.options-static:hover { background: transparent; }
.options-label { font-size: 12px; color: var(--muted); }
.options-menu .badge { margin: 0; }

.privacy { color: var(--text-soft); }
.privacy input { accent-color: #22c55e; width: 15px; height: 15px; margin: 0; cursor: pointer; }
.privacy.on { color: #86efac; background: rgba(34, 197, 94, 0.1); }

.model-tag.haiku { color: #a7f3d0; }
.model-tag.opus { color: #fda4af; }
.model-tag.fable { color: #d8b4fe; }
.select-wrap select optgroup { background: #0a1634; color: var(--muted); font-style: normal; font-weight: 600; }

.chat-title {
	max-width: 820px;
	margin: 0 auto 8px;
	font-size: 12px;
	color: var(--muted);
	display: flex;
	gap: 6px;
	align-items: center;
}
.chat-title[hidden] { display: none; }
.chat-title #chatTitle { color: #fde68a; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* system prompt editor (Options → System prompt) */
.dialog-backdrop {
	position: fixed;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	background: rgba(3, 8, 24, 0.6);
	z-index: 22;
}
.dialog-backdrop[hidden] { display: none; }
.dialog {
	display: flex;
	flex-direction: column;
	width: min(720px, 100%);
	max-height: 100%;
	border-radius: 16px;
	border: 1px solid var(--border-strong);
	background: var(--topbar);
	box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.8);
	animation: drop 0.14s ease-out;
}
.dialog-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 18px;
	border-bottom: 1px solid var(--border);
	font-weight: 650;
	font-size: 14px;
}
.dialog-head .or-clear { font-size: 20px; color: var(--text-soft); }
.dialog-help { margin: 12px 18px 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.dialog-text {
	margin: 10px 18px 0;
	min-height: 180px;
	max-height: 55vh;
	padding: 10px 12px;
	resize: vertical;
	border-radius: 10px;
	border: 1px solid var(--border);
	background: rgba(3, 8, 24, 0.5);
	color: var(--text);
	font: 14px/1.5 var(--font);
	outline: none;
}
.dialog-text:focus { border-color: rgba(125, 165, 255, 0.5); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2); }
.dialog-text::placeholder { color: var(--muted); }
.dialog-text:disabled { opacity: 0.6; }
.dialog .or-status { margin: 8px 18px 0; }
.dialog-actions { display: flex; align-items: center; gap: 8px; padding: 12px 18px 16px; }
.dialog-count { flex: 1; font-size: 12px; color: var(--muted); }
.dialog-count.error { color: #fca5a5; }
.dialog-actions .btn-primary { height: 30px; padding: 0 14px; }

/* history drawer */
.history-backdrop { position: fixed; inset: 0; background: rgba(3, 8, 24, 0.55); z-index: 20; }
.history-backdrop[hidden] { display: none; }
.history-panel {
	position: fixed;
	top: 0;
	left: 0;
	bottom: 0;
	width: min(380px, 92vw);
	z-index: 21;
	display: flex;
	flex-direction: column;
	background: var(--topbar);
	border-right: 1px solid var(--border-strong);
	box-shadow: 20px 0 60px -20px rgba(0, 0, 0, 0.7);
	animation: slide 0.16s ease-out;
}
@keyframes slide { from { transform: translateX(-24px); opacity: 0; } to { transform: none; opacity: 1; } }
.history-panel[hidden] { display: none; }
.history-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
	border-bottom: 1px solid var(--border);
	font-weight: 650;
	font-size: 14px;
}
.history-head .or-clear { font-size: 20px; color: var(--text-soft); }
.history-panel .or-status { margin: 10px 16px 0; }
.history-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
.history-list li {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 2px 8px;
	padding: 9px 10px;
	border-radius: 10px;
	cursor: pointer;
	outline: none;
}
.history-list li:hover, .history-list li:focus { background: rgba(59, 130, 246, 0.16); }
.history-list li.current { background: rgba(251, 191, 36, 0.1); }
.history-list .h-title { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-list .h-meta { grid-column: 1; font-size: 11.5px; color: var(--muted); }
.history-list .h-actions { grid-row: 1 / span 2; align-self: center; display: flex; gap: 2px; opacity: 0; }
.history-list li:hover .h-actions, .history-list li:focus-within .h-actions { opacity: 1; }
.history-list .icon-btn { padding: 3px 6px; }
.history-list .icon-btn.danger:hover { color: #fecaca; background: rgba(127, 29, 29, 0.35); border-color: rgba(248, 113, 113, 0.4); }
.history-list input.h-rename {
	grid-column: 1;
	width: 100%;
	border: 1px solid var(--border-strong);
	border-radius: 7px;
	background: #10245a;
	color: var(--text);
	font: 600 13.5px var(--font);
	padding: 3px 8px;
	outline: none;
}
.history-list .h-confirm { grid-column: 1 / -1; display: flex; gap: 6px; align-items: center; font-size: 12px; color: #fecaca; }
.history-empty { padding: 24px 16px; text-align: center; color: var(--muted); font-size: 13px; }

/* auth pages */
.auth-body {
	overflow: auto;
	align-items: center;
	justify-content: center;
	padding: calc(24px + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) calc(16px + env(safe-area-inset-left, 0px));
}
.auth-card {
	width: 100%;
	max-width: 400px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
	padding: 32px 28px;
	border-radius: 18px;
	background: rgba(17, 36, 79, 0.85);
	border: 1px solid var(--border-strong);
	box-shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.7);
	text-align: center;
}
.auth-card h1 {
	margin: 6px 0 0;
	font-size: 22px;
	font-weight: 650;
	background: linear-gradient(90deg, #e8efff, #93c5fd);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
}
.auth-sub { margin: 0 0 8px; color: var(--muted); font-size: 13.5px; }
.auth-form { width: 100%; display: flex; flex-direction: column; gap: 12px; text-align: left; }
.auth-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--text-soft); }
.auth-form input {
	height: 40px;
	padding: 0 12px;
	border-radius: 10px;
	border: 1px solid var(--border-strong);
	background: #10245a;
	color: var(--text);
	font: 14px var(--font);
	outline: none;
}
.auth-form input:focus { border-color: rgba(96, 165, 250, 0.7); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2); }
.btn-primary { justify-content: center; height: 40px; background: linear-gradient(135deg, var(--accent-deep), var(--accent-bright)); border: 0; text-decoration: none; }
.btn-primary:hover { filter: brightness(1.1); background: linear-gradient(135deg, var(--accent-deep), var(--accent-bright)); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }
.auth-error { padding: 8px 12px; border-radius: 10px; font-size: 13px; color: #fecaca; background: rgba(127, 29, 29, 0.3); border: 1px solid rgba(248, 113, 113, 0.4); }
.auth-success { padding: 8px 12px; border-radius: 10px; font-size: 13px; color: #bbf7d0; background: rgba(20, 83, 45, 0.3); border: 1px solid rgba(34, 197, 94, 0.4); }
.auth-error[hidden], .auth-success[hidden] { display: none; }
.auth-alt { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.auth-alt a { color: var(--accent-bright); text-decoration: none; }

@media (max-width: 640px) {
	.brand-name { display: none; }
	.thread { padding: 16px 12px 8px; }
	.composer-wrap { padding: 8px 12px 10px; }
	.composer-hint { display: none; }
	.msg.user .bubble { max-width: 92%; }
}

/* ------------------------------------------------------------ attachments */

.send.attach { background: #10245a; border: 1px solid var(--border-strong); color: var(--text-soft); }
.send.attach:hover { color: var(--text); border-color: rgba(125, 165, 255, 0.6); filter: none; }
.composer.drop { border-color: rgba(96, 165, 250, 0.9); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3); }

.attachments {
	max-width: 820px;
	margin: 0 auto 8px;
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}
.attachments[hidden] { display: none; }
.chip {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	max-width: 100%;
	padding: 4px 8px 4px 6px;
	border-radius: 10px;
	font-size: 12.5px;
	color: var(--text-soft);
	background: rgba(17, 36, 79, 0.85);
	border: 1px solid var(--border-strong);
}
.chip img { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; background: #081230; }
.chip .chip-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 6px; background: rgba(59, 130, 246, 0.14); color: var(--accent-bright); font: 700 10px var(--font); text-transform: uppercase; }
.chip .chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.chip .chip-size { color: var(--muted); font-size: 11px; }
.chip .or-clear { font-size: 16px; color: var(--muted); }
.chip .or-clear:hover { color: var(--text); }
.chip a { color: inherit; text-decoration: none; }
.chip a:hover { text-decoration: underline; }

.msg.user .user-files { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-bottom: 6px; max-width: 78%; }
.msg.user .user-files img.user-image { max-width: 220px; max-height: 220px; border-radius: 12px; border: 1px solid var(--border-strong); display: block; }
.msg.user .bubble:empty { display: none; }
/* double-click/tap to copy: no double-tap zoom, and a brief flash when copied */
.msg.user .bubble { touch-action: manipulation; cursor: copy; transition: box-shadow 0.2s, filter 0.2s; }
.msg.user .bubble.copied { box-shadow: 0 0 0 3px rgba(134, 239, 172, 0.7); filter: brightness(1.15); }

/* ------------------------------------------------------------ video + music */

.model-tag.video { color: #67e8f9; }
.model-tag.music { color: #f0abfc; }
.select-wrap[hidden] { display: none; }
.gen-video {
	display: block;
	max-width: 100%;
	max-height: 70vh;
	border-radius: 10px;
	background: #081230;
}
.gen-audio { display: block; width: min(100%, 480px); margin: 2px 0; }
.gen-audio::-webkit-media-controls-panel { background: #10245a; }
