/**
 * vprof UI
 *
 * Light / dark theme: tokens on :root, html[data-theme] (default "dark" from views/layout.php,
 * changed by the theme toggle - public/js/theme.js, ui.js). Without data-theme css follows the OS setting.
 */

:root {
	--bg: #f4f6f8;
	--surface: #ffffff;
	--ink: #14202b;
	--muted: #5b6b79;
	--line: #dde3e9;
	--accent: #0f7f9c;
	--accent-ink: #ffffff;
	--accent-soft: #e2f2f6;
	--ok: #1f8a4c;
	--ok-soft: #e1f4e8;
	--bad: #b42318;
	--bad-soft: #fde8e7;
	--dev: #b4540a;
	--dev-soft: #fdebd9;
	--key: #eef2f5;
	--font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
	--font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
	color-scheme: light;
}
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #0e151b; --surface: #16212a; --ink: #e7eef3; --muted: #93a4b2; --line: #263540;
		--accent: #3cb6d3; --accent-ink: #06222b; --accent-soft: #14323c;
		--ok: #52c783; --ok-soft: #153324; --bad: #ff8a80; --bad-soft: #3a1a1a;
		--dev: #f0a15c; --dev-soft: #3a2614; --key: #1d2b36;
		color-scheme: dark;
	}
}
:root[data-theme="dark"] {
	--bg: #0e151b; --surface: #16212a; --ink: #e7eef3; --muted: #93a4b2; --line: #263540;
	--accent: #3cb6d3; --accent-ink: #06222b; --accent-soft: #14323c;
	--ok: #52c783; --ok-soft: #153324; --bad: #ff8a80; --bad-soft: #3a1a1a;
	--dev: #f0a15c; --dev-soft: #3a2614; --key: #1d2b36;
	color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 400 16px/1.55 var(--font-body); -webkit-font-smoothing: antialiased;
       min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
/* footer at the bottom of the window: main takes the free space */
body > main { flex: 1 0 auto; width: 100%; }
h1, h2, h3 { text-wrap: balance; margin: 0; line-height: 1.2; }
p { margin: 0; }
a { color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 20px; }

/* ------------------------------------------------------------------ top bar */
.bar { background: var(--surface); border-bottom: 1px solid var(--line); }
.bar .wrap { display: flex; align-items: center; gap: 10px; height: 56px; }
.pill { display: inline-block; font: 500 12px/1 var(--font-mono); padding: 5px 8px; border-radius: 999px; letter-spacing: .04em; }
.pill.dev { background: var(--dev-soft); color: var(--dev); }
.pill.ok, .pill.bad { font-family: var(--font-body); font-size: 13px; font-weight: 500; letter-spacing: 0; padding: 5px 10px; }
.pill.ok  { background: var(--ok-soft);  color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.host { font: 400 13px var(--font-mono); color: var(--muted); }
.spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 6px 10px; font-size: 13px; font-weight: 500; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; background: transparent; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); }
.icon-btn:hover { color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }

/* theme icon: moon in light theme, sun in dark theme */
.icon-btn .i-sun { display: none; }
:root[data-theme="dark"] .icon-btn .i-sun { display: block; }
:root[data-theme="dark"] .icon-btn .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .icon-btn .i-sun { display: block; }
	:root:not([data-theme="light"]) .icon-btn .i-moon { display: none; }
}

/* ------------------------------------------------------------------ hero */
.hero { text-align: center; padding: 36px 0 28px; }
.hero .rule { border: 0; border-top: 1px solid var(--line); margin: 0; }
.hero-inner { padding: 28px 0; }
.hero h1 { display: inline-flex; align-items: center; gap: 14px; font-weight: 300; font-size: clamp(40px, 7vw, 60px); letter-spacing: -.01em; line-height: 1; }
.hero h1 a { display: inline-flex; align-items: center; gap: inherit; color: inherit; text-decoration: none; cursor: pointer; }
.hero h1 img { width: clamp(44px, 7vw, 64px); height: auto; }
.hero .lead { margin: 16px auto 0; color: var(--muted); font-size: 18px; font-weight: 300; }

/* ------------------------------------------------------------------ grid */
.grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; padding-bottom: 56px; }
@media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }
.grid.single { grid-template-columns: minmax(0, 1fr); max-width: 460px; margin: 0 auto; gap: 16px; }
.grid.single.wide { max-width: 560px; }
.grid.narrow { grid-template-columns: minmax(0, 1fr); max-width: 720px; margin: 0 auto; }

.steps { display: grid; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 22px; }
.step { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 16px; }
.step.no-num { grid-template-columns: minmax(0, 1fr); }
.num { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font: 500 14px var(--font-mono); background: var(--accent-soft); color: var(--accent); }
.step h2, .card > h2 { font-size: 18px; font-weight: 600; }
.lead-s { margin-top: 6px; color: var(--muted); font-size: 15px; max-width: 58ch; }
.step.primary { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.btn { display: inline-flex; align-items: center; gap: 8px; border-radius: 8px; padding: 10px 16px; font-weight: 500; font-size: 15px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; color: var(--ink); }
.btn:hover { border-color: var(--accent); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.main { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); padding: 12px 20px; font-size: 16px; }
.btn.main:hover { filter: brightness(1.08); }
.btn[disabled] { opacity: .6; cursor: default; }
.actions { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.actions.center { justify-content: center; }
.variant { margin-top: 16px; font-size: 13px; color: var(--muted); }
.variant + .actions { margin-top: 6px; }
.hint { font-size: 13px; color: var(--muted); }

/* ------------------------------------------------------------------ OS / clients */
.os { margin-top: 16px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 400px) { .os { grid-template-columns: minmax(0, 1fr); } }
.os a { display: grid; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: inherit; position: relative; }
.os a:hover { border-color: var(--accent); }
.os .name { font-weight: 600; font-size: 15px; }
.os .client { font-size: 13px; color: var(--muted); }
.os a.mine { border-color: var(--accent); background: var(--accent-soft); }
.os a.mine::after { content: attr(data-badge); position: absolute; top: 10px; right: 10px; font: 500 11px var(--font-mono); color: var(--accent); }

/* ------------------------------------------------------------------ certificate */
.cert { position: sticky; top: 16px; }
@media (max-width: 860px) { .cert { position: static; } }
.cert-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.facts { margin: 14px 0 0; display: grid; gap: 14px; }
.facts dt { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-size: 15px; word-break: break-word; }
.mono { font-family: var(--font-mono); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.copyrow { display: flex; gap: 8px; align-items: flex-start; }
.copyrow .mono { flex: 1; }
.copy { flex: none; background: transparent; border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; font-size: 12px; color: var(--muted); }
.copy:hover { color: var(--ink); border-color: var(--accent); }

/* ------------------------------------------------------------------ errors / alerts */
.card.error { border-color: var(--bad); }
.card.error h2, .card.error a { color: var(--bad); }
.card.error .lead-s + .lead-s { margin-top: 10px; }
.alert { margin-top: 16px; padding: 10px 14px; border-radius: 8px; font-size: 14px; background: var(--bad-soft); color: var(--bad); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }

/* ------------------------------------------------------------------ OTP / PIN */
.otp { text-align: center; }
.otp h2 { font-size: 20px; }
.otp .lead-s { margin-left: auto; margin-right: auto; max-width: 46ch; }
.pin { margin-top: 24px; display: grid; grid-template-columns: repeat(4, minmax(0, 72px)); gap: 12px; justify-content: center; }
.pin input { width: 100%; height: 64px; text-align: center; font: 500 28px var(--font-mono); background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; }
.pin input.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 380px; margin: 0 auto; touch-action: manipulation; }
.pad button { height: 64px; font: 500 22px var(--font-body); background: var(--key); border: 1px solid var(--line); border-radius: 10px; color: var(--ink); }
.pad button:hover { border-color: var(--accent); }
.pad button:active { transform: translateY(1px); }
.pad .clear { color: var(--muted); }
.pad .ok { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.pad .ok svg { width: 24px; height: 24px; }
.otp-note { margin-top: 20px; font-size: 13px; color: var(--muted); }

/* secret */
.qr { margin: 22px auto 0; width: 196px; height: 196px; padding: 13px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.qr img, .qr canvas { display: block; width: 170px !important; height: 170px !important; }
.secret-row { margin: 18px auto 0; max-width: 440px; align-items: center; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; }
.secret-code { font-size: 17px; font-weight: 500; letter-spacing: .06em; text-align: left; }
.secret .sensitive > p:last-child { margin-top: 14px; }
.secret .sensitive + .lead-s { margin-top: 18px; }
.apps { display: inline-block; margin: 8px 0 0; padding-left: 20px; text-align: left; color: var(--muted); font-size: 15px; }
.confirm .lead-s { margin-top: 0; }

/* ------------------------------------------------------------------ toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } .pad button:active { transform: none; } }

/* ------------------------------------------------------------------ small screens */
@media (max-width: 520px) {
	.bar .wrap { gap: 8px; }
	.host { display: none; }
	.card { padding: 18px; }
	.step { grid-template-columns: minmax(0, 1fr); gap: 10px; }
	.pin { gap: 8px; }
	.pin input { height: 56px; }
	.pad button { height: 56px; }
}

/* ------------------------------------------------------------------ footer */
footer { border-top: 1px solid var(--line); padding: 20px 0 32px; color: var(--muted); font-size: 13px; }
footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }
footer a { color: inherit; }
