:root {
	--bg-base: #0d0d0f;
	--fg: #e8e8ea;
	--accent: #ffffff;

	/* Accent pulled toward the ink so the surfaces read as light tints, not
	   slabs of colour. */
	--accent-soft: color-mix(in srgb, var(--accent) 55%, var(--fg));

	/* Ground takes a third of that wash - barely there, never a colour. */
	--bg: color-mix(in srgb, var(--accent-soft) 3%, var(--bg-base));

	--text: var(--fg);
	--panel: var(--bg);
	--muted: color-mix(in srgb, var(--fg) 58%, transparent);

	/* Surfaces carry that softened accent at low alpha, so the shell leans with
	   the chosen colour while text keeps its contrast. */
	--tint-1: color-mix(in srgb, var(--accent-soft) 8%, transparent);
	--tint-2: color-mix(in srgb, var(--accent-soft) 14%, transparent);
	--tint-3: color-mix(in srgb, var(--accent-soft) 20%, transparent);

	--panel-2: var(--tint-1);
	--border: var(--tint-3);
	--field: var(--tint-1);
	--field-2: var(--tint-2);
	--tab-active: var(--tint-2);
	--hover: var(--tint-1);
	color-scheme: dark;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
	box-sizing: border-box;
	scrollbar-color: var(--tint-3) transparent;
}

::selection {
	background: color-mix(in srgb, var(--accent-soft) 38%, transparent);
	color: var(--text);
}

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

body {
	display: flex;
	flex-direction: column;
	background: var(--bg);
	color: var(--text);
	font-size: 13px;
}

svg {
	width: 16px;
	height: 16px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

button {
	font: inherit;
}

/* header: tabs, new tab */

header {
	display: flex;
	align-items: flex-end;
	gap: 4px;
	height: 40px;
	padding: 8px 8px 0;
	background: var(--panel);
	border-bottom: 1px solid var(--border);
}

#tabs {
	display: flex;
	align-items: flex-end;
	gap: 2px;
	overflow-x: auto;
	overflow-y: hidden;
	scrollbar-width: none;
}

#tabs::-webkit-scrollbar {
	display: none;
}

.tab {
	display: flex;
	align-items: center;
	gap: 7px;
	width: 210px;
	height: 32px;
	padding: 0 6px 0 10px;
	border-radius: 8px 8px 0 0;
	color: var(--muted);
	cursor: pointer;
	flex: none;
}

.tab:hover {
	background: var(--panel-2);
}

.tab.active {
	background: var(--tab-active);
	color: var(--text);
}

.tab img {
	width: 14px;
	height: 14px;
	flex: none;
}

.tab-title {
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	flex: 1;
	min-width: 0;
}

.tab-close {
	display: grid;
	place-items: center;
	width: 18px;
	height: 18px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: inherit;
	opacity: 0;
	flex: none;
}

.tab:hover .tab-close,
.tab.active .tab-close {
	opacity: 1;
}

.tab-close:hover {
	background: var(--hover);
}

.tab-close svg {
	width: 12px;
	height: 12px;
}

#new-tab {
	display: grid;
	place-items: center;
	width: 30px;
	height: 30px;
	margin-bottom: 2px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: var(--muted);
	cursor: pointer;
	flex: none;
}

#new-tab:hover {
	background: var(--panel-2);
	color: var(--text);
}

/* toolbar: nav + address */

#toolbar {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 6px 10px;
	background: var(--panel);
	border-bottom: 1px solid var(--border);
}

.controls {
	display: flex;
	gap: 2px;
}

.controls button,
#settings-btn {
	display: grid;
	place-items: center;
	width: 28px;
	height: 28px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: var(--muted);
	cursor: pointer;
}

.controls button:hover,
#settings-btn:hover {
	background: var(--panel-2);
	color: var(--text);
}

#engine {
	height: 28px;
	padding: 0 6px;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: var(--field);
	color: var(--text);
	font: inherit;
	font-size: 12px;
	outline: none;
	cursor: pointer;
}

#settings-btn.active {
	background: var(--panel-2);
	color: var(--text);
}

#bar {
	position: relative;
	flex: 1;
	min-width: 0;
}

#site-icon {
	position: absolute;
	left: 12px;
	top: 50%;
	display: grid;
	place-items: center;
	transform: translateY(-50%);
	color: var(--muted);
	pointer-events: none;
}

#site-icon svg {
	width: 14px;
	height: 14px;
}

#address {
	width: 100%;
	height: 30px;
	padding: 0 12px 0 34px;
	border: 1px solid transparent;
	border-radius: 999px;
	background: var(--field);
	color: var(--text);
	font: inherit;
	outline: none;
}

#address:focus {
	border-color: var(--accent);
}

input::placeholder {
	color: var(--muted);
}

/* main */

main {
	position: relative;
	flex: 1;
	min-height: 0;
}

#frames,
#frames iframe {
	width: 100%;
	height: 100%;
}

#frames iframe {
	display: none;
	border: 0;
	background: #fff;
}

#frames iframe.active {
	display: block;
}

#home {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 24px;
	background: var(--bg);
	overflow-y: auto;
}

.wordmark {
	margin: 0 0 26px;
	font-family: "Space Grotesk", system-ui, sans-serif;
	font-size: clamp(40px, 7vw, 64px);
	font-weight: 700;
	letter-spacing: -0.045em;
	line-height: 1;
	color: var(--text);
}

#search {
	display: flex;
	align-items: center;
	gap: 12px;
	width: min(620px, 100%);
	height: 48px;
	padding: 0 18px;
	border: 1px solid var(--border);
	border-radius: 999px;
	background: var(--field);
}

#search:focus-within {
	border-color: var(--border);
	background: var(--field);
}

#search svg {
	width: 18px;
	height: 18px;
	color: var(--muted);
	flex: none;
}

#query {
	flex: 1;
	min-width: 0;
	height: 100%;
	padding: 0;
	border: 0;
	background: none;
	color: var(--text);
	font-size: 15px;
	outline: none;
}

.shortcuts {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px;
	margin: 30px 0 0;
	padding: 0;
	list-style: none;
}

.shortcuts button {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	width: 84px;
	padding: 8px 4px;
	border: 0;
	border-radius: 10px;
	background: none;
	color: var(--muted);
	cursor: pointer;
}

.shortcuts button:hover {
	background: var(--hover);
	color: var(--text);
}

.tile {
	display: grid;
	place-items: center;
	width: 46px;
	height: 46px;
	border-radius: 50%;
	background: var(--field-2);
	color: var(--text);
	font-size: 18px;
	font-weight: 600;
}

.tile img {
	display: none;
	width: 24px;
	height: 24px;
	border-radius: 4px;
}

.tile.has-icon img {
	display: block;
}

.tile.has-icon .initial {
	display: none;
}

.label {
	max-width: 100%;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	font-size: 11px;
}

#loading {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	background: var(--bg);
	pointer-events: none;
}

#loading-host {
	margin: 0;
	color: var(--muted);
	font-size: 12px;
}

#boot {
	position: fixed;
	inset: 0;
	z-index: 20;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 16px;
	background: var(--bg);
}

#boot p {
	margin: 0;
	color: var(--muted);
	font-size: 12px;
}

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

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

#settings {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	overflow-y: auto;
	padding: 48px 24px;
	background: var(--bg);
}

#settings h1 {
	width: min(560px, 100%);
	margin: 0 0 20px;
	font-size: 18px;
	font-weight: 600;
}

.setting {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	width: min(560px, 100%);
	padding: 14px 0;
	border-bottom: 1px solid var(--border);
}

.setting-label {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.setting-label small {
	color: var(--muted);
	font-size: 12px;
}

.swatches {
	display: flex;
	gap: 8px;
}

.swatch {
	width: 18px;
	height: 18px;
	padding: 0;
	border: 1px solid var(--border);
	border-radius: 50%;
	background: var(--sw);
	cursor: pointer;
}

.swatch.active {
	outline: 2px solid var(--fg);
	outline-offset: 2px;
}

#error {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	padding: 32px;
	background: var(--bg);
}

#error-title {
	margin: 0;
	color: var(--accent);
	font-size: 15px;
	font-weight: 600;
}

#error-detail {
	max-width: min(720px, 100%);
	max-height: 40vh;
	overflow: auto;
	margin: 0;
	padding: 12px;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: var(--panel);
	color: var(--muted);
	font-size: 12px;
	line-height: 1.5;
	white-space: pre-wrap;
	word-break: break-word;
}

#error-close {
	padding: 6px 14px;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: var(--panel);
	color: var(--text);
	cursor: pointer;
}

#error-close:hover {
	background: var(--panel-2);
}

[hidden] {
	display: none !important;
}
