:root {
  --ink: #11141b;
  --muted: #687081;
  --line: #e2e6ed;
  --paper: #f5f6f9;
  --panel: #ffffff;
  --blue: #3155eb;
  --blue-dark: #2444c8;
  --green: #20a86b;
  --red: #d94b55;
  --stage: #0b0e14;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.01em;
}
.brand img { display: block; }
.brand b {
  margin-left: 3px;
  padding-left: 13px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.brand-light { color: #fff; }

.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(440px, 1.08fr) minmax(440px, .92fr);
}
.login-intro {
  position: relative;
  min-height: 100vh;
  padding: clamp(32px, 5vw, 72px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(circle at 78% 34%, rgba(86, 104, 255, .16), transparent 29%),
    linear-gradient(145deg, #111832 0%, #141b39 56%, #10162e 100%);
}
.login-intro::before {
  position: absolute;
  top: 12%;
  right: -14%;
  width: min(42vw, 660px);
  aspect-ratio: 1;
  border: 1px solid rgba(130, 148, 255, .12);
  border-radius: 50%;
  box-shadow:
    0 0 0 72px rgba(107, 124, 255, .035),
    0 0 0 144px rgba(107, 124, 255, .018);
  content: "";
}
.login-intro::after {
  position: absolute;
  inset: 0;
  opacity: .13;
  background-image: radial-gradient(rgba(177, 187, 255, .55) .7px, transparent .7px);
  background-size: 26px 26px;
  mask-image: linear-gradient(120deg, transparent 7%, #000 49%, transparent 88%);
  content: "";
}
.login-intro > * { position: relative; z-index: 1; }
.intro-copy { max-width: 760px; margin-block: 90px; }
.eyebrow, .panel-kicker, .section-label {
  margin: 0;
  color: #8198ff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.intro-copy h1 {
  margin: 22px 0 0;
  font-size: clamp(47px, 5.4vw, 78px);
  line-height: 1.12;
  letter-spacing: -.025em;
  font-weight: 700;
  text-shadow: 0 18px 44px rgba(0, 0, 0, .16);
}
.intro-copy > p:last-child {
  max-width: 600px;
  margin: 30px 0 0;
  color: #aeb9db;
  font-size: 17px;
  line-height: 1.78;
}
.intro-specs {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid rgba(255,255,255,.15);
}
.intro-specs div { padding: 24px 18px 0 0; }
.intro-specs dt { color: #7f89a9; font-size: 12px; }
.intro-specs dd { margin: 8px 0 0; font-size: 14px; font-weight: 500; }

.login-panel {
  position: relative;
  min-height: 100vh;
  padding: 56px clamp(36px, 6vw, 92px);
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 92% 8%, rgba(49, 85, 235, .08), transparent 27%),
    radial-gradient(circle at 8% 92%, rgba(105, 73, 255, .055), transparent 24%),
    #f8f9fc;
}
.login-panel::before,
.login-panel::after {
  position: absolute;
  border: 1px solid rgba(49, 85, 235, .08);
  border-radius: 50%;
  content: "";
}
.login-panel::before {
  top: -138px;
  right: -108px;
  width: 310px;
  height: 310px;
}
.login-panel::after {
  bottom: -92px;
  left: -66px;
  width: 210px;
  height: 210px;
}
.login-panel-inner {
  position: relative;
  z-index: 1;
  width: min(100%, 500px);
  padding: clamp(34px, 4vw, 50px);
  border: 1px solid rgba(218, 223, 234, .88);
  border-radius: 26px;
  background: rgba(255, 255, 255, .92);
  box-shadow:
    0 30px 80px rgba(29, 39, 78, .09),
    0 3px 10px rgba(29, 39, 78, .035);
  backdrop-filter: blur(16px);
}
.login-panel-inner::before {
  position: absolute;
  top: 0;
  left: 48px;
  width: 72px;
  height: 3px;
  border-radius: 0 0 4px 4px;
  background: linear-gradient(90deg, #3155eb, #7255f6);
  content: "";
}
.panel-kicker { color: var(--blue); }
.login-panel h2 { margin: 13px 0 36px; font-size: 36px; line-height: 1.25; letter-spacing: -.02em; }
.form-stack { display: grid; gap: 20px; }
.form-stack label { display: grid; gap: 9px; }
.form-stack label > span:first-child { color: #4e5667; font-size: 13px; font-weight: 500; }
input {
  width: 100%;
  height: 56px;
  padding: 0 17px;
  border: 1px solid #dfe3ea;
  border-radius: 13px;
  outline: none;
  color: var(--ink);
  background: #fff;
  transition: border-color .18s ease, box-shadow .18s ease;
}
input::placeholder { color: #a2a8b4; }
input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(49,85,235,.1); }
input:disabled { color: #8c93a1; background: #f2f4f7; }
.code-field { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.button {
  min-height: 44px;
  padding: 0 17px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background .18s ease, color .18s ease, transform .18s ease, opacity .18s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .5; }
.button-primary { color: #fff; background: var(--blue); box-shadow: 0 12px 24px rgba(49,85,235,.2); }
.button-primary:hover:not(:disabled) { background: var(--blue-dark); }
.button-secondary { color: var(--blue); background: #eef1ff; white-space: nowrap; }
.button-quiet { color: #4f5766; background: #eef0f4; }
.button-danger { color: #b52f3a; background: #ffebed; }
.button-block { width: 100%; min-height: 56px; }
.message { margin-bottom: 20px; padding: 12px 14px; border-radius: 9px; font-size: 13px; line-height: 1.65; }
.message-error { color: #a32c35; background: #fff0f1; border: 1px solid #ffd9dd; }
.workspace {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: var(--paper);
}
.workspace-header {
  height: 70px;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.96);
}
.workspace-header > .brand { justify-self: start; }
.header-status { display: flex; align-items: center; gap: 9px; color: #596171; font-size: 13px; }
.header-status i { width: 8px; height: 8px; border-radius: 50%; background: #e0a82f; box-shadow: 0 0 0 5px rgba(224,168,47,.12); }
.header-status i[data-kind="ready"] { background: #738096; box-shadow: 0 0 0 5px rgba(115,128,150,.12); }
.header-status i[data-kind="connected"] { background: var(--green); box-shadow: 0 0 0 5px rgba(32,168,107,.12); }
.header-status i[data-kind="error"] { background: var(--red); box-shadow: 0 0 0 5px rgba(217,75,85,.12); }
.header-actions { justify-self: end; display: flex; align-items: center; gap: 9px; }
.workspace-grid {
  height: calc(100vh - 70px);
  height: calc(100dvh - 70px);
  min-height: 0;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  overflow: hidden;
}
.control-sidebar {
  min-height: 0;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  border-right: 1px solid var(--line);
  background: #fff;
  overflow-y: auto;
}
.connect-section h1 { margin: 9px 0 23px; font-size: 25px; letter-spacing: -.015em; }
.section-label { color: var(--blue); }
.connection-form { gap: 16px; }
.pending-connection-actions {
  display: grid;
  grid-template-columns: .82fr 1.18fr;
  gap: 9px;
}
.pending-connection-actions .button { min-height: 48px; padding-inline: 12px; }
.pending-cancel-button {
  color: #6b4650;
  border: 1px solid #f0dadd;
  background: #fff5f6;
}
.pending-cancel-button:hover:not(:disabled) { color: #ae303b; border-color: #edc4c8; background: #ffedef; }
.pending-password-button { color: #fff; background: var(--blue); box-shadow: 0 10px 20px rgba(49,85,235,.17); }
.pending-password-button:hover:not(:disabled) { background: var(--blue-dark); }
.connection-status {
  margin-top: 14px;
  padding-left: 12px;
  border-left: 2px solid #d4a43d;
  color: #676f7e;
  font-size: 12px;
  line-height: 1.65;
}
.connection-status[data-kind="connected"] { border-color: var(--green); color: #257550; }
.connection-status[data-kind="error"] { border-color: var(--red); color: #a63740; }
.connection-status[data-kind="ready"] { border-color: #8a95a7; }
.recent-connections { padding-top: 22px; border-top: 1px solid var(--line); }
.recent-clear { padding: 0; border: 0; color: #9299a6; background: transparent; cursor: pointer; font-size: 11px; }
.recent-clear:hover { color: var(--blue); }
.recent-device-list { margin-top: 10px; display: grid; gap: 7px; }
.recent-device {
  width: 100%;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid #e4e7ed;
  border-radius: 9px;
  color: #343b48;
  background: #fafbfc;
  cursor: pointer;
  text-align: left;
}
.recent-device:hover { border-color: #cbd3f6; background: #f5f7ff; }
.recent-device strong { overflow: hidden; font-size: 12px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.recent-device span { color: #858d9b; font: 11px ui-monospace, SFMono-Regular, Consolas, monospace; }
.session-section { padding-top: 25px; border-top: 1px solid var(--line); }
.section-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.session-section h2 { margin: 14px 0 0; font-size: 19px; letter-spacing: 0; }
.remote-code { margin: 5px 0 20px; color: #858d9b; font: 12px ui-monospace, SFMono-Regular, Consolas, monospace; word-break: break-all; }
.input-badge { padding: 5px 8px; border-radius: 6px; color: #757d8d; background: #eef0f4; font-size: 11px; font-weight: 500; }
.input-badge[data-enabled="true"] { color: #1f7e52; background: #e4f7ed; }
.lan-notice { margin-top: auto; padding: 18px; border: 1px solid #dce2fb; border-radius: 12px; background: #f3f5ff; }
.lan-notice strong { color: #273d9e; font-size: 14px; }
.lan-notice p { margin: 8px 0 12px; color: #64709a; font-size: 12px; line-height: 1.72; }
.lan-notice a { color: var(--blue); font-size: 12px; font-weight: 500; }

.viewer-shell {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 24px;
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr);
  background: #e9ecf2;
}
.viewer-toolbar { padding: 0 4px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.viewer-title, .viewer-toolbar-actions { display: flex; align-items: center; gap: 10px; }
.viewer-toolbar strong { font-size: 14px; }
.viewer-toolbar p { margin: 1px 0 0; color: #7a8290; font-size: 12px; }
.viewer-fps {
  min-width: 57px;
  color: #667083;
  font: 11px ui-monospace, SFMono-Regular, Consolas, monospace;
  text-align: right;
}
.shortcut-menu { position: relative; }
.shortcut-menu summary {
  padding: 5px 9px;
  border: 1px solid #d5dae3;
  border-radius: 7px;
  color: #535c6d;
  background: rgba(255,255,255,.72);
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  list-style: none;
}
.shortcut-menu summary::-webkit-details-marker { display: none; }
.shortcut-menu[open] summary { border-color: #bfc9f6; color: var(--blue); background: #fff; }
.shortcut-popover {
  position: absolute;
  z-index: 8;
  top: calc(100% + 8px);
  right: 0;
  width: 176px;
  padding: 7px;
  display: grid;
  gap: 4px;
  border: 1px solid #dfe3ea;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 16px 36px rgba(26,34,51,.2);
}
.shortcut-popover button {
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  color: #3f4755;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  text-align: left;
}
.shortcut-popover button:hover:not(:disabled) { color: var(--blue); background: #f1f4ff; }
.shortcut-popover button:disabled { color: #afb5c0; cursor: not-allowed; }
.live-mark { padding: 4px 6px; border-radius: 5px; color: #fff; background: #8c95a5; font-size: 9px; font-weight: 700; letter-spacing: .1em; }
.session-connected .live-mark { background: var(--red); }
.canvas-stage {
  position: relative;
  min-height: 420px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 14px;
  background: var(--stage);
  box-shadow: 0 24px 55px rgba(20,27,44,.15);
}
#remoteCanvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  outline: none;
  cursor: default;
  touch-action: none;
}
.session-connected #remoteCanvas { cursor: default; }
.canvas-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  pointer-events: none;
  text-align: center;
}
.canvas-placeholder::before {
  position: absolute;
  width: min(480px, 55vw);
  height: min(480px, 55vw);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(78,92,255,.14) 0, rgba(63,76,190,.05) 34%, transparent 68%);
  content: "";
}
.placeholder-visual {
  position: relative;
  width: 112px;
  height: 112px;
  display: grid;
  place-items: center;
}
.placeholder-ring {
  position: absolute;
  border: 1px solid rgba(142,153,180,.18);
  border-radius: 50%;
}
.placeholder-ring-outer {
  inset: 0;
  border-color: rgba(93,108,255,.2);
  animation: placeholderPulse 3s ease-in-out infinite;
}
.placeholder-ring-inner {
  inset: 16px;
  border-color: rgba(151,161,190,.2);
  animation: placeholderPulse 3s .45s ease-in-out infinite;
}
.placeholder-mark {
  position: relative;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
}
.placeholder-mark img {
  width: 38px;
  height: 38px;
  opacity: .94;
  filter: drop-shadow(0 8px 20px rgba(69,82,241,.2));
}
.canvas-placeholder strong { position: relative; margin-top: 20px; color: #e7eaf1; font-size: 17px; letter-spacing: .01em; }
.canvas-placeholder p { position: relative; margin: 9px 0 0; color: #737e92; font-size: 12px; letter-spacing: 0; }

.control-filing {
  margin-top: 6px;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #7a8499;
  font-size: 11px;
  line-height: 1.2;
  text-decoration: none;
  transition: color .2s ease;
  text-wrap: nowrap;
}
.control-filing img {
  width: 14px;
  height: 14px;
  display: block;
}
.control-filing:hover {
  color: #3e4658;
}

body.confirm-dialog-open { overflow: hidden; }
.confirm-dialog {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
}
.confirm-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 14, 24, .5);
  backdrop-filter: blur(7px);
  opacity: 0;
  transition: opacity .18s ease;
}
.confirm-dialog-panel {
  position: relative;
  width: min(100%, 430px);
  padding: 27px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 17px;
  border: 1px solid rgba(220, 224, 234, .95);
  border-radius: 20px;
  outline: none;
  background:
    radial-gradient(circle at 100% 0, rgba(217, 75, 85, .06), transparent 34%),
    #fff;
  box-shadow:
    0 28px 80px rgba(19, 25, 43, .26),
    0 4px 14px rgba(19, 25, 43, .08);
  opacity: 0;
  transform: translateY(10px) scale(.975);
  transition: opacity .18s ease, transform .18s ease;
}
.confirm-dialog.is-visible .confirm-dialog-backdrop { opacity: 1; }
.confirm-dialog.is-visible .confirm-dialog-panel { opacity: 1; transform: none; }
.confirm-dialog-symbol {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid #f4c9cd;
  border-radius: 13px;
  color: #bd3540;
  background: #fff0f1;
  box-shadow: 0 8px 20px rgba(217, 75, 85, .1);
  font-size: 20px;
  font-weight: 700;
}
.confirm-dialog-copy > p {
  margin: 1px 0 7px;
  color: #9b6770;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
}
.confirm-dialog-copy h2 {
  margin: 0;
  color: #202532;
  font-size: 22px;
  line-height: 1.35;
  letter-spacing: -.01em;
}
.confirm-dialog-copy > div {
  margin-top: 10px;
  color: #707887;
  font-size: 14px;
  line-height: 1.7;
}
.confirm-dialog-actions {
  grid-column: 1 / -1;
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.confirm-dialog-actions .button {
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: 12px;
}
.confirm-dialog-cancel {
  color: #505867;
  border-color: #e1e5ec !important;
  background: #f7f8fa;
}
.confirm-dialog-cancel:hover:not(:disabled) {
  color: #27303e;
  border-color: #cfd5df !important;
  background: #f1f3f6;
}
.confirm-dialog-confirm {
  color: #fff;
  border-color: #c73e48 !important;
  background: linear-gradient(135deg, #df5862, #c83d48);
  box-shadow: 0 12px 24px rgba(201, 61, 72, .2);
}
.confirm-dialog-confirm:hover:not(:disabled) {
  background: linear-gradient(135deg, #d84b56, #b9323c);
  box-shadow: 0 14px 28px rgba(201, 61, 72, .25);
}
.confirm-dialog-panel:focus-visible {
  box-shadow:
    0 0 0 4px rgba(49, 85, 235, .14),
    0 28px 80px rgba(19, 25, 43, .26);
}
@keyframes placeholderPulse {
  0%, 100% { opacity: .42; transform: scale(.94); }
  50% { opacity: 1; transform: scale(1.04); }
}
@media (prefers-reduced-motion: reduce) {
  .placeholder-ring { animation: none; }
  .confirm-dialog-backdrop,
  .confirm-dialog-panel { transition: none; }
}

.viewer-shell:fullscreen { padding: 0; grid-template-rows: 0 minmax(0, 1fr); background: #000; }
.viewer-shell:fullscreen .viewer-toolbar {
  position: absolute;
  z-index: 5;
  top: 12px;
  right: 12px;
  left: 12px;
  padding: 8px 10px;
  align-items: center;
  border-radius: 10px;
  background: rgba(16,21,31,.78);
  backdrop-filter: blur(12px);
}
.viewer-shell:fullscreen .viewer-title,
.viewer-shell:fullscreen .viewer-toolbar p { color: #fff; }
.viewer-shell:fullscreen .viewer-fps { color: #dce2eb; }
.viewer-shell:fullscreen .canvas-stage { min-height: 100vh; border-radius: 0; box-shadow: none; }

@media (max-width: 1040px) {
  .login-view { grid-template-columns: 1fr; }
  .login-intro { min-height: auto; padding: 40px; }
  .intro-copy { margin-block: 70px; }
  .login-panel { min-height: auto; padding-block: 80px; }
  .workspace-grid { grid-template-columns: 310px minmax(0, 1fr); }
  .control-sidebar { padding: 22px; }
  .viewer-toolbar p { display: none; }
  .shortcut-popover { right: 0; }
}

@media (max-width: 760px) {
  .login-intro { padding: 28px 24px; }
  .intro-copy { margin-block: 60px; }
  .intro-copy h1 { font-size: 46px; }
  .intro-specs { grid-template-columns: repeat(3, 1fr); }
  .intro-specs div { padding-top: 15px; }
  .login-panel { padding: 52px 24px; }
  .login-panel-inner { padding: 34px 26px; border-radius: 22px; }
  .login-panel-inner::before { left: 26px; }
  .workspace {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: visible;
  }
  .workspace-header { height: auto; min-height: 68px; padding: 14px 16px; grid-template-columns: 1fr auto; gap: 12px; }
  .workspace-header .brand b, .header-status { display: none; }
  .header-actions { gap: 6px; }
  .header-actions .button { min-height: 38px; padding-inline: 11px; font-size: 12px; }
  .workspace-grid {
    height: auto;
    min-height: calc(100vh - 68px);
    min-height: calc(100dvh - 68px);
    display: flex;
    flex-direction: column;
    overflow: visible;
  }
  .control-sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .session-section { display: none; }
  .viewer-shell { min-height: 64vh; padding: 14px; grid-template-rows: 42px minmax(360px, 1fr); }
  .viewer-title strong { display: none; }
  .viewer-toolbar-actions { margin-left: auto; }
  .canvas-stage { min-height: 360px; }
  .confirm-dialog { padding: 16px; }
  .confirm-dialog-panel { padding: 22px; border-radius: 17px; }
  .confirm-dialog-copy h2 { font-size: 19px; }

  .control-filing {
    font-size: 10px;
  }
  .control-filing img { width: 13px; height: 13px; }
}
