:root {
  --bg: #0d0c14;
  --surface: rgba(25, 23, 38, 0.96);
  --surface-soft: #211e31;
  --surface-raised: #2b2740;
  --border: rgba(255, 255, 255, 0.1);
  --text: #f6f4ff;
  --muted: #aaa5bd;
  --accent: #9d78ff;
  --accent-strong: #7a4ff0;
  --success: #63d8a2;
  --danger: #ff7d8c;
  --toolbar-height: 112px;
  font-family: Inter, ui-rounded, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 70%, white);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  background:
    radial-gradient(circle at 50% -20%, rgba(126, 80, 240, 0.18), transparent 38%),
    var(--bg);
}

.browser-toolbar {
  flex: 0 0 auto;
  padding: max(9px, env(safe-area-inset-top)) 10px 9px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 7px 24px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  z-index: 10;
}

.status-row,
.navigation-row,
.browser-footer {
  display: flex;
  align-items: center;
}

.status-row {
  justify-content: space-between;
  min-height: 28px;
  margin: 0 2px 7px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-mark,
.login-logo {
  display: grid;
  place-items: center;
  color: white;
  font-weight: 800;
  background: linear-gradient(145deg, #b393ff, #6740d4);
  box-shadow: 0 4px 16px rgba(122, 79, 240, 0.4);
}

.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  font-size: 13px;
}

.brand-name {
  overflow: hidden;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-size: 11px;
  font-weight: 700;
}

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

.connection-status[data-state="online"] {
  color: #b9f5d8;
  border-color: rgba(99, 216, 162, 0.28);
  background: rgba(99, 216, 162, 0.09);
}

.connection-status[data-state="online"] .status-dot {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(99, 216, 162, 0.12);
}

.connection-status[data-state="connecting"] .status-dot {
  background: #f2c96b;
  animation: pulse 1.1s ease-in-out infinite;
}

.navigation-row {
  gap: 7px;
}

.icon-button,
.go-button,
.footer-button,
.primary-button {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.icon-button {
  flex: 0 0 40px;
  width: 40px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 13px;
  color: #e9e5f4;
  background: var(--surface-soft);
  font-size: 28px;
  line-height: 1;
}

.icon-button:active,
.footer-button:active {
  transform: scale(0.96);
  background: var(--surface-raised);
}

.address-form {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  height: 42px;
  overflow: hidden;
  border: 1px solid rgba(157, 120, 255, 0.3);
  border-radius: 14px;
  background: #12101d;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.address-form:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(157, 120, 255, 0.12);
}

.address-form input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  padding: 0 11px;
  color: var(--text);
  background: transparent;
  outline: 0;
  font-size: 16px;
}

.address-form input::placeholder {
  color: #7f7a91;
}

.go-button {
  flex: 0 0 auto;
  margin: 4px;
  padding: 0 12px;
  border-radius: 10px;
  color: white;
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  font-size: 13px;
  font-weight: 800;
}

.browser-stage {
  position: relative;
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
  place-items: center;
  overflow: hidden;
  background: #09080e;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.browser-frame {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
  -webkit-user-drag: none;
}

.browser-frame:not([src]) {
  opacity: 0;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
  background:
    radial-gradient(circle at 50% 40%, rgba(157, 120, 255, 0.1), transparent 35%),
    #09080e;
}

.empty-state strong {
  color: var(--text);
  font-size: 16px;
}

.empty-state span {
  max-width: 280px;
  font-size: 13px;
  line-height: 1.45;
}

.empty-spinner {
  width: 34px;
  height: 34px;
  margin-bottom: 7px;
  border: 3px solid rgba(157, 120, 255, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.error-banner {
  position: absolute;
  top: 10px;
  left: 50%;
  max-width: calc(100% - 24px);
  transform: translateX(-50%);
  padding: 9px 13px;
  border: 1px solid rgba(255, 125, 140, 0.38);
  border-radius: 12px;
  color: #ffd6dc;
  background: rgba(90, 24, 36, 0.94);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  font-size: 13px;
  z-index: 5;
}

.browser-footer {
  flex: 0 0 auto;
  gap: 8px;
  min-height: 54px;
  padding: 7px 10px max(7px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.footer-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: #e7e2f4;
  background: var(--surface-soft);
  font-size: 13px;
  font-weight: 750;
}

.footer-button[aria-expanded="true"] {
  color: white;
  border-color: rgba(157, 120, 255, 0.55);
  background: rgba(122, 79, 240, 0.3);
}

.footer-button-muted {
  margin-left: auto;
  color: var(--muted);
  background: transparent;
}

.keyboard-capture {
  flex: 1 1 auto;
  min-width: 0;
  height: 40px;
  border: 1px solid rgba(157, 120, 255, 0.38);
  border-radius: 12px;
  padding: 0 11px;
  color: var(--text);
  background: #12101d;
  outline: 0;
  font-size: 16px;
}

.login-panel {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 50% 22%, rgba(145, 98, 255, 0.26), transparent 38%),
    linear-gradient(160deg, #171424, #09080f 72%);
  z-index: 100;
}

.login-panel.is-hidden {
  display: none;
}

.login-card {
  width: min(100%, 390px);
  padding: 28px 24px 24px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 26px;
  background: rgba(28, 25, 42, 0.91);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.login-logo {
  width: 54px;
  height: 54px;
  margin-bottom: 20px;
  border-radius: 18px;
  font-size: 26px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #bba4ff;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.login-card h1 {
  margin: 0;
  font-size: clamp(27px, 8vw, 36px);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.login-copy {
  margin: 13px 0 22px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.login-form {
  display: grid;
  gap: 10px;
}

.login-form label {
  color: #d7d2e5;
  font-size: 13px;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  height: 50px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 14px;
  color: var(--text);
  background: #100e19;
  outline: 0;
  font-size: 17px;
}

.primary-button {
  height: 50px;
  margin-top: 5px;
  border-radius: 14px;
  color: white;
  background: linear-gradient(145deg, #a786ff, #7145dd);
  box-shadow: 0 12px 26px rgba(113, 69, 221, 0.3);
  font-weight: 850;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.login-error {
  margin: 4px 0 0;
  color: #ffacb7;
  font-size: 13px;
}

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

@keyframes pulse {
  50% { opacity: 0.35; }
}

@media (max-width: 420px) {
  .brand-name {
    max-width: 120px;
  }

  .icon-button {
    flex-basis: 37px;
    width: 37px;
  }

  .go-button {
    padding-inline: 10px;
  }

  .footer-button-muted {
    padding-inline: 10px;
    font-size: 0;
  }

  .footer-button-muted::before {
    content: "×";
    font-size: 22px;
  }
}

@media (orientation: landscape) and (max-height: 540px) {
  .browser-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: max(6px, env(safe-area-inset-top));
    padding-bottom: 6px;
  }

  .status-row {
    flex: 0 0 auto;
    margin: 0;
  }

  .brand-name,
  .connection-status .status-label {
    display: none;
  }

  .connection-status {
    padding: 6px;
  }

  .navigation-row {
    flex: 1 1 auto;
  }

  .icon-button,
  .address-form {
    height: 38px;
  }

  .browser-footer {
    min-height: 46px;
    padding-top: 4px;
    padding-bottom: max(4px, env(safe-area-inset-bottom));
  }

  .footer-button,
  .keyboard-capture {
    min-height: 36px;
    height: 36px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
