:root {
  --bg:#111;
  --panel:#1f1f1f;
  --panel2:#262626;
  --line:#3b3b3b;
  --text:#eee;
  --muted:#aaa;
  --accent:#ffdd66;
  --blue:#5db6ff;
  --danger:#ffcc00;
}
* { box-sizing:border-box; }
html, body {
  margin:0;
  height:100%;
  background:var(--bg);
  color:var(--text);
  font-family:system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow:hidden;
}
button {
  cursor:pointer;
  border:1px solid rgba(255,255,255,.2);
  border-radius:4px;
  background:#2d2d2d;
  color:#fff;
  padding:7px 10px;
  font-weight:600;
}
button:hover { background:#383838; }
button:active { transform:translateY(1px); }
.muted { color:var(--muted); }
.danger { color:#111; background:var(--danger); border-color:var(--danger); }
.danger-soft { border-color:#555; color:#fff; }
.warn { color:#ffdd66; }
.small { font-size:12px; }

.topbar {
  position:fixed;
  left:0;
  right:0;
  top:0;
  z-index:20;
  min-height:36px;
  padding:8px 12px;
  background:rgba(0,0,0,.76);
  display:flex;
  gap:12px;
  align-items:center;
  font-size:14px;
  white-space:nowrap;
  box-shadow:0 1px 0 rgba(255,255,255,.08);
}
.status { font-weight:800; }
.meta { font-size:13px; }
.badge {
  padding:3px 7px;
  border-radius:4px;
  font-size:12px;
  font-weight:800;
  border:1px solid rgba(255,255,255,.18);
}
.badge.off { color:#bbb; background:#222; }
.badge.on { color:#111; background:var(--danger); }

#wrap {
  width:100%;
  height:100%;
  box-sizing:border-box;
  padding-top:36px;
  background:#111;
}
#wrap.fit { display:flex; align-items:center; justify-content:center; overflow:hidden; }
#wrap.actual { display:block; overflow:auto; }
canvas { background:#000; image-rendering:auto; display:block; }
#wrap.fit canvas { max-width:100%; max-height:100%; width:auto; height:auto; }
#wrap.actual canvas { max-width:none; max-height:none; }
canvas.control-on { cursor: crosshair; outline: 2px solid var(--danger); outline-offset:-2px; }

.side-tab {
  position:fixed;
  right:0;
  top:50%;
  transform:translateY(-50%);
  z-index:40;
  width:34px;
  height:58px;
  border-radius:9px 0 0 9px;
  border-right:none;
  font-size:34px;
  line-height:1;
  padding:0 0 3px 0;
  background:rgba(45,45,45,.92);
  box-shadow:0 4px 20px rgba(0,0,0,.35);
}
.side-panel {
  position:fixed;
  top:0;
  right:0;
  z-index:50;
  height:100vh;
  width:min(390px, calc(100vw - 28px));
  background:rgba(31,31,31,.98);
  color:#fff;
  border-left:1px solid rgba(255,255,255,.12);
  box-shadow:-10px 0 30px rgba(0,0,0,.45);
  transform:translateX(100%);
  transition:transform .18s ease;
  overflow-y:auto;
  overscroll-behavior:contain;
  padding-bottom:22px;
}
.side-panel.open { transform:translateX(0); }
.panel-head {
  position:sticky;
  top:0;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 16px 10px;
  background:rgba(31,31,31,.98);
  z-index:2;
}
.icon-btn {
  width:34px;
  height:34px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:0;
  font-size:22px;
  border:none;
  background:transparent;
}
#panelPin { font-size:13px; color:#ddd; }
.panel-actions {
  padding:0 16px 14px;
  display:grid;
  gap:12px;
  border-bottom:1px solid var(--line);
}
.panel-actions.two { grid-template-columns:1fr 1fr; }
.big-action {
  height:60px;
  border-radius:4px;
  font-size:16px;
}
.panel-section {
  border-bottom:1px solid var(--line);
}
.panel-section summary {
  list-style:none;
  cursor:pointer;
  padding:18px 18px 14px;
  font-weight:800;
  color:#fff;
  position:relative;
}
.panel-section summary::-webkit-details-marker { display:none; }
.panel-section summary::after {
  content:'›';
  position:absolute;
  right:18px;
  top:17px;
  font-size:26px;
  transform:rotate(0deg);
  transition:transform .15s;
}
.panel-section[open] summary::after { transform:rotate(90deg); }
.section-body {
  padding:0 20px 18px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.section-body.compact {
  display:grid;
  grid-template-columns:1fr;
  gap:7px;
  font-size:13px;
  color:#e6e6e6;
}
.hint {
  margin:0;
  color:#ddd;
  font-size:12px;
  line-height:1.35;
}

.mouse-debug-row {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  color:#d9ecff;
}
.mouse-debug-row.strong {
  color:#ffdd66;
  font-weight:800;
}
.mouse-debug-row span {
  display:inline-block;
  min-width:105px;
  text-align:right;
}

#toastBox {
  position:fixed;
  top:48px;
  right:14px;
  z-index:60;
  display:flex;
  flex-direction:column;
  gap:8px;
  pointer-events:none;
  max-width:360px;
}
.side-panel.open ~ #toastBox { right:405px; }
.toast {
  background:rgba(18,18,18,.9);
  border:1px solid rgba(255,255,255,.18);
  box-shadow:0 6px 24px rgba(0,0,0,.38);
  border-radius:9px;
  padding:9px 12px;
  min-width:230px;
  color:#fff;
  backdrop-filter: blur(4px);
}
.toast .t { font-weight:700; color:var(--accent); margin-bottom:3px; }
.toast .m { font-size:13px; color:#eee; word-break:break-all; }
.toast .bar { margin-top:7px; height:5px; background:#333; border-radius:99px; overflow:hidden; }
.toast .fill { height:100%; width:0%; background:var(--accent); }
#fileInput { display:none; }
#imeBox { position:fixed; left:-2000px; top:0; width:1px; height:1px; opacity:0.01; z-index:-1; resize:none; }

#clipPanel {
  position:fixed;
  right:14px;
  bottom:14px;
  z-index:61;
  width:min(520px, calc(100vw - 28px));
  background:rgba(18,18,18,.96);
  border:1px solid rgba(255,255,255,.22);
  border-radius:10px;
  box-shadow:0 8px 30px rgba(0,0,0,.45);
  padding:10px;
  display:none;
}
#clipPanel .head { display:flex; justify-content:space-between; align-items:center; margin-bottom:7px; font-weight:700; color:var(--accent); }
#clipPanel textarea { width:100%; height:96px; box-sizing:border-box; background:#070707; color:#fff; border:1px solid #444; border-radius:6px; padding:8px; resize:vertical; }
#clipPanel .actions { display:flex; gap:8px; justify-content:flex-end; margin-top:8px; }

.modal {
  position:fixed;
  inset:0;
  z-index:80;
  background:rgba(0,0,0,.5);
  display:none;
  align-items:center;
  justify-content:center;
  padding:24px;
}
.modal.open { display:flex; }
.modal-card {
  width:min(640px, 96vw);
  max-height:86vh;
  overflow:auto;
  background:#1f1f1f;
  border:1px solid rgba(255,255,255,.2);
  box-shadow:0 14px 44px rgba(0,0,0,.55);
  border-radius:10px;
}
.modal-head {
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 16px;
  border-bottom:1px solid var(--line);
}
.modal-body { padding:16px; line-height:1.55; font-size:14px; }
.modal-body ul { margin-top:8px; padding-left:22px; }

body.panel-pinned #sidePanel { transform:translateX(0); }
body.panel-pinned #sideTab { display:none; }
body.panel-pinned #wrap { padding-right:min(390px, calc(100vw - 28px)); }

body.fullscreen-mode .topbar {
  min-height:30px;
  padding:5px 9px;
  opacity:.88;
  font-size:12px;
}
body.fullscreen-mode #wrap { padding-top:30px; }
body.fullscreen-mode .side-tab { opacity:.82; }

@media (max-width:720px) {
  .topbar { gap:7px; font-size:12px; }
  #netStats, #timeStats { display:none; }
  .side-panel { width:min(360px, calc(100vw - 22px)); }
}

/* Chrome Remote Desktop style viewer shell - UI only overlay patch */
body {
  background:#050505;
}

.topbar {
  display:none;
}

#wrap {
  padding-top:0;
  background:#050505;
}

#wrap.fit {
  width:100vw;
  height:100vh;
}

canvas.control-on {
  cursor: crosshair;
  outline: 2px solid var(--danger);
  outline-offset:-2px;
}

.top-hot-zone {
  position:fixed;
  top:0;
  left:50%;
  transform:translateX(-50%);
  width:min(460px, 56vw);
  height:46px;
  z-index:35;
  pointer-events:none;
}

.floating-header {
  position:fixed;
  top:10px;
  left:50%;
  transform:translate(-50%, -18px);
  z-index:45;
  min-width:min(440px, calc(100vw - 92px));
  max-width:calc(100vw - 92px);
  height:42px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:12px;
  padding:0 12px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.18);
  background:rgba(18,18,18,.88);
  box-shadow:0 8px 28px rgba(0,0,0,.42);
  backdrop-filter:blur(8px);
  opacity:0;
  pointer-events:none;
  transition:opacity .16s ease, transform .16s ease;
  white-space:nowrap;
}

body.top-ui-visible .floating-header,
.floating-header:hover,
.floating-header:focus-within {
  opacity:1;
  pointer-events:auto;
  transform:translate(-50%, 0);
}

.floating-x {
  width:30px;
  height:30px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:0;
  border-radius:50%;
  border:1px solid rgba(255,255,255,.25);
  background:#2b2b2b;
  font-size:21px;
  line-height:1;
  color:#fff;
}

.floating-status {
  font-weight:800;
  font-size:13px;
  overflow:hidden;
  text-overflow:ellipsis;
}

.floating-stats {
  font-size:12px;
  color:#cfcfcf;
}

.side-tab {
  right:0;
  width:32px;
  height:72px;
  border-radius:12px 0 0 12px;
  font-size:38px;
  background:rgba(32,32,32,.78);
  backdrop-filter:blur(6px);
  border-color:rgba(255,255,255,.22);
  transition:opacity .14s ease, transform .14s ease, background .14s ease;
}

.side-tab:hover {
  background:rgba(50,50,50,.95);
  transform:translateY(-50%) translateX(-2px);
}

body.panel-open #sideTab,
body.panel-pinned #sideTab {
  opacity:0;
  pointer-events:none;
}

.side-panel {
  width:min(410px, calc(100vw - 32px));
  background:rgba(29,29,29,.985);
  transition:transform .2s cubic-bezier(.2,.8,.2,1);
}

body.panel-open #sidePanel,
body.panel-pinned #sidePanel,
.side-panel.open {
  transform:translateX(0);
}

body.panel-pinned #wrap {
  padding-right:0;
}

body.panel-open #toastBox,
body.panel-pinned #toastBox,
.side-panel.open ~ #toastBox {
  right:min(424px, calc(100vw - 20px));
}

.panel-head::before {
  content:'원격 데스크톱';
  font-size:14px;
  font-weight:800;
  color:#f3f3f3;
  margin-right:auto;
}

.panel-head {
  gap:8px;
}

#panelBack {
  order:-1;
}

#panelPin {
  font-size:12px;
  min-width:40px;
}

#snapshotBtn[disabled],
button:disabled {
  opacity:.55;
  cursor:not-allowed;
}

body.fullscreen-mode .floating-header {
  top:8px;
}

body.fullscreen-mode #wrap {
  padding-top:0;
}

@media (max-width:720px) {
  .floating-header {
    min-width:min(360px, calc(100vw - 70px));
    gap:8px;
  }
  .floating-status { max-width:130px; }
  .floating-stats { max-width:150px; overflow:hidden; text-overflow:ellipsis; }
  body.panel-open #toastBox,
  body.panel-pinned #toastBox,
  .side-panel.open ~ #toastBox { right:14px; top:58px; }
}
