/* Auth, account, and pricing pages */

.turnstile-hidden {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.auth-page,
.account-page,
.pricing-page {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  width: 100%;
  min-width: 0;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  overflow-x: clip;
}

.auth-card {
  max-width: 420px;
  margin: 4rem auto;
  padding: 2.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}

.auth-card h1 {
  font-size: 1.75rem;
  margin-bottom: 0.75rem;
}

.auth-lead {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

.auth-form {
  text-align: left;
  margin-bottom: 1rem;
}

.auth-field {
  margin-bottom: 1rem;
}

.auth-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.auth-optional {
  font-weight: 400;
  color: var(--muted);
}

.auth-field input,
.auth-field textarea {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 0.7rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  line-height: 1.5;
  appearance: none;
  -webkit-appearance: none;
}

.auth-field textarea {
  min-height: 8rem;
  resize: vertical;
}

.auth-field input:focus,
.auth-field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.auth-hint {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.auth-error {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 8px;
  color: var(--danger);
  font-size: 0.875rem;
  text-align: left;
}

.auth-switch {
  margin: 1rem 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.auth-switch a {
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
  color: var(--muted);
  font-size: 0.8rem;
}

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

.auth-divider span {
  flex-shrink: 0;
}

.btn-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.85rem 1.25rem;
  background: #fff;
  color: #1f2937;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-google:hover {
  opacity: 0.92;
}

.auth-sso-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.btn-github {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.85rem 1.25rem;
  background: #24292f;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

.btn-github:hover {
  background: #2f363d;
}

.auth-notice {
  padding: 1rem;
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 0.875rem;
  color: var(--muted);
  text-align: left;
}

.auth-foot {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.auth-foot a {
  color: var(--accent);
}

.account-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.account-profile {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.account-avatar {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 2px solid var(--border);
}

.account-avatar-initial {
  color: var(--accent);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1;
  user-select: none;
}

.account-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.account-email {
  color: var(--muted);
  font-size: 0.9rem;
}

.account-shell .page-subtabs-shell {
  margin-bottom: 1.5rem;
}

.account-main {
  max-width: 100%;
}

.account-shell .account-hero {
  margin-bottom: 1.25rem;
}

.account-billing-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.5;
  max-width: 36rem;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 1.5rem;
  min-width: 0;
}

.account-card--wide {
  grid-column: 1 / -1;
}

.ci-setup-steps {
  margin: 0 0 1rem 1.25rem;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.6;
}

.ci-setup-steps code {
  font-size: 0.8rem;
}

.workflow-box {
  position: relative;
}

.workflow-box .btn-sm {
  margin-bottom: 0.5rem;
}

.workflow-box pre {
  max-height: 320px;
  overflow: auto;
}

.workflow-textarea {
  width: 100%;
  max-width: 100%;
  min-height: 280px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.account-card {
  padding: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 0;
  max-width: 100%;
  overflow-wrap: break-word;
}

.account-card h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.plan-name {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.plan-tagline {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.usage-bars {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.usage-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.usage-track {
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.usage-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  max-width: 100%;
}

.usage-fill--api {
  background: var(--accent-2);
}

.usage-fill--stack {
  background: var(--warning, #d97706);
}

.usage-hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin: -0.35rem 0 0.75rem;
  line-height: 1.4;
}

.usage-reset {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.account-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.api-key-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--surface-2);
  border-radius: 8px;
  margin-bottom: 0.75rem;
  max-width: 100%;
  min-width: 0;
}

.api-key-box code {
  font-family: var(--mono);
  font-size: 0.75rem;
  word-break: break-all;
  overflow-wrap: anywhere;
  min-width: 0;
  flex: 1 1 auto;
}

.api-key-label {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0 0 1rem;
  overflow-wrap: break-word;
}

.api-key-label code {
  word-break: break-all;
  overflow-wrap: anywhere;
}

.api-key-label + .banner {
  margin-bottom: 1rem;
}

.api-key-meta {
  white-space: nowrap;
}

.api-key-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.api-key-row {
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.api-key-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.api-key-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.api-key-label-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.api-key-created {
  font-size: 0.7rem;
  color: var(--muted);
}

.api-key-slots-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-left: 0.5rem;
}

.api-key-row .api-key-box {
  margin-bottom: 0.5rem;
}

.api-key-row .regen-form {
  margin: 0;
}

.api-key-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.btn-danger-text {
  color: var(--danger);
}

.btn-danger-text:hover {
  color: #fca5a5;
  background: rgba(248, 113, 113, 0.1);
}

.api-key-empty {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 1rem;
}

.api-example {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--surface-2);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.55;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  color: var(--muted);
}

.api-key-locked {
  color: var(--muted);
  margin-bottom: 1rem;
}

.banner {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.banner-success {
  background: rgba(74, 222, 128, 0.12);
  border: 1px solid rgba(74, 222, 128, 0.3);
  color: var(--success);
}

.banner-error {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: var(--danger);
}

.pricing-hero {
  text-align: center;
  padding: 2rem 0 3rem;
}

.pricing-hero h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  margin-bottom: 1rem;
}

.pricing-lead {
  color: var(--muted);
  max-width: 640px;
  margin: 0 auto;
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 3rem;
}

.pricing-card {
  position: relative;
  padding: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
}

.pricing-card--featured {
  border-color: rgba(34, 211, 238, 0.4);
  box-shadow: 0 0 40px rgba(34, 211, 238, 0.08);
}

.pricing-badge {
  position: absolute;
  top: -0.6rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.2rem 0.75rem;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 999px;
}

.pricing-price {
  margin: 0.5rem 0 0.75rem;
}

.price-amount {
  font-size: 2rem;
  font-weight: 700;
}

.price-period {
  color: var(--muted);
  font-size: 0.9rem;
}

.pricing-tagline {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.pricing-features {
  list-style: none;
  flex: 1;
  margin-bottom: 1rem;
}

.pricing-features li {
  padding: 0.4rem 0;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border);
}

.feat-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
}

.pricing-vs {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
  line-height: 1.4;
}

.btn-block {
  width: 100%;
  text-align: center;
}

.btn-disabled {
  opacity: 0.6;
  pointer-events: none;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.pricing-more {
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  margin-bottom: 2rem;
}

.pricing-more h2 {
  margin-bottom: 0.5rem;
}

.pricing-more > p {
  color: var(--muted);
  max-width: 36rem;
  margin: 0 auto;
}

.pricing-more a {
  color: var(--accent);
}

.pricing-usage {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.regen-form {
  margin-bottom: 0.5rem;
}

.pricing-legal {
  margin-top: 2rem;
  border-top: none;
  padding-top: 0;
}

@media (max-width: 900px) {
  .auth-page,
  .account-page,
  .pricing-page {
    padding: 1.25rem 1rem 3rem;
  }

  .auth-card {
    margin: 2rem auto;
    padding: 1.75rem 1.25rem;
  }

  .account-hero {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .pricing-grid {
    grid-template-columns: 1fr;
    max-width: 22rem;
    margin: 0 auto;
  }

  .pricing-card--featured {
    order: -1;
  }

  .account-card {
    padding: 1.35rem;
  }

  .account-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .account-actions .btn,
  .account-actions form {
    width: 100%;
  }

  .account-actions form button {
    width: 100%;
  }
}

@media (max-width: 600px) {
  .pricing-hero h1 {
    font-size: clamp(1.5rem, 6vw, 2rem);
  }

  .account-page {
    padding: 1.25rem 0.85rem 3rem;
  }

  .account-card .scan-disclaimer {
    text-align: left;
  }

  .plan-name {
    line-height: 1.35;
  }

  .usage-row {
    flex-wrap: wrap;
  }

  .usage-row span:last-child {
    margin-left: auto;
  }

  .api-key-meta {
    white-space: normal;
    display: block;
    margin-top: 0.35rem;
  }

  .api-key-box {
    flex-direction: column;
    align-items: stretch;
  }

  .api-key-box .btn-sm {
    align-self: flex-start;
  }

  .ci-setup-steps {
    margin-left: 1rem;
    padding-right: 0;
  }

  .ci-setup-steps code {
    word-break: break-all;
    overflow-wrap: anywhere;
  }

  .workflow-box {
    max-width: 100%;
    min-width: 0;
  }

  .api-key-row-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
  }

  .api-key-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .api-key-actions .btn,
  .api-key-actions form {
    width: 100%;
  }

  .api-key-actions form button {
    width: 100%;
  }

  .api-example {
    font-size: 0.65rem;
  }

  .workflow-textarea {
    min-height: 200px;
  }
}

/* Custom rules page — reuse auth-field styling from login/contact */
.rules-page .rules-grid {
  grid-template-columns: 1fr;
  max-width: 720px;
  margin: 0 auto;
}

.rules-page .rules-lead {
  color: var(--muted);
  font-size: 0.9rem;
  margin: -0.35rem 0 1.25rem;
  line-height: 1.5;
}

.rules-page .rules-form {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  min-width: 0;
}

.rules-page .rules-form .auth-field {
  margin-bottom: 1rem;
  width: 100%;
  min-width: 0;
}

.rules-page .rules-form .auth-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--text);
}

.rules-page .rules-form .auth-field input,
.rules-page .rules-form .auth-field textarea,
.rules-page .rules-form .auth-field select,
.rules-page .rules-form .field-select {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 0.7rem 0.85rem;
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  line-height: 1.5;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  margin: 0;
  color-scheme: dark;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.rules-page .rules-form .auth-field select,
.rules-page .rules-form .field-select {
  cursor: pointer;
  padding-right: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px 16px;
}

.rules-page .rules-form .auth-field input:focus,
.rules-page .rules-form .auth-field textarea:focus,
.rules-page .rules-form .auth-field select:focus,
.rules-page .rules-form .field-select:focus {
  outline: none;
  border-color: rgba(34, 211, 238, 0.55);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
}

.rules-page .rules-form .auth-field textarea {
  min-height: 5.5rem;
  resize: vertical;
}

.rules-page .rules-form .auth-field--textarea textarea {
  min-height: 6.5rem;
}

.rules-page .rules-mono,
.rules-page .rules-pattern,
.rules-page .rules-test-result {
  font-family: var(--mono);
  font-size: 0.85rem;
}

.rules-page .rules-field-grid {
  display: grid;
  gap: 0 1rem;
  width: 100%;
  min-width: 0;
}

.rules-page .rules-field-grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.rules-page .rules-field-grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.rules-page .rules-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  margin: 0.25rem 0 1rem;
  padding: 0.85rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.rules-page .rules-check {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.rules-page .rules-check input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.rules-page .rules-actions {
  margin-top: 0.25rem;
  gap: 0.75rem;
}

.rules-page .rules-form-msg {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--danger);
}

.rules-page .rules-test-result {
  margin: -0.25rem 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  max-height: 240px;
  overflow-y: auto;
}

.rules-page .rules-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.rules-page .rules-list--spaced {
  margin-top: 1.5rem;
}

.rules-page .rules-list-item {
  padding: 1rem 0;
  border-top: 1px solid var(--border);
}

.rules-page .rules-list-item:first-child {
  border-top: none;
  padding-top: 0;
}

.rules-page .rules-list-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.rules-page .rules-pattern {
  display: block;
  margin: 0.35rem 0 0.75rem;
  padding: 0.65rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  word-break: break-all;
  overflow-wrap: anywhere;
}

.rules-page .rules-waiver-reason {
  color: var(--muted);
  font-size: 0.875rem;
  margin: 0 0 0.5rem;
}

@media (max-width: 640px) {
  .rules-page .rules-field-grid--2,
  .rules-page .rules-field-grid--3 {
    grid-template-columns: 1fr;
  }

  .rules-page .account-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .rules-page .account-actions .btn {
    width: 100%;
  }
}
