/* ==========================================================================
   Reaction Axis — Index Modals (Account & Privacy Policy)
   Scoped strictly to .ra-modal / .ra-modal-* / #ra-toast.ra-modal-toast
   ========================================================================== */

.ra-modal-open {
  overflow: hidden;
}

.ra-modal {
  position: fixed;
  inset: 0;
  z-index: 160;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.36);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.ra-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.ra-modal[hidden],
.ra-modal [hidden] {
  display: none !important;
}

.ra-modal-dialog {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: min(86vh, 760px);
  display: flex;
  flex-direction: column;
  background: #ffffff;
  color: #111111;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.14), 0 4px 16px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  transform: translateY(10px) scale(0.985);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.ra-modal.is-open .ra-modal-dialog {
  transform: translateY(0) scale(1);
}

.ra-modal-dialog--wide {
  max-width: 680px;
}

/* Header */

.ra-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 24px 8px;
  border-bottom: none;
  flex: 0 0 auto;
}

.ra-modal#privacy-modal .ra-modal-header {
  border-bottom: 1px solid #f0f0f0;
  padding-bottom: 14px;
  align-items: flex-start;
}

.ra-modal-title-group {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.ra-modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #111111;
  margin: 0;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.ra-modal-close {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #525252;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.ra-modal-close svg {
  width: 16px;
  height: 16px;
  display: block;
}

.ra-modal-close:hover {
  background: #f3f3f3;
  color: #111111;
  border-color: #e2e2e2;
}

.ra-modal-close:active {
  background: #eaeaea;
}

.ra-modal-close:focus-visible {
  outline: 2px solid #0067c0;
  outline-offset: 2px;
}

/* Body & Footer */

.ra-modal-body {
  padding: 14px 24px 22px;
  overflow-y: auto;
  flex: 1 1 auto;
  display: grid;
  gap: 16px;
}

.ra-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 24px 16px;
  border-top: 1px solid #f2f2f2;
  background: transparent;
  font-size: 12px;
  color: #767676;
  flex: 0 0 auto;
}

.ra-modal-subtle-link {
  background: none;
  border: none;
  padding: 2px 0;
  font: inherit;
  font-size: 12px;
  color: #767676;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 2px;
  transition: color 0.16s ease, text-decoration-color 0.16s ease;
}

.ra-modal-subtle-link:hover {
  color: #111111;
  text-decoration-color: rgba(17, 17, 17, 0.35);
}

.ra-modal-subtle-link:focus-visible {
  outline: 2px solid #0067c0;
  outline-offset: 2px;
  border-radius: 3px;
}

/* ==========================================================================
   Modal Account Components (Scoped to .ra-modal)
   ========================================================================== */

.ra-modal #account-login-view {
  display: grid;
  gap: 12px;
}

.ra-modal #account-dashboard-view {
  display: grid;
  gap: 14px;
}

.ra-modal .account-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 36px 20px;
  color: #525252;
  font-size: 0.92rem;
}

.ra-modal .account-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #d4d4d4;
  border-top-color: #0067c0;
  animation: ra-modal-spin 0.8s linear infinite;
  flex: 0 0 auto;
}

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

.ra-modal .account-alert {
  padding: 10px 13px;
  border-radius: 8px;
  border: 1px solid #e5e5e5;
  font-size: 0.86rem;
  line-height: 1.5;
}

.ra-modal .account-alert-error {
  background: #fff1f2;
  border-color: rgba(225, 29, 72, 0.28);
  color: #9f1239;
}

.ra-modal .account-alert-success {
  background: #ecfdf5;
  border-color: rgba(16, 185, 129, 0.3);
  color: #065f46;
}

.ra-modal .account-login-body {
  width: 100%;
  display: grid;
  gap: 16px;
}

.ra-modal .account-google-section {
  display: grid;
  gap: 16px;
}

.ra-modal .account-google-btn-wrap {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.ra-modal .account-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #767676;
  font-size: 0.82rem;
  font-weight: 500;
}

.ra-modal .account-divider::before,
.ra-modal .account-divider::after {
  content: "";
  flex: 1 1 0;
  height: 1px;
  background: #e5e5e5;
}

.ra-modal .account-form {
  display: grid;
  gap: 16px;
}

.ra-modal .account-field {
  display: grid;
  gap: 6px;
}

.ra-modal .account-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: #525252;
}

.ra-modal .account-input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.ra-modal .account-input {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 13px;
  border-radius: 8px;
  border: 1px solid #d4d4d4;
  background: #ffffff;
  color: #111111;
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1.4;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ra-modal .account-input::placeholder {
  color: #8c8c8c;
}

.ra-modal .account-input:focus {
  outline: none;
  border-color: #0067c0;
  box-shadow: 0 0 0 3px rgba(0, 103, 192, 0.14);
}

.ra-modal .account-code-input {
  max-width: none;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-align: left;
}

.ra-modal .account-send-btn {
  flex-shrink: 0;
  height: 42px;
  border-radius: 8px;
  min-width: 112px;
  font-weight: 500;
}

.ra-modal .account-form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 2px;
}

.ra-modal .account-submit-btn {
  width: 100%;
}

/* Buttons & Badges inside Modal */

.ra-modal .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 0.885rem;
  font-weight: 600;
  line-height: 1.25;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.ra-modal .btn:active:not(:disabled) {
  transform: translateY(0.5px);
}

.ra-modal .btn:focus-visible {
  outline: 2px solid #0067c0;
  outline-offset: 2px;
}

.ra-modal .btn:disabled,
.ra-modal .account-send-btn:disabled,
.ra-modal .account-submit-btn:disabled {
  opacity: 0.58;
  cursor: not-allowed;
  transform: none;
}

.ra-modal .btn-primary {
  background: #ffffff;
  color: #1b1b1b;
  border: 1px solid #cccccc;
  border-bottom-color: #b8b8b8;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  font-weight: 500;
  height: 44px;
  border-radius: 8px;
  transition:
    background-color 0.26s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.26s cubic-bezier(0.22, 1, 0.36, 1),
    color 0.22s ease,
    box-shadow 0.3s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}

.ra-modal .btn-primary:hover:not(:disabled),
.ra-modal .btn-primary:focus-visible:not(:disabled) {
  background: #0067c0;
  color: #ffffff;
  border-color: #0067c0;
  border-bottom-color: #005a9e;
  box-shadow: 0 6px 18px rgba(0, 103, 192, 0.22), 0 1px 4px rgba(0, 103, 192, 0.12);
  transform: translateY(-1px);
}

.ra-modal .btn-primary:active:not(:disabled) {
  background: #004c8c;
  border-color: #004c8c;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 103, 192, 0.18);
  transform: translateY(0.5px);
}

.ra-modal .btn-secondary {
  background: #ffffff;
  color: #1b1b1b;
  border-color: #cccccc;
  border-bottom-color: #b8b8b8;
}

.ra-modal .btn-secondary:hover:not(:disabled) {
  background: #f3f3f3;
  border-color: #bfbfbf;
  color: #111111;
}

.ra-modal .btn-sm {
  padding: 6px 11px;
  font-size: 0.8125rem;
}

.ra-modal .btn-lg {
  padding: 11px 20px;
  font-size: 0.94rem;
}

.ra-modal .btn-danger-ghost {
  background: transparent;
  color: #be123c;
  border-color: rgba(225, 29, 72, 0.32);
}

.ra-modal .btn-danger-ghost:hover:not(:disabled) {
  background: #fff1f2;
  border-color: rgba(225, 29, 72, 0.55);
  color: #9f1239;
}

.ra-modal .badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.35;
}

.ra-modal .badge-cyan {
  background: rgba(0, 103, 192, 0.09);
  color: #005a9e;
  border: 1px solid rgba(0, 103, 192, 0.22);
}

.ra-modal .badge-navy {
  background: #f3f4f6;
  color: #1f2937;
  border: 1px solid #e5e5e5;
}

/* Lightweight Account Cards inside Modal */

.ra-modal .account-card {
  background: #fafafa;
  border: 1px solid #e5e5e5;
  border-radius: 10px;
  padding: 16px;
}

.ra-modal .account-card-head h2,
.ra-modal .account-devices-title-row h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  color: #111111;
}

.ra-modal .account-card-head p,
.ra-modal .account-devices-head p {
  margin: 4px 0 0;
  font-size: 0.84rem;
  line-height: 1.5;
  color: #525252;
}

.ra-modal .account-profile-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.ra-modal .account-profile-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.ra-modal .account-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #0067c0;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.98rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ra-modal .account-profile-info {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.ra-modal .account-profile-email-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ra-modal .account-profile-email {
  font-size: 0.94rem;
  font-weight: 650;
  color: #111111;
  word-break: break-all;
}

.ra-modal .account-profile-meta {
  font-size: 0.8rem;
  color: #525252;
}

.ra-modal .account-devices-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.ra-modal .account-devices-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ra-modal .device-list {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.ra-modal .device-empty {
  margin: 0;
  padding: 16px;
  text-align: center;
  border-radius: 8px;
  background: #ffffff;
  border: 1px dashed #cccccc;
  color: #525252;
  font-size: 0.86rem;
}

.ra-modal .device-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #e5e5e5;
  background: #ffffff;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.ra-modal .device-row.is-current {
  background: rgba(0, 103, 192, 0.05);
  border-color: rgba(0, 103, 192, 0.25);
}

.ra-modal .device-icon {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: #f7f7f7;
  border: 1px solid #e5e5e5;
  color: #0067c0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ra-modal .device-row.is-current .device-icon {
  background: #ffffff;
}

.ra-modal .device-info {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  gap: 3px;
}

.ra-modal .device-name-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.ra-modal .device-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #111111;
  word-break: break-word;
}

.ra-modal .device-meta {
  font-size: 0.78rem;
  color: #525252;
  line-height: 1.45;
  word-break: break-word;
}

.ra-modal .device-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ra-modal .device-rename-form {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ra-modal .device-rename-input {
  flex: 1 1 150px;
  padding: 5px 9px;
  font-size: 0.85rem;
}

.ra-modal .callout {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #e5e5e5;
  font-size: 0.83rem;
  line-height: 1.55;
  color: #525252;
}

.ra-modal .callout-info {
  background: #f5f8fc;
  border-color: rgba(0, 103, 192, 0.16);
}

.ra-modal .callout strong {
  display: block;
  margin-bottom: 3px;
  font-size: 0.85rem;
  font-weight: 650;
  color: #1b1b1b;
}

.ra-modal .callout p {
  margin: 0;
}

/* ==========================================================================
   Modal Privacy Policy Components (Scoped to .ra-modal)
   ========================================================================== */

.ra-modal .privacy-updated {
  margin: 0;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.8rem;
  color: #767676;
}

.ra-modal .privacy-section {
  padding: 14px 16px;
  border-radius: 9px;
  border: 1px solid #e8e8e8;
  background: #fafafa;
  display: grid;
  gap: 8px;
}

.ra-modal .privacy-section h3 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 650;
  color: #111111;
  line-height: 1.4;
}

.ra-modal .privacy-section p {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.62;
  color: #404040;
}

.ra-modal .privacy-section ul {
  margin: 2px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  font-size: 0.875rem;
  line-height: 1.6;
  color: #404040;
}

.ra-modal .privacy-section a {
  color: #0067c0;
  font-weight: 500;
  text-decoration: none;
}

.ra-modal .privacy-section a:hover {
  color: #005a9e;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ==========================================================================
   Modal Toast (#ra-toast.ra-modal-toast)
   ========================================================================== */

#ra-toast.ra-modal-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(14px);
  z-index: 220;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(92vw, 480px);
  padding: 10px 18px;
  background: #ffffff;
  color: #1b1b1b;
  border: 1px solid #cccccc;
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.14);
  font-size: 13.5px;
  font-weight: 500;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

#ra-toast.ra-modal-toast.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   Mobile Responsive
   ========================================================================== */

@media (max-width: 600px) {
  .ra-modal {
    padding: 12px;
  }

  .ra-modal-dialog {
    max-height: 90vh;
  }

  .ra-modal-header {
    padding: 16px;
  }

  .ra-modal-body {
    padding: 16px;
  }

  .ra-modal-footer {
    padding: 12px 16px;
  }

  .ra-modal .account-input-row {
    flex-direction: column;
  }

  .ra-modal .account-code-input {
    max-width: none;
    width: 100%;
  }

  .ra-modal .device-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .ra-modal .device-actions {
    width: 100%;
    justify-content: flex-end;
  }
}
