:root {
  color-scheme: dark;
  --bg: #090c12;
  --surface: #111620;
  --surface-2: #171d29;
  --line: rgba(255,255,255,.11);
  --text: #f7f9ff;
  --muted: #9ca6ba;
  --accent: #6f86ff;
  --accent-2: #8fa0ff;
  --good: #45dda2;
  --danger: #ff6f7d;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { min-height: 100%; margin: 0; background: var(--bg); color: var(--text); }
body { overscroll-behavior: none; }
button, input, textarea { font: inherit; }
button { color: inherit; cursor: pointer; }
.app-shell { width: min(680px, 100%); min-height: 100dvh; margin: auto; padding: max(26px, env(safe-area-inset-top)) 20px max(22px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
.app-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 34px; }
.eyebrow { margin: 0 0 7px; color: var(--accent-2); font-size: 12px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(30px, 8vw, 44px); line-height: 1.05; letter-spacing: -.04em; }
h2 { font-size: 23px; letter-spacing: -.03em; }
.icon-button { width: 46px; height: 46px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); font-size: 28px; line-height: 1; }
.device-list { display: grid; gap: 14px; }
.device-card { position: relative; overflow: hidden; padding: 20px; border: 1px solid var(--line); border-radius: 24px; background: linear-gradient(145deg, #161c28, #10151e); box-shadow: 0 22px 70px rgba(0,0,0,.22); }
.device-top { display: flex; align-items: center; gap: 14px; }
.device-icon { width: 52px; height: 52px; border: 1px solid rgba(255,255,255,.12); border-radius: 17px; background: linear-gradient(135deg, rgba(111,134,255,.25), rgba(255,255,255,.06)); display: grid; place-items: center; font-size: 24px; }
.device-main { min-width: 0; flex: 1; }
.device-main h2 { margin: 0 0 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-state { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 14px; }
.online-dot, .safe-dot { width: 8px; height: 8px; display: inline-block; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 5px rgba(69,221,162,.08); }
.device-card.offline .online-dot { background: #667085; box-shadow: none; }
.device-card.error .online-dot { background: var(--danger); box-shadow: none; }
.connect-button { width: 100%; margin-top: 19px; min-height: 50px; border: 0; border-radius: 15px; background: var(--accent); font-weight: 800; font-size: 16px; }
.connect-button:disabled { background: #2a303d; color: #778094; cursor: default; }
.remove-host { position: absolute; top: 15px; right: 15px; width: 32px; height: 32px; border: 0; border-radius: 10px; background: transparent; color: #6f788b; font-size: 18px; }
.safe-footer { margin-top: auto; padding-top: 34px; display: flex; justify-content: center; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.empty-state { text-align: center; padding: 56px 18px; border: 1px dashed var(--line); border-radius: 28px; background: rgba(255,255,255,.02); }
.empty-icon { width: 70px; height: 70px; margin: 0 auto 20px; display: grid; place-items: center; border-radius: 23px; background: linear-gradient(135deg, var(--accent), #4b5dd4); font-size: 30px; box-shadow: 0 18px 50px rgba(90,110,255,.25); }
.empty-state p { max-width: 360px; margin: 0 auto 24px; color: var(--muted); line-height: 1.7; }
.notice { display: grid; gap: 5px; margin-bottom: 16px; padding: 14px 16px; border: 1px solid rgba(255,190,92,.25); border-radius: 16px; background: rgba(255,190,92,.08); color: #ffd89a; font-size: 13px; }
.primary, .secondary { min-height: 48px; padding: 0 20px; border-radius: 14px; font-weight: 800; }
.primary { border: 0; background: var(--accent); }
.secondary { border: 1px solid var(--line); background: var(--surface-2); }
.full { width: 100%; }
dialog { width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: 0; border: 0; background: transparent; color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.68); backdrop-filter: blur(5px); }
.sheet { position: absolute; inset: auto 0 0; width: min(560px, 100%); margin: 0 auto; padding: 10px 20px max(24px, env(safe-area-inset-bottom)); border: 1px solid var(--line); border-bottom: 0; border-radius: 26px 26px 0 0; background: #111620; box-shadow: 0 -30px 80px rgba(0,0,0,.4); }
.sheet-handle { width: 42px; height: 5px; margin: 0 auto 20px; border-radius: 5px; background: #3c4350; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.sheet-head h2 { margin-bottom: 18px; }
.close { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); font-size: 24px; }
label { display: grid; gap: 8px; margin-bottom: 15px; color: var(--muted); font-size: 13px; font-weight: 700; }
input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 14px; outline: 0; background: #0b0f16; color: var(--text); }
input { height: 52px; padding: 0 15px; }
textarea { min-height: 130px; resize: none; padding: 15px; line-height: 1.6; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(111,134,255,.12); }
.form-error { min-height: 21px; margin: 2px 0 10px; color: #ff99a3; font-size: 13px; }
.hint { margin: 13px 0 0; text-align: center; color: var(--muted); font-size: 12px; line-height: 1.6; }
.session { position: fixed; inset: 0; z-index: 20; display: none; grid-template-rows: auto minmax(0,1fr) auto; background: #05070a; }
.session.active { display: grid; }
.session-head { min-height: calc(62px + env(safe-area-inset-top)); padding: max(12px, env(safe-area-inset-top)) 15px 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: rgba(11,14,20,.94); border-bottom: 1px solid var(--line); }
.session-head > div { display: flex; align-items: center; gap: 10px; }
.session-head > div:first-child { min-width: 0; }
.session-head strong { display: block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.disconnect { min-height: 38px; padding: 0 16px; border: 1px solid rgba(255,111,125,.3); border-radius: 12px; background: rgba(255,111,125,.1); color: #ff9aa4; font-weight: 800; }
.session-actions { display: flex; align-items: center; gap: 8px; }
.quality-mode { min-height: 38px; padding: 0 14px; border: 1px solid rgba(113,182,255,.3); border-radius: 12px; background: rgba(113,182,255,.1); color: #a9d4ff; font-size: 12px; font-weight: 800; white-space: nowrap; }
.input-mode { min-height: 38px; padding: 0 13px; border: 1px solid rgba(69,221,162,.28); border-radius: 12px; background: rgba(69,221,162,.08); color: #91edc9; font-size: 12px; font-weight: 800; white-space: nowrap; }
.screen-wrap { position: relative; min-height: 0; overflow: hidden; touch-action: none; user-select: none; background: #020304; display: grid; place-items: center; }
#remote-screen { display: block; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.screen-state { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 16px; background: #070a0f; color: var(--muted); }
.screen-state.hidden { display: none; }
.virtual-mouse { position: absolute; right: 14px; bottom: 14px; z-index: 3; width: 150px; padding: 8px; border: 1px solid rgba(255,255,255,.18); border-radius: 22px; background: rgba(13,18,27,.88); box-shadow: 0 14px 45px rgba(0,0,0,.42); backdrop-filter: blur(14px); }
.virtual-mouse[hidden] { display: none; }
.virtual-mouse-buttons { display: grid; grid-template-columns: 1fr 34px 1fr; gap: 5px; }
.virtual-mouse button { min-height: 43px; border: 0; border-radius: 12px; background: #252d3b; font-size: 11px; font-weight: 800; touch-action: none; }
.virtual-mouse #virtual-wheel { color: #b8c5ff; background: #182343; font-size: 16px; }
.virtual-mouse > span { display: block; padding: 9px 3px 3px; text-align: center; color: var(--muted); font-size: 10px; }
.spinner { width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.12); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.control-bar { display: grid; grid-template-columns: repeat(5,1fr); gap: 7px; padding: 10px 10px max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #0d1118; }
.control-bar button { min-width: 0; min-height: 52px; padding: 5px 2px; border: 0; border-radius: 12px; background: #171d27; color: var(--muted); font-size: 10px; }
.control-bar button span { display: block; margin-bottom: 4px; color: var(--text); font-size: 19px; }
.session-error { position: absolute; z-index: 4; top: 78px; left: 50%; transform: translateX(-50%); width: min(90%,420px); padding: 12px 15px; border: 1px solid rgba(255,111,125,.25); border-radius: 13px; background: rgba(60,16,24,.92); text-align: center; color: #ffc1c7; font-size: 13px; }
.shortcut-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin: 12px 0 16px; }
.shortcut-grid button { height: 42px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.toast { position: fixed; z-index: 100; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translate(-50%,20px); max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 12px; background: rgba(245,247,252,.94); color: #10131a; font-weight: 700; font-size: 13px; opacity: 0; pointer-events: none; transition: .2s ease; box-shadow: 0 15px 50px rgba(0,0,0,.28); }
.toast.show { opacity: 1; transform: translate(-50%,0); }

.host-body { min-height: 100vh; display: grid; place-items: center; padding: 30px; background: radial-gradient(circle at 20% 15%, #19233b, #090c12 45%); }
.host-window { width: min(780px,100%); overflow: hidden; border: 1px solid var(--line); border-radius: 24px; background: rgba(13,17,24,.96); box-shadow: 0 40px 110px rgba(0,0,0,.5); }
.host-titlebar { height: 58px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 20px; border-bottom: 1px solid var(--line); }
.traffic { display: flex; gap: 8px; }
.traffic i { width: 11px; height: 11px; border-radius: 50%; background: #ff656d; }
.traffic i:nth-child(2) { background: #f7c64c; }.traffic i:nth-child(3) { background: #49cf76; }
.host-status { justify-self: end; display: flex; align-items: center; gap: 8px; color: var(--good); font-size: 13px; }
.host-status i { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.host-content { padding: 34px; }
.host-identity { display: flex; align-items: center; gap: 18px; }
.host-identity h1 { font-size: 34px; margin-bottom: 8px; }
.host-identity p:last-child { margin: 0; color: var(--muted); }
.mac-symbol { width: 68px; height: 68px; border-radius: 20px; background: linear-gradient(135deg,var(--accent),#4f5fd7); display: grid; place-items: center; font-size: 30px; }
.permission-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 30px 0 12px; }
.permission-grid article { padding: 17px 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); display: flex; justify-content: space-between; }
.permission-grid article span { color: var(--muted); }
.permission-grid strong.good { color: var(--good); }.permission-grid strong.bad { color: #ff9aa4; }
.pair-card { margin-top: 26px; padding: 24px; border: 1px solid rgba(111,134,255,.28); border-radius: 20px; background: rgba(111,134,255,.07); }
.pair-code { margin: 12px 0; font-variant-numeric: tabular-nums; font-size: clamp(36px,7vw,56px); font-weight: 850; letter-spacing: .14em; }
.pair-card > p:not(.eyebrow) { color: var(--muted); line-height: 1.65; }
.trtc-pair-card { background: rgba(69,221,162,.055); border-color: rgba(69,221,162,.22); }
.trtc-pair-button { margin-top: 14px; }
.copy-row { display: flex; gap: 10px; align-items: center; }
.copy-row code { flex: 1; min-width: 0; padding: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 1px solid var(--line); border-radius: 13px; background: #090c12; color: #bdc7dc; }
.host-note { margin-top: 22px; padding: 17px 19px; border-radius: 16px; background: rgba(255,255,255,.035); }
.host-note p { margin: 7px 0 0; color: var(--muted); line-height: 1.65; }

@media (max-width: 560px) {
  .session-head { padding-inline: 10px; gap: 7px; }
  .session-head strong { max-width: 86px; font-size: 13px; }
  .session-head > div, .session-actions { gap: 6px; }
  .quality-mode { padding: 0 8px; font-size: 11px; }
  .input-mode, .disconnect { padding: 0 10px; font-size: 11px; }
  .host-body { padding: 0; display: block; }
  .host-window { min-height: 100dvh; border: 0; border-radius: 0; }
  .host-titlebar { grid-template-columns: auto 1fr; }
  .host-titlebar > strong { padding-left: 14px; }
  .host-status { display: none; }
  .host-content { padding: 26px 18px; }
  .permission-grid { grid-template-columns: 1fr; }
  .copy-row { align-items: stretch; flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

#remote-screen {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #020304;
}

#remote-screen video {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  background: #020304;
}

.quality-mode:disabled {
  opacity: 1;
  cursor: default;
}

@media (min-width: 761px) {
  .session-head strong {
    max-width: 320px;
  }
}

