.legal-row {
  display: grid;
  grid-template-columns: minmax(170px, 0.35fr) 1fr;
  gap: 12px;
  padding: 12px;
  border: 1px solid #e2e7f2;
  border-radius: 14px;
}

.legal-row strong {
  color: var(--ink);
}

.auth-modal.is-open {
  display: grid;
}

[hidden] {
  display: none !important;
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 28px;
  background: rgba(10, 16, 28, 0.78);
  backdrop-filter: blur(18px);
}

.image-viewer.is-open {
  display: grid;
}

.image-viewer img {
  display: block;
  max-width: min(94vw, 1180px);
  max-height: 88vh;
  object-fit: contain;
  border-radius: 18px;
  background: #eef5ff;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.32);
  cursor: zoom-out;
}

.image-viewer-close {
  position: fixed;
  top: 18px;
  right: 18px;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: #fff;
  border: 0;
  border-radius: 50%;
  background: rgba(17, 24, 39, 0.72);
  font-size: 30px;
  line-height: 1;
}

.auth-card {
  position: relative;
  width: min(420px, 100%);
  padding: 28px;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(17, 24, 39, 0.26);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #f1f2f8;
  font-size: 22px;
}

.auth-card h2 {
  margin-top: 0;
}

.auth-card p {
  color: var(--muted);
  line-height: 1.45;
}

.auth-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 18px 0;
}

.auth-options button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-weight: 750;
}

.email-login {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.email-login span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.email-login input {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: 0;
}

.auth-message {
  min-height: 20px;
  margin: 4px 0 12px;
  color: #1f5fbd;
  font-size: 14px;
  font-weight: 650;
}

.auth-message.is-error {
  color: #dc2626;
}

.primary-login {
  width: 100%;
}

.secondary-login {
  background: #eef5ff;
  color: var(--blue-dark);
  box-shadow: inset 0 0 0 1px #c6dcff;
}

.auth-separator {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.auth-separator::before,
.auth-separator::after {
  content: "";
  height: 1px;
  background: var(--line);
}

.account-status-line {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  padding: 14px;
  border-radius: 16px;
  background: #f3f7ff;
}

.account-status-line strong,
.account-status-line span {
  display: block;
}

.account-status-line strong {
  margin-bottom: 2px;
}

.account-status-line span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.account-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.account-support-id {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -4px 0 12px;
  padding: 10px 14px;
  border: 1px solid #e2e9f8;
  border-radius: 12px;
  background: #f8fbff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.account-support-id strong {
  color: var(--ink);
  font-size: 15px;
  letter-spacing: 0.08em;
}

.account-stats div,
.subscription-status {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid #dce5f7;
  border-radius: 16px;
  background: #fff;
}

.account-stats span,
.subscription-status span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.account-stats strong,
.subscription-status strong {
  font-size: 24px;
}

.subscription-status p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.telegram-link-status {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid #dce5f7;
  border-radius: 16px;
  background: #f8fbff;
}

.telegram-link-status strong,
.telegram-link-status span {
  display: block;
}

.telegram-link-status strong {
  margin-bottom: 3px;
}

.telegram-link-status span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.subscription-manage {
  margin-top: 12px;
}

.subscription-manage-toggle,
.muted-action {
  width: 100%;
  min-height: 38px;
  color: #42506a;
  border: 1px solid #dce5f7;
  border-radius: 12px;
  background: #fff;
  font-size: 14px;
  font-weight: 800;
}

.subscription-manage-toggle {
  text-align: left;
  padding: 0 14px;
}

.subscription-manage-panel {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid #e2e9f8;
  border-radius: 16px;
  background: #f8fbff;
}

.subscription-manage-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.muted-action {
  color: #526176;
  background: #fff;
}

.muted-action.danger {
  color: #b42318;
  border-color: #ffd1ce;
  background: #fff7f7;
}

.retention-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  background: #eef5ff;
}

.retention-panel strong {
  color: var(--blue-dark);
}

.retention-actions {
  display: grid;
  gap: 8px;
}

.subscription-action-message {
  min-height: 18px;
  color: var(--blue-dark) !important;
  font-weight: 750;
}

.subscription-action-message.is-error {
  color: #b42318 !important;
}

.account-plan-link {
  display: grid;
  place-items: center;
  margin-top: 14px;
  text-decoration: none;
}

/* Keep account actions visually consistent and keep provider marks centered. */
.account-card .account-status-line .provider-icon {
  display: inline-grid;
  flex: 0 0 44px;
  place-items: center;
  text-align: center;
  line-height: 1;
}

.account-card .account-plan-link,
.account-card .account-logout {
  box-sizing: border-box;
  min-height: 52px;
  border-radius: 999px;
  font-size: 16px;
  line-height: 1;
}

.account-card .account-logout {
  margin-top: 8px;
}

.primary-login:disabled {
  cursor: wait;
  opacity: 0.72;
}

@media (max-width: 760px) {
  .app-header {
    min-height: 70px;
    padding: 0 12px;
  }

  .brand-name {
    font-size: 18px;
  }

  .top-nav {
    gap: 8px;
    font-size: 13px;
  }

  .top-nav a,
  .subscription-button {
    min-height: 34px;
    padding: 0 12px;
  }

  .account-button {
    max-width: 170px;
  }

  #accountLabel {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .home-shell {
    width: calc(100% - 28px);
    padding-top: 54px;
    --header-height: 70px;
    --hero-top-offset: 54px;
  }

  .guest-banner,
  .section-heading,
  .account-preview {
    grid-template-columns: 1fr;
    align-items: stretch;
    flex-direction: column;
  }

  .guest-banner {
    display: grid;
  }

  .conversation-panel {
    min-height: calc(230px + var(--hero-top-offset, 54px));
    max-height: calc(420px + var(--hero-top-offset, 54px));
    padding: calc(16px + var(--hero-top-offset, 54px)) 14px 20px;
  }

  .chat-entry {
    max-width: 94%;
  }

  .result-card {
    width: min(360px, 100%);
  }

  .result-card img {
    max-height: 300px;
  }

  .composer-box {
    min-height: 128px;
    padding: 20px 18px 16px;
    border-radius: 10px 10px 22px 22px;
  }

  .composer-box > span,
  textarea {
    font-size: 16px;
  }

  .mode-switch {
    width: 100%;
  }

  .generation-controls {
    width: 100%;
    margin-top: 24px;
  }

  .size-select {
    width: 100%;
    justify-content: space-between;
  }

  .template-grid,
  .account-preview {
    grid-template-columns: 1fr;
  }

  .pricing-intro {
    grid-column: auto;
  }

  .credits-card,
  .free-card {
    grid-column: auto;
  }

  .credit-list {
    grid-template-columns: 1fr;
  }

  .account-stats {
    grid-template-columns: 1fr;
  }

  .site-footer {
    padding: 30px 16px 36px;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .legal-shell {
    width: calc(100% - 24px);
    padding-top: 26px;
  }

  .legal-document {
    padding: 22px;
    border-radius: 20px;
  }

  .legal-row {
    grid-template-columns: 1fr;
  }
}
