.phase4b-locked > :not(#phase4bAuthGate) {
  display: none !important;
}

.phase4b-auth-gate[hidden],
.phase4b-auth-card[hidden],
.phase4b-account-bar[hidden],
.phase4b-account-bar button[hidden] {
  display: none !important;
}

.phase4b-auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  color: #ecf8ff;
  background:
    radial-gradient(circle at 50% 16%, rgb(51 194 226 / 0.18), transparent 38%),
    linear-gradient(145deg, #07111d, #0a1c2b 55%, #061019);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.phase4b-auth-card {
  width: min(460px, 100%);
  padding: 28px;
  border: 1px solid rgb(113 216 238 / 0.4);
  border-radius: 18px;
  background: rgb(6 20 31 / 0.94);
  box-shadow: 0 28px 90px rgb(0 0 0 / 0.52), inset 0 1px rgb(255 255 255 / 0.08);
}

.phase4b-auth-card h1 {
  margin: 0 0 8px;
  font-size: clamp(1.45rem, 5vw, 2rem);
}

.phase4b-auth-card p {
  margin: 8px 0 18px;
  color: #b7d5df;
  line-height: 1.5;
}

.phase4b-auth-card label {
  display: grid;
  gap: 6px;
  margin: 14px 0;
  color: #d8edf3;
  font-weight: 700;
}

.phase4b-auth-card input {
  box-sizing: border-box;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #3b6674;
  border-radius: 9px;
  color: #f5fcff;
  background: #07141e;
  font: inherit;
}

.phase4b-auth-card button,
.phase4b-account-bar button,
.phase4b-conflict-dialog button {
  padding: 10px 14px;
  border: 1px solid #5cb8cf;
  border-radius: 8px;
  color: #f6fdff;
  background: #14536a;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.phase4b-auth-card button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.phase4b-reset-request-button {
  margin-left: 8px;
  color: #cfeef5 !important;
  background: transparent !important;
}

.phase4b-auth-message {
  min-height: 1.5em;
  margin-top: 14px !important;
  color: #ffd994 !important;
}

.phase4b-proof-button {
  display: none;
  width: 100%;
  margin-top: 10px;
  background: #554315 !important;
  border-color: #d2ad55 !important;
}

.phase4b-proof-button.is-available {
  display: block;
}

.phase4b-account-bar {
  position: fixed;
  z-index: 99990;
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  left: max(8px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  pointer-events: none;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.phase4b-account-chip,
.phase4b-sync-chip,
.phase4b-account-bar button {
  pointer-events: auto;
  padding: 7px 10px;
  border: 1px solid rgb(115 217 237 / 0.55);
  border-radius: 999px;
  color: #ecfbff;
  background: rgb(4 22 32 / 0.92);
  box-shadow: 0 8px 26px rgb(0 0 0 / 0.35);
  font-size: 12px;
}

.phase4b-sync-chip[data-state="pending"],
.phase4b-sync-chip[data-state="offline"] {
  color: #ffe19a;
  border-color: #a98738;
}

.phase4b-sync-chip[data-state="conflict"],
.phase4b-sync-chip[data-state="error"] {
  color: #ffd0d0;
  border-color: #b94a4a;
}

.phase4b-account-bar button {
  padding: 7px 10px;
  background: rgb(24 65 78 / 0.96);
}

.phase4b-migration-notice {
  position: fixed;
  z-index: 99980;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  width: min(440px, calc(100vw - 24px));
  box-sizing: border-box;
  padding: 14px 16px;
  border: 1px solid #b3914c;
  border-radius: 12px;
  color: #fff3d0;
  background: rgb(36 27 10 / 0.96);
  box-shadow: 0 18px 50px rgb(0 0 0 / 0.45);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.phase4b-migration-notice p {
  margin: 0 0 8px;
  line-height: 1.4;
}

.phase4b-migration-notice button {
  padding: 7px 10px;
  border: 1px solid #d0ae62;
  border-radius: 7px;
  color: #fff6dc;
  background: #654c1b;
  font: inherit;
  font-weight: 800;
}

.phase4b-conflict-dialog {
  width: min(780px, calc(100vw - 28px));
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  border: 1px solid #c16f6f;
  border-radius: 14px;
  color: #eef9fc;
  background: #091722;
  box-shadow: 0 28px 90px rgb(0 0 0 / 0.65);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.phase4b-conflict-dialog::backdrop {
  background: rgb(0 0 0 / 0.72);
}

.phase4b-conflict-item {
  margin: 14px 0;
  padding: 14px;
  border: 1px solid #5e3940;
  border-radius: 10px;
  background: #111f2a;
}

.phase4b-conflict-versions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.phase4b-conflict-versions pre {
  overflow: auto;
  max-height: 260px;
  padding: 10px;
  color: #d9edf2;
  background: #061019;
  white-space: pre-wrap;
}

@media (max-width: 680px) {
  .phase4b-account-bar {
    justify-content: center;
    flex-wrap: wrap;
  }

  .phase4b-account-chip {
    display: none;
  }

  .phase4b-conflict-versions {
    grid-template-columns: 1fr;
  }
}
