:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #182235;
  background: #f6f8fb;
  font-size: 16px;
  --blue: #1687ff;
  --blue-dark: #0875e4;
  --ink: #182235;
  --muted: #69758a;
  --line: #dfe5ee;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input { font: inherit; }
button, .button { cursor: pointer; }
[hidden] { display: none !important; }

#shell { min-height: 100vh; }
.wordmark { color: #eef5ff; font-size: 27px; font-weight: 760; letter-spacing: -.045em; }
.wordmark span { color: var(--blue); }

.login {
  width: min(460px, calc(100% - 40px));
  margin: 0 auto;
  padding-top: 10vh;
}
.login .wordmark, .workspace .wordmark { color: var(--ink); }
.eyebrow { margin: 60px 0 12px; color: var(--blue-dark); font-size: 11px; font-weight: 760; letter-spacing: .16em; }
.login h1 { margin: 0; font-size: clamp(42px, 7vw, 62px); line-height: .98; letter-spacing: -.055em; }
.lede { max-width: 390px; color: var(--muted); line-height: 1.6; }
form { display: grid; gap: 17px; margin-top: 34px; }
label { display: grid; gap: 8px; color: #38445a; font-size: 13px; font-weight: 650; }
input {
  width: 100%;
  padding: 14px 15px;
  color: var(--ink);
  border: 1px solid #cdd5e1;
  border-radius: 9px;
  background: #fff;
}
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 11px 17px;
  color: #273349;
  border: 1px solid #cfd7e3;
  border-radius: 8px;
  background: #fff;
  text-decoration: none;
  font-weight: 650;
}
button:hover, .button:hover { filter: brightness(.96); }
button:disabled { cursor: wait; opacity: .55; }
button:focus-visible, .button:focus-visible, input:focus-visible { outline: 3px solid #6ab5ff; outline-offset: 3px; }
.primary { color: #fff; border-color: var(--blue); background: var(--blue); }
.quiet { color: var(--muted); background: transparent; }

.workspace { width: min(1040px, calc(100% - 48px)); margin: 0 auto; padding: 42px 0; }
.workspace-header { display: flex; align-items: flex-start; justify-content: space-between; padding-bottom: 30px; border-bottom: 1px solid var(--line); }
.workspace-header p { margin: 8px 0 0; color: var(--muted); }
.devices { display: grid; gap: 12px; margin: 28px 0; }
.device {
  display: grid;
  grid-template-columns: 50px 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.device > img { width: 28px; height: 28px; opacity: .72; }
.device h2 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.device p { display: flex; align-items: center; gap: 7px; margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.device p i, .device-switcher small i { width: 8px; height: 8px; border-radius: 50%; background: #2bd47d; }
.device-controls { display: flex; gap: 8px; }
.remove { color: #7e899b; border-color: transparent; }
.add-phone, .empty {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 0;
  border-top: 1px solid var(--line);
}
.add-phone > div { display: grid; flex: 1; gap: 5px; }
.add-phone span, .empty span { color: var(--muted); font-size: 13px; }
.empty { display: grid; min-height: 130px; place-content: center; text-align: center; }

.controller {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 360px;
  grid-template-rows: auto minmax(0, 1fr);
  color: #f6f8fc;
  background: #090d13;
  z-index: 10;
}
.topbar {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid #26303d;
  background: #141b25;
  z-index: 3;
}
.topbar .wordmark { padding: 0 8px; font-size: 20px; }
.topbar-group { display: flex; gap: 4px; align-items: center; padding: 0 8px; border-left: 1px solid #2b3543; }
.topbar-spacer { flex: 1; }
.topbar .device-switcher { width: auto; min-width: 150px; max-width: 240px; margin-top: 0; padding: 6px 10px; }
.topbar .control { width: auto; min-height: 0; gap: 7px; padding: 7px 10px; font-size: 12px; }
.topbar .control img, .topbar .disconnect img, .topbar .input-modes img { width: 16px; height: 16px; }
.topbar .input-modes { display: flex; gap: 4px; padding: 0 8px; border-top: 0; border-left: 1px solid #2b3543; }
.topbar .input-modes button { display: flex; gap: 6px; align-items: center; padding: 7px 10px; font-size: 12px; }
.topbar .disconnect { margin-top: 0; gap: 7px; padding: 7px 10px; font-size: 12px; }
.device-switcher {
  width: 100%;
  justify-content: flex-start;
  gap: 12px;
  margin-top: 25px;
  padding: 11px 10px;
  color: #f6f8fc;
  border-color: #384353;
  background: #1a232f;
  text-align: left;
}
.device-switcher > img { width: 19px; filter: invert(1); }
.device-switcher > span { display: grid; gap: 4px; min-width: 0; }
.device-switcher strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.device-switcher small { display: flex; align-items: center; gap: 7px; color: #aeb8c8; font-size: 11px; font-weight: 500; }
.device-switcher small b { overflow: hidden; font: inherit; text-overflow: ellipsis; white-space: nowrap; }
.device-switcher small.connecting i { background: #f1b64c; }
.device-switcher small.unavailable { color: #ff8d8d; }
.device-switcher small.unavailable i { background: #ff6464; }
.control {
  justify-content: flex-start;
  gap: 15px;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  color: #e9eef7;
  border-color: transparent;
  background: transparent;
  font-size: 14px;
  font-weight: 520;
}
.control img, .disconnect img, .input-modes img { width: 21px; height: 21px; filter: invert(94%) sepia(6%) saturate(378%) hue-rotate(183deg) brightness(105%); }
.control:hover, .control.pressed { background: #202c3a; filter: none; }
.input-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding-top: 15px; border-top: 1px solid #2b3543; }
.input-modes button {
  display: grid;
  gap: 7px;
  justify-items: center;
  min-width: 0;
  padding: 10px 4px;
  color: #dce4ef;
  border-color: #394454;
  background: #1b2531;
  font-size: 11px;
}
.input-modes button.selected { color: #fff; border-color: var(--blue); background: #0f4f94; }
.disconnect {
  justify-content: flex-start;
  gap: 14px;
  margin-top: auto;
  color: #ff6868;
  border-color: transparent;
  background: transparent;
  font-size: 13px;
}
.disconnect img { filter: invert(51%) sepia(90%) saturate(1847%) hue-rotate(326deg) brightness(105%); }

.phone-stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #090d13; }
.control-warning {
  position: absolute;
  top: 18px;
  left: 50%;
  max-width: min(520px, calc(100% - 140px));
  padding: 11px 15px;
  color: #3b2b05;
  border: 1px solid #e7b840;
  border-radius: 9px;
  background: #fff2c9f2;
  box-shadow: 0 8px 28px #0007;
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  transform: translateX(-50%);
  z-index: 5;
}
.protected-notice {
  position: absolute;
  top: 12px;
  left: 50%;
  max-width: min(460px, calc(100% - 40px));
  font-size: 13px;
  line-height: 1.5;
  transform: translateX(-50%);
  z-index: 5;
  /* Let clicks through to the video: remote taps must still reach the phone
     even while its picture is black. */
  pointer-events: none;
}
.protected-card {
  padding: 12px 16px;
  color: #d7e2f2;
  border: 1px solid #384454;
  border-radius: 9px;
  background: #141b25f2;
  box-shadow: 0 8px 28px #0007;
  text-align: center;
  pointer-events: auto;
}
.protected-actions { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }
.protected-actions button { padding: 8px 14px; font-size: 13px; border-radius: 8px; }
.display, .display iframe { width: 100%; height: 100%; }
.display iframe { display: block; border: 0; background: #090d13; }
.fullscreen {
  position: absolute;
  top: 18px;
  right: 18px;
  gap: 8px;
  min-height: 38px;
  padding: 8px 11px;
  color: #e6edf7;
  border-color: #394452;
  background: #161e29e8;
  font-size: 12px;
}
.fullscreen img { width: 17px; filter: invert(1); }

.input-panel {
  position: fixed;
  left: 14px;
  top: 76px;
  width: 244px;
  min-width: 220px;
  min-height: 140px;
  max-width: 92vw;
  max-height: 86vh;
  padding: 15px;
  color: #f2f6fb;
  border: 1px solid #384454;
  border-radius: 11px;
  background: #18212c;
  box-shadow: 0 18px 60px #0009;
  z-index: 60;
  resize: both;
  overflow: auto;
}
.panel-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; font-size: 14px; cursor: move; touch-action: none; user-select: none; }
.close-panel { min-width: 32px; min-height: 32px; padding: 0; color: #acb6c5; border: 0; background: transparent; font-size: 22px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button {
  min-width: 0;
  min-height: 52px;
  padding: 0;
  color: #fff;
  border-color: #354150;
  background: #252f3d;
  font-size: 18px;
  font-weight: 550;
}
.keypad button img { width: 20px; filter: invert(1); }
.keypad button.pressed { color: #fff; border-color: var(--blue); background: #0f4f94; }
.keypad .enter { color: #fff; border-color: var(--blue); background: var(--blue); font-size: 12px; }
.gestures { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.gestures button {
  display: grid;
  gap: 6px;
  justify-items: center;
  min-width: 0;
  padding: 10px 4px;
  color: #dce4ef;
  border-color: #354150;
  background: #252f3d;
  font-size: 11px;
}
.gestures button img { width: 18px; height: 18px; filter: invert(1); }
.gestures button.pressed { color: #fff; border-color: var(--blue); background: #0f4f94; }
.gestures .rot-90 { transform: rotate(90deg); }
.gestures .rot-180 { transform: rotate(180deg); }
.gestures .rot-270 { transform: rotate(270deg); }
.perm-list { display: grid; gap: 8px; }
.perm-list button {
  display: grid;
  gap: 3px;
  justify-items: start;
  min-width: 0;
  padding: 10px 12px;
  color: #dce4ef;
  border-color: #354150;
  background: #252f3d;
  font-size: 12px;
  text-align: left;
  line-height: 1.35;
}
.perm-list button strong { color: #f2f6fb; font-size: 13px; }
.perm-list button.pressed { border-color: var(--blue); background: #0f4f94; }
.perm-on { color: #4ade80; }
.perm-off { color: #ff8d8d; }
.pattern-panel { width: 276px; }
.pattern-panel p { margin: -3px 0 13px; color: #aeb8c6; font-size: 12px; line-height: 1.45; }
.pattern-panel small { display: block; min-height: 32px; margin-top: 12px; color: #aeb8c6; font-size: 11px; line-height: 1.45; }
.pattern-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 30px;
  width: 240px;
  height: 240px;
  padding: 24px;
  touch-action: none;
  user-select: none;
}
.pattern-grid canvas { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.pattern-grid button {
  position: relative;
  min-width: 0;
  min-height: 0;
  width: 34px;
  height: 34px;
  padding: 0;
  place-self: center;
  border: 3px solid #8e9caf;
  border-radius: 50%;
  background: #202a37;
  z-index: 2;
}
.pattern-grid button::after {
  position: absolute;
  inset: 9px;
  content: "";
  border-radius: 50%;
  background: #8e9caf;
}
.pattern-grid button.selected { border-color: var(--blue); background: #15385f; filter: none; }
.pattern-grid button.selected::after { background: var(--blue); }

#message {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100% - 40px));
  margin: 0;
  padding: 13px 16px;
  color: #dff7ea;
  border: 1px solid #2d6b4c;
  border-radius: 9px;
  background: #133925;
  box-shadow: 0 10px 35px #0005;
  z-index: 30;
}
#message:empty { display: none; }
#message.error { color: #ffe4e4; border-color: #7d3a3a; background: #4b2020; }

@media (max-width: 760px) {
  .workspace { width: min(100% - 28px, 1040px); padding-top: 24px; }
  .device { grid-template-columns: 36px 1fr; }
  .device-controls { grid-column: 1 / -1; }
  .add-phone { align-items: stretch; flex-direction: column; }
  .topbar .wordmark { display: none; }
  .topbar .device-switcher { min-width: 0; }
  .fullscreen span { display: none; }
  .control-warning { max-width: calc(100% - 96px); }
}

#align-pattern { width: 100%; margin-bottom: 12px; }
#pattern-alignment { width: min(960px, 95vw); max-height: 95vh; padding: 18px; border: 1px solid #354150; border-radius: 12px; color: #edf3fa; background: #182330; }
#pattern-alignment::backdrop { background: #000b; }
#sensitive-view { width: min(720px, 95vw); max-height: 90vh; padding: 18px; border: 1px solid #354150; border-radius: 12px; color: #edf3fa; background: #182330; }
#sensitive-view::backdrop { background: #000b; }
#sensitive-view > p { margin: -3px 0 13px; color: #aeb8c6; font-size: 12px; line-height: 1.45; }
#overlay-editor { width: min(1100px, 97vw); max-height: 94vh; padding: 18px; border: 1px solid #354150; border-radius: 12px; color: #edf3fa; background: #182330; }
#overlay-editor::backdrop { background: #000b; }
#overlay-editor > p { margin: -3px 0 10px; color: #aeb8c6; font-size: 12px; line-height: 1.45; }
.overlay-status { font-weight: 600; }
.overlay-grid { display: grid; grid-template-columns: 1fr 300px 190px; gap: 18px; align-items: start; }
.ov-side-label { margin: 0 0 6px; color: #9ec5ff; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
#ov-live { width: 190px; border: 1px solid #354150; border-radius: 12px; background: #0a0a0a; }
.ov-live-note { color: #aeb8c6; font-size: 11px; line-height: 1.45; }
.overlay-form label { display: block; margin-bottom: 10px; color: #aeb8c6; font-size: 12px; }
.overlay-form input[type="text"], .overlay-form input[type="number"], .overlay-form textarea, .overlay-form select { box-sizing: border-box; width: 100%; margin-top: 4px; padding: 8px; color: #edf3fa; font: inherit; background: #101820; border: 1px solid #354150; border-radius: 8px; }
.ov-check { display: flex; align-items: center; gap: 8px; }
#ov-logo-preview { display: block; width: 48px; height: 48px; object-fit: contain; margin-bottom: 10px; }
.overlay-actions { display: flex; gap: 8px; margin-top: 6px; }
#ov-preview { width: 300px; height: 62vh; border: 1px solid #354150; border-radius: 12px; background: #0a0a0a; }
.ov-results { margin-top: 14px; padding: 10px; color: #aeb8c6; font-size: 12px; line-height: 1.6; background: #101820; border: 1px solid #354150; border-radius: 8px; }
.ov-results b { color: #9ec5ff; }
@media (max-width: 760px) {
  .overlay-grid { grid-template-columns: 1fr; }
  #ov-preview { width: 100%; }
  #ov-live { width: 100%; max-width: 260px; }
}
#sensitive-body { max-height: 65vh; overflow: auto; color: #aeb8c6; font-size: 13px; }
#sensitive-body table { width: 100%; border-collapse: collapse; font-size: 12px; }
#sensitive-body th { padding: 6px 10px 6px 0; color: #9ec5ff; font-size: 11px; font-weight: 600; text-align: left; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid #354150; }
#sensitive-body td { padding: 7px 10px 7px 0; color: #edf3fa; line-height: 1.45; vertical-align: top; word-break: break-word; border-bottom: 1px solid #232f3d; }
#sensitive-body td:first-child, #sensitive-body td:last-child { white-space: nowrap; }
#sensitive-body tr:last-child td { border-bottom: 0; }
#pattern-alignment small { display: block; margin: 12px 0; }
.alignment-image { position: relative; width: fit-content; margin: auto; }
#alignment-screen { display: block; max-width: 100%; max-height: 65vh; cursor: crosshair; }
#alignment-first { position: absolute; width: 14px; height: 14px; border: 2px solid #1687ff; border-radius: 50%; transform: translate(-50%, -50%); pointer-events: none; }

.device p[data-health="ready"] { color: #15803d; }
.device p[data-health="warning"] { color: #b45309; }
.keylog-panel { width: 276px; max-height: 70vh; overflow: auto; }
.keylog-panel p { margin: -3px 0 13px; color: #aeb8c6; font-size: 12px; line-height: 1.45; }
.keylog-count { margin-bottom: 8px; color: #aeb8c6; font-size: 12px; }
.keylog-filter { margin-left: 10px; cursor: pointer; user-select: none; }
.keylog-filter input { margin: 0 4px 0 0; vertical-align: -1px; }
.keylog-scroll {
  max-height: 46vh;
  overflow: auto;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid #384454;
  border-radius: 7px;
  padding: 10px;
  background: #101820;
}
.keylog-scroll pre { margin: 0; }
.keylog-panel small { display: block; min-height: 32px; margin-top: 12px; color: #aeb8c6; font-size: 11px; line-height: 1.45; }
#capture-pattern { margin-top: 10px; width: 100%; }
#pattern-capture-status { margin-top: 8px; color: #aeb8c6; font-size: 11px; line-height: 1.5; min-height: 32px; }

/* Side column: Camera | SMS | Keylog */
.side-panel { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid #1c2733; background: #0c1219; }
.side-tabs { display: flex; gap: 4px; padding: 10px 10px 0; }
.side-tab { flex: 1; padding: 8px 4px; color: #aeb8c6; font-size: 13px; background: transparent; border: 1px solid #232f3d; border-radius: 8px 8px 0 0; }
.side-tab.active { color: #edf3fa; background: #182330; border-bottom-color: #182330; }
.side-content { display: flex; flex: 1; flex-direction: column; min-height: 0; padding: 12px; overflow: hidden; }
.side-status { margin: 8px 0; color: #aeb8c6; font-size: 12px; }
.camera-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; color: #aeb8c6; font-size: 13px; }
.camera-controls label { display: flex; gap: 4px; align-items: center; }
.camera-view { flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; border-radius: 10px; background: #101820; }
.camera-view img { max-width: 100%; max-height: 100%; object-fit: contain; }
.sms-controls { display: flex; flex-wrap: wrap; gap: 6px; }
.sms-controls button { padding: 6px 10px; font-size: 12px; }
.sms-filter.active { color: #fff; background: #2563eb; border-color: #2563eb; }
.sms-list { flex: 1; min-height: 0; margin-top: 8px; overflow: auto; }
.sms-row { padding: 8px 0; border-bottom: 1px solid #1c2733; }
.sms-head { margin-bottom: 3px; color: #9ec5ff; font-size: 11px; }
.sms-body { color: #edf3fa; font-size: 13px; line-height: 1.45; word-break: break-word; }
.side-keylog { max-height: none; flex: 1; }

@media (max-width: 1280px) {
  .controller { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr) auto; }
  .side-panel { grid-column: 1; max-height: 44vh; border-top: 1px solid #1c2733; border-left: 0; }
}

.login-alert { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 6; max-width: min(460px, calc(100% - 40px)); padding: 10px 16px; color: #fde68a; border: 1px solid #a16207; border-radius: 9px; background: #3b2f10f2; box-shadow: 0 8px 28px #0007; font-size: 13px; line-height: 1.4; }
.screen-fields { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.screen-field { padding: 8px 10px; border: 1px solid #232f3d; border-radius: 8px; background: #101820; font-size: 13px; color: #edf3fa; }
.screen-field.focused { border-color: #2563eb; }
.role-tag { display: inline-block; margin-right: 8px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: uppercase; background: #263241; color: #9ec5ff; }
.role-tag.password, .role-tag.pin { background: #4c1d1d; color: #fca5a5; }
.role-tag.email, .role-tag.username { background: #3b2f10; color: #fde68a; }
.screen-field .field-text { color: #aeb8c6; }
.screen-map { position: relative; width: 100%; max-width: 210px; margin: 0 auto 10px; border: 1px solid #354150; border-radius: 12px; background: #0b1220; overflow: hidden; }
.screen-map-node { position: absolute; padding: 0; color: #d7e2f2; font-size: 12px; font-weight: 600; background: #2563eb22; border: 1px solid #2563eb88; border-radius: 8px; cursor: pointer; overflow: hidden; }
.screen-map-node:hover { background: #2563eb55; }
.screen-map-node.sent { background: #22c55e66; border-color: #22c55e; }
.screen-map-node.unlabeled { border-style: dashed; }
.screen-map-hint { color: #aeb8c6; font-size: 11px; margin: 0 0 8px; line-height: 1.4; }
.screen-texts { margin-bottom: 8px; color: #aeb8c6; font-size: 12px; line-height: 1.5; max-height: 120px; overflow: auto; }
.screen-typed { flex: 1; min-height: 60px; }
