:root {
  color-scheme: dark;
  font: 15px/1.5 system-ui, "Microsoft YaHei UI", sans-serif;
  color: #e9eef6;
  background: #10141c;
  --paper: #171e29;
  --edge: #2b3545;
  --quiet: #a4b0c1;
  --accent: #83e4cb;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
h1, h2, h3, p, ul { margin: 0; }
h1 { font-size: 20px; letter-spacing: -.025em; }
h2 { font-size: 19px; }
h3 { font-size: 14px; }
.muted { color: var(--quiet); font-size: 13px; }
button, input, select, textarea { font: inherit; color: inherit; }
button, input:not([type=checkbox]), select {
  min-height: 43px; border-radius: 8px; border: 1px solid var(--edge); background: #202938;
}
button { cursor: pointer; padding: 6px 12px; white-space: nowrap; }
button:hover:not(:disabled), :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { cursor: default; opacity: .48; }
input:not([type=checkbox]), select { padding: 8px 10px; min-width: 0; width: 100%; font-size: 16px; }
input:not([type=checkbox]) { background: #111722; }
input[type=checkbox] { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }
.primary { background: var(--accent); color: #142821; border-color: transparent; font-weight: 720; }
.danger { color: #ffc1c4; background: #342028; border-color: #613640; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--edge); background: #151b25;
}
.brand, .peer, .remote-header-actions { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mark { width: 22px; height: 15px; border: 2px solid var(--accent); border-radius: 4px; position: relative; }
.mark::after { content: ""; position: absolute; left: 5px; right: 5px; height: 2px; bottom: -6px; background: var(--accent); }
.status { display: inline-flex; align-items: center; gap: 6px; color: var(--quiet); font-size: 12px; white-space: nowrap; }
.status i { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; background: #69788d; }
.status[data-level=up] i { background: #71e2b1; }
.status[data-level=wait] i { background: #efb66e; }
.status[data-level=down] i { background: #f09095; }
.device-content { max-width: 640px; margin: 0 auto; padding: 22px 16px 32px; }
.connect-card { padding: 18px; border-radius: 14px; border: 1px solid var(--edge); background: var(--paper); }
.connect-card > p { margin: 4px 0 17px; }
form, .drawer-body { display: grid; gap: 11px; }
label:not(.check) { display: grid; gap: 4px; color: #ccd6e4; font-size: 13px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.message { color: #f3be87; font-size: 13px; overflow-wrap: anywhere; }
.recent { margin-top: 25px; }
.recent h2 { margin-bottom: 8px; }
.recent ul { padding: 0; list-style: none; }
.recent li + li { margin-top: 6px; }
.recent button { display: flex; text-align: left; align-items: center; width: 100%; gap: 12px; background: var(--paper); }
.recent .recent-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.recent code { color: var(--quiet); }
.remote-page { position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100vh; height: 100dvh; overflow: hidden; background: #10141c; }
.peer { flex-wrap: wrap; gap: 2px 10px; }
.peer h1 { max-width: min(44vw, 460px); white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.surface { position: relative; touch-action: none; user-select: none; overscroll-behavior: contain; background: #07090d; overflow: hidden; }
.surface:focus-visible { outline-offset: -2px; }
.surface video { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.overlay { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 20px; text-align: center; background: #07090dcb; }
.stats {
  position: absolute; top: 8px; left: 8px; max-width: calc(100% - 16px); padding: 5px 8px;
  border-radius: 6px; background: #0b101ad9; color: #bce5dd; font: 12px/1.5 monospace; pointer-events: none;
}
.toolbar {
  display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 7px;
  padding: 7px max(12px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: #151b25; border-top: 1px solid var(--edge);
}
.mode-tag { color: #baded7; background: #203a37; border-radius: 6px; padding: 5px 8px; font-size: 12px; white-space: nowrap; }
.toolbar .mode-tag { margin-right: auto; }
.toolbar button:last-child { border-color: #4c756d; color: var(--accent); }
.tool-area { position: relative; }
.drawer {
  display: flex; flex-direction: column; position: absolute; z-index: 2; right: max(8px, env(safe-area-inset-right));
  bottom: calc(100% + 8px); width: min(360px, calc(100% - 16px));
  max-height: min(720px, 62vh); max-height: min(720px, 62dvh);
  background: #1a2230; border: 1px solid #3b495c; border-radius: 12px; box-shadow: 0 12px 35px #0008;
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--edge); }
.drawer-body { overflow: auto; overscroll-behavior: contain; padding: 12px; }
.shortcuts, .custom-quality { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.custom-quality > label { flex: 1 1 80px; }
.shortcuts button { font-size: 13px; padding: 5px 8px; }
.clip-update { display: flex; justify-content: flex-end; align-items: center; gap: 7px; padding: 2px 12px; background: #203a37; font-size: 13px; }
.clip-update button { min-height: 32px; }
#clip-panel textarea { resize: vertical; min-width: 0; width: 100%; border: 1px solid var(--edge); border-radius: 7px; background: #111722; padding: 7px; font-size: 16px; }
.file-panel { width: min(435px, calc(100% - 16px)); }
.file-entries, .file-transfers { display: grid; gap: 5px; list-style: none; padding: 0; }
.file-entries:not(:empty) { margin-bottom: 8px; }
.file-entries button { width: 100%; max-width: 100%; text-align: left; white-space: normal; overflow-wrap: anywhere; }
#file-crumbs button { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.file-transfers li { display: grid; gap: 4px; padding: 6px 0; overflow-wrap: anywhere; font-size: 13px; }
.file-transfers progress { width: 100%; accent-color: var(--accent); }
.file-transfers a { color: var(--accent); }
.keyboard-proxy { position: absolute; bottom: 2px; left: 10px; width: 2px; height: 2px; opacity: 0; padding: 0; font-size: 16px; pointer-events: none; }
.floating {
  position: absolute; display: flex; right: 12px; bottom: 12px; gap: 4px; padding: 4px;
  border-radius: 10px; background: #131b28e8; border: 1px solid #485468; touch-action: none;
}
.floating button { min-height: 40px; }
.floating button[data-pressed="true"] { background: #396b60; }
#float-handle { cursor: move; }
.immersive .top { display: none; }
@media (min-width: 760px) {
  .device-content { padding-top: 40px; }
  .connect-card { padding: 25px; }
  .device-page .top { padding-left: max(24px, calc((100vw - 900px) / 2)); padding-right: max(24px, calc((100vw - 900px) / 2)); }
}
