:root {
	color-scheme: light dark;
	--bg: #ffffff;
	--surface: #f7f7f8;
	--chrome: #efeff1;
	--hover: rgba(0, 0, 0, 0.06);
	--text: #0a0a0b;
	--muted: #71717a;
	--border: #e4e4e7;
	--accent: #f56565;
	--ring: rgba(245, 101, 101, 0.22);
	--error: #dc2626;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0a0a0b;
		--surface: #141416;
		--chrome: #1b1b1e;
		--hover: rgba(255, 255, 255, 0.07);
		--text: #f4f4f5;
		--muted: #a1a1aa;
		--border: #27272a;
		--error: #f87171;
	}
}

[hidden] {
	display: none !important;
}

body {
	font-family:
		system-ui,
		-apple-system,
		"Segoe UI",
		Roboto,
		Helvetica,
		Arial,
		sans-serif;
	margin: 0;
	color: var(--text);
	background-color: var(--bg);
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

body.app {
	height: 100vh;
	overflow: hidden;
}

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

.icon-btn {
	display: grid;
	place-items: center;
	width: 32px;
	height: 32px;
	flex: none;
	padding: 0;
	color: var(--muted);
	background: none;
	border: none;
	border-radius: 8px;
	cursor: pointer;
}

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

/* browser chrome */

#browser {
	flex: none;
	background: var(--chrome);
	border-bottom: 1px solid var(--border);
}

#tabs {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 6px 8px 0;
}

#tab-list {
	display: flex;
	gap: 2px;
	min-width: 0;
	overflow-x: auto;
	scrollbar-width: none;
}

.tab {
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 0 1 220px;
	min-width: 72px;
	height: 34px;
	padding: 0 6px 0 12px;
	font-size: 13px;
	color: var(--muted);
	border-radius: 10px 10px 0 0;
	cursor: default;
	user-select: none;
}

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

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

.tab-icon {
	width: 16px;
	height: 16px;
	flex: none;
}

.tab-globe {
	color: var(--accent);
}

.tab-icon:not([hidden]) + .tab-globe {
	display: none;
}

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

.tab-close {
	display: grid;
	place-items: center;
	width: 20px;
	height: 20px;
	flex: none;
	padding: 0;
	color: inherit;
	background: none;
	border: none;
	border-radius: 6px;
	cursor: pointer;
}

.tab-close .icon {
	width: 14px;
	height: 14px;
}

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

#toolbar {
	display: flex;
	align-items: center;
	gap: 2px;
	padding: 6px 8px;
	background: var(--bg);
}

#omnibox {
	position: relative;
	display: flex;
	align-items: center;
	flex: 1;
	margin-left: 6px;
}

#omnibox .icon {
	position: absolute;
	left: 12px;
	color: var(--muted);
	pointer-events: none;
}

#url-bar {
	box-sizing: border-box;
	width: 100%;
	height: 34px;
	padding: 0 14px 0 36px;
	font: inherit;
	font-size: 14px;
	color: var(--text);
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 999px;
	outline: none;
	transition:
		border-color 0.15s,
		box-shadow 0.15s;
}

#url-bar:focus {
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--ring);
}

/* extensions panel */

#ext-panel {
	box-sizing: border-box;
	width: min(520px, calc(100vw - 32px));
	max-height: calc(100vh - 32px);
	margin: 92px 12px auto auto;
	padding: 16px;
	color: var(--text);
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 14px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

#ext-panel::backdrop {
	background: rgba(0, 0, 0, 0.25);
}

.panel-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 12px;
}

.panel-head h2 {
	margin: 0;
	font-size: 16px;
}

.ext-card {
	display: flex;
	gap: 12px;
	padding: 14px;
	margin-bottom: 10px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 12px;
}

.ext-card > div {
	flex: 1;
	min-width: 0;
}

.ext-icon {
	width: 20px;
	height: 20px;
	color: var(--accent);
}

.ext-card h3 {
	margin: 0 0 4px;
	font-size: 14px;
}

.ext-card p {
	margin: 0;
	font-size: 13px;
	line-height: 1.45;
	color: var(--muted);
}

.ext-card code {
	font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
	font-size: 12px;
}

#script-list {
	margin: 10px 0 0;
	padding: 0;
	list-style: none;
}

#script-list li {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 6px 0;
	border-top: 1px solid var(--border);
}

#script-list input {
	accent-color: var(--accent);
}

.script-info {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	font-size: 13px;
}

.script-info small {
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	color: var(--muted);
}

#script-form {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-top: 10px;
}

#script-form input,
#script-form textarea {
	box-sizing: border-box;
	width: 100%;
	padding: 8px 10px;
	font: inherit;
	font-size: 13px;
	color: var(--text);
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 8px;
	outline: none;
}

#script-form textarea {
	resize: vertical;
	font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}

#script-form input:focus,
#script-form textarea:focus {
	border-color: var(--accent);
}

.form-actions {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
}

.text-btn {
	margin-top: 10px;
	padding: 6px 12px;
	font: inherit;
	font-size: 13px;
	color: var(--text);
	background: none;
	border: 1px solid var(--border);
	border-radius: 8px;
	cursor: pointer;
}

.form-actions .text-btn {
	margin-top: 0;
}

.form-actions.start {
	justify-content: flex-start;
	margin-top: 10px;
}

.text-btn:hover {
	background: var(--hover);
}

.text-btn.primary {
	color: #fff;
	background: var(--accent);
	border-color: var(--accent);
}

/* page area */

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

.view {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: none;
	background-color: var(--bg);
}

.view.hidden {
	visibility: hidden;
}

#home {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	overflow: auto;
	background-image: radial-gradient(var(--border) 1px, transparent 1px);
	background-size: 22px 22px;
}

/* home page */

.flex-center {
	display: flex;
	justify-content: center;
}

.header-center {
	align-items: center;
	flex-direction: column;
	margin-top: 14vh;
}

.left-margin {
	margin: 0px 16px;
}

.errors {
	flex-direction: column;
	align-items: center;
}

#sj-error {
	color: var(--error) !important;
	white-space: pre-wrap;
	margin-bottom: 4px;
}

#sj-error-code {
	max-width: min(560px, 100%);
	margin: 0;
	font-size: 12px;
	color: var(--muted);
	white-space: pre-wrap;
	font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}

.logo {
	width: 34px;
	height: 34px;
	padding: 14px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
	color: var(--accent);
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 16px;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.logo-wrapper h1 {
	margin: 18px 0 6px;
	font-size: 2.25rem;
	font-weight: 700;
	letter-spacing: -0.03em;
	color: var(--text);
}

.desc p {
	width: min(560px, 100%);
	margin: 0 0 24px;
	text-align: center;
	color: var(--muted);
}

.search {
	position: relative;
	display: flex;
	align-items: center;
	width: min(560px, 100%);
}

.search .icon {
	position: absolute;
	left: 16px;
	width: 18px;
	height: 18px;
	color: var(--muted);
	pointer-events: none;
}

#sj-address {
	box-sizing: border-box;
	width: 100%;
	height: 52px;
	padding: 0 18px 0 46px;
	font: inherit;
	font-size: 16px;
	color: var(--text);
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 12px;
	outline: none;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
	transition:
		border-color 0.15s,
		box-shadow 0.15s;
}

#sj-address::placeholder,
#url-bar::placeholder {
	color: var(--muted);
}

#sj-address:focus {
	border-color: var(--accent);
	box-shadow: 0 0 0 4px var(--ring);
}

footer {
	margin-top: auto;
	padding: 16px 24px;
	display: flex;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 8px;
	font-size: 14px;
	border-top: 1px solid var(--border);
	background: var(--bg);
}

footer > div {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 20px;
}

footer a,
footer span {
	text-decoration: none;
	color: var(--muted);
}

footer a:hover {
	color: var(--text);
}

/* credits page */

.credit {
	border-radius: 12px;
	padding: 12px 16px;
	border: 1px solid var(--border);
	background: var(--surface);
	color: var(--text);
	display: flex;
	flex-wrap: wrap;
	margin-bottom: 12px;
}

.credit label {
	margin-left: auto;
	margin-right: 15px;
}

.credit a,
.credit label {
	color: var(--muted);
	text-decoration: underline;
	text-align: right;
}

.credit pre {
	display: none;
	width: 100%;
	white-space: pre-wrap;
}

.credit label::after {
	content: "show license";
	cursor: pointer;
}

.credit input:checked + label::after {
	content: "hide license";
}

.credit input:checked ~ pre {
	display: block;
}
