/* inbrowser — web UI. Dark browser chrome around the remote screen. */
:root {
  --bg: #0c0d11;
  --bar: #15161c;
  --tab: #1c1d24;
  --tab-hover: #23242c;
  --tab-active: #2b2c35;
  --surface: #1a1b22;
  --surface-2: #22232b;
  --line: #2d2f39;
  --line-strong: #3a3c48;
  --text: #e8e9ee;
  --muted: #9b9dab;
  --faint: #6c6e7c;
  --accent: #8b7cff;
  --accent-strong: #7564ff;
  --accent-soft: rgb(139 124 255 / 0.16);
  --tor: #b48cff;
  --ok: #3ccf8e;
  --warn: #f2b84b;
  --danger: #f2626a;
  --danger-soft: rgb(242 98 106 / 0.14);
  --ff: #ff7a3d;
  --radius: 10px;
  --bar-h: 44px;
  --shadow: 0 18px 50px rgb(0 0 0 / 0.5), 0 2px 8px rgb(0 0 0 / 0.35);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.spacer { flex: 1; }

.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------------ buttons & fields -- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--line-strong);
  font-weight: 550; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: #2a2b34; border-color: #4a4c5a; }
.btn:focus-visible, .icon-btn:focus-visible, .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.primary { background: var(--accent-strong); border-color: transparent; color: #fff; }
.btn.primary:hover { background: #8576ff; }
.btn.danger { color: #ffb3b7; border-color: rgb(242 98 106 / .4); background: var(--danger-soft); }
.btn.danger:hover { background: rgb(242 98 106 / .24); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.wide { width: 100%; height: 42px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn .ico { width: 16px; height: 16px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border-radius: 8px; background: transparent; border: 0; color: var(--muted);
  transition: background .12s, color .12s;
}
.icon-btn:hover, .icon-btn[aria-expanded="true"] { background: var(--tab-hover); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; background: transparent; }
.link-btn { background: none; border: 0; padding: 2px; color: var(--muted); display: inline-grid; place-items: center; border-radius: 6px; }
.link-btn:hover { color: var(--text); background: var(--surface-2); }
.link-btn .ico { width: 15px; height: 15px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 12.5px; color: var(--muted); }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%; min-width: 0; height: 38px; padding: 0 11px;
  background: #101116; border: 1px solid var(--line-strong); border-radius: 8px;
  outline: none; transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; padding: 9px 11px; resize: vertical; font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 16px, calc(100% - 11px) 16px; background-size: 5px 5px; background-repeat: no-repeat; }
.check { display: flex; align-items: center; gap: 9px; color: var(--muted); cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.form-error { color: var(--danger); min-height: 1.2em; margin: 4px 0 0; font-size: 13px; }
.form-msg { font-size: 13px; color: var(--muted); margin-right: auto; }
.form-msg.ok { color: var(--ok); }
.form-msg.err { color: var(--danger); }
.row-btns { display: flex; align-items: center; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 12px; }
.row-btns.left { justify-content: flex-start; }

/* --------------------------------------------------------------------------- sign in -- */
.login {
  height: 100%; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 50% -10%, rgb(139 124 255 / .14), transparent 60%), var(--bg);
}
.login-card {
  width: min(380px, 100%); padding: 32px 28px 22px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}
.login-card h1 { margin: 4px 0 0; font-size: 22px; letter-spacing: -.01em; }
.login-card p.muted { margin: -6px 0 6px; font-size: 13.5px; }
.login-card input { height: 44px; font-size: 16px; text-align: center; letter-spacing: .08em; }
.login-card .check { justify-content: center; font-size: 13px; }
.login-mark { width: 52px; height: 52px; margin: 0 auto; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.login-mark .ico { width: 28px; height: 28px; }
.login-card.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* ------------------------------------------------------------------------- app frame -- */
.app { height: 100%; display: flex; flex-direction: column; }
.bar {
  height: var(--bar-h); flex: none; display: flex; align-items: center; gap: 4px;
  padding: 0 6px 0 8px; padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(6px, env(safe-area-inset-right));
  background: var(--bar); border-bottom: 1px solid var(--line); position: relative; z-index: 5;
}
.brand { width: 30px; height: 30px; display: grid; place-items: center; color: var(--accent); flex: none; margin-right: 2px; }
.brand .ico { width: 20px; height: 20px; }
.tools { display: flex; align-items: center; gap: 2px; }
.tools-more { display: none; }
.touch-only { display: none; }
@media (pointer: coarse) { .touch-only { display: inline-grid; } }

/* tabs */
.tabs { display: flex; align-items: center; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; height: 100%; padding: 0 2px; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 6px 0 10px;
  width: 210px; min-width: 120px; flex: 0 1 210px;
  background: var(--tab); border: 1px solid transparent; border-radius: 8px; color: var(--muted);
  text-align: left; position: relative; transition: background .12s, color .12s;
}
.tab:hover { background: var(--tab-hover); color: var(--text); }
.tab[aria-selected="true"] { background: var(--tab-active); color: var(--text); border-color: var(--line-strong); }
.tab .t-title { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; }
.tab .t-net { display: grid; place-items: center; color: var(--tor); }
.tab .t-net .ico { width: 14px; height: 14px; }
.tab .t-net.proxy { color: var(--warn); }
.tab .t-close { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; color: var(--faint); background: transparent; border: 0; padding: 0; flex: none; }
.tab .t-close:hover { background: rgb(255 255 255 / .08); color: var(--text); }
.tab .t-close .ico { width: 14px; height: 14px; }
.tab.ended { opacity: .55; }
.new-tab { flex: none; }

/* browser marks: small abstract glyphs (not the vendors' logos) */
.bmark { display: inline-block; width: 16px; height: 16px; border-radius: 50%; flex: none; position: relative; }
.tab .t-mark { display: grid; place-items: center; width: 16px; height: 16px; flex: none; }
.bmark.firefox { background: radial-gradient(circle at 35% 30%, #ffd567 0 18%, #ff7a3d 45%, #c9378a 80%, #6b2fc4); }
.bmark.chromium { background: conic-gradient(from -30deg, #e5534b 0 120deg, #f2b84b 0 240deg, #3fb468 0); }
.bmark.chromium::after { content: ""; position: absolute; inset: 4.5px; border-radius: 50%; background: #5b8def; box-shadow: 0 0 0 1.5px #fff; }
.bmark.lg { width: 34px; height: 34px; }
.bmark.lg.chromium::after { inset: 10px; box-shadow: 0 0 0 3px #fff; }
.spin-sm { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }

/* ------------------------------------------------------------------------ the stage -- */
.stage { flex: 1; position: relative; min-height: 0; background: var(--bg); }
.screen { position: absolute; inset: 0; overflow: hidden; }
.screen > div { background: var(--bg) !important; }
.screen canvas { outline: none; }

.overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; background: rgb(12 13 17 / .72); backdrop-filter: blur(2px); z-index: 2; }
.overlay-card { max-width: 420px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ov-title { margin: 10px 0 0; font-size: 16px; font-weight: 600; }
.overlay-card p.muted { margin: 0; font-size: 13.5px; max-width: 360px; word-break: break-word; }
.ov-icon { width: 34px; height: 34px; color: var(--warn); }
.ov-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; justify-content: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line-strong); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* empty state */
.empty { position: absolute; inset: 0; overflow: auto; display: grid; place-items: center; padding: 24px 16px; }
.empty-card { width: min(560px, 100%); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.empty-card h2 { margin: 0; font-size: 24px; letter-spacing: -.015em; }
.empty-card > p { margin: -4px 0 4px; max-width: 460px; }
.empty-mark { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.empty-mark .ico { width: 30px; height: 30px; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.quick button {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; transition: border-color .12s, background .12s, transform .12s;
}
.quick button:hover { border-color: var(--accent); background: var(--surface-2); }
.quick button:active { transform: scale(.985); }
.quick b { display: block; font-size: 15px; }
.quick small { color: var(--muted); font-size: 12.5px; }

.seg { display: inline-flex; padding: 3px; gap: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.seg button { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 14px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-weight: 550; }
.seg button .ico { width: 16px; height: 16px; }
.seg button[aria-checked="true"] { background: var(--tab-active); color: var(--text); box-shadow: 0 1px 0 rgb(255 255 255 / .04) inset; }
.seg button[data-net="tor"][aria-checked="true"] { color: var(--tor); }

/* --------------------------------------------------------------------------- popovers -- */
.pop {
  position: fixed; z-index: 20; width: 280px; max-width: calc(100vw - 16px); max-height: calc(100vh - var(--bar-h) - 16px); overflow: auto;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow); padding: 8px;
}
.pop.wide { width: 360px; }
.pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 4px; font-size: 12px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); }
.pop-note { margin: 2px 8px 10px; font-size: 12.5px; color: var(--muted); }
.pop textarea { margin: 0 0 2px; }
.pop .row-btns { margin-top: 8px; }
.pop .row-btns .btn { flex: 1; }
.menu { display: flex; flex-direction: column; gap: 1px; }
.sound-row { display: flex; align-items: center; gap: 8px; padding: 2px 8px 4px 4px; }
.sound-row input[type=range] { flex: 1; height: 24px; padding: 0; border: 0; background: none; box-shadow: none; accent-color: var(--accent); }
.sound-pct { width: 3em; text-align: right; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
#btn-sound.live { color: var(--accent); }
#btn-sound.off { color: var(--faint); }
#btn-sound.attn { position: relative; }
#btn-sound.attn::after { content: ""; position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
  background: transparent; text-align: left; color: var(--text);
}
.menu button:hover { background: var(--surface-2); }
.menu button .ico { color: var(--muted); }
.menu kbd { margin-left: auto; font: 11.5px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); background: #111217; border: 1px solid var(--line); border-bottom-width: 2px; padding: 1px 6px; border-radius: 5px; white-space: nowrap; }
.menu.radio button { flex-direction: column; align-items: flex-start; gap: 0; padding: 8px 10px 8px 32px; position: relative; }
.menu.radio button::before { content: ""; position: absolute; left: 10px; top: 12px; width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--line-strong); }
.menu.radio button[aria-checked="true"]::before { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 0 3px, transparent 3.5px); }
.menu.radio span { font-size: 12.5px; color: var(--muted); }
.menu .sep { height: 1px; background: var(--line); margin: 4px 6px; }

.files { list-style: none; margin: 0 0 8px; padding: 0; max-height: 260px; overflow: auto; }
.files li { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px; }
.files li:hover { background: var(--surface-2); }
.files .f-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files .f-meta { font-size: 12px; color: var(--faint); white-space: nowrap; }
.files a.f-dl { color: var(--accent); display: grid; place-items: center; }
.files .empty-row { color: var(--faint); justify-content: center; font-size: 13px; padding: 14px; }
.files .empty-row:hover { background: none; }
.upload { width: 100%; }

/* ---------------------------------------------------------------------------- dialogs -- */
.dlg {
  width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 32px); padding: 0; color: var(--text);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: var(--shadow);
}
.dlg::backdrop { background: rgb(5 5 8 / .62); backdrop-filter: blur(3px); }
.dlg form { display: flex; flex-direction: column; max-height: calc(100vh - 34px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px 22px; }
.dlg-head h2 { margin: 0; font-size: 18px; }
.dlg-body { padding: 4px 22px 12px; overflow: auto; }
.dlg-body h3 { margin: 18px 0 10px; font-size: 12px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); }
.dlg-body h3:first-child { margin-top: 6px; }
.dlg-foot { display: flex; align-items: center; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); flex-wrap: wrap; }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cards.three { grid-template-columns: repeat(3, 1fr); }
.card {
  position: relative; display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center;
  padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: #15161c; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.card:hover { border-color: #4b4d5c; }
.card input { position: absolute; opacity: 0; pointer-events: none; }
.card > .ico, .card > .bmark { grid-row: span 2; width: 22px; height: 22px; color: var(--muted); }
.card > .bmark { width: 24px; height: 24px; }
.card > .bmark.chromium::after { inset: 7px; box-shadow: 0 0 0 2px #fff; }
.card b { font-size: 14px; }
.card span { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.card:has(input:checked) > .ico { color: var(--accent); }
.card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.card.disabled { opacity: .45; cursor: not-allowed; }

.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.toggle { display: flex; align-items: center; gap: 11px; padding: 7px 4px; cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .sw { width: 34px; height: 20px; flex: none; border-radius: 99px; background: #3a3c48; position: relative; transition: background .15s; }
.toggle .sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle input:checked + .sw { background: var(--accent-strong); }
.toggle input:checked + .sw::after { transform: translateX(14px); }
.toggle input:focus-visible + .sw { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle b { display: block; font-weight: 550; font-size: 13.5px; }
.toggle small { display: block; color: var(--muted); font-size: 12px; }
.toggle.disabled { opacity: .4; cursor: not-allowed; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-items: end; }
.span2 { grid-column: span 2; }

.sect { padding: 4px 0 16px; border-bottom: 1px solid var(--line); }
.sect:last-of-type { border-bottom: 0; }
.sect h3 { margin-bottom: 6px; }
.sect > p.muted { margin: 0 0 10px; }
.sect.danger { border-bottom: 0; }
.tor-line { display: flex; align-items: center; gap: 9px; margin: 4px 0 10px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgb(60 207 142 / .18); }
.dot.wait { background: var(--warn); }
.dot.err { background: var(--danger); }
.about { margin: 8px 0 4px; }

/* ----------------------------------------------------------------------------- toasts -- */
.toasts { position: fixed; right: 14px; bottom: 14px; z-index: 50; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast { max-width: min(380px, calc(100vw - 28px)); padding: 10px 14px; border-radius: 10px; background: #262731; border: 1px solid var(--line-strong); box-shadow: var(--shadow); font-size: 13.5px; pointer-events: auto; animation: toast-in .18s ease-out; }
.toast.err { border-color: rgb(242 98 106 / .5); }
.toast.ok { border-color: rgb(60 207 142 / .45); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

.kbd-proxy { position: fixed; left: -100px; top: 50%; width: 10px; height: 10px; opacity: 0; border: 0; padding: 0; resize: none; }

/* ----------------------------------------------------------------------------- narrow -- */
@media (max-width: 760px) {
  .tools { display: none; }
  .tools-more { display: inline-grid; }
  .tab { width: 150px; flex-basis: 150px; min-width: 96px; }
}
@media (max-width: 600px) {
  .quick, .cards, .cards.three, .toggles, .grid2, .grid3 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .dlg-body { padding: 4px 16px 12px; }
  .dlg-head { padding-left: 16px; }
  .dlg-foot { padding: 12px 16px; }
  .dlg-foot .check { width: 100%; }
  .tab { width: 128px; flex-basis: 128px; }
  .empty-card h2 { font-size: 21px; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition: none !important; } }
