.login {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  min-height: 100vh;
}

.login-panel {
  display: grid;
  place-items: center;
  padding: 40px 24px;
  background:
    radial-gradient(700px 400px at 0% 0%, rgba(155, 89, 240, 0.1), transparent 60%),
    var(--bg);
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 20px;
}

.login-card [hidden] {
  display: none !important;
}

.login-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 850;
  font-size: 18px;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.login-brand img {
  width: 38px;
  height: 38px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 30px;
  font-weight: 750;
  letter-spacing: -0.025em;
}

.lead {
  margin: 0 0 22px;
  color: var(--text-2);
  font-size: 15px;
}

.connect-btn {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #fff;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 18px 36px -18px rgba(106, 63, 208, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: transform 120ms, box-shadow 160ms, filter 160ms;
}

.connect-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 22px 40px -18px rgba(106, 63, 208, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.connect-btn:active {
  transform: translateY(1px);
}

.connect-btn:disabled {
  opacity: 0.7;
  cursor: progress;
}

.connect-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
}

.connect-icon svg,
.connect-arrow {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.connect-text strong {
  display: block;
  font-size: 16px;
  font-weight: 700;
}

.connect-text small {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  opacity: 0.85;
}

.how {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.how-title {
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.how ol {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 6px;
  font-size: 14px;
  color: var(--text-2);
}

.how code {
  font-family: var(--mono);
  white-space: nowrap;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 12px;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-strong);
}

.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 48px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: background 120ms, transform 80ms;
}

.google-btn:hover {
  background: var(--surface-2);
}

.google-btn svg {
  width: 20px;
  height: 20px;
}

.error {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--critical-soft);
  color: var(--critical);
  font-size: 13px;
  font-weight: 550;
}

.local {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--good-soft);
  font-size: 14px;
  color: var(--text-2);
}

.local p {
  margin: 0;
}

.local strong {
  color: var(--text);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 16px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 14px;
  font-weight: 650;
  justify-self: start;
}

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

/* ---- Pairing: the code, the two ways to use it, the dark command boxes ---- */

#pairing {
  display: grid;
  gap: 16px;
}

#done {
  display: grid;
}

.pair-head h1 {
  margin-bottom: 6px;
}

.pair-head .lead {
  margin: 0;
}

.code-card {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 16px 16px 14px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.code-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.code {
  font-family: var(--mono);
  font-size: clamp(30px, 8.5vw, 40px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.1em;
  color: var(--accent);
  user-select: all;
  transition: color 160ms, opacity 160ms;
}

.code-card.expired .code {
  color: var(--muted);
  opacity: 0.55;
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.waiting {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 10px;
  font-size: 14px;
  color: var(--text-2);
}

.waiting .expires {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.code-card.expired .spinner {
  display: none;
}

/* The commands still carry the dead code until "Gerar outro". */
.code-card.expired ~ .panel .command {
  opacity: 0.45;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--accent-track);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

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

/* Segmented control: "Ainda não tenho o Gengar" / "Já tenho o Gengar". */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-3);
}

/* Sized by their labels, so both fit on one line even on a phone. */
.tab {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 6px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  transition: background 140ms, color 140ms, box-shadow 140ms;
}

.tab:hover {
  color: var(--text);
}

.tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(30, 15, 70, 0.08), 0 4px 12px -6px rgba(60, 30, 140, 0.25);
}

.tab svg {
  flex: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.panel {
  display: grid;
  gap: 10px;
}

.panel-lead {
  margin: 0;
  font-size: 14px;
  color: var(--text-2);
}

.panel-lead strong {
  color: var(--text);
}

.panel-note {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

/* Text padded to the copy button's height: one line sits centred, several start at the top. */
.command {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  padding: 8px 8px 8px 14px;
  border-radius: 14px;
  background: var(--night);
  color: #f1eaff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.command .prompt {
  padding: 7px 0;
  color: #9b7ce6;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.45;
  user-select: none;
}

.command code {
  padding: 7px 0;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 120ms, color 120ms;
}

.copy:hover {
  background: rgba(255, 255, 255, 0.16);
}

.copy svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.copy .ok,
.copy.done .clip {
  display: none;
}

.copy.done .ok {
  display: block;
}

.copy.done {
  background: rgba(60, 207, 100, 0.18);
  border-color: rgba(60, 207, 100, 0.4);
  color: #a6f0bd;
}

.nobr {
  white-space: nowrap;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chips span {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
}

.hint {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.link {
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
  justify-self: center;
}

/* Texts that differ between the gengar.work hub and the Gengar on this computer. */
:root:not([data-mode="hub"]) .only-hub,
:root[data-mode="hub"] .only-local {
  display: none !important;
}

/* macOS / Windows installer: a small switch, lighter than the tabs above it. */
:root[data-os="win"] .only-mac,
:root:not([data-os="win"]) .only-win {
  display: none !important;
}

.os-switch {
  display: inline-flex;
  justify-self: start;
  gap: 2px;
  padding: 3px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.os-opt {
  min-height: 30px;
  padding: 4px 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  transition: background 140ms, color 140ms;
}

.os-opt:hover {
  color: var(--text);
}

.os-opt[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.panel-note code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
  overflow-wrap: anywhere;
}

@media (max-width: 480px) {
  .login-panel {
    padding: 28px 16px 32px;
  }
  .login-card h1 {
    font-size: 27px;
  }
  .tab svg {
    display: none;
  }
  .tab {
    padding: 6px 8px;
    font-size: 13px;
  }
  /* A short command keeps copy beside it; a long one takes the width and copy drops below, on the right. */
  .command {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    padding: 8px 8px 8px 14px;
  }
  .command code {
    flex: 1 1 auto;
    max-width: calc(100% - 24px);
  }
  /* "PS>" is wider than "$" and must still fit beside the command. */
  .command .prompt.ps + code {
    max-width: calc(100% - 42px);
  }
  .command code,
  .command .prompt {
    font-size: 13px;
  }
  .command .copy {
    margin-left: auto;
  }
}

.done-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 14px;
  border-radius: 20px;
  background: var(--good);
  color: #fff;
  animation: pop 420ms cubic-bezier(0.2, 1.4, 0.4, 1);
}

.done-mark svg {
  width: 32px;
  height: 32px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@keyframes pop {
  from { transform: scale(0.4); opacity: 0; }
}

.fine {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.login-hero {
  position: relative;
  display: grid;
  place-items: center;
  padding: 48px;
  overflow: hidden;
  background:
    radial-gradient(900px 520px at 100% 0%, rgba(155, 89, 240, 0.42), transparent 60%),
    radial-gradient(700px 480px at 0% 100%, rgba(106, 63, 208, 0.38), transparent 60%),
    var(--night);
  color: #fff;
}

.hero-inner {
  width: min(520px, 100%);
  display: grid;
  gap: 26px;
}

.hero-brand {
  display: flex;
  align-items: center;
  gap: 18px;
}

.hero-brand img {
  width: 92px;
  height: 92px;
  filter: drop-shadow(0 16px 30px rgba(155, 89, 240, 0.5));
  animation: float 6s ease-in-out infinite;
}

.hero-word {
  font-size: 44px;
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 1;
}

.hero-tag {
  margin-top: 8px;
  color: #b9a1ec;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.3em;
}

.login-hero h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hero-card {
  display: grid;
  gap: 14px;
  padding: 20px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.11);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.6);
}

.hero-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) 110px 34px;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.hero-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.88);
}

.hero-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.hero-dot.run {
  background: #b38cff;
  animation: blink 1.4s infinite;
}

.hero-dot.wait {
  background: var(--warning);
  animation: blink 1s infinite;
}

.hero-dot.ok {
  background: #3ccf3c;
}

.hero-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
  overflow: hidden;
}

.hero-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #9b59f0, #c9a8ff);
}

.hero-bar.warn span {
  background: var(--warning);
}

.hero-bar.ok span {
  background: #3ccf3c;
}

.hero-num {
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.65);
  text-align: right;
}

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

@keyframes float {
  50% { transform: translateY(-8px) rotate(-1.5deg); }
}

@media (max-width: 900px) {
  .login {
    grid-template-columns: minmax(0, 1fr);
  }
  .login-hero {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-brand img,
  .hero-dot,
  .spinner,
  .done-mark {
    animation: none;
  }
}

/* "O comando não aparece?": collapsed help under the pairing code. */
.help {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-2);
}

.help summary {
  width: fit-content;
  margin: 0 auto;
  padding: 4px 6px;
  border-radius: 8px;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.help summary::-webkit-details-marker {
  display: none;
}

.help summary::after {
  content: " ▾";
  font-size: 11px;
}

.help[open] summary::after {
  content: " ▴";
}

.help code {
  font-family: var(--mono);
  font-size: 12px;
}

.help ol {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding: 14px 16px 14px 34px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.help li > code:not(.block) {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
}

.help-os {
  display: block;
  margin-top: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.help code.block {
  display: block;
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--night);
  color: #f1eaff;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: all;
}

/* Keyboard focus ring (mouse clicks don't show it). */
:where(a, button, summary):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---- Phones -------------------------------------------------------------------------- */

/* The brand is a link: it shouldn't stretch across the card (taps beside it went home). */
.login-brand {
  justify-self: start;
}

/* Without the hero (<= 900px) this is the only branding: match the app's mobile bar. */
@media (max-width: 900px) {
  .login-brand img {
    width: 44px;
    height: 44px;
  }
}

.tab-short {
  display: none;
}

@media (max-width: 480px) {
  .os-opt {
    min-height: 38px;
    padding: 6px 16px;
  }
  .link {
    padding: 10px 16px;
  }
  .help summary {
    padding: 10px 8px;
  }
}

/* 320-360: a shorter first tab keeps both labels on one line; the CTA drops its arrow. */
@media (max-width: 360px) {
  .tab-long {
    display: none;
  }
  .tab-short {
    display: inline;
  }
  .tab {
    padding: 6px;
    font-size: 12.5px;
  }
  .connect-btn {
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 12px;
    padding: 12px 14px;
  }
  .connect-icon {
    width: 38px;
    height: 38px;
  }
  .connect-arrow {
    display: none;
  }
  .connect-text strong {
    font-size: 15px;
  }
}

/* iOS Safari zooms into fields under 16px: any field here gets 16px on touch screens and phones
   (today the page has none: the login is by code, approved on the computer). Zoom stays allowed. */
@media (max-width: 760px), (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]),
  textarea,
  select {
    font-size: 16px;
  }
}
