:root {
  --bg-0: #0c1219;
  --bg-1: #121b26;
  --bg-2: #1a2636;
  --bg-panel: rgba(22, 34, 50, 0.82);
  --stroke: rgba(148, 178, 210, 0.18);
  --stroke-strong: rgba(148, 178, 210, 0.32);
  --text: #e8eef6;
  --text-muted: #93a4b8;
  --accent: #2ec4b6;
  --accent-deep: #1a9f94;
  --accent-soft: rgba(46, 196, 182, 0.14);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.12);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --radius: 14px;
  --font: "Outfit", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --transition: 380ms cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 60% at 10% -10%, rgba(46, 196, 182, 0.18), transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 0%, rgba(56, 120, 180, 0.22), transparent 50%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1) 45%, #0e1722);
  background-attachment: fixed;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 2rem clamp(1rem, 4vw, 3rem) 3rem;
  max-width: 960px;
  margin: 0 auto;
}

.header {
  margin-bottom: 2.5rem;
  animation: rise-in 600ms ease both;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--accent), #4d8dff);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.brand-title {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-tagline {
  margin: 0.65rem 0 0;
  color: var(--text-muted);
  font-size: 1rem;
}

.main {
  flex: 1;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--stroke);
  border-radius: calc(var(--radius) + 4px);
  padding: clamp(1.25rem, 3vw, 2rem);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  animation: rise-in 700ms ease both;
  animation-delay: 60ms;
}

.email-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.field-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.field-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.email-input {
  flex: 1 1 240px;
  min-height: 52px;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--stroke-strong);
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.email-input::placeholder {
  color: #5f7085;
}

.email-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn {
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 12px;
  transition: transform 180ms ease, background var(--transition), opacity var(--transition);
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  flex: 0 0 auto;
  min-height: 52px;
  padding: 0 1.4rem;
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  color: #062c28;
  box-shadow: 0 8px 24px rgba(46, 196, 182, 0.28);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--stroke-strong);
  padding: 0.55rem 0.95rem;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
}

.btn-icon {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  border: 1px solid var(--stroke);
}

.btn-icon:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.field-hint {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.field-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
  background: var(--danger-soft);
  border: 1px solid rgba(255, 107, 107, 0.25);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--stroke);
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.info-item p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.info-step {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.08em;
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 18, 0.72);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.loading-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.loading-overlay[hidden] {
  display: flex !important;
  opacity: 0;
  pointer-events: none !important;
}

.loading-overlay[hidden] *,
.loading-overlay:not(.is-visible) * {
  pointer-events: none !important;
}

.loading-card {
  text-align: center;
  padding: 2rem 2.25rem;
  border-radius: var(--radius);
  background: var(--bg-2);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  min-width: min(320px, 90vw);
  animation: pop-in 400ms ease both;
}

.spinner img {
  display: block;
  margin: 0 auto 1rem;
  animation: spin 1.1s linear infinite;
}

.loading-status {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.loading-sub {
  margin: 0.45rem 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Browser overlay — popup matches GoLogin profile resolution (1024x576).
   Slim Chrome header matches real Chrome; stream is shifted up so GoLogin chrome stays hidden. */
.browser-overlay {
  --gologin-w: 1024px;
  --gologin-h: 576px;
  /* Cover GoLogin's own chrome under our header without cropping the page away */
  --gologin-chrome-offset: -56px;
  --gologin-scale: 1.035;
  /* Exact slim Chrome header proportions from reference */
  --chrome-header-h: 66px;
  --chrome-title-h: 30px;
  --chrome-toolbar-h: 36px;

  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(6, 10, 16, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.browser-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.browser-overlay[hidden] {
  display: flex !important;
  opacity: 0;
  pointer-events: none !important;
}

/* Children with pointer-events:auto still capture clicks when parent is none — block them while hidden */
.browser-overlay[hidden] *,
.browser-overlay:not(.is-visible) * {
  pointer-events: none !important;
}

.browser-shell {
  position: relative;
  width: var(--gologin-w);
  height: var(--gologin-h);
  max-width: calc(100vw - 2rem);
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  background: #e9efed;
  border: none;
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transform: translateY(12px) scale(0.99);
  transition: transform var(--transition), width 200ms ease, height 200ms ease;
}

.browser-shell.is-maximized {
  width: min(100vw, calc(100vh * 1024 / 576)) !important;
  height: min(100vh, calc(100vw * 576 / 1024)) !important;
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 0;
}

.browser-overlay.is-visible .browser-shell {
  transform: translateY(0) scale(1);
}

.browser-shell.is-minimized {
  display: none !important;
}

/* —— Fake Chrome header (covers GoLogin header) —— */
.chrome-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  height: var(--chrome-header-h);
  display: flex;
  flex-direction: column;
  font-family: "Segoe UI", system-ui, Roboto, Arial, sans-serif;
  user-select: none;
  pointer-events: auto;
  box-shadow: none;
  isolation: isolate;
}

.chrome-titlebar {
  height: var(--chrome-title-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 0 12px;
  background: #e9efed;
  color: #1f1f1f;
  flex-shrink: 0;
}

.chrome-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  padding-right: 8px;
}

.chrome-favicon {
  display: inline-flex;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}

.chrome-favicon svg {
  display: block;
}

.chrome-title-text {
  font-size: 12px;
  line-height: 1.2;
  font-weight: 400;
  color: #1f1f1f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chrome-window-controls {
  position: relative;
  z-index: 210;
  display: flex;
  align-items: stretch;
  height: 100%;
  flex-shrink: 0;
}

.chrome-win-btn {
  width: 46px;
  height: 100%;
  border: 0;
  background: transparent;
  color: #1f1f1f;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  pointer-events: auto;
}

.chrome-win-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}

.chrome-win-btn--close:hover {
  background: #e81123;
  color: #fff;
}

.chrome-toolbar {
  position: relative;
  z-index: 205;
  height: var(--chrome-toolbar-h);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px 0 6px;
  background: #e9efed;
  border-top: 1px solid #d8ddd9;
  border-bottom: 1px solid #d8ddd9;
  flex-shrink: 0;
}

.chrome-omnibox-tune {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  color: #444746;
  pointer-events: auto;
}

.chrome-omnibox-tune:hover {
  background: rgba(60, 64, 67, 0.08);
}

.chrome-omnibox-tune[aria-expanded="true"] {
  background: rgba(60, 64, 67, 0.12);
}

.chrome-omnibox-tune svg {
  display: block;
}

/* Chrome omnibox pill matching reference screenshot */
.chrome-omnibox {
  flex: 1;
  height: 28px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: #f1f4f2;
  border-radius: 14px;
  border: 0;
  box-shadow: none;
  min-width: 0;
}

.chrome-url-text {
  flex: 1;
  font-size: 13px;
  line-height: 1.2;
  font-weight: 400;
  color: #1f1f1f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* Chrome-like site information popup */
.chrome-site-info {
  position: absolute;
  top: calc(100% + 6px);
  left: 4px;
  z-index: 220;
  width: min(340px, calc(100% - 8px));
  padding: 2px 0 6px;
  background: #f8f9fa;
  border: 1px solid #dadce0;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2), 0 1px 3px rgba(0, 0, 0, 0.12);
  font-family: "Segoe UI", system-ui, Roboto, Arial, sans-serif;
  pointer-events: auto;
}

.chrome-site-info[hidden] {
  display: none !important;
}

.chrome-site-info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 10px 10px 16px;
}

.chrome-site-info-host {
  font-size: 14px;
  font-weight: 600;
  color: #1f1f1f;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chrome-site-info-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #444746;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  pointer-events: auto;
}

.chrome-site-info-close:hover {
  background: rgba(60, 64, 67, 0.1);
}

.chrome-site-info-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 16px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: #1f1f1f;
  font-family: inherit;
  font-size: 13px;
  font-weight: 400;
  pointer-events: auto;
}

.chrome-site-info-row:hover {
  background: rgba(60, 64, 67, 0.06);
}

.chrome-site-info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: #444746;
}

.chrome-site-info-icon svg {
  display: block;
}

.chrome-site-info-label {
  flex: 1;
  min-width: 0;
}

.chrome-site-info-chevron {
  color: #444746;
  display: inline-flex;
  flex-shrink: 0;
}

.chrome-site-info-external {
  display: inline-flex;
  flex-shrink: 0;
  color: #444746;
}

.iframe-frame {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #fff;
  overflow: hidden;
  pointer-events: auto;
}

.iframe-frame iframe {
  position: absolute;
  top: var(--gologin-chrome-offset);
  left: 0;
  width: 100%;
  height: calc(100% - var(--gologin-chrome-offset));
  border: 0;
  display: block;
  background: #fff;
  transform: scale(var(--gologin-scale));
  transform-origin: top left;
}

/* Restore bar when window is minimized */
.browser-restore-chip {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 1200;
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--stroke-strong);
  background: var(--bg-2);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.browser-restore-chip.is-visible {
  display: inline-flex;
}

/* Toasts */
.toast-region {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(360px, calc(100vw - 2rem));
}

.toast {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: var(--bg-2);
  border: 1px solid var(--stroke-strong);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  animation: rise-in 300ms ease both;
}

.toast.is-error {
  border-color: rgba(255, 107, 107, 0.4);
  background: #2a1a1d;
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 250ms ease, transform 250ms ease;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 720px) {
  .info-grid {
    grid-template-columns: 1fr;
  }

  .browser-overlay {
    padding: 0.5rem;
    --gologin-w: min(1024px, calc(100vw - 1rem));
    --gologin-h: calc(var(--gologin-w) * 576 / 1024);
  }

  .browser-shell {
    width: var(--gologin-w);
    height: var(--gologin-h);
  }

  .iframe-frame iframe {
    width: 100%;
    height: calc(100% - var(--gologin-chrome-offset));
  }

  .field-row {
    flex-direction: column;
  }

  .btn-primary {
    width: 100%;
  }
}
