:root {
  --auth-bg: #080808;
  --auth-panel: #101010;
  --auth-panel-raised: #171717;
  --auth-line: #2e2e2e;
  --auth-line-strong: #555555;
  --auth-text: #f2f2f2;
  --auth-muted: #999999;
  --auth-subtle: #6f6f6f;
  --auth-accent: #f2f2f2;
  --auth-danger: #d2d2d2;
  --auth-success: #e1e1e1;
}

.auth-pending [data-auth-entry],
.auth-pending [data-auth-account],
.auth-pending [data-auth-adaptive-trigger] {
  visibility: hidden;
}

.auth-dialog [hidden],
.auth-trigger[hidden],
.auth-legal[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

body.auth-dialog-open {
  overflow: hidden;
}

.auth-dialog {
  box-sizing: border-box;
  width: min(430px, calc(100vw - 32px));
  max-width: none;
  max-height: min(680px, calc(100dvh - 32px));
  overflow: auto;
  padding: 0;
  color: var(--auth-text);
  background: var(--auth-bg);
  border: 1px solid var(--auth-line);
  border-radius: 14px;
  box-shadow: 0 28px 100px rgba(0, 0, 0, 0.82);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior: contain;
}

.auth-dialog[open] {
  animation: auth-panel-in 160ms ease-out;
}

.auth-dialog::backdrop {
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(5px);
}

.auth-dialog-shell {
  position: relative;
  box-sizing: border-box;
  min-height: 100%;
  padding: 25px;
}

@keyframes auth-panel-in {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-close {
  position: absolute;
  top: 11px;
  right: 11px;
  z-index: 1;
  width: 31px;
  height: 31px;
  padding: 0;
  color: var(--auth-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  font: 400 25px/27px Arial, sans-serif;
  cursor: pointer;
}

.auth-close:hover {
  color: var(--auth-text);
  background: #1e1e1e;
  border-color: var(--auth-line);
}

.auth-methods h2,
.auth-account-copy h2 {
  margin: 0;
  padding-right: 38px;
  color: var(--auth-text);
  font-size: clamp(21px, 5vw, 26px);
  font-weight: 760;
  line-height: 1.14;
  letter-spacing: -0.035em;
}

.auth-subtitle {
  max-width: 360px;
  margin: 8px 0 18px;
  color: var(--auth-muted);
  font-size: 13px;
  line-height: 1.55;
}

.auth-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  margin-bottom: 14px;
  padding: 3px;
  background: #111111;
  border: 1px solid #2c2c2c;
  border-radius: 10px;
}

.auth-mode-tabs button {
  min-height: 34px;
  padding: 0 10px;
  color: var(--auth-muted);
  background: transparent;
  border: 0;
  border-radius: 7px;
  font: 700 11px/1 Inter, sans-serif;
  cursor: pointer;
}

.auth-mode-tabs button:hover {
  color: var(--auth-text);
}

.auth-mode-tabs button.active {
  color: #0a0a0a;
  background: var(--auth-text);
}

.auth-email-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}

.auth-email-input,
.auth-email-continue {
  box-sizing: border-box;
  min-height: 45px;
  border-radius: 9px;
  font: 650 13px/1 Inter, sans-serif;
}

.auth-email-input {
  min-width: 0;
  padding: 0 12px;
  color: var(--auth-text);
  background: #111111;
  border: 1px solid var(--auth-line);
  outline: 0;
}

.auth-email-input::placeholder {
  color: #6d6d6d;
}

.auth-email-input:hover {
  border-color: var(--auth-line-strong);
}

.auth-email-continue {
  min-width: 104px;
  padding: 0 14px;
  color: #0b0b0b;
  background: var(--auth-accent);
  border: 1px solid var(--auth-accent);
  cursor: pointer;
}

.auth-email-continue:not(:disabled):hover {
  color: #050505;
  background: #ffffff;
  border-color: #ffffff;
}

.auth-email-continue:not(:disabled):active,
.auth-provider-button:not(:disabled):active,
.auth-signout:not(:disabled):active {
  transform: translateY(1px);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 15px 0;
  color: var(--auth-subtle);
  font: 650 10px/1 Inter, sans-serif;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
  height: 1px;
  flex: 1 1 auto;
  background: #2c2c2c;
  content: "";
}

.auth-provider-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.auth-provider-button {
  display: inline-flex;
  box-sizing: border-box;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 10px;
  color: #e7e7e7;
  background: #111111;
  border: 1px solid var(--auth-line);
  border-radius: 9px;
  font: 680 11px/1.25 Inter, sans-serif;
  text-align: center;
  cursor: pointer;
  transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.auth-provider-button:hover {
  color: #ffffff;
  background: #1b1b1b;
  border-color: var(--auth-line-strong);
}

.auth-provider-mark {
  display: inline-grid;
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  place-items: center;
  overflow: hidden;
  background: #f7f7f7;
  border-radius: 7px;
}

.auth-provider-mark img {
  display: block;
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.auth-account-panel {
  padding-top: 3px;
}

.auth-account-heading {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 14px;
  padding-right: 34px;
}

.auth-account-avatar,
.auth-header-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  overflow: hidden;
  color: #0b0b0b;
  background: var(--auth-accent);
  border-radius: 50%;
  font: 800 12px/1 Inter, sans-serif;
  text-transform: uppercase;
}

.auth-account-avatar {
  width: 44px;
  height: 44px;
  font-size: 13px;
}

.auth-header-avatar {
  width: 21px;
  height: 21px;
}

.auth-account-avatar img,
.auth-header-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.auth-account-copy {
  min-width: 0;
}

.auth-account-copy h2 {
  overflow: hidden;
  padding-right: 0;
  font-size: 24px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-account-copy p {
  margin: 6px 0 0;
  overflow: hidden;
  color: var(--auth-muted);
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-status button {
  min-height: 30px;
  padding: 0 9px;
  color: #bcbcbc;
  background: transparent;
  border: 1px solid #3b3b3b;
  border-radius: 8px;
  font: 700 10px/1 Inter, sans-serif;
  cursor: pointer;
}

.auth-status button:hover {
  color: #f5f5f5;
  background: rgba(255, 255, 255, 0.08);
  border-color: #707070;
}

.auth-signout {
  width: 100%;
  min-height: 39px;
  margin-top: 15px;
  color: #e7e7e7;
  background: transparent;
  border: 1px solid var(--auth-line);
  border-radius: 10px;
  font: 700 12px/1 Inter, sans-serif;
  cursor: pointer;
}

.auth-signout:hover {
  color: #ffffff;
  background: #1b1b1b;
  border-color: var(--auth-line-strong);
}

.auth-status {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 14px;
  padding: 9px 10px;
  color: #b8b8b8;
  background: #111111;
  border: 1px solid #303030;
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.45;
}

.auth-status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  margin-top: 5px;
  background: #898989;
  border-radius: 50%;
}

.auth-status [data-auth-status-text] {
  min-width: 0;
  flex: 1 1 auto;
}

.auth-status[data-state="pending"] .auth-status-dot {
  background: var(--auth-accent);
  animation: auth-status-pulse 900ms ease-in-out infinite;
}

.auth-status[data-state="success"] {
  color: #d0d0d0;
  border-color: #454545;
}

.auth-status[data-state="success"] .auth-status-dot {
  background: var(--auth-success);
}

.auth-status[data-state="error"] {
  color: #dedede;
  background: #171717;
  border-color: #515151;
}

.auth-status[data-state="error"] .auth-status-dot {
  background: var(--auth-danger);
}

@keyframes auth-status-pulse {
  0%, 100% { opacity: 0.42; }
  50% { opacity: 1; }
}

.auth-legal {
  margin: 16px 4px 0;
  color: var(--auth-subtle);
  font-size: 10px;
  line-height: 1.5;
  text-align: center;
}

.auth-legal a {
  color: #ababab;
  text-underline-offset: 2px;
}

.auth-trigger-account {
  max-width: 190px;
  align-items: center;
  gap: 7px;
}

.auth-trigger-account [data-auth-header-name] {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.part1-module .auth-trigger-account {
  display: inline-flex;
  padding: 0 11px;
}

.part1-module .auth-trigger-account[hidden] {
  display: none;
}

.terminal-profile-button.auth-terminal-trigger {
  display: inline-flex;
  width: auto;
  min-width: 70px;
  max-width: 154px;
  height: 34px;
  flex: 0 1 auto;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  color: #e8e8e8;
  background: #151515;
  border: 1px solid #3b3b3b;
  border-radius: 18px;
  font: 700 11px/1 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.terminal-profile-button.auth-terminal-trigger:hover {
  color: #ffffff;
  background: #202020;
  border-color: #5b5b5b;
}

.terminal-profile-button.auth-terminal-trigger [data-auth-terminal-label] {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-trigger:focus-visible,
.auth-close:focus-visible,
.auth-mode-tabs button:focus-visible,
.auth-email-input:focus-visible,
.auth-email-continue:focus-visible,
.auth-provider-button:focus-visible,
.auth-signout:focus-visible,
.auth-status button:focus-visible,
.terminal-profile-button.auth-terminal-trigger:focus-visible {
  outline: 2px solid var(--auth-accent);
  outline-offset: 2px;
}

.auth-mode-tabs button:disabled,
.auth-email-input:disabled,
.auth-email-continue:disabled,
.auth-provider-button:disabled,
.auth-signout:disabled,
.auth-status button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
}

@media (max-width: 820px) {
  .terminal-account-controls {
    display: flex;
    min-width: 0;
    margin-left: 2px;
  }

  .terminal-profile-button.auth-terminal-trigger {
    min-width: 64px;
    max-width: 112px;
    padding: 0 10px;
  }
}

@media (max-width: 560px) {
  .auth-dialog {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
    border-radius: 12px;
  }

  .auth-dialog-shell {
    padding: 22px 15px 18px;
  }

  .auth-methods h2 {
    padding-right: 30px;
    font-size: 21px;
  }

  .auth-subtitle {
    margin-bottom: 16px;
    font-size: 12px;
  }

  .auth-email-form,
  .auth-provider-stack {
    grid-template-columns: 1fr;
  }

  .auth-email-continue {
    width: 100%;
  }

  .terminal-chart-toolbar,
  .terminal-actions {
    display: flex;
    min-width: 0;
  }

  .terminal-chart-tool span {
    display: none;
  }

  .terminal-account-controls {
    flex: 0 0 auto;
    margin-left: 0;
  }

  .terminal-profile-button.auth-terminal-trigger {
    min-width: 58px;
    max-width: 92px;
    height: 32px;
    padding: 0 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-dialog[open],
  .auth-status[data-state="pending"] .auth-status-dot {
    animation: none;
  }
}
