:root {
  color-scheme: light;
  --page: #f7f7f7;
  --surface: #ffffff;
  --surface-muted: #f1f1f1;
  --ink: #202020;
  --muted: #6f6f6f;
  --line: #e2e2e2;
  --line-strong: #cfcfcf;
  --button: #303030;
  --button-hover: #1f1f1f;
  --brand: #f7a917;
  --success: #14805e;
  --danger: #b42318;
  --radius: 6px;
}

* { box-sizing: border-box; }

html,
body { min-height: 100%; }

html { background: var(--page); }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input { font: inherit; }

.app-header {
  position: relative;
  z-index: 20;
  height: 58px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(12px);
}

.header-inner {
  width: min(100% - 28px, 1500px);
  height: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(170px, 1fr) auto minmax(170px, 1fr);
  align-items: center;
  gap: 16px;
}

.brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-self: start;
  color: var(--ink);
  text-decoration: none;
}

.brand img {
  width: 20px;
  height: 27px;
  margin-right: 10px;
  object-fit: contain;
}

.brand-name { font-size: 15px; font-weight: 700; }

.brand-product {
  margin-left: 9px;
  padding-left: 9px;
  border-left: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.header-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 3px;
}

.header-actions form { margin: 0; }

.account-name {
  max-width: 150px;
  margin: 0 7px 0 8px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-button:hover { background: var(--surface-muted); color: var(--ink); }

.icon-button:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--brand) 55%, transparent);
  outline-offset: 1px;
}

.icon-button svg,
.header-popover svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.header-icon { border-radius: 7px; }
.header-icon svg { width: 22px; height: 22px; }
.theme-toggle .sun-icon { display: none; }
.theme-toggle .moon-icon { display: block; }

.header-menu { position: relative; height: 36px; }
.header-menu > summary { list-style: none; }
.header-menu > summary::-webkit-details-marker { display: none; }
.header-menu[open] > summary { background: var(--surface-muted); color: var(--ink); }

.header-popover {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  z-index: 30;
  width: 210px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 16px 38px rgba(32, 32, 32, .14);
}

.popover-label {
  display: block;
  padding: 5px 9px 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.header-popover a,
.popover-current {
  min-height: 36px;
  padding: 0 9px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 6px;
  color: var(--ink);
  font-size: 13px;
  text-decoration: none;
}

.header-popover a:hover { background: var(--surface-muted); }
.header-popover svg { width: 17px; height: 17px; color: var(--muted); }
.popover-current { color: var(--muted); }
.current-mark { margin-left: auto; font-size: 10px; }

.connection-state {
  min-width: 84px;
  height: 28px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.connection-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d49b23;
}

.connection-state[data-state="connected"] .connection-dot { background: var(--success); }
.connection-state[data-state="disconnected"] .connection-dot { background: var(--danger); }

.browser-body { overflow: hidden; }

.browser-shell {
  width: 100%;
  height: calc(100vh - 58px);
  height: calc(100dvh - 58px);
  padding: 0;
  background: #181818;
}

.browser-stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #101010;
}

.browser-stage:fullscreen { border: 0; border-radius: 0; }

.remote-screen {
  width: 100%;
  height: 100%;
  overflow: hidden;
  outline: none;
  background: #101010;
}

.remote-screen canvas { outline: none; }

.connection-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 9px;
  background: #181818;
  color: #f5f5f5;
  text-align: center;
}

.connection-overlay[hidden] { display: none; }
.connection-overlay strong { font-size: 15px; font-weight: 650; }
.connection-overlay span:last-child { color: #a7a7a7; font-size: 12px; }

.spinner {
  width: 24px;
  height: 24px;
  margin-bottom: 5px;
  border: 2px solid #555;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.browser-toast {
  position: absolute;
  right: 14px;
  bottom: 14px;
  max-width: min(360px, calc(100% - 28px));
  padding: 9px 12px;
  border: 1px solid #3b6657;
  border-radius: 5px;
  background: rgba(24, 54, 44, .96);
  color: #e8fff6;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.browser-toast[data-kind="error"] { border-color: #75423f; background: rgba(75, 38, 35, .96); }
.browser-toast.is-visible { opacity: 1; transform: translateY(0); }

.login-shell {
  min-height: calc(100vh - 58px);
  min-height: calc(100dvh - 58px);
  padding: 32px 24px;
  display: grid;
  place-items: center;
}

.login-panel {
  width: min(390px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 16px 42px rgba(32, 32, 32, .07);
}

.login-heading { margin-bottom: 24px; }

.login-heading img {
  width: 19px;
  height: 25px;
  margin-right: 8px;
  object-fit: contain;
  vertical-align: middle;
}

.login-heading > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  vertical-align: middle;
}

.login-heading h1 { margin: 18px 0 0; font-size: 26px; line-height: 1.2; }
.stack { display: grid; gap: 15px; }

label { min-width: 0; display: grid; gap: 6px; }
label > span { color: var(--muted); font-size: 12px; font-weight: 600; }

input {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
}

input:focus { outline: 2px solid rgba(247, 169, 23, .24); border-color: var(--brand); }

.primary-button {
  min-height: 40px;
  margin-top: 4px;
  border: 0;
  border-radius: var(--radius);
  background: var(--button);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}

.primary-button:hover { background: var(--button-hover); }

.alert {
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid #f2b8b5;
  border-radius: var(--radius);
  background: #fff1f0;
  color: #8e1b13;
  font-size: 13px;
}

.dark {
  color-scheme: dark;
  --page: #242424;
  --surface: #353535;
  --surface-muted: #424242;
  --ink: #fafafa;
  --muted: #d0d0d0;
  --line: #4c4c4c;
  --line-strong: #686868;
  --button: #f2f2f2;
  --button-hover: #fff;
}

.dark .app-header { background: rgba(49, 49, 49, .96); }
.dark .header-popover { background: rgba(36, 36, 36, .98); box-shadow: 0 16px 38px rgba(0, 0, 0, .3); }
.dark .theme-toggle .sun-icon { display: block; }
.dark .theme-toggle .moon-icon { display: none; }
.dark .primary-button { color: #202020; }
.dark .login-panel { box-shadow: 0 16px 42px rgba(0, 0, 0, .2); }
.dark .alert { border-color: #7d4845; background: #4b3030; color: #ffd0cc; }

@media (max-width: 760px) {
  .header-inner {
    width: calc(100% - 16px);
    grid-template-columns: minmax(88px, 1fr) auto minmax(88px, 1fr);
    gap: 6px;
  }

  .brand-name,
  .account-name,
  .workspace-action:first-child { display: none; }

  .brand-product { margin-left: 0; padding-left: 0; border-left: 0; color: var(--ink); font-size: 14px; font-weight: 650; }
  .brand img { width: 17px; height: 24px; margin-right: 7px; }
  .header-actions { gap: 0; }
  .header-icon { width: 34px; height: 34px; }
  .header-icon svg { width: 20px; height: 20px; }
  .connection-state { min-width: 66px; padding-inline: 8px; font-size: 11px; }
  .browser-shell { padding: 4px; }
  .login-panel { padding: 25px 22px; }
}

@media (max-width: 470px) {
  .workspace-action,
  #product-menu { display: none; }
  .header-inner { grid-template-columns: 1fr auto 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 1600ms; }
  .browser-toast { transition: none; }
}
