:root {
	--bg: #0b0f14;
	--panel: #0f1621;
	--text: #d7e1ee;
	--muted: #95a9c1;
	--accent: #7ee787;
	--error: #ff7e75;
	--link: #79c0ff;
	--shadow: rgba(0, 0, 0, 0.35);
	--frame-pad: clamp(12px, 2.5vw, 18px);
	--font:
		ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
		"Courier New", monospace;
	color-scheme: dark;
}

:root[data-theme="light"] {
	--bg: #d6cfb8;
	--panel: #e3dcc5;
	--text: #222a2f;
	--muted: #354045;
	--accent: #0d7000;
	--error: #c11518;
	--link: #0c5cac;
	--shadow: rgba(20, 34, 64, 0.18);
	color-scheme: light;
}

* {
	box-sizing: border-box;
}
html,
body {
	height: 100%;
	min-height: 100%;
	touch-action: manipulation;
}

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

body {
	margin: 0;
	min-height: 100svh;
	background: radial-gradient(
		1200px 800px at 20% 10%,
		#172235 0%,
		var(--bg) 60%
	);
	color: var(--text);
	font-family: var(--font), serif;
	display: grid;
	place-items: center;
	padding: var(--frame-pad);
}

:root[data-theme="light"] body {
	background: radial-gradient(
		1200px 800px at 18% 8%,
		#c8c0a8 0%,
		var(--bg) 60%
	);
}

.terminal {
	width: min(980px, 100%);
	max-width: calc(100vw - (var(--frame-pad) * 2));
	height: min(720px, 100%);
	max-height: calc(100svh - (var(--frame-pad) * 2));
	background:
		linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0)),
		var(--panel);
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-radius: 16px;
	box-shadow: 0 20px 50px var(--shadow);
	overflow: hidden;
	display: grid;
	grid-template-rows: auto 1fr auto;
}

.topbar {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	gap: clamp(8px, 1.4vw, 12px);
	align-items: center;
	padding: clamp(10px, 1.4vw, 12px) clamp(12px, 1.8vw, 14px);
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
	background: rgba(0, 0, 0, 0.2);
}

.dots {
	display: flex;
	gap: 8px;
}
.dot {
	width: 10px;
	height: 10px;
	border-radius: 999px;
	opacity: 0.9;
	position: relative;
}
.dot::before {
	content: "•ᴗ•";
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -52%);
	font-family: "Segoe UI", "Apple Symbols", "Arial Unicode MS", sans-serif;
	font-size: 7px;
	line-height: 1;
	white-space: nowrap;
	color: rgba(0, 0, 0, 0.58);
}
.dot.red {
	background: #ff5f57;
}
.dot.yellow {
	background: #febc2e;
}
.dot.green {
	background: #28c840;
}

.title {
	color: var(--muted);
	font-size: 13px;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.hint {
	color: var(--muted);
	font-size: 13px;
}
.hint kbd {
	font: inherit;
	border: 1px solid rgba(255, 255, 255, 0.18);
	border-bottom-color: rgba(255, 255, 255, 0.08);
	padding: 1px 6px;
	border-radius: 6px;
	color: var(--text);
	background: rgba(255, 255, 255, 0.03);
}

.actions {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}

.wip-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: clamp(10px, 1.1vw, 11px);
	line-height: 1;
	font-weight: 600;
	letter-spacing: 0.08em;
	color: var(--accent);
	border: 1px solid rgba(126, 231, 135, 0.52);
	border-bottom-color: rgba(126, 231, 135, 0.32);
	background: rgba(126, 231, 135, 0.1);
	border-radius: 999px;
	padding: 4px 9px;
	white-space: nowrap;
}

.theme-toggle {
	font: inherit;
	font-size: clamp(11px, 1.3vw, 12px);
	color: var(--text);
	border: 1px solid rgba(255, 255, 255, 0.18);
	border-bottom-color: rgba(255, 255, 255, 0.08);
	background: rgba(255, 255, 255, 0.04);
	padding: clamp(3px, 0.7vw, 4px) clamp(8px, 1.3vw, 10px);
	border-radius: 999px;
	cursor: pointer;
	transition:
		transform 120ms ease,
		border-color 120ms ease,
		background 120ms ease;
}

.theme-toggle:hover {
	border-color: rgba(255, 255, 255, 0.28);
	background: rgba(255, 255, 255, 0.08);
}

.theme-toggle:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

:root[data-theme="light"] .topbar,
:root[data-theme="light"] .prompt {
	background: rgba(227, 220, 197, 0.92);
}

:root[data-theme="light"] .terminal {
	border: 1px solid rgba(34, 42, 47, 0.2);
	background:
		linear-gradient(180deg, rgba(34, 42, 47, 0.07), rgba(34, 42, 47, 0)),
		var(--panel);
}

:root[data-theme="light"] .hint kbd,
:root[data-theme="light"] .wip-badge,
:root[data-theme="light"] .theme-toggle {
	border: 1px solid rgba(34, 42, 47, 0.24);
	border-bottom-color: rgba(34, 42, 47, 0.16);
	background: rgba(34, 42, 47, 0.08);
}

:root[data-theme="light"] .wip-badge {
	color: #0c5e00;
	border: 1px solid rgba(12, 94, 0, 0.34);
	border-bottom-color: rgba(12, 94, 0, 0.24);
	background: rgba(5, 158, 0, 0.15);
}

:root[data-theme="light"] .theme-toggle:hover {
	border-color: rgba(34, 42, 47, 0.34);
	background: rgba(34, 42, 47, 0.12);
}

:root[data-theme="light"] .topbar {
	border-bottom: 1px solid rgba(34, 42, 47, 0.18);
}

:root[data-theme="light"] .prompt {
	border-top: 1px solid rgba(34, 42, 47, 0.18);
}

.screen {
	padding: clamp(12px, 1.6vw, 14px);
	overflow-x: auto;
	overflow-y: auto;
	line-height: 1.45;
	-webkit-overflow-scrolling: touch;
}

.block {
	margin: 0 0 12px 0;
	width: max-content;
	min-width: 100%;
}
.block .line {
	white-space: pre;
	word-break: normal;
	overflow-wrap: normal;
}

.block.wrap-text {
	width: 100%;
}

.block.wrap-text .line.wrap-text {
	width: 100%;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	word-break: break-word;
}

.pre {
	margin: 0;
	white-space: pre;
}
.block .cmd {
	color: var(--muted);
}
.block .ok {
	color: var(--text);
}
.block .muted {
	color: var(--muted);
}
.block .accent {
	color: var(--accent);
}
.block .error {
	color: var(--error);
}
.block .banner {
	font-size: 1.05rem;
	line-height: 1.3;
	color: var(--accent);
}

.block .banner .banner-border,
.block .banner .banner-text {
	text-shadow: 0 0 14px rgba(126, 231, 135, 0.22);
}

:root[data-theme="light"] .block .banner .banner-border {
	text-shadow: 0 0 10px rgba(5, 158, 0, 0.12);
}

:root[data-theme="light"] .block .banner .banner-text {
	color: var(--text);
	text-shadow: none;
}

a {
	color: var(--link);
	text-decoration: none;
}
a:hover {
	text-decoration: underline;
}

.quick-links,
.mobile-command-tray {
	display: grid;
	align-items: center;
	gap: clamp(8px, 1.2vw, 10px);
	padding: clamp(8px, 1.2vw, 10px) clamp(12px, 1.8vw, 14px);
	border-top: 1px solid rgba(255, 255, 255, 0.08);
	background: rgba(0, 0, 0, 0.14);
	min-width: 0;
	overflow: hidden;
}

.quick-links {
	grid-template-columns: auto 1fr;
}

.mobile-command-tray {
	grid-template-columns: 1fr auto;
	display: none;
}

.mobile-command-actions {
	display: flex;
	gap: 8px;
	align-items: center;
	justify-self: end;
	padding: 4px 0 8px 4px;
}

.quick-links[hidden],
.mobile-command-tray[hidden] {
	display: none;
}

.mobile-tray-back[hidden] {
	display: none;
}

.mobile-custom-trigger[hidden] {
	display: none;
}

.quick-links-label {
	color: var(--muted);
	font-size: clamp(10px, 1.1vw, 11px);
	text-transform: uppercase;
	letter-spacing: 0.08em;
	white-space: nowrap;
}

.quick-links-list,
.mobile-command-list {
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	gap: 8px;
	min-width: 0;
	overflow-x: auto;
	overflow-y: hidden;
	padding: 4px 12px 8px 2px;
	scrollbar-width: none;
	-ms-overflow-style: none;
	-webkit-overflow-scrolling: touch;
	scroll-padding-inline: 12px;
	scrollbar-gutter: stable;
	touch-action: pan-x;
}

.mobile-command-list {
	padding-right: 26px;
	padding-left: 4px;
	-webkit-mask-image: linear-gradient(
		90deg,
		transparent 0,
		#000 12px,
		#000 calc(100% - 24px),
		transparent 100%
	);
	mask-image: linear-gradient(
		90deg,
		transparent 0,
		#000 12px,
		#000 calc(100% - 24px),
		transparent 100%
	);
}

.quick-links-list {
	padding-left: 10px;
	-webkit-mask-image: linear-gradient(
		90deg,
		transparent 0,
		#000 12px,
		#000 calc(100% - 12px),
		transparent 100%
	);
	mask-image: linear-gradient(
		90deg,
		transparent 0,
		#000 12px,
		#000 calc(100% - 12px),
		transparent 100%
	);
}

.quick-links-list::-webkit-scrollbar,
.mobile-command-list::-webkit-scrollbar {
	display: none;
	width: 0;
	height: 0;
}

.quick-link,
.mobile-command,
.mobile-custom-trigger,
.mobile-tray-back {
	appearance: none;
	-webkit-appearance: none;
	font: inherit;
	line-height: 1.2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: clamp(11px, 1.2vw, 12px);
	color: var(--muted);
	border: 1px solid rgba(255, 255, 255, 0.16);
	border-bottom-color: rgba(255, 255, 255, 0.1);
	background: rgba(255, 255, 255, 0.03);
	padding: 4px 10px;
	border-radius: 999px;
	cursor: pointer;
	white-space: nowrap;
	flex: 0 0 auto;
	transition:
		color 120ms ease,
		border-color 120ms ease,
		background 120ms ease;
}

.mobile-custom-trigger {
	color: var(--accent);
	border-color: rgba(126, 231, 135, 0.52);
	border-bottom-color: rgba(126, 231, 135, 0.34);
	background: rgba(126, 231, 135, 0.1);
}

.mobile-command-arg {
	color: var(--text);
	border-color: rgba(126, 231, 135, 0.36);
	border-bottom-color: rgba(126, 231, 135, 0.24);
	background: rgba(126, 231, 135, 0.08);
}

.quick-link-sigil {
	color: var(--accent);
	margin-right: 6px;
}

.quick-link:hover,
.mobile-command:hover,
.mobile-custom-trigger:hover,
.mobile-tray-back:hover {
	color: var(--text);
	border-color: rgba(126, 231, 135, 0.6);
	background: rgba(126, 231, 135, 0.1);
}

.quick-link:focus-visible,
.mobile-command:focus-visible,
.mobile-custom-trigger:focus-visible,
.mobile-tray-back:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

:root[data-theme="light"] .quick-links,
:root[data-theme="light"] .mobile-command-tray {
	border-top: 1px solid rgba(34, 42, 47, 0.18);
	background: rgba(227, 220, 197, 0.9);
}

:root[data-theme="light"] .quick-link,
:root[data-theme="light"] .mobile-command,
:root[data-theme="light"] .mobile-custom-trigger,
:root[data-theme="light"] .mobile-tray-back {
	border: 1px solid rgba(34, 42, 47, 0.24);
	border-bottom-color: rgba(34, 42, 47, 0.16);
	background: rgba(34, 42, 47, 0.08);
}

:root[data-theme="light"] .mobile-command-arg {
	border-color: rgba(5, 158, 0, 0.35);
	border-bottom-color: rgba(5, 158, 0, 0.24);
	background: rgba(5, 158, 0, 0.13);
}

:root[data-theme="light"] .quick-link:hover,
:root[data-theme="light"] .mobile-command:hover,
:root[data-theme="light"] .mobile-custom-trigger:hover,
:root[data-theme="light"] .mobile-tray-back:hover {
	border-color: rgba(5, 158, 0, 0.5);
	background: rgba(5, 158, 0, 0.12);
}

.mobile-command-dialog {
	position: fixed;
	inset: 0;
	z-index: 30;
	display: grid;
	align-items: end;
	padding: clamp(12px, 2.5vw, 16px);
}

.mobile-command-dialog[hidden] {
	display: none;
}

.mobile-command-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.58);
}

.mobile-custom-form {
	position: relative;
	display: grid;
	gap: 10px;
	background:
		linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0)),
		var(--panel);
	border: 1px solid rgba(255, 255, 255, 0.14);
	border-radius: 12px;
	padding: 12px;
	box-shadow: 0 20px 45px var(--shadow);
}

.mobile-custom-title {
	margin: 0;
	font-size: 13px;
	color: var(--muted);
	font-weight: 600;
}

#mobileCustomInput {
	width: 100%;
	background: rgba(0, 0, 0, 0.22);
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 10px;
	outline: none;
	color: var(--text);
	font: inherit;
	font-size: 16px;
	padding: 9px 11px;
	caret-color: var(--accent);
}

#mobileCustomInput::placeholder {
	color: var(--muted);
}

#mobileCustomInput:focus-visible {
	border-color: rgba(126, 231, 135, 0.7);
	box-shadow: 0 0 0 2px rgba(126, 231, 135, 0.16);
}

.mobile-custom-suggestions-wrap {
	display: grid;
	gap: 6px;
	min-height: 34px;
}

.mobile-custom-suggestions-hint {
	display: flex;
	align-items: center;
	min-height: 34px;
	color: var(--muted);
	font-size: 11px;
	letter-spacing: 0.02em;
}

.mobile-custom-suggestions-hint[hidden] {
	display: none;
}

.mobile-custom-suggestions {
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	gap: 8px;
	min-height: 34px;
	min-width: 0;
	overflow-x: auto;
	overflow-y: hidden;
	padding: 2px 2px 8px;
	scrollbar-width: none;
	-ms-overflow-style: none;
	-webkit-overflow-scrolling: touch;
	scroll-padding-inline: 12px;
}

.mobile-custom-suggestions::-webkit-scrollbar {
	display: none;
	width: 0;
	height: 0;
}

.mobile-custom-suggestions[hidden] {
	display: none;
}

.mobile-custom-suggestion {
	appearance: none;
	-webkit-appearance: none;
	font: inherit;
	line-height: 1.2;
	display: inline-flex;
	align-items: center;
	font-size: 12px;
	color: var(--muted);
	border: 1px solid rgba(255, 255, 255, 0.16);
	border-bottom-color: rgba(255, 255, 255, 0.1);
	background: rgba(255, 255, 255, 0.03);
	padding: 4px 10px;
	border-radius: 999px;
	cursor: pointer;
	white-space: nowrap;
	flex: 0 0 auto;
	transition:
		color 120ms ease,
		border-color 120ms ease,
		background 120ms ease;
}

.mobile-custom-suggestion[data-kind="completion"] {
	color: var(--text);
	border-color: rgba(126, 231, 135, 0.32);
	border-bottom-color: rgba(126, 231, 135, 0.24);
	background: rgba(126, 231, 135, 0.08);
}

.mobile-custom-suggestion:hover {
	color: var(--text);
	border-color: rgba(126, 231, 135, 0.62);
	background: rgba(126, 231, 135, 0.14);
}

.mobile-custom-suggestion:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

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

.mobile-custom-cancel,
.mobile-custom-run {
	appearance: none;
	-webkit-appearance: none;
	font: inherit;
	line-height: 1.2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	border-radius: 999px;
	padding: 5px 12px;
	cursor: pointer;
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-bottom-color: rgba(255, 255, 255, 0.1);
	background: rgba(255, 255, 255, 0.04);
	color: var(--text);
	transition:
		color 120ms ease,
		border-color 120ms ease,
		background 120ms ease;
}

.mobile-custom-run {
	color: var(--accent);
	border-color: rgba(126, 231, 135, 0.56);
	border-bottom-color: rgba(126, 231, 135, 0.36);
	background: rgba(126, 231, 135, 0.1);
}

.mobile-custom-cancel:hover,
.mobile-custom-run:hover {
	border-color: rgba(126, 231, 135, 0.6);
	background: rgba(126, 231, 135, 0.14);
}

.mobile-custom-cancel:focus-visible,
.mobile-custom-run:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

:root[data-theme="light"] .mobile-command-backdrop {
	background: rgba(20, 24, 28, 0.45);
}

:root[data-theme="light"] .mobile-custom-form {
	border: 1px solid rgba(34, 42, 47, 0.22);
	background:
		linear-gradient(180deg, rgba(34, 42, 47, 0.08), rgba(34, 42, 47, 0)),
		var(--panel);
}

:root[data-theme="light"] #mobileCustomInput {
	background: rgba(34, 42, 47, 0.06);
	border: 1px solid rgba(34, 42, 47, 0.24);
}

:root[data-theme="light"] #mobileCustomInput:focus-visible {
	border-color: rgba(5, 158, 0, 0.62);
	box-shadow: 0 0 0 2px rgba(5, 158, 0, 0.18);
}

:root[data-theme="light"] .mobile-custom-suggestions-hint {
	color: rgba(34, 42, 47, 0.78);
}

:root[data-theme="light"] .mobile-custom-suggestion {
	border: 1px solid rgba(34, 42, 47, 0.24);
	border-bottom-color: rgba(34, 42, 47, 0.16);
	background: rgba(34, 42, 47, 0.08);
}

:root[data-theme="light"] .mobile-custom-suggestion[data-kind="completion"] {
	border-color: rgba(5, 158, 0, 0.35);
	border-bottom-color: rgba(5, 158, 0, 0.24);
	background: rgba(5, 158, 0, 0.13);
}

:root[data-theme="light"] .mobile-custom-suggestion:hover {
	border-color: rgba(5, 158, 0, 0.52);
	background: rgba(5, 158, 0, 0.16);
}

:root[data-theme="light"] .mobile-custom-cancel,
:root[data-theme="light"] .mobile-custom-run {
	border: 1px solid rgba(34, 42, 47, 0.24);
	border-bottom-color: rgba(34, 42, 47, 0.16);
	background: rgba(34, 42, 47, 0.08);
}

:root[data-theme="light"] .mobile-custom-run {
	border-color: rgba(5, 158, 0, 0.4);
	border-bottom-color: rgba(5, 158, 0, 0.28);
	background: rgba(5, 158, 0, 0.12);
}

:root[data-theme="light"] .mobile-custom-cancel:hover,
:root[data-theme="light"] .mobile-custom-run:hover {
	border-color: rgba(5, 158, 0, 0.52);
	background: rgba(5, 158, 0, 0.16);
}
.prompt {
	display: flex;
	gap: clamp(6px, 1.1vw, 8px);
	align-items: center;
	padding: clamp(10px, 1.4vw, 12px) clamp(12px, 1.8vw, 14px);
	border-top: 1px solid rgba(255, 255, 255, 0.08);
	background: rgba(0, 0, 0, 0.18);
	overflow-x: auto;
	overflow-y: hidden;
	white-space: nowrap;
	scrollbar-width: thin;
	scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
	-webkit-overflow-scrolling: touch;
}

.prompt::-webkit-scrollbar {
	height: 8px;
}

.prompt::-webkit-scrollbar-track {
	background: transparent;
}

.prompt::-webkit-scrollbar-thumb {
	background: rgba(255, 255, 255, 0.18);
	border-radius: 999px;
}

.ps1 {
	color: var(--accent);
	flex: 0 0 auto;
}
.cwd {
	color: var(--muted);
	flex: 0 0 auto;
}
.sep {
	color: var(--muted);
	flex: 0 0 auto;
}

#input {
	flex: 1 0 16ch;
	min-width: 16ch;
	margin-left: 6px;
	background: transparent;
	border: none;
	outline: none;
	color: var(--text);
	font: inherit;
	font-size: 16px;
	padding: 0;
	caret-color: var(--accent);
}

#input::placeholder {
	color: var(--muted);
	font-size: 13px;
	opacity: 0.85;
}

#input:focus-visible {
	outline: 1px solid var(--accent);
	outline-offset: 5px;
	border-radius: 6px;
}

.sr-only {
	position: absolute;
	left: -10000px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.toast {
	position: fixed;
	right: 18px;
	bottom: 18px;
	background:
		linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0)),
		var(--panel);
	color: var(--text);
	border: 1px solid rgba(255, 255, 255, 0.12);
	border-radius: 10px;
	padding: 10px 14px;
	box-shadow: 0 12px 30px var(--shadow);
	opacity: 0;
	transform: translateY(8px);
	pointer-events: none;
	transition:
		opacity 160ms ease,
		transform 160ms ease;
	z-index: 20;
}

.toast.show {
	opacity: 1;
	transform: translateY(0);
}

:root[data-theme="light"] .toast {
	border: 1px solid rgba(34, 42, 47, 0.22);
	background:
		linear-gradient(180deg, rgba(34, 42, 47, 0.09), rgba(34, 42, 47, 0)),
		var(--panel);
}

@media (prefers-reduced-motion: no-preference) {
	.terminal {
		animation: pop 220ms ease-out;
	}
	@keyframes pop {
		from {
			transform: translateY(8px);
			opacity: 0.7;
		}
		to {
			transform: none;
			opacity: 1;
		}
	}
}

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

@media (pointer: coarse) {
	body {
		place-items: start center;
	}

	.mobile-command-tray {
		display: grid;
	}

	.prompt {
		display: none;
	}
}

@media (max-width: 520px) {
	.prompt .ps1,
	.prompt .cwd,
	.prompt .sep:first-of-type {
		display: none;
	}

	#input {
		flex-basis: 20ch;
		min-width: 20ch;
	}
}
