/*
 * THE SKY VR — điều khiển từ xa: trang thử P0 (#/thu-ket-noi, remote/p0.js). Phong cách DJI: nền sáng, thẻ trắng, nút viên thuốc.
 * Chỉ nạp khi bật SKY360_REMOTE (inc/learn.php). Tiền tố class: s3rc.
 */
body.s3rc-body { height: 100%; margin: 0; overflow: hidden; background: #f4f5f7; overscroll-behavior: none; }
.s3rc {
	position: fixed; inset: 0; overflow: auto; color: #1f2329; background: #f4f5f7;
	font-family: var(--s3-font, "Open Sans", system-ui, sans-serif); font-size: 15px; line-height: 1.5;
	-webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
.s3rc *, .s3rc *::before, .s3rc *::after { box-sizing: border-box; }
.s3rc [hidden] { display: none !important; }
.s3rc h2, .s3rc h3 { margin: 0 0 .4em; font-family: inherit; font-weight: 600; letter-spacing: -.01em; line-height: 1.25; color: #1f2329; }
.s3rc h2 { font-size: 22px; }
.s3rc h3 { font-size: 17px; }
.s3rc h3 small { font-size: 13px; font-weight: 400; color: #6b7280; }
.s3rc p { margin: 0 0 .8em; }

.s3rc__wrap { max-width: 880px; margin: 0 auto; padding: 24px 20px 40px; }
.s3rc__wrap--wide { max-width: 1040px; }
.s3rc__head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; color: #6b7280; font-size: 14px; }
.s3rc__head .s3rc__btn { margin-left: auto; }
.s3rc__brand { color: #000; font-weight: 800; font-style: italic; letter-spacing: .02em; text-decoration: none; font-size: 18px; }
.s3rc__brand b { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 6px; background: #000; color: #fff; font-style: normal; font-size: 12px; line-height: 20px; vertical-align: 3px; }

.s3rc__cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.s3rc__cards.is-phone section:first-child { order: 2; }
.s3rc__card { padding: 26px; border-radius: 16px; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 28px -12px rgba(0, 0, 0, .12); }
.s3rc__card p { color: #4b5563; }
.s3rc__msg { padding: 12px 16px; border-radius: 12px; background: #fff7e6; color: #8a5a00; }
.s3rc p.s3rc__note { margin-top: 14px; } /* .s3rc p (margin 0) mạnh hơn .s3rc__note → khoảng cách không ăn */
.s3rc__note { color: #6b7280 !important; font-size: 13px; }
.s3rc__err { margin: 10px 0 0; color: #d1435b !important; font-size: 14px; }

.s3rc__btn {
	display: inline-flex; align-items: center; justify-content: center; height: 44px; padding: 0 22px; border: 1px solid #d5d9e0;
	border-radius: 999px; background: #fff; color: #1f2329; font: inherit; font-weight: 600; cursor: pointer; touch-action: manipulation;
}
.s3rc__btn:active { transform: scale(.98); }
.s3rc__btn--primary { border-color: transparent; background: #1f2329; color: #fff; }
.s3rc__btn--sm { height: 34px; padding: 0 14px; font-size: 13px; }
.s3rc__row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.s3rc form { display: grid; gap: 14px; }
.s3rc__code {
	width: 100%; height: 64px; border: 1px solid #d5d9e0; border-radius: 14px; background: #f7f8fa; text-align: center;
	font: 600 32px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .12em; color: #1f2329;
}
.s3rc__code:focus { outline: 2px solid #1f2329; outline-offset: 1px; background: #fff; }
.s3rc__net { display: grid; gap: 6px; font-size: 13px; color: #6b7280; }
.s3rc__net select { height: 44px; padding: 0 12px; border: 1px solid #d5d9e0; border-radius: 12px; background: #fff; font: inherit; font-size: 15px; color: #1f2329; }

/* máy tính: mã */
.s3rc__pair { max-width: 520px; margin: 0 auto; text-align: center; }
.s3rc__lbl { margin: 0 !important; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: #6b7280 !important; }
.s3rc__bigcode { margin: 6px 0 4px !important; font: 700 64px/1.1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .08em; color: #000 !important; font-variant-numeric: tabular-nums; }
.s3rc__count { font-variant-numeric: tabular-nums; }
.s3rc__how { font-size: 14px; }
.s3rc__status { font-weight: 600; color: #1f2329 !important; }
.s3rc__pair .s3rc__row { justify-content: center; }

/* máy tính: đã kết nối */
.s3rc__live { display: grid; gap: 16px; }
.s3rc__sig { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 14px; background: #fff; }
.s3rc__sig b { font-variant-numeric: tabular-nums; }
.s3rc__sig span { color: #6b7280; }
.s3rc__dot { width: 10px; height: 10px; border-radius: 50%; background: #c0c4cc; }
.s3rc__dot[data-q="good"] { background: #18b26b; }
.s3rc__dot[data-q="ok"] { background: #f2a516; }
.s3rc__dot[data-q="bad"] { background: #e5484d; }
.s3rc__lost { margin-left: auto; padding: 3px 10px; border-radius: 999px; background: #fdecee; color: #c62f45 !important; font-weight: 600; font-size: 13px; }
.s3rc__gates { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.s3rc__gate { position: relative; aspect-ratio: 1; width: min(100%, 300px); margin: 0 auto; border-radius: 22px; background: #1d2129; }
.s3rc__gate::before, .s3rc__gate::after { content: ""; position: absolute; background: rgba(255, 255, 255, .14); }
.s3rc__gate::before { left: 50%; top: 10%; bottom: 10%; width: 1px; }
.s3rc__gate::after { top: 50%; left: 10%; right: 10%; height: 1px; }
.s3rc__gate i {
	--x: 0; --y: 0; position: absolute; z-index: 1; width: 34px; height: 34px; border-radius: 50%; background: #fff;
	box-shadow: 0 0 0 6px rgba(255, 255, 255, .18);
	left: calc(50% + var(--x) * (40% - 17px)); top: calc(50% - var(--y) * (40% - 17px)); transform: translate(-50%, -50%);
}
.s3rc__gate span { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; font-size: 12px; color: rgba(255, 255, 255, .6); }
.s3rc__table { width: 100%; border-collapse: collapse; font-size: 14px; }
.s3rc__table th, .s3rc__table td { padding: 8px 0; border-bottom: 1px solid #eceef2; text-align: left; vertical-align: top; }
.s3rc__table th { width: 46%; padding-right: 12px; font-weight: 400; color: #6b7280; }
.s3rc__table td { font-weight: 600; font-variant-numeric: tabular-nums; }
.s3rc__stats, .s3rc__result { margin: 0; padding: 16px 20px; border-radius: 14px; background: #fff; }
.s3rc__result:empty { display: none; }

/* điện thoại: tay cầm */
.s3rc__pad {
	position: fixed; inset: 0; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto 1fr;
	background: #15181e; color: #fff; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
	padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.s3rc__padbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: rgba(255, 255, 255, .06); font-size: 14px; }
.s3rc__padbar b { font-variant-numeric: tabular-nums; }
.s3rc__padpath { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: rgba(255, 255, 255, .6); }
.s3rc__padbar .s3rc__btn { border-color: rgba(255, 255, 255, .25); background: transparent; color: #fff; }
.s3rc__padbar .s3rc__btn--primary { border-color: transparent; background: #fff; color: #15181e; }
.s3rc__zone { position: relative; overflow: hidden; touch-action: none; }
.s3rc__zone[data-zone="left"] { margin-left: 24px; border-right: 1px solid rgba(255, 255, 255, .06); } /* tránh cử chỉ vuốt lùi ở mép trái Safari */
.s3rc__hint { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); margin: 0 !important; text-align: center; font-weight: 600; color: rgba(255, 255, 255, .45); pointer-events: none; }
.s3rc__hint small { font-weight: 400; font-size: 12px; }
.s3rc__stick {
	--r: 80px; position: absolute; width: calc(var(--r) * 2); height: calc(var(--r) * 2); transform: translate(-50%, -50%);
	border-radius: 24%; border: 1.5px solid rgba(255, 255, 255, .28); background: rgba(255, 255, 255, .05); pointer-events: none;
}
.s3rc__stick i { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: #fff; box-shadow: 0 4px 18px rgba(0, 0, 0, .5); }
.s3rc__overlay { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px; overflow: auto; background: rgba(21, 24, 30, .78); }
.s3rc__overlay .s3rc__card { width: min(560px, 100%); color: #1f2329; }
.s3rc__rotate { display: none; }
@media (orientation: portrait) and (pointer: coarse) {
	.s3rc__rotate { display: block; position: absolute; left: 0; right: 0; bottom: max(14px, env(safe-area-inset-bottom)); margin: 0 !important; text-align: center; font-size: 13px; color: rgba(255, 255, 255, .5); pointer-events: none; }
	.s3rc__padbar .s3rc__padpath { display: none; }
}
@media (max-width: 700px) {
	.s3rc__cards, .s3rc__gates { grid-template-columns: 1fr; }
	.s3rc__bigcode { font-size: 48px; }
	.s3rc__card { padding: 20px; }
}

/* =====================================================================================================================
 * P1 — điện thoại làm tay cầm (remote/host.js trên máy tính, remote/controller.js trên điện thoại)
 * ===================================================================================================================*/

/* máy tính: nút / chip trên thanh đầu trang */
.s3rc-chip { display: inline-flex; align-items: center; gap: 4px; }
.s3rc-chip__ms { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; color: #18a35f; }
.s3rc-chip__ms:empty { display: none; }
.s3rc-chip[data-state="on"] { color: #18a35f; }
.s3rc-chip[data-state="lost"] { color: #d9363e; }
.s3rc-chip[data-state="lost"] .s3rc-chip__ms { color: #d9363e; }
.s3rc-chip[data-state="on"]::after, .s3rc-chip[data-state="lost"]::after {
	content: ""; position: absolute; top: 5px; left: 21px; width: 8px; height: 8px; border-radius: 50%; border: 2px solid #fff; background: currentColor;
}

/* máy tính: hộp mã */
.s3rcpair { text-align: center; }
.s3rcpair h2 { padding: 0 30px !important; }
.s3rcpair__steps { display: grid; gap: 8px; margin: 14px auto 6px !important; padding: 0; max-width: 400px; list-style: none; text-align: left; }
.s3rcpair__steps li { display: flex; align-items: flex-start; gap: 10px; color: var(--s3-muted); font-size: 15px; }
.s3rcpair__steps .s3-i { flex: none; margin-top: 2px; color: #111; }
.s3rcpair__code { margin: 8px 0 2px !important; font: 700 58px/1.1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .08em; color: #000; font-variant-numeric: tabular-nums; }
.s3rcpair__code.is-off { color: #c3c7cc; text-decoration: line-through; text-decoration-thickness: 3px; }
.s3rcpair__count { min-height: 1.5em; margin: 0 !important; color: var(--s3-muted); font-variant-numeric: tabular-nums; }
.s3rcpair__status { margin: 10px 0 0 !important; font-weight: 600; color: #111; }
.s3rcpair__status:empty { display: none; }
.s3rcpair__warn { margin: 12px 0 0 !important; padding: 10px 14px; border-radius: 12px; background: #fff6e5; color: #7a4d00; font-size: 14px; text-align: left; }
.s3rcpair__warn b { color: inherit !important; }
.s3rcpair__row { justify-content: center; margin-top: 16px; }
.s3rcpair__row:not(:has(:not([hidden]))) { display: none; }
.s3rcinfo { display: grid; gap: 6px; padding: 8px; }
.s3rcinfo p { margin: 0; display: flex; align-items: center; gap: 6px; }
.s3rcinfo .s3btn { justify-self: start; margin-top: 6px; background: #f1f2f4; border-color: #d9dce0; color: #111 !important; }

/* điện thoại: màn nhập mã / kết nối / lỗi (dùng chung khung .s3rc__* của trang P0) */
.s3rc__wrap--narrow { max-width: 480px; }
.s3rc__wifi { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; background: #eef5ff; color: #164a8a !important; font-size: 14px; font-weight: 600; }
.s3rc__wifi .s3-i { flex: none; }
.s3rc__msg--warn { background: #fff6e5; color: #7a4d00; }
.s3rc__msg--ok { background: #e9f8ef; color: #106b3c; }
.s3rc__center { text-align: center; }
.s3rc__center .s3rc__row { justify-content: center; }
.s3rc__center .s3rc__msg { text-align: left; }
.s3rc__spin { display: inline-block; width: 34px; height: 34px; margin-bottom: 10px; border-radius: 50%; border: 3px solid #e3e6ea; border-top-color: #1f2329; animation: s3rcspin .8s linear infinite; }
@keyframes s3rcspin { to { transform: rotate(360deg); } }
.s3rc__tips { display: grid; gap: 10px; margin: 6px 0 4px; padding-left: 20px; color: #4b5563; }
.s3rc__tips b { color: #1f2329; }
.s3rc__note a { color: #1565c0; text-decoration: none; }
/* điện thoại: liên kết về app dưới thẻ nhập mã — tách khỏi mép thẻ, vùng chạm 44 px */
.s3rc__back { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; margin: 18px auto 0; color: #1565c0; font-size: 15px; font-weight: 600; text-decoration: none; }
.s3rc__btn--ghost { border-color: rgba(255, 255, 255, .25) !important; background: transparent !important; color: #fff !important; }

/* điện thoại: tay cầm. Ngang: [cần trái] [nút] [cần phải]. Dọc: thanh trên, hàng nút, 2 cần ở dưới. */
.s3rc-pad {
	position: fixed; inset: 0; display: grid; grid-template-columns: 1fr minmax(120px, auto) 1fr; grid-template-rows: auto auto 1fr;
	background: #14171c; color: #fff; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
	padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); overflow: hidden;
}
.s3rc-pad__bar { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px 14px; background: rgba(255, 255, 255, .06); font-size: 14px; }
.s3rc-pad__bar > b { font-variant-numeric: tabular-nums; }
.s3rc-pad__title { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: rgba(255, 255, 255, .72); }
.s3rc-pad__hud { display: flex; gap: 10px; font-variant-numeric: tabular-nums; color: rgba(255, 255, 255, .85); white-space: nowrap; }
.s3rc-pad__hud b { display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 6px; background: #fff; color: #14171c; font-size: 12px; }
.s3rc-pad__note { grid-column: 1 / -1; margin: 8px auto 0 !important; padding: 6px 14px; border-radius: 999px; background: rgba(255, 196, 77, .16); color: #ffd27a !important; font-size: 13px; text-align: center; }
.s3rc-pad__zone { position: relative; grid-row: 3; overflow: hidden; touch-action: none; }
.s3rc-pad__zone[data-zone="left"] { margin-left: 24px; } /* tránh cử chỉ vuốt lùi ở mép trái của Safari */
.s3rc-pad__zone.is-active .s3rc-pad__hint { opacity: 0; }
.s3rc-pad__hint { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); margin: 0 !important; text-align: center; font-weight: 600; color: rgba(255, 255, 255, .42); pointer-events: none; transition: opacity .15s; }
.s3rc-pad__hint small { display: block; margin-top: 4px; font-weight: 400; font-size: 12px; line-height: 1.45; }
.s3rc-stick {
	--r: 80px; position: absolute; width: calc(var(--r) * 2); height: calc(var(--r) * 2); transform: translate(-50%, -50%);
	border-radius: 24%; border: 1.5px solid rgba(255, 255, 255, .3); background: rgba(255, 255, 255, .05); pointer-events: none;
}
.s3rc-stick i { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; background: #fff; box-shadow: 0 4px 18px rgba(0, 0, 0, .5); }
.s3rc-pad__mid { grid-row: 3; display: flex; flex-direction: column; justify-content: center; gap: 10px; padding: 10px 6px; }
.s3rc-key {
	position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 104px; min-height: 52px;
	padding: 6px 12px; border: 1px solid rgba(255, 255, 255, .2); border-radius: 16px; background: rgba(255, 255, 255, .08); color: #fff;
	font: inherit; font-size: 12px; line-height: 1.2; touch-action: manipulation; overflow: hidden;
}
.s3rc-key:active { background: rgba(255, 255, 255, .18); }
.s3rc-key b { font-size: 16px; }
.s3rc-key--go { border-color: transparent; background: #fff; color: #14171c; font-weight: 700; }
.s3rc-key--hold::before { content: ""; position: absolute; inset: 0; transform: scaleX(0); transform-origin: left; background: rgba(255, 255, 255, .28); }
.s3rc-key--hold.is-holding::before { transform: scaleX(1); transition: transform .8s linear; }
.s3rc-key > * { position: relative; }
.s3rc-pad__rotate { display: none; }
@media (orientation: portrait) {
	.s3rc-pad { grid-template-columns: 1fr 1fr; grid-template-rows: auto auto auto 1fr; }
	.s3rc-pad__mid { grid-column: 1 / -1; grid-row: 3; flex-direction: row; flex-wrap: wrap; justify-content: center; }
	.s3rc-key { min-width: 92px; }
	.s3rc-pad__zone { grid-row: 4; }
	.s3rc-pad__hud span { display: none; }
	.s3rc-pad__rotate { display: block; position: absolute; left: 0; right: 0; bottom: max(12px, env(safe-area-inset-bottom)); margin: 0 !important; text-align: center; font-size: 12px; color: rgba(255, 255, 255, .45); pointer-events: none; }
}

/* tiếng Việt: không để dòng cuối chỉ 1–2 chữ (docs: vi-no-orphan-lines) */
.s3rcpair__steps li, .s3rcpair__warn, .s3rc__wifi, .s3rc__tips li, .s3rc__card p, .s3rc__msg { text-wrap: pretty; }

/* P2 — tự nối lại: lớp phủ trên tay cầm khi đang nối lại */
.s3rc-pad__relink {
	position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
	padding: 24px; background: rgba(20, 23, 28, .86); text-align: center; touch-action: none;
}
.s3rc-pad__relink[hidden] { display: none; }
.s3rc-pad__relink p { margin: 0 !important; display: grid; gap: 4px; color: #fff; text-wrap: pretty; }
.s3rc-pad__relink small { color: rgba(255, 255, 255, .65); font-size: 13px; }
.s3rc__spin--dark { border-color: rgba(255, 255, 255, .18); border-top-color: #fff; margin: 0; }
