@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
	--bg: #0f1115;
	--panel: #171a21;
	--panel-2: #1f232b;
	--field: #0d1016;
	--line: #30343d;
	--line-2: #3b414d;
	--text: #e6e8ec;
	--muted: #9aa3af;
	--muted-2: #737c89;
	--accent: #0a6af5;
	--accent-2: #2f81f7;
	--danger: #ff7b72;
	--shadow: 0 18px 42px rgba(0, 0, 0, 0.36);
}

* {
	box-sizing: border-box;
}

html,
body {
	width: 100%;
	height: 100%;
	margin: 0;
	overflow: hidden;
	background: var(--bg);
	color: var(--text);
	font-family: "Inter", Arial, Helvetica, sans-serif;
	font-size: 14px;
}

button,
input {
	font: inherit;
}

.app-bg {
	position: fixed;
	inset: 0;
	z-index: 0;
	pointer-events: none;
	background:
		linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
		linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px),
		var(--bg);
	background-size: 32px 32px;
}

.browser-top {
	position: fixed;
	inset: 10px 10px auto;
	z-index: 10;
	height: 52px;
	display: grid;
	grid-template-columns: auto auto 1fr;
	align-items: center;
	gap: 8px;
	padding: 7px;
	border: 1px solid var(--line);
	border-radius: 12px;
	background: rgba(23, 26, 33, 0.94);
	box-shadow: var(--shadow);
	backdrop-filter: blur(12px);
}

.traffic {
	display: none;
}

.nav-btn,
#go-btn,
.quick-row button {
	border: 1px solid var(--line);
	border-radius: 9px;
	background: var(--panel-2);
	color: var(--text);
	font-weight: 500;
	cursor: pointer;
	transition: background 0.14s ease, border-color 0.14s ease, transform 0.08s ease;
}

.nav-btn:hover,
.quick-row button:hover,
#go-btn:hover {
	background: #262b35;
	border-color: var(--line-2);
}

.nav-btn:active,
.quick-row button:active,
#go-btn:active {
	transform: translateY(1px);
}

.nav-btn {
	min-width: 42px;
	height: 36px;
	padding: 0 12px;
}

.nav-btn.icon {
	width: 38px;
	min-width: 38px;
	padding: 0;
	font-size: 24px;
	line-height: 1;
}

.address-form {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 8px;
	min-width: 0;
}

#sj-address {
	width: 100%;
	height: 36px;
	min-width: 0;
	border: 1px solid var(--line);
	border-radius: 9px;
	background: var(--field);
	color: var(--text);
	outline: none;
	padding: 0 12px;
	font-weight: 400;
	transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

#sj-address::placeholder {
	color: var(--muted-2);
}

#sj-address:focus {
	border-color: var(--accent-2);
	box-shadow: 0 0 0 3px rgba(47, 129, 247, 0.16);
}

#go-btn {
	height: 36px;
	padding: 0 15px;
	background: var(--accent);
	border-color: #1f6feb;
	color: #fff;
	font-weight: 600;
}

#go-btn:disabled {
	opacity: 0.72;
	cursor: default;
	transform: none;
}

.home-screen {
	position: fixed;
	inset: 0;
	z-index: 2;
	display: grid;
	place-items: center;
	padding: 88px 18px 26px;
	transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
}

.home-screen.hidden {
	opacity: 0;
	transform: translateY(8px);
	visibility: hidden;
	pointer-events: none;
}

.home-card {
	width: min(520px, 100%);
	text-align: left;
	border: 1px solid var(--line);
	border-radius: 12px;
	background: rgba(23, 26, 33, 0.94);
	box-shadow: var(--shadow);
	padding: 22px;
}

.logo-mark {
	width: 54px;
	height: 54px;
	display: grid;
	place-items: center;
	margin-bottom: 14px;
	border: 1px solid var(--line);
	border-radius: 12px;
	background: var(--field);
	overflow: hidden;
}

.logo-mark img {
	width: 42px;
	height: 42px;
	object-fit: contain;
}

.logo-mark img.broken {
	display: none;
}

.logo-fallback {
	display: none;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	border-radius: 9px;
	background: var(--accent);
	font-size: 15px;
	font-weight: 600;
	color: #fff;
}

.logo-mark img.broken + .logo-fallback {
	display: flex;
}

.home-card h1 {
	margin: 0 0 6px;
	font-size: 24px;
	font-weight: 600;
	letter-spacing: 0;
}

.home-card p {
	margin: 0;
	color: var(--muted);
	line-height: 1.45;
	font-weight: 400;
}

.quick-row {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 8px;
	margin-top: 18px;
}

.quick-row button {
	min-height: 38px;
	padding: 0 10px;
	color: #d6d9df;
}

#sj-frame {
	border: none;
	position: absolute;
	z-index: 1;
	top: 72px;
	left: 0;
	width: 100vw;
	height: calc(100vh - 72px);
	background: #fff;
	opacity: 0;
	transition: opacity 0.18s ease;
}

#sj-frame.ready {
	opacity: 1;
}

.loading-layer {
	position: fixed;
	inset: 0;
	z-index: 8;
	display: grid;
	place-items: center;
	padding: 20px;
	background: rgba(15, 17, 21, 0.5);
	backdrop-filter: blur(6px);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.16s ease, visibility 0.16s ease;
}

body.loading .loading-layer {
	opacity: 1;
	visibility: visible;
}

.loading-card {
	display: flex;
	align-items: center;
	gap: 13px;
	width: min(360px, 100%);
	border: 1px solid var(--line);
	border-radius: 12px;
	background: var(--panel);
	box-shadow: var(--shadow);
	padding: 15px;
}

.loader {
	width: 24px;
	height: 24px;
	border: 3px solid rgba(154, 163, 175, 0.22);
	border-top-color: var(--accent-2);
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
	flex: 0 0 auto;
}

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

.loading-title {
	font-weight: 600;
	line-height: 1.3;
}

.loading-sub {
	margin-top: 3px;
	color: var(--muted);
	font-size: 12px;
	line-height: 1.35;
}

#sj-error {
	color: var(--danger);
	white-space: pre-wrap;
	margin-top: 16px;
	font-size: 13px;
	font-weight: 500;
}

#sj-error-code {
	max-height: 120px;
	overflow: auto;
	font-size: 11px;
	color: var(--muted);
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	white-space: pre-wrap;
}

#debug-toggle {
	position: fixed;
	left: 10px;
	bottom: 10px;
	z-index: 40;
	width: 22px;
	height: 22px;
	border: 1px solid var(--line);
	border-radius: 50%;
	background: rgba(23, 26, 33, 0.58);
	color: var(--muted);
	font-size: 11px;
	font-weight: 600;
	opacity: 0.24;
	cursor: pointer;
	transition: opacity 0.14s ease, background 0.14s ease;
}

#debug-toggle:hover {
	opacity: 1;
	background: var(--panel-2);
}

#debug-panel {
	position: fixed;
	left: 12px;
	right: 12px;
	bottom: 12px;
	z-index: 45;
	display: none;
	max-height: min(360px, calc(100vh - 94px));
	border: 1px solid var(--line);
	border-radius: 12px;
	background: rgba(15, 17, 21, 0.96);
	box-shadow: var(--shadow);
	overflow: hidden;
	backdrop-filter: blur(12px);
}

#debug-panel.show {
	display: block;
}

.debug-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 10px 12px;
	border-bottom: 1px solid var(--line);
	color: var(--text);
}

.debug-head strong {
	font-size: 13px;
	font-weight: 600;
}

.debug-head div {
	display: flex;
	gap: 6px;
}

.debug-head button {
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--panel-2);
	color: var(--text);
	font-size: 12px;
	font-weight: 500;
	padding: 6px 9px;
	cursor: pointer;
}

#debug-log {
	margin: 0;
	max-height: 300px;
	overflow: auto;
	padding: 11px 12px;
	color: #b8c0cc;
	font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	white-space: pre-wrap;
}

@media (max-width: 620px) {
	.browser-top {
		inset: 8px 8px auto;
		height: auto;
		grid-template-columns: auto auto 1fr;
	}

	.address-form {
		grid-column: 1 / -1;
	}

	.home-card {
		padding: 18px;
	}

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

	#sj-frame {
		top: 100px;
		height: calc(100vh - 100px);
	}
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
	}
}
