@font-face {
	font-family: Archivo;
	src: url("fonts/archivo.ttf") format("truetype");
	font-weight: 400 800;
	font-stretch: 100% 125%;
	font-display: swap;
}
@font-face {
	font-family: Inter;
	src: url("fonts/inter.ttf") format("truetype");
	font-weight: 100 900;
	font-display: swap;
}
:root {
	color-scheme: dark;
	--bg: #0b0b0e;
	--rail: #060608;
	--surface: #15151a;
	--surface-2: #212128;
	--line: #25252c;
	--line-2: #3b3b45;
	--ink: #f2f2f2;
	--soft: #d3d3d8;
	--muted: #9a9aa3;
	--accent: #d61616;
	--accent-ink: #ff6b6b;
	--ok: #46c98b;
	--warn: #e0a23a;
	--side: 17rem;
	--ease: cubic-bezier(0.2, 0.7, 0.2, 1);
	background: var(--bg);
	color: var(--ink);
	font:
		100% / 1.55 Inter,
		system-ui,
		sans-serif;
	-webkit-text-size-adjust: 100%;
}
:root.high-contrast {
	--bg: #000;
	--rail: #000;
	--surface: #101010;
	--surface-2: #262626;
	--line: #8d8d94;
	--line-2: #b9b9bf;
	--soft: #fff;
	--ink: #fff;
	--muted: #e1e1e1;
	--accent-ink: #ff8a8a;
}
* {
	box-sizing: border-box;
}
[hidden] {
	display: none !important;
}
.sr {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}
svg {
	width: 1.25rem;
	height: 1.25rem;
	flex: none;
}
a {
	color: inherit;
	text-underline-offset: 0.2em;
}
:focus-visible {
	outline: 2px solid var(--accent-ink);
	outline-offset: 2px;
}
.high-contrast :focus-visible {
	outline-width: 4px;
}

/* Shell */
body {
	margin: 0;
	height: 100dvh;
	overflow: hidden;
	display: grid;
	grid-template-columns: var(--side) minmax(0, 1fr);
	transition: grid-template-columns 0.24s var(--ease);
}
.side-closed body {
	grid-template-columns: 0 minmax(0, 1fr);
}
.skip {
	position: fixed;
	z-index: 40;
	top: 0.5rem;
	left: 0.5rem;
	padding: 0.5rem 0.9rem;
	border-radius: 0.6rem;
	background: var(--ink);
	color: var(--bg);
	transform: translateY(-200%);
}
.skip:focus {
	transform: none;
}
#sidebar {
	grid-column: 1;
	width: var(--side);
	height: 100dvh;
	display: flex;
	flex-direction: column;
	background: var(--rail);
	border-right: 1px solid var(--line);
	transition:
		transform 0.24s var(--ease),
		visibility 0s;
}
.side-closed #sidebar {
	transform: translateX(-100%);
	visibility: hidden;
	transition:
		transform 0.24s var(--ease),
		visibility 0s 0.24s;
}
#scrim {
	position: fixed;
	inset: 0;
	z-index: 19;
	background: rgb(0 0 0 / 0.55);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.24s;
}
.brand {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	height: 3.5rem;
	padding: 0 1.1rem;
	flex: none;
	text-decoration: none;
}
.brand img {
	width: 20px;
	height: 30px;
}
.words {
	display: grid;
	gap: 4px;
	line-height: 1;
	text-transform: uppercase;
	font-family: Archivo, system-ui, sans-serif;
	font-variation-settings: "wdth" 125;
}
.words b {
	font-weight: 800;
	font-size: 13px;
	letter-spacing: 0.14em;
}
.words i {
	font-style: normal;
	font-weight: 500;
	font-size: 8.3px;
	letter-spacing: 0.526em;
	color: var(--muted);
}
#sidebar nav {
	display: grid;
	gap: 1px;
	padding: 0.25rem 0.5rem 0;
	flex: none;
}
#sidebar nav a,
#account-link {
	display: flex;
	align-items: center;
	gap: 0.7rem;
	padding: 0.5rem 0.6rem;
	border-radius: 0.6rem;
	color: var(--soft);
	font-size: 0.92rem;
	text-decoration: none;
	transition:
		background-color 0.15s,
		color 0.15s;
}
#sidebar nav a:hover,
#account-link:hover,
.chat-row:hover,
.chat-row:focus-within {
	background: var(--surface);
	color: var(--ink);
}
#sidebar [aria-current],
.chat-row:has([aria-current]) {
	background: var(--surface-2);
	color: var(--ink);
}
#chats {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	padding: 0.25rem 0.5rem 1rem;
	scrollbar-width: thin;
	scrollbar-color: var(--line-2) transparent;
}
#chats h2 {
	margin: 0;
	padding: 1.1rem 0.6rem 0.35rem;
	font:
		600 0.72rem / 1.4 Inter,
		sans-serif;
	letter-spacing: 0.02em;
	color: var(--muted);
}
#chats p {
	margin: 0;
	padding: 0.6rem;
	font-size: 0.85rem;
	color: var(--muted);
}
#chat-search {
	margin-top: 1rem;
	padding: 0.4rem 0.7rem;
	font-size: 0.88rem;
}
.chat-row {
	display: flex;
	min-height: 2.3rem;
	align-items: center;
	border-radius: 0.6rem;
	color: var(--soft);
	transition: background-color 0.15s;
	animation: arrive 0.2s var(--ease);
}
.chat-row a {
	flex: 1;
	min-width: 0;
	padding: 0.45rem 0 0.45rem 0.6rem;
	font-size: 0.9rem;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	text-decoration: none;
	border-radius: 0.6rem;
}
#sidebar .chat-row a {
	background: none;
}
.chat-row .icon {
	width: 1.9rem;
	height: 1.9rem;
	opacity: 0;
}
.chat-row:hover .icon,
.chat-row .icon:focus-visible,
.chat-row .icon[aria-expanded="true"] {
	opacity: 1;
}
@media (hover: none) {
	.chat-row .icon {
		opacity: 1;
	}
}
.chat-row input {
	min-height: 0;
	height: 2rem;
	margin: 0 0.15rem;
	padding: 0 0.45rem;
	font-size: 0.9rem;
}
#account-link {
	flex: none;
	margin: 0.5rem;
	position: relative;
}
#account-link::before {
	content: "";
	position: absolute;
	inset: -0.5rem -0.5rem auto;
	border-top: 1px solid var(--line);
}
#account-name {
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}
.avatar {
	display: grid;
	place-items: center;
	width: 1.75rem;
	height: 1.75rem;
	flex: none;
	border-radius: 50%;
	background: var(--surface-2);
	color: var(--muted);
	font:
		700 0.8rem / 1 Archivo,
		sans-serif;
}
.avatar svg {
	width: 1rem;
	height: 1rem;
}
.avatar.named {
	background: var(--accent);
	color: #fff;
}
#account-link .trail {
	width: 1.1rem;
	height: 1.1rem;
	margin-left: auto;
	color: var(--muted);
	transition: color 0.15s;
}
#account-link:hover .trail,
#account-link[aria-current] .trail {
	color: var(--ink);
}
#chat-menu {
	position: fixed;
	z-index: 30;
	min-width: 9.5rem;
	padding: 0.25rem;
	background: var(--surface-2);
	border: 1px solid var(--line-2);
	border-radius: 0.7rem;
	box-shadow: 0 0.6rem 1.8rem rgb(0 0 0 / 0.5);
	animation: arrive 0.14s var(--ease);
}
#chat-menu button,
#model-options button {
	display: block;
	width: 100%;
	min-height: 2.25rem;
	padding: 0.4rem 0.7rem;
	background: none;
	border: 0;
	border-radius: 0.45rem;
	color: var(--ink);
	font-weight: 500;
	text-align: left;
}
#chat-menu button:hover,
#chat-menu button:focus-visible,
#model-options button:hover,
#model-options button:focus-visible {
	background: rgb(255 255 255 / 0.08);
	color: var(--ink);
	outline-offset: -2px;
}
#chat-menu [data-do="delete"] {
	color: var(--accent-ink);
}

main {
	grid-column: 2;
	min-width: 0;
	height: 100dvh;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
}
.topbar {
	position: sticky;
	top: 0;
	z-index: 5;
	flex: none;
	display: flex;
	align-items: center;
	gap: 0.5rem;
	height: 3.5rem;
	padding: 0 0.75rem;
	background: var(--bg);
}
h1,
h2,
h3 {
	font-family: Archivo, system-ui, sans-serif;
	font-variation-settings: "wdth" 104;
	letter-spacing: -0.01em;
	line-height: 1.2;
}
.topbar h1 {
	margin: 0;
	font-size: 1.05rem;
	font-weight: 650;
}
.topbar-note,
.state-dot,
.section-head span {
	margin-left: auto;
	padding-right: 0.5rem;
	color: var(--muted);
	font-size: 0.82rem;
	font-variant-numeric: tabular-nums;
	text-align: right;
}
.state-dot {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 0.45rem;
	min-width: 7rem;
}
.state-dot::before,
.node .process::before,
.models .state::before {
	content: "";
	width: 0.5rem;
	height: 0.5rem;
	flex: none;
	border-radius: 50%;
	background: #66666e;
	transition: background-color 0.2s;
}
.state-dot[data-level="on"]::before,
.node[data-running="yes"] .process::before,
.models [data-state="enabled"] .state::before {
	background: var(--ok);
}
.state-dot[data-level="busy"]::before {
	background: var(--warn);
}
.state-dot[data-level="off"]::before,
.models [data-state="failed"] .state::before {
	background: var(--accent);
}

/* Controls */
button,
input,
textarea,
select {
	font: inherit;
}
button,
.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	min-height: 2.5rem;
	padding: 0.45rem 1rem;
	border: 1px solid var(--ink);
	border-radius: 0.6rem;
	background: var(--ink);
	color: var(--bg);
	font-weight: 600;
	text-decoration: none;
	white-space: nowrap;
	cursor: pointer;
	transition:
		background-color 0.15s,
		border-color 0.15s,
		color 0.15s,
		opacity 0.15s;
}
button:hover:enabled,
.button:hover {
	background: #cfcfd4;
	border-color: #cfcfd4;
}
.quiet {
	background: transparent;
	border-color: var(--line-2);
	color: var(--ink);
}
.quiet:hover:enabled {
	background: var(--surface-2);
	border-color: var(--line-2);
}
button:disabled {
	opacity: 0.45;
	cursor: default;
}
.icon {
	width: 2.25rem;
	height: 2.25rem;
	min-height: 0;
	padding: 0;
	flex: none;
	background: none;
	border: 0;
	color: var(--muted);
}
.icon:hover:enabled {
	background: var(--surface-2);
	color: var(--ink);
}
label,
legend {
	display: block;
	margin-bottom: 0.4rem;
	padding: 0;
	font-size: 0.85rem;
	font-weight: 550;
	color: var(--muted);
}
input,
textarea,
select {
	width: 100%;
	min-height: 2.5rem;
	padding: 0.5rem 0.75rem;
	background: var(--surface);
	color: var(--ink);
	border: 1px solid var(--line-2);
	border-radius: 0.6rem;
	transition:
		border-color 0.15s,
		opacity 0.15s;
}
input::placeholder,
textarea::placeholder {
	color: var(--muted);
}
select:disabled,
fieldset:disabled {
	opacity: 0.6;
}
.secret-entry {
	display: flex;
	gap: 0.4rem;
}
.secret-entry input {
	min-width: 0;
	flex: 1;
}
.secret-entry button {
	min-width: 4.5rem;
}
.actions {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.6rem 0.9rem;
}
#feedback,
#model-feedback,
#limit-feedback,
#picker-empty {
	font-size: 0.85rem;
	color: var(--muted);
}

/* Chat */
.chat main {
	overflow: hidden;
	position: relative;
}
.chat main::after {
	content: "";
	flex: 0 1 0px;
	transition: flex-grow 0.38s var(--ease);
}
.chat main.empty::after {
	flex-grow: 1.35;
}
#transcript {
	flex: 1 1 0px;
	min-height: 0;
	overflow-y: auto;
	scrollbar-gutter: stable both-edges;
	scrollbar-width: thin;
	scrollbar-color: var(--line-2) transparent;
	outline: none;
}
#thread,
.dock {
	width: min(47rem, 100% - 2rem);
	margin: 0 auto;
}
#thread {
	padding: 0.5rem 0 2rem;
}
.turn {
	margin: 1.6rem 0;
	animation: arrive 0.22s var(--ease);
}
.turn.user {
	display: flex;
	justify-content: flex-end;
}
.bubble {
	max-width: min(85%, 34rem);
	padding: 0.6rem 1rem;
	border-radius: 1.25rem;
	background: var(--surface-2);
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}
.reply-body {
	min-width: 0;
	min-height: 1.65rem;
	line-height: 1.65;
	overflow-wrap: anywhere;
}
.reply-body > :first-child {
	margin-top: 0;
}
.reply-body > :last-child {
	margin-bottom: 0;
}
.reply-body p {
	margin: 0.75em 0;
}
.reply-body h1,
.reply-body h2,
.reply-body h3,
.reply-body h4 {
	font-size: 1.1rem;
	margin: 1.4em 0 0.4em;
}
.reply-body ul,
.reply-body ol {
	padding-inline-start: 1.4rem;
	margin: 0.75em 0;
}
.reply-body li {
	margin: 0.25em 0;
}
.reply-body blockquote {
	border-inline-start: 2px solid var(--line-2);
	margin: 0.75em 0;
	padding-inline-start: 1rem;
	color: var(--soft);
}
.reply-body hr {
	border: 0;
	border-top: 1px solid var(--line);
	margin: 1.5em 0;
}
.reply-body code {
	font:
		0.88em / 1.55 ui-monospace,
		"SF Mono",
		Menlo,
		monospace;
	background: var(--surface-2);
	padding: 0.12em 0.36em;
	border-radius: 0.3rem;
}
.code {
	margin: 0.9em 0;
	border: 1px solid var(--line);
	border-radius: 0.7rem;
	overflow: hidden;
	background: #08080a;
}
.code-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.25rem 0.3rem 0.25rem 0.9rem;
	background: var(--surface);
	color: var(--muted);
	font-size: 0.78rem;
}
.code-head button {
	min-height: 1.75rem;
	min-width: 4.2rem;
	padding: 0.1rem 0.6rem;
	border: 0;
	font-size: 0.78rem;
	color: var(--soft);
}
.reply-body pre {
	margin: 0;
	padding: 0.85rem 1rem;
	overflow-x: auto;
	white-space: pre;
	scrollbar-width: thin;
}
.reply-body pre code {
	background: none;
	padding: 0;
}
.reply-body > pre {
	margin: 0.9em 0;
	border: 1px solid var(--line);
	border-radius: 0.7rem;
	background: #08080a;
}
.reply-body table {
	display: block;
	max-width: 100%;
	overflow-x: auto;
	border-collapse: collapse;
	margin: 0.9em 0;
	font-size: 0.92rem;
}
.reply-body td,
.reply-body th {
	border-bottom: 1px solid var(--line);
	padding: 0.45rem 0.9rem 0.45rem 0;
	text-align: left;
}
.reply-body.waiting::before {
	content: "";
	display: block;
	width: 0.6rem;
	height: 0.6rem;
	margin: 0.5rem 0.2rem;
	background: var(--accent);
	transform: rotate(45deg);
	animation: pulse 0.9s ease-in-out infinite alternate;
}
.reply-body.streaming > :last-child::after {
	content: "";
	display: inline-block;
	width: 0.5rem;
	height: 0.5rem;
	margin-left: 0.35em;
	background: var(--accent);
	transform: rotate(45deg);
	animation: pulse 0.9s ease-in-out infinite alternate;
}
.reply-body.streaming > .code:last-child::after {
	display: none;
}
.turn-actions {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	height: 2rem;
	margin: 0.3rem 0 0 -0.45rem;
	color: var(--muted);
	font-size: 0.8rem;
}
.turn-actions .icon {
	width: 2rem;
	height: 2rem;
	animation: arrive 0.2s var(--ease);
}
.turn-actions svg {
	width: 1.05rem;
	height: 1.05rem;
}
.dock {
	position: relative;
	flex: none;
	padding-bottom: max(0.4rem, env(safe-area-inset-bottom));
}
.hero {
	position: absolute;
	left: 50%;
	bottom: calc(100% + 2rem);
	width: 40px;
	height: 60px;
	translate: -50% 0.5rem;
	opacity: 0;
	pointer-events: none;
	transition:
		opacity 0.25s,
		translate 0.38s var(--ease);
}
.empty .hero {
	opacity: 1;
	translate: -50% 0;
}
#jump {
	position: absolute;
	left: 50%;
	bottom: calc(100% + 0.75rem);
	translate: -50% 0;
	border: 1px solid var(--line-2);
	border-radius: 50%;
	background: var(--surface);
	color: var(--ink);
	box-shadow: 0 0.3rem 1rem rgb(0 0 0 / 0.4);
	transition:
		opacity 0.18s,
		translate 0.18s,
		background-color 0.15s;
}
#jump[inert] {
	opacity: 0;
	translate: -50% 0.4rem;
}
#composer {
	display: flex;
	align-items: flex-end;
	gap: 0.5rem;
	padding: 0.45rem 0.45rem 0.45rem 1.15rem;
	background: var(--surface);
	border: 1px solid var(--line-2);
	border-radius: 1.6rem;
	transition: border-color 0.15s;
	cursor: text;
}
#composer:focus-within {
	border-color: #6d6d78;
}
#prompt {
	flex: 1;
	min-height: 0;
	height: 2.4rem;
	max-height: 13rem;
	padding: 0.45rem 0;
	border: 0;
	border-radius: 0;
	background: none;
	outline: none;
	resize: none;
	line-height: 1.5;
	scrollbar-width: thin;
}
#send {
	width: 2.4rem;
	height: 2.4rem;
	min-height: 0;
	padding: 0;
	flex: none;
	border-radius: 50%;
}
#send:disabled {
	background: var(--surface-2);
	border-color: var(--surface-2);
	color: var(--muted);
	opacity: 1;
}
#feedback {
	min-height: 1.3rem;
	margin: 0.4rem 0 0;
	text-align: center;
	font-size: 0.8rem;
}
.model-picker {
	position: relative;
	min-width: 0;
}
#model {
	max-width: min(22rem, 52vw);
	padding: 0.4rem 0.5rem 0.4rem 0.75rem;
	border: 0;
	font-size: 1rem;
}
#model:disabled {
	opacity: 1;
}
#model:disabled svg {
	opacity: 0;
}
#model-name {
	overflow: hidden;
	text-overflow: ellipsis;
}
#model svg {
	width: 1rem;
	height: 1rem;
	color: var(--muted);
	transition:
		rotate 0.2s var(--ease),
		opacity 0.15s;
}
#model[aria-expanded="true"] svg {
	rotate: 180deg;
}
#picker-panel {
	position: absolute;
	z-index: 10;
	top: calc(100% + 0.35rem);
	left: 0;
	width: min(20rem, 85vw);
	padding: 0.3rem;
	background: var(--surface-2);
	border: 1px solid var(--line-2);
	border-radius: 0.8rem;
	box-shadow: 0 0.6rem 1.8rem rgb(0 0 0 / 0.5);
	animation: arrive 0.14s var(--ease);
}
#model-search {
	margin-bottom: 0.3rem;
	background: var(--bg);
}
#model-options {
	max-height: min(18rem, 40dvh);
	overflow-y: auto;
}
#model-options button {
	position: relative;
	padding-right: 2rem;
	white-space: normal;
	overflow-wrap: anywhere;
}
#model-options [aria-pressed="true"]::after {
	content: "✓";
	position: absolute;
	right: 0.7rem;
	color: var(--accent-ink);
}
#picker-empty {
	margin: 0.5rem 0.7rem;
}
.clipboard-source {
	position: fixed;
	left: -200vw;
	top: 0;
}

/* Pages */
.page {
	width: min(46rem, 100% - 2.5rem);
	margin: 0 auto;
	padding: 1rem 0 4rem;
}
.page.wide {
	width: min(60rem, 100% - 2.5rem);
}
.page section {
	margin-top: 2.75rem;
}
.page section:first-child,
#activity > section:first-child {
	margin-top: 0.5rem;
}
.page h2 {
	margin: 0 0 0.85rem;
	font-size: 1.05rem;
	font-weight: 650;
}
.section-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 1rem;
}
.section-head span {
	padding: 0;
}
dl,
dd {
	margin: 0;
}
dd {
	font-variant-numeric: tabular-nums;
	overflow-wrap: anywhere;
}
.tiles {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
	gap: 0.6rem;
}
.tiles div {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
	min-height: 5.1rem;
	padding: 0.85rem 1rem;
	border-radius: 0.8rem;
	background: var(--surface);
}
.tiles dt {
	font-size: 0.8rem;
	color: var(--muted);
}
.tiles dd {
	font:
		650 1.15rem / 1.25 Archivo,
		sans-serif;
}
.rows {
	color: var(--muted);
}
.rows div {
	display: flex;
	justify-content: space-between;
	gap: 1.5rem;
	padding: 0.7rem 0;
	border-bottom: 1px solid var(--line);
	color: var(--ink);
}
.rows dt {
	color: var(--soft);
	overflow-wrap: anywhere;
}
.rows dd {
	text-align: right;
	color: var(--muted);
}
.note {
	margin: 1rem 0 0;
	font-size: 0.85rem;
	color: var(--muted);
}
#activity,
#stats-login {
	animation: arrive 0.22s var(--ease);
}

/* Settings */
.page.settings {
	width: min(30rem, 100% - 2.5rem);
	animation: arrive 0.22s var(--ease);
}
.settings section {
	position: relative;
	margin-top: 2.5rem;
}
.settings section:first-child {
	margin-top: 0.5rem;
}
.settings h2 {
	margin: 0 0 0.6rem;
	font:
		600 0.78rem / 1.4 Inter,
		sans-serif;
	letter-spacing: 0.02em;
	color: var(--muted);
}
.group {
	border-bottom: 1px solid var(--line);
}
.setting,
.fold,
.host-row {
	border-top: 1px solid var(--line);
}
.setting,
.fold-head {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	min-height: 3.5rem;
	margin: 0;
	color: var(--ink);
	font-size: 0.95rem;
	font-weight: 500;
}
.setting > :last-child {
	margin-left: auto;
}
.setting.empty {
	color: var(--muted);
	font-weight: 400;
	animation: arrive 0.2s var(--ease);
}
.row-status {
	flex: 1;
	color: var(--muted);
	font-size: 0.85rem;
	font-weight: 400;
	text-align: right;
}
.fold-head {
	width: 100%;
	justify-content: space-between;
	padding: 0;
	border: 0;
	border-radius: 0.4rem;
	background: none;
	text-align: left;
	white-space: normal;
}
.fold-head:hover:enabled {
	background: none;
}
.fold-head svg {
	width: 1.1rem;
	height: 1.1rem;
	color: var(--muted);
	transition:
		rotate 0.24s var(--ease),
		color 0.15s;
}
.fold-head:hover:enabled svg,
.fold-head[aria-expanded="true"] svg {
	color: var(--ink);
}
.fold-head[aria-expanded="true"] svg {
	rotate: 180deg;
}
.fold-body {
	display: grid;
	grid-template-rows: 0fr;
	visibility: hidden;
	transition:
		grid-template-rows 0.26s var(--ease),
		visibility 0s 0.26s;
}
.fold-head[aria-expanded="true"] + .fold-body {
	grid-template-rows: 1fr;
	visibility: visible;
	transition:
		grid-template-rows 0.26s var(--ease),
		visibility 0s;
}
/* The side padding keeps focus rings inside the clipped area. */
.fold-body form {
	min-height: 0;
	margin-inline: -0.4rem;
	padding-inline: 0.4rem;
	overflow: hidden;
}
.settings form label {
	margin-top: 0.9rem;
}
.fold-body form > label:first-child {
	margin-top: 0.15rem;
}
.settings form .actions {
	margin-top: 1.1rem;
}
.form-status {
	min-height: 1.4rem;
	margin: 0.6rem 0 0;
	font-size: 0.85rem;
	color: var(--muted);
}
.fold-body .form-status {
	margin-bottom: 0.8rem;
}
#profile .setting {
	min-height: 4rem;
}
#profile .avatar {
	width: 2.25rem;
	height: 2.25rem;
	font-size: 1rem;
}
#profile-name {
	min-width: 0;
	font-weight: 600;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}
#app-return {
	display: flex;
	margin-bottom: 1.5rem;
}
#google-signin {
	padding: 0;
	border: 0;
	border-radius: 4px;
	background: transparent;
}
#google-signin:hover:enabled {
	opacity: 0.85;
}
.or {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	margin: 1.1rem 0 0.1rem;
	color: var(--muted);
	font-size: 0.8rem;
}
.or::before,
.or::after {
	content: "";
	flex: 1;
	border-top: 1px solid var(--line);
}
#google-signin[hidden] + .or {
	display: none;
}
#google-signin[hidden] ~ label:first-of-type {
	margin-top: 0;
}
#credentials .actions button {
	flex: 1;
}
/* Signed in, a rare sign-out error sits in the gap below the row instead of moving the page. */
#profile:not([hidden]) ~ #identity {
	position: absolute;
	top: 100%;
}
.switch {
	cursor: pointer;
}
.switch input {
	appearance: none;
	position: relative;
	width: 2.6rem;
	min-height: 0;
	height: 1.5rem;
	padding: 0;
	flex: none;
	border: 0;
	border-radius: 1rem;
	background: var(--line-2);
	cursor: pointer;
	transition: background-color 0.18s;
}
.switch input::before {
	content: "";
	position: absolute;
	top: 0.2rem;
	left: 0.2rem;
	width: 1.1rem;
	height: 1.1rem;
	border-radius: 50%;
	background: #fff;
	transition: translate 0.18s var(--ease);
}
.switch input:checked {
	background: var(--accent);
}
.switch input:checked::before {
	translate: 1.1rem 0;
}
.compact {
	min-height: 2rem;
	padding: 0.2rem 0.7rem;
	font-size: 0.8rem;
}
.turn-actions .compact {
	animation: arrive 0.2s var(--ease);
}
.quiet.danger,
.quiet.danger:hover:enabled {
	border-color: var(--accent-ink);
	color: var(--accent-ink);
}
#history-count {
	font-variant-numeric: tabular-nums;
}
input[type="file"] {
	padding: 0.3rem;
	color: var(--muted);
	font-size: 0.88rem;
	cursor: pointer;
}
input[type="file"]::file-selector-button {
	min-height: 1.9rem;
	margin-right: 0.75rem;
	padding: 0.2rem 0.8rem;
	border: 1px solid var(--line-2);
	border-radius: 0.45rem;
	background: var(--surface-2);
	color: var(--ink);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}
.host-row {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 4.6rem auto;
	align-items: center;
	gap: 0.3rem 0.75rem;
	padding: 0.7rem 0;
	animation: arrive 0.2s var(--ease);
}
.host-row b {
	font-size: 0.95rem;
	font-weight: 600;
	overflow-wrap: anywhere;
}
.host-row .state-dot {
	min-width: 0;
	margin: 0;
	padding: 0;
	justify-content: flex-start;
}
.host-row button {
	min-width: 5.2rem;
}
.fingerprint {
	font:
		0.8rem / 1.5 ui-monospace,
		SFMono-Regular,
		Menlo,
		monospace;
	letter-spacing: 0.02em;
	overflow-wrap: anywhere;
}
.host-row .fingerprint {
	grid-column: 1 / -1;
	color: var(--muted);
}
input.fingerprint {
	font-size: 0.9rem;
}

/* Stats */
#join-grid {
	display: grid;
	grid-template-rows: repeat(7, 1rem);
	grid-auto-flow: column;
	grid-auto-columns: 1rem;
	gap: 4px;
}
#join-grid button {
	min-height: 0;
	padding: 0;
	border: 0;
	border-radius: 3px;
	background: var(--surface-2);
}
#join-grid button[data-level="1"] {
	background: #6b2227;
}
#join-grid button[data-level="2"] {
	background: #b3323a;
}
#join-grid button[data-level="3"] {
	background: #ff7a80;
}
#join-grid button[aria-pressed="true"] {
	outline: 2px solid var(--ink);
	outline-offset: 1px;
}
#join-detail {
	display: block;
	min-height: 1.4rem;
	margin-top: 0.7rem;
	color: var(--muted);
	font-size: 0.85rem;
}

/* Network */
.device-run {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	min-height: 3rem;
}
#state {
	margin: 0;
	font:
		650 1.3rem / 1.25 Archivo,
		sans-serif;
}
.contribute #toggle {
	min-width: 11.5rem;
	flex: none;
}
#session-steps {
	display: grid !important;
	grid-template-columns: repeat(4, 1fr);
	gap: 0.4rem;
	margin: 0.75rem 0 1rem;
	padding: 0;
	list-style: none;
	transition:
		opacity 0.2s,
		visibility 0.2s;
}
#session-steps[hidden] {
	opacity: 0;
	visibility: hidden;
}
#session-steps li {
	padding-top: 0.4rem;
	border-top: 3px solid var(--line-2);
	color: var(--muted);
	font-size: 0.8rem;
	transition:
		border-color 0.2s,
		color 0.2s;
}
#session-steps li[data-done="true"] {
	border-color: var(--soft);
}
#session-steps li[aria-current="step"] {
	border-color: var(--accent);
	color: var(--ink);
	font-weight: 600;
}
#limits {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1.1rem 0.75rem;
}
#limits fieldset,
#limits .actions {
	grid-column: 1 / -1;
}
#limits .actions {
	min-height: 2.5rem;
}
.segmented {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem;
	margin: 0;
	padding: 0;
	border: 0;
	transition: opacity 0.15s;
}
.segmented label {
	position: relative;
	margin: 0;
	cursor: pointer;
}
.segmented input {
	position: absolute;
	width: 1px;
	min-height: 0;
	height: 1px;
	opacity: 0;
}
.segmented span {
	display: block;
	padding: 0.5rem 0.95rem;
	border: 1px solid var(--line-2);
	border-radius: 0.6rem;
	color: var(--ink);
	transition:
		color 0.15s,
		background-color 0.15s,
		border-color 0.15s;
}
.segmented input:checked + span {
	background: var(--ink);
	border-color: var(--ink);
	color: var(--bg);
}
.segmented input:focus-visible + span {
	outline: 2px solid var(--accent-ink);
	outline-offset: 2px;
}
.network-help details,
#model-updates {
	border-top: 1px solid var(--line);
}
.network-help details:last-child {
	border-bottom: 1px solid var(--line);
}
summary {
	padding: 0.8rem 0;
	cursor: pointer;
}
.network-help p {
	margin: 0 0 1rem;
	color: var(--muted);
}

/* Admin */
#controls,
#add-model {
	display: grid;
	grid-template-columns: minmax(0, 24rem) auto;
	justify-content: start;
	align-items: end;
	gap: 0.4rem 0.6rem;
}
#controls [role="status"],
#add-model [role="status"] {
	grid-column: 1 / -1;
	min-height: 1.4rem;
}
#controls #toggle {
	min-width: 8.5rem;
}
.topology {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 2.25rem 0.75rem;
	margin: 0;
	padding: 0;
	list-style: none;
}
.node {
	position: relative;
	padding: 0.85rem 1rem;
	border: 1px solid transparent;
	border-radius: 0.8rem;
	background: var(--surface);
	transition: border-color 0.15s;
}
.node:first-child {
	grid-column: 2;
}
.node:nth-child(2) {
	grid-column: 1;
}
.node:has(.node-open:hover),
.node:focus-within {
	border-color: var(--line-2);
}
.node h3,
.node p {
	margin: 0;
}
.node h3 {
	font-size: 1rem;
}
.node p {
	margin: 0.1rem 0 0.7rem;
	font-size: 0.82rem;
	color: var(--muted);
}
.node span {
	display: flex;
	align-items: center;
	gap: 0.45rem;
	font-size: 0.84rem;
	color: var(--soft);
}
.node .host::before {
	content: "";
	width: 0.5rem;
	height: 0.5rem;
	flex: none;
	border-radius: 50%;
	background: #66666e;
	transition: background-color 0.2s;
}
.node[data-host="yes"] .host::before {
	background: var(--ok);
}
#controls + section {
	margin-top: 1.25rem;
}
.node .node-open {
	display: inline;
	min-height: 0;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	text-align: left;
}
.node-open::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	cursor: pointer;
}
.node::before,
.node:not(:first-child)::after {
	content: "";
	position: absolute;
	left: 50%;
	bottom: calc(100% + 1px);
	height: 1.125rem;
	border-left: 1px solid var(--line-2);
}
.node:first-child::before {
	top: calc(100% + 1px);
	bottom: auto;
}
.node:not(:first-child)::after {
	left: -0.4rem;
	right: -0.4rem;
	bottom: calc(100% + 1.125rem);
	height: 0;
	border: 0;
	border-top: 1px solid var(--line-2);
}
.node:nth-child(2)::after {
	left: 50%;
}
.node:last-child::after {
	right: 50%;
}
#node-details {
	position: fixed;
	inset: 0 0 0 auto;
	width: min(24rem, 88vw);
	height: 100dvh;
	max-width: 100%;
	max-height: 100dvh;
	margin: 0;
	padding: 1.5rem;
	border: 0;
	border-inline-start: 1px solid var(--line);
	background: var(--surface);
	color: var(--ink);
	transform: translateX(100%);
	opacity: 0;
	transition:
		transform 0.24s var(--ease),
		opacity 0.24s,
		display 0.24s allow-discrete,
		overlay 0.24s allow-discrete;
}
#node-details[open] {
	transform: none;
	opacity: 1;
}
@starting-style {
	#node-details[open] {
		transform: translateX(100%);
		opacity: 0;
	}
}
#node-details::backdrop {
	background: rgb(0 0 0 / 0.5);
}
.drawer-heading {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: 1rem;
}
.drawer-heading h2 {
	margin: 0;
	font-size: 1.25rem;
}
.models {
	display: grid;
	gap: 0.5rem;
	margin: 0 0 1.5rem;
	padding: 0;
	list-style: none;
}
.models li {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: center;
	gap: 0.3rem 1rem;
	min-height: 4.2rem;
	padding: 0.7rem 0.75rem 0.7rem 1rem;
	border-radius: 0.8rem;
	background: var(--surface);
	animation: arrive 0.22s var(--ease);
}
.models .empty {
	display: flex;
	color: var(--muted);
}
.model-name strong {
	display: block;
	font-weight: 600;
	overflow-wrap: anywhere;
}
.models .state {
	display: flex;
	align-items: center;
	gap: 0.45rem;
	font-size: 0.84rem;
	color: var(--muted);
}
.models [data-state="verifying"] .state::before,
.models [data-state="removing"] .state::before {
	background: var(--warn);
	animation: pulse 1s ease-in-out infinite alternate;
}
.model-error {
	grid-column: 1;
	margin: 0;
	font-size: 0.84rem;
	color: var(--accent-ink);
	overflow-wrap: anywhere;
}
.model-actions {
	grid-column: 2;
	grid-row: 1 / span 2;
	display: flex;
	gap: 0.4rem;
}
.model-actions button {
	min-width: 5.4rem;
	min-height: 2.25rem;
	font-size: 0.9rem;
}
.model-actions [data-action="confirm"],
.model-actions [data-action="remove"] {
	color: var(--accent-ink);
}
#manifest {
	padding: 0.4rem 0.6rem;
}
#model-updates {
	margin-top: 1.5rem;
	border-bottom: 1px solid var(--line);
}
#update-list {
	max-height: 14rem;
	margin: 0 0 0.8rem;
	padding: 0;
	overflow-y: auto;
	list-style: none;
	font-size: 0.85rem;
	color: var(--muted);
}
#update-list li {
	padding: 0.4rem 0;
	overflow-wrap: anywhere;
}
#model-toast {
	position: fixed;
	z-index: 15;
	right: 1rem;
	bottom: 1rem;
	max-width: min(26rem, 100vw - 2rem);
	padding: 0.7rem 1rem;
	border: 1px solid var(--line-2);
	border-radius: 0.8rem;
	background: var(--surface-2);
	color: var(--ink);
	box-shadow: 0 0.6rem 1.8rem rgb(0 0 0 / 0.5);
	opacity: 0;
	transform: translateY(0.5rem);
	pointer-events: none;
	transition:
		opacity 0.18s,
		transform 0.18s var(--ease);
}
#model-toast.visible {
	opacity: 1;
	transform: none;
}

@keyframes arrive {
	from {
		opacity: 0;
		transform: translateY(4px);
	}
}
@keyframes pulse {
	to {
		opacity: 0.25;
	}
}

@media (max-width: 47.99rem) {
	:root body {
		grid-template-columns: minmax(0, 1fr);
	}
	main {
		grid-column: 1;
	}
	#sidebar,
	.side-closed #sidebar {
		position: fixed;
		z-index: 20;
		inset: 0 auto 0 0;
		width: min(var(--side), 86vw);
		transform: translateX(-100%);
		visibility: hidden;
		transition:
			transform 0.24s var(--ease),
			visibility 0s 0.24s;
	}
	.side-open #sidebar {
		transform: none;
		visibility: visible;
		transition:
			transform 0.24s var(--ease),
			visibility 0s;
	}
	.side-open #scrim {
		opacity: 1;
		pointer-events: auto;
	}
	.topbar {
		padding: 0 0.4rem;
	}
	#thread,
	.dock {
		width: calc(100% - 1.5rem);
	}
	.bubble {
		max-width: 88%;
	}
	.state-dot {
		min-width: 0;
	}
	.topology {
		display: flex;
		flex-direction: column;
		gap: 0.5rem;
	}
	.node:not(:first-child) {
		margin-left: 1.5rem;
	}
	.node::before,
	.node:not(:first-child)::after {
		display: none;
	}
	#limits,
	#controls,
	#add-model {
		grid-template-columns: minmax(0, 1fr);
	}
	.device-run {
		flex-direction: column;
		align-items: stretch;
	}
	#state {
		min-height: 3.3rem;
	}
	.models li {
		grid-template-columns: minmax(0, 1fr);
	}
	.model-actions {
		grid-column: 1;
		grid-row: auto;
	}
	#node-details {
		inset: auto 0 0;
		width: 100%;
		height: auto;
		max-height: 75dvh;
		padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
		border-inline-start: 0;
		border-radius: 1rem 1rem 0 0;
		transform: translateY(100%);
	}
	@starting-style {
		#node-details[open] {
			transform: translateY(100%);
		}
	}
}
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation: none !important;
		transition: none !important;
	}
}
