/* ============================================================
   comet · minimal black browser
   ============================================================ */

:root {
	--bg: #000000;
	--bg-1: #070707;
	--bg-2: #0c0c0c;
	--bg-3: #141414;
	--line: rgba(255, 255, 255, 0.06);
	--line-2: rgba(255, 255, 255, 0.12);
	--line-3: rgba(255, 255, 255, 0.22);
	--text: #f4f4f4;
	--text-mid: rgba(244, 244, 244, 0.6);
	--text-dim: rgba(244, 244, 244, 0.4);
	--text-faint: rgba(244, 244, 244, 0.22);
	--danger: #ff7a7a;
	--radius-sm: 4px;
	--radius: 8px;
	--radius-pill: 999px;
	--font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, sans-serif;
	--font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
	--ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	padding: 0;
	height: 100%;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font-sans);
	font-size: 14px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizeLegibility;
}

body {
	overflow: hidden;
}

a {
	color: inherit;
	text-decoration: none;
}

button {
	font-family: inherit;
	font-size: inherit;
	color: inherit;
	background: none;
	border: none;
	padding: 0;
	cursor: pointer;
}

input {
	font-family: inherit;
	color: inherit;
}

/* layout shell ------------------------------------------------ */

.app {
	display: flex;
	flex-direction: column;
	height: 100vh;
	width: 100vw;
}

.chrome {
	position: relative;
	z-index: 5;
	background: var(--bg);
	border-bottom: 1px solid var(--line);
	flex: 0 0 auto;
}

/* tab bar ----------------------------------------------------- */

.tabbar {
	display: flex;
	align-items: stretch;
	height: 38px;
	padding: 0 6px;
	gap: 4px;
	border-bottom: 1px solid var(--line);
	background: var(--bg-1);
	overflow: hidden;
}

.tabs {
	display: flex;
	flex: 1 1 auto;
	min-width: 0;
	overflow-x: auto;
	scrollbar-width: none;
	gap: 2px;
	align-items: stretch;
	padding: 5px 0;
}

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

.tab {
	position: relative;
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 110px;
	max-width: 220px;
	flex: 0 1 200px;
	padding: 0 10px;
	height: 28px;
	color: var(--text-dim);
	border-radius: var(--radius-sm);
	cursor: pointer;
	user-select: none;
	font-size: 12.5px;
	font-weight: 400;
	transition:
		background 0.18s var(--ease),
		color 0.18s var(--ease),
		max-width 0.2s var(--ease),
		min-width 0.2s var(--ease),
		padding 0.2s var(--ease),
		opacity 0.18s var(--ease),
		transform 0.22s var(--ease);
	white-space: nowrap;
}

.tab.closing {
	pointer-events: none;
	overflow: hidden;
	max-width: 0 !important;
	min-width: 0 !important;
	flex: 0 0 0 !important;
	padding-left: 0 !important;
	padding-right: 0 !important;
	opacity: 0;
}

.tab:hover {
	background: rgba(255, 255, 255, 0.035);
	color: var(--text-mid);
}

.tab.active {
	background: var(--bg-3);
	color: var(--text);
	box-shadow: inset 0 0 0 1px var(--line);
}

.tab-favicon {
	width: 12px;
	height: 12px;
	flex: 0 0 auto;
	color: var(--text-faint);
	display: grid;
	place-items: center;
}

.tab-favicon img {
	width: 12px;
	height: 12px;
	object-fit: contain;
	display: block;
}

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

.tab-title {
	flex: 1 1 auto;
	overflow: hidden;
	text-overflow: ellipsis;
}

.tab-close {
	width: 16px;
	height: 16px;
	display: grid;
	place-items: center;
	border-radius: 3px;
	color: var(--text-faint);
	opacity: 0;
	transition: opacity 0.15s var(--ease), background 0.15s var(--ease), color 0.15s var(--ease);
	flex: 0 0 auto;
}

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

.tab-close:hover {
	background: rgba(255, 255, 255, 0.08);
	color: var(--text);
}

.tab.tab-enter {
	animation: tabIn 0.18s var(--ease);
}

@keyframes tabIn {
	from {
		opacity: 0;
		transform: translateY(-2px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* pinned tabs --------------------------------------------------- */

.tab.pinned {
	min-width: 36px;
	max-width: 36px;
	flex: 0 0 36px;
	padding: 0;
	justify-content: center;
	gap: 0;
}

.tab.pinned .tab-title,
.tab.pinned .tab-close {
	display: none;
}

.tab.pinned::after {
	content: "";
	position: absolute;
	left: 50%;
	bottom: 2px;
	transform: translateX(-50%);
	width: 3px;
	height: 3px;
	border-radius: 50%;
	background: var(--text-faint);
	transition: background 0.15s var(--ease);
}

.tab.pinned.active::after {
	background: var(--text-mid);
}

/* loading spinner ----------------------------------------------- */

.tab-spinner {
	display: block;
	width: 11px;
	height: 11px;
	border-radius: 50%;
	border: 1.4px solid var(--line-2);
	border-top-color: var(--text);
	animation: tab-spin 0.7s linear infinite;
}

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

/* drag & drop --------------------------------------------------- */

.tab.dragging {
	opacity: 0.4;
}

.tab.drop-before::before,
.tab.drop-after::before {
	content: "";
	position: absolute;
	top: 4px;
	bottom: 4px;
	width: 2px;
	background: var(--text);
	border-radius: 1px;
	pointer-events: none;
}

.tab.drop-before::before {
	left: -2px;
}

.tab.drop-after::before {
	right: -2px;
}

/* progress bar -------------------------------------------------- */

.progress-bar {
	position: absolute;
	top: 0;
	left: 0;
	height: 2px;
	width: 0;
	background: linear-gradient(90deg, rgba(255, 255, 255, 0.2), var(--text));
	opacity: 0;
	z-index: 8;
	pointer-events: none;
	transition: opacity 0.18s var(--ease);
}

.progress-bar.loading {
	opacity: 1;
	width: 80%;
	transition:
		width 8s cubic-bezier(0.05, 0.7, 0.1, 0.95),
		opacity 0.18s var(--ease);
}

.progress-bar.complete {
	opacity: 0;
	width: 100%;
	transition:
		width 0.18s ease,
		opacity 0.4s ease 0.18s;
}

/* tab hover tooltip --------------------------------------------- */

.tab-tooltip[hidden] {
	display: none;
}

.tab-tooltip {
	position: fixed;
	z-index: 60;
	max-width: 320px;
	padding: 8px 10px;
	background: var(--bg-1);
	border: 1px solid var(--line-2);
	border-radius: var(--radius-sm);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
	pointer-events: none;
	animation: ttIn 0.12s var(--ease);
}

@keyframes ttIn {
	from {
		opacity: 0;
		transform: translateY(-2px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.tab-tooltip .ttl {
	font-size: 12px;
	color: var(--text);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 300px;
}

.tab-tooltip .url {
	margin-top: 3px;
	font-family: var(--font-mono);
	font-size: 10.5px;
	color: var(--text-dim);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 300px;
}

.tab-tooltip .url[hidden] {
	display: none;
}

/* tab context menu ---------------------------------------------- */

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

.ctx-menu {
	position: fixed;
	z-index: 70;
	min-width: 160px;
	padding: 4px;
	background: var(--bg-1);
	border: 1px solid var(--line-2);
	border-radius: var(--radius-sm);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
	display: flex;
	flex-direction: column;
	animation: ttIn 0.12s var(--ease);
}

.ctx-item {
	display: flex;
	align-items: center;
	height: 28px;
	padding: 0 10px;
	font-size: 12px;
	color: var(--text-mid);
	border-radius: 3px;
	text-align: left;
	transition:
		background 0.12s var(--ease),
		color 0.12s var(--ease);
}

.ctx-item[hidden] {
	display: none;
}

.ctx-item:hover {
	background: rgba(255, 255, 255, 0.05);
	color: var(--text);
}

.ctx-item.danger:hover {
	background: rgba(255, 122, 122, 0.08);
	color: var(--danger);
}

.ctx-item.disabled,
.ctx-item:disabled {
	color: var(--text-faint);
	cursor: default;
	pointer-events: none;
}

.ctx-sep {
	height: 1px;
	background: var(--line);
	margin: 4px 2px;
}

.new-tab {
	align-self: center;
	width: 28px;
	height: 28px;
	border-radius: var(--radius-sm);
	color: var(--text-mid);
	display: grid;
	place-items: center;
	flex: 0 0 auto;
	transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.new-tab:hover {
	background: rgba(255, 255, 255, 0.05);
	color: var(--text);
}

.tabbar-spacer {
	flex: 0 0 auto;
	width: 0;
}

.brand-mark {
	align-self: center;
	font-family: var(--font-mono);
	font-size: 10.5px;
	letter-spacing: 0.18em;
	text-transform: lowercase;
	color: var(--text-faint);
	padding: 0 12px 0 14px;
	flex: 0 0 auto;
	user-select: none;
}

@media (max-width: 640px) {
	.brand-mark {
		display: none;
	}
}

/* nav bar ----------------------------------------------------- */

.navbar {
	display: flex;
	align-items: center;
	gap: 10px;
	height: 48px;
	padding: 0 12px;
	background: var(--bg);
}

.nav-group {
	display: flex;
	align-items: center;
	gap: 2px;
	flex: 0 0 auto;
}

.icon-btn {
	width: 30px;
	height: 30px;
	display: grid;
	place-items: center;
	border-radius: var(--radius-sm);
	color: var(--text-mid);
	transition:
		background 0.15s var(--ease),
		color 0.15s var(--ease),
		transform 0.2s var(--ease);
}

.icon-btn:hover:not(:disabled) {
	background: rgba(255, 255, 255, 0.06);
	color: var(--text);
}

.icon-btn:active:not(:disabled) {
	transform: scale(0.94);
}

.icon-btn:disabled {
	color: var(--text-faint);
	cursor: default;
}

#refresh.spinning svg {
	animation: spin 0.55s linear;
}

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

/* address bar ------------------------------------------------- */

.address-form {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
}

.address-wrap {
	position: relative;
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	height: 32px;
	padding: 0 10px 0 12px;
	background: var(--bg-2);
	border: 1px solid var(--line);
	border-radius: var(--radius-pill);
	transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
}

.address-wrap:hover {
	border-color: var(--line-2);
}

.address-wrap:focus-within {
	border-color: var(--line-3);
	background: var(--bg-3);
}

.address-leader {
	color: var(--text-faint);
	display: grid;
	place-items: center;
	flex: 0 0 auto;
}

.address-wrap:focus-within .address-leader {
	color: var(--text-mid);
}

#sj-address {
	flex: 1 1 auto;
	min-width: 0;
	background: transparent;
	border: none;
	outline: none;
	color: var(--text);
	font-size: 12.5px;
	font-family: var(--font-mono);
	font-weight: 400;
	height: 100%;
	padding: 0;
}

#sj-address::placeholder {
	color: var(--text-faint);
	font-family: var(--font-sans);
	font-weight: 400;
}

.address-hint {
	font-family: var(--font-mono);
	font-size: 10px;
	color: var(--text-faint);
	background: rgba(255, 255, 255, 0.04);
	border: 1px solid var(--line);
	padding: 1px 6px;
	border-radius: 3px;
	flex: 0 0 auto;
	opacity: 0;
	transition: opacity 0.15s var(--ease);
}

.address-wrap:focus-within .address-hint {
	opacity: 1;
}

@media (max-width: 520px) {
	.address-hint {
		display: none;
	}
}

/* viewport ---------------------------------------------------- */

.viewport {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	background: var(--bg);
	overflow: hidden;
}

.frames {
	position: absolute;
	inset: 0;
	pointer-events: none;
}

.frames iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
	background: var(--bg-1);
	display: none;
	pointer-events: auto;
}

.frames iframe.active {
	display: block;
}

/* home / new tab ---------------------------------------------- */

.home {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	overflow-y: auto;
	background: var(--bg);
	transition: opacity 0.2s var(--ease);
}

.home.hidden {
	opacity: 0;
	pointer-events: none;
}

.home-inner {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	justify-content: center;
	max-width: 560px;
	width: 100%;
	margin: 0 auto;
	padding: 48px 32px;
	gap: 32px;
}

.wordmark {
	margin: 0;
	font-family: var(--font-sans);
	font-weight: 300;
	font-size: clamp(48px, 8vw, 84px);
	line-height: 1;
	letter-spacing: -0.04em;
	color: var(--text);
}

.home-form {
	display: flex;
	width: 100%;
}

.home-input-wrap {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	height: 48px;
	padding: 0 16px;
	background: var(--bg-1);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.home-input-wrap:hover {
	border-color: var(--line-2);
}

.home-input-wrap:focus-within {
	border-color: var(--line-3);
	background: var(--bg-2);
}

#home-address {
	flex: 1 1 auto;
	min-width: 0;
	background: transparent;
	border: none;
	outline: none;
	font-family: var(--font-mono);
	font-size: 13px;
	color: var(--text);
}

#home-address::placeholder {
	color: var(--text-faint);
	font-family: var(--font-sans);
}

.home-input-hint {
	font-family: var(--font-mono);
	font-size: 11px;
	color: var(--text-faint);
	flex: 0 0 auto;
}

/* autocomplete dropdown ------------------------------------- */

.ac-list {
	position: absolute;
	left: 0;
	right: 0;
	top: calc(100% + 4px);
	margin: 0;
	padding: 4px;
	list-style: none;
	background: var(--surface, #16181d);
	border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
	border-radius: 10px;
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
	z-index: 40;
	max-height: 320px;
	overflow-y: auto;
}

.address-form { position: relative; }
.home-input-wrap { position: relative; }
.home-ac { left: 0; right: 0; }

.ac-item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 7px 10px;
	border-radius: 6px;
	cursor: pointer;
	color: var(--text-dim);
	font-size: 13px;
	line-height: 1.2;
	user-select: none;
}

.ac-item .ac-kind {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 14px;
	height: 14px;
	color: var(--text-faint);
}

.ac-item .ac-text {
	flex: 1 1 auto;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	color: var(--text);
}

.ac-item .ac-sub {
	flex: 0 0 auto;
	font-family: var(--font-mono);
	font-size: 11px;
	color: var(--text-faint);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	max-width: 50%;
}

.ac-item:hover,
.ac-item.active {
	background: var(--surface-hover, rgba(255, 255, 255, 0.06));
	color: var(--text);
}

/* errors */

.error-line {
	margin: 0;
	color: var(--danger);
	font-size: 13px;
	white-space: pre-wrap;
}

.error-code {
	margin: 0;
	color: var(--text-mid);
	font-family: var(--font-mono);
	font-size: 11.5px;
	white-space: pre-wrap;
}

.error-line:empty,
.error-code:empty {
	display: none;
}

/* small screen tweaks ---------------------------------------- */

@media (max-width: 480px) {
	.tab {
		min-width: 90px;
		max-width: 140px;
	}
	.navbar {
		gap: 6px;
		padding: 0 8px;
	}
	.home-inner {
		padding: 32px 20px;
		gap: 24px;
	}
}

/* standalone pages ------------------------------------------- */

body.standalone {
	overflow: auto;
	padding: 64px 32px 48px;
}

.standalone-wrap {
	max-width: 560px;
	margin: 0 auto;
}

.standalone-wrap h1 {
	font-family: var(--font-sans);
	font-weight: 300;
	font-size: clamp(36px, 5vw, 48px);
	letter-spacing: -0.03em;
	margin: 0 0 12px;
}

.standalone-wrap .lead {
	color: var(--text-mid);
	margin: 0 0 24px;
}

.standalone-wrap .back-link {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-family: var(--font-mono);
	font-size: 12px;
	color: var(--text-mid);
	transition: color 0.15s var(--ease);
}

.standalone-wrap .back-link:hover {
	color: var(--text);
}

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

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

.modal-backdrop {
	position: fixed;
	inset: 0;
	z-index: 50;
	background: rgba(0, 0, 0, 0.55);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
	display: grid;
	place-items: center;
	padding: 24px;
	animation: backdropIn 0.18s var(--ease);
}

@keyframes backdropIn {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

.modal {
	width: 100%;
	max-width: 460px;
	background: var(--bg-1);
	border: 1px solid var(--line-2);
	border-radius: var(--radius);
	display: flex;
	flex-direction: column;
	max-height: calc(100vh - 48px);
	overflow: hidden;
	animation: modalIn 0.2s var(--ease);
}

@keyframes modalIn {
	from {
		opacity: 0;
		transform: translateY(6px) scale(0.99);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

.modal-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 14px 14px 18px;
	border-bottom: 1px solid var(--line);
}

.modal-head h2 {
	margin: 0;
	font-family: var(--font-mono);
	font-size: 11px;
	letter-spacing: 0.18em;
	text-transform: lowercase;
	color: var(--text-mid);
	font-weight: 400;
}

.modal-close {
	width: 26px;
	height: 26px;
}

.modal-body {
	padding: 18px;
	display: flex;
	flex-direction: column;
	gap: 18px;
	overflow-y: auto;
}

.modal-foot {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	padding: 12px 14px;
	border-top: 1px solid var(--line);
	background: var(--bg);
}

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

.setting-row {
	flex-direction: row;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
}

.setting-text {
	flex: 1 1 auto;
	min-width: 0;
}

.setting-label {
	font-family: var(--font-mono);
	font-size: 11px;
	letter-spacing: 0.12em;
	text-transform: lowercase;
	color: var(--text-mid);
}

.setting-hint {
	color: var(--text-faint);
	letter-spacing: 0.04em;
	margin-left: 6px;
}

.setting-desc {
	margin-top: 4px;
	font-size: 12px;
	color: var(--text-dim);
	line-height: 1.45;
}

.setting-input-row {
	display: flex;
	gap: 8px;
	align-items: center;
}

.setting-input-row .setting-input { flex: 1 1 auto; }

.setting-inline-btn {
	height: 34px;
	padding: 0 12px;
	flex: 0 0 auto;
}

.setting-select,
.setting-input {
	width: 100%;
	height: 34px;
	padding: 0 12px;
	background: var(--bg-2);
	border: 1px solid var(--line);
	border-radius: var(--radius-sm);
	color: var(--text);
	font-family: var(--font-mono);
	font-size: 12.5px;
	outline: none;
	transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}

.setting-select {
	appearance: none;
	-webkit-appearance: none;
	background-image: linear-gradient(45deg, transparent 50%, var(--text-mid) 50%),
		linear-gradient(135deg, var(--text-mid) 50%, transparent 50%);
	background-position:
		calc(100% - 16px) 50%,
		calc(100% - 11px) 50%;
	background-size: 5px 5px, 5px 5px;
	background-repeat: no-repeat;
	padding-right: 28px;
	cursor: pointer;
}

.setting-select:hover,
.setting-input:hover {
	border-color: var(--line-2);
}

.setting-select:focus,
.setting-input:focus {
	border-color: var(--line-3);
	background: var(--bg-3);
}

.setting-input::placeholder {
	color: var(--text-faint);
}

/* toggle ----------------------------------------------------- */

.toggle {
	position: relative;
	display: inline-block;
	flex: 0 0 auto;
	cursor: pointer;
}

.toggle input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.toggle-track {
	display: block;
	width: 34px;
	height: 20px;
	background: var(--bg-3);
	border: 1px solid var(--line-2);
	border-radius: var(--radius-pill);
	transition: background 0.18s var(--ease), border-color 0.18s var(--ease);
}

.toggle-thumb {
	position: absolute;
	top: 3px;
	left: 3px;
	width: 14px;
	height: 14px;
	background: var(--text-mid);
	border-radius: 50%;
	transition: transform 0.18s var(--ease), background 0.18s var(--ease);
}

.toggle input:checked + .toggle-track {
	background: var(--text);
	border-color: var(--text);
}

.toggle input:checked + .toggle-track .toggle-thumb {
	transform: translateX(14px);
	background: var(--bg);
}

.toggle input:focus-visible + .toggle-track {
	outline: 1px solid var(--line-3);
	outline-offset: 2px;
}

/* buttons ---------------------------------------------------- */

.btn-primary,
.btn-ghost {
	height: 30px;
	padding: 0 14px;
	font-family: var(--font-mono);
	font-size: 11.5px;
	letter-spacing: 0.08em;
	border-radius: var(--radius-sm);
	border: 1px solid transparent;
	transition: background 0.15s var(--ease), color 0.15s var(--ease),
		border-color 0.15s var(--ease);
}

.btn-primary {
	background: var(--text);
	color: var(--bg);
}

.btn-primary:hover {
	background: #fff;
}

.btn-ghost {
	color: var(--text-mid);
	border-color: var(--line);
}

.btn-ghost:hover {
	color: var(--text);
	border-color: var(--line-2);
	background: rgba(255, 255, 255, 0.03);
}

/* selection */
::selection {
	background: var(--text);
	color: var(--bg);
}

/* focus ring (keyboard only) */
:focus-visible {
	outline: 1px solid var(--line-3);
	outline-offset: 2px;
}
.address-wrap:focus-within,
.home-input-wrap:focus-within {
	outline: none;
}