:root {
  --bg: #0f1419;
  --fg: #e8eef4;
  --muted: #8b97a5;
  --accent: #2dd4a8;
  --accent-dim: rgba(45, 212, 168, 0.16);
  --warn: #f5a524;
  --danger: #f07178;
  --line: rgba(255, 255, 255, 0.08);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "PingFang SC", "Noto Sans SC", -apple-system, sans-serif;
  overflow: hidden;
  user-select: none;
}

.bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 480px at 50% -10%, rgba(45, 212, 168, 0.14), transparent 60%),
    repeating-linear-gradient(0deg, transparent, transparent 23px, rgba(255,255,255,0.02) 24px),
    repeating-linear-gradient(90deg, transparent, transparent 23px, rgba(255,255,255,0.02) 24px);
  pointer-events: none;
}

.view {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 20px 22px calc(20px + var(--safe-bottom));
}
.hidden { display: none !important; }

.top-right { display: flex; justify-content: flex-end; }
.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  text-align: center;
  gap: 12px;
}
.hero h1 {
  margin: 0 0 6px;
  font-size: 40px;
  letter-spacing: 0.08em;
}
.hero p { margin: 0; color: var(--muted); }

.code, .pwd, #signalUrl, #deviceName, #textInput {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--fg);
  border-radius: 12px;
  padding: 14px 12px;
  font-size: 16px;
  outline: none;
}
.code {
  text-align: center;
  font-size: 28px;
  letter-spacing: 0.35em;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  transition: transform 0.18s ease;
}
.code:focus { transform: scale(1.02); border-color: rgba(45,212,168,0.55); box-shadow: 0 0 0 3px var(--accent-dim); }

button {
  border: 0;
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--accent);
  color: #06241c;
  font-weight: 700;
  font-size: 16px;
}
button.ghost {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--line);
  font-weight: 500;
}
button.danger {
  background: rgba(240,113,120,0.16);
  color: #ffb4b8;
  border: 1px solid rgba(240,113,120,0.35);
  width: 100%;
}
.error { color: var(--warn); min-height: 1.2em; font-size: 13px; }
.recent { text-align: left; margin-top: 18px; }
.recent button {
  margin: 0 8px 8px 0;
  background: var(--accent-dim);
  color: var(--fg);
  font-weight: 500;
  font-family: ui-monospace, monospace;
}

#settingsView label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  margin: 12px 0;
}
.row { display: flex; gap: 10px; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.6; }

.remote { padding: 0; background: #000; }
.bar {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  background: rgba(15,20,25,0.92);
}
.bar .ghost { padding: 8px 12px; }
.peer { flex: 1; display: flex; align-items: center; gap: 8px; font-weight: 600; }
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-dim);
  animation: breath 1.6s ease-in-out 1;
}
@keyframes breath {
  40% { box-shadow: 0 0 0 8px rgba(45,212,168,0.22); }
}
.badge { color: var(--muted); font-family: ui-monospace, monospace; font-size: 12px; padding-right: 8px; }

.conn-status {
  padding: 6px 12px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(15, 20, 25, 0.92);
}

.stage { flex: 1; position: relative; background: #000; min-height: 0; }
#video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  pointer-events: none;
}
.touch {
  position: absolute;
  inset: 0;
  z-index: 5;
  touch-action: none;
  cursor: crosshair;
}

.tabs {
  display: flex;
  background: rgba(15,20,25,0.96);
  padding-bottom: var(--safe-bottom);
}
.tabs button {
  flex: 1;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  padding: 12px 4px;
}
.tabs button.on { color: var(--accent); font-weight: 700; }

.panel {
  position: absolute;
  left: 0; right: 0; bottom: calc(48px + var(--safe-bottom));
  background: rgba(15,20,25,0.96);
  padding: 12px 14px 16px;
  max-height: 42%;
  overflow: auto;
}
.keys { display: flex; flex-wrap: wrap; gap: 6px; }
.keys button, .file-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--fg);
  font-weight: 500;
  padding: 10px 12px;
  font-size: 13px;
}
.text-row { display: flex; gap: 8px; margin-top: 10px; }
.text-row button { padding: 12px 14px; }
.file-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
#fileList { list-style: none; margin: 0; padding: 0; color: var(--muted); font-size: 13px; }
#fileList li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.bar-track { height: 3px; margin-top: 6px; background: rgba(255,255,255,0.06); border-radius: 99px; overflow: hidden; }
.bar-track > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width 0.25s ease; }
