.account-sync-btn,
.account-profile-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: auto;
  min-width: 40px;
  height: 36px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border-color, rgba(17, 24, 39, 0.12));
  border-radius: 999px;
  background: var(--panel-bg, rgba(255, 255, 255, 0.88));
  color: var(--text-main, #1f2937);
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  order: 100;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
}

.account-sync-btn:hover,
.account-profile-trigger:hover {
  transform: none;
}

.account-sync-btn.is-signed-in,
.account-profile-trigger.is-signed-in {
  color: #047857;
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(236, 253, 245, 0.92);
}

.account-sync-avatar {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
  font-size: 0.78rem;
  font-weight: 800;
}

.account-sync-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: none;
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(6px);
}

.account-sync-backdrop.active {
  display: block;
}

.account-sync-panel {
  position: fixed;
  z-index: 9501;
  left: 50%;
  top: 50%;
  width: min(92vw, 480px);
  max-height: min(86vh, 720px);
  overflow: auto;
  transform: translate(-50%, -50%);
  display: none;
  border: 1px solid var(--border-color, rgba(17, 24, 39, 0.12));
  border-radius: 16px;
  background: var(--panel-bg, #ffffff);
  color: var(--text-main, #111827);
  box-shadow: 0 26px 70px rgba(15, 23, 42, 0.22);
}

.account-sync-panel.active {
  display: block;
}

.account-sync-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--border-color, rgba(17, 24, 39, 0.1));
}

.account-sync-head h3,
.account-sync-root h4 {
  margin: 0;
  font-size: 1.05rem;
}

.account-sync-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.16);
  color: inherit;
  cursor: pointer;
  font-size: 1.2rem;
}

.account-sync-body {
  padding: 16px 20px 20px;
}

.account-sync-root {
  display: grid;
  gap: 12px;
}

.account-sync-embedded {
  margin-top: 0 !important;
  margin-bottom: 16px;
  padding: 0;
  background: transparent;
  border: 0;
}

.account-sync-install-card {
  margin-top: 16px;
}

.account-sync-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.account-sync-title-row p,
.account-sync-note {
  margin: 4px 0 0;
  color: var(--text-muted, #64748b);
  font-size: 0.88rem;
  line-height: 1.55;
}

.account-sync-status {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(59, 130, 246, 0.1);
  color: #1d4ed8;
  font-size: 0.88rem;
  line-height: 1.45;
}

.account-sync-status.is-ok {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
}

.account-sync-status.is-warn {
  background: rgba(245, 158, 11, 0.14);
  color: #92400e;
}

.account-sync-status.is-error {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}

.account-sync-form {
  display: grid;
  gap: 10px;
}

.account-sync-form label {
  display: grid;
  gap: 5px;
  color: var(--text-muted, #64748b);
  font-size: 0.82rem;
  font-weight: 700;
}

.account-sync-form input {
  width: 100%;
  min-height: 42px;
  box-sizing: border-box;
  border: 1px solid var(--border-color, rgba(17, 24, 39, 0.14));
  border-radius: 10px;
  padding: 8px 11px;
  background: var(--input-bg, #ffffff);
  color: var(--text-main, #111827);
  font-size: 0.95rem;
}

.account-sync-form input:disabled {
  color: var(--text-muted, #64748b);
  background: rgba(148, 163, 184, 0.12);
}

.account-sync-form input.is-locked {
  cursor: not-allowed;
  border-style: dashed;
}

.account-sync-field-note {
  color: var(--text-muted, #64748b);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.45;
}

.account-sync-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 2px;
}

.account-sync-actions button,
.account-sync-device-row button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0 13px;
  font-weight: 700;
  cursor: pointer;
}

.account-sync-actions button:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.account-sync-primary {
  background: var(--primary-color, #2563eb);
  color: #ffffff;
}

.account-sync-secondary,
.account-sync-device-row button {
  background: rgba(148, 163, 184, 0.16);
  color: var(--text-main, #1f2937);
  border-color: var(--border-color, rgba(17, 24, 39, 0.12)) !important;
}

.account-sync-danger {
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.22) !important;
}

.account-sync-divider {
  height: 1px;
  margin: 4px 0 2px;
  background: var(--border-color, rgba(17, 24, 39, 0.1));
}

.account-sync-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.account-sync-kpis span {
  display: grid;
  gap: 3px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-muted, #64748b);
  font-size: 0.74rem;
}

.account-sync-kpis strong {
  color: var(--text-main, #111827);
  font-size: 1rem;
}

.account-sync-device-list {
  display: grid;
  gap: 8px;
}

.account-sync-device-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border-color, rgba(17, 24, 39, 0.1));
  border-radius: 12px;
  background: rgba(148, 163, 184, 0.08);
}

.account-sync-device-row span {
  display: grid;
  gap: 2px;
}

.account-sync-device-row small {
  color: var(--text-muted, #64748b);
  font-size: 0.76rem;
}

.account-sync-device-row button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.account-sync-footnote {
  margin-top: 2px;
}

.account-sync-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9600;
  max-width: min(92vw, 360px);
  display: none;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.92);
  color: #ffffff;
  box-shadow: 0 16px 42px rgba(15, 23, 42, 0.22);
  font-size: 0.9rem;
  line-height: 1.45;
}

.account-sync-toast.active {
  display: block;
}

.account-posting-hint {
  padding: 9px 11px;
  border-radius: 12px;
  background: rgba(37, 99, 235, 0.08);
  color: #1d4ed8;
  font-size: 0.86rem;
  font-weight: 700;
}

@media (max-width: 720px) {
  .account-sync-btn {
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 999px;
    font-size: 0;
  }

  .account-sync-btn .account-sync-avatar {
    font-size: 0.78rem;
  }

  .account-sync-panel {
    top: auto;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 88vh;
    border-radius: 18px 18px 0 0;
    transform: none;
  }

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

  .account-sync-device-row {
    align-items: stretch;
    flex-direction: column;
  }
}

/* v238: keep the account pill readable in tablet top bars. */
.top-bar .account-sync-btn,
.top-bar .account-profile-trigger,
.top-bar .settings-btn.account-profile-trigger,
.top-bar .settings-btn.account-sync-btn {
  width: 44px !important;
  min-width: 44px !important;
  max-width: 44px !important;
  height: 44px !important;
  min-height: 44px !important;
  padding: 0 !important;
  border-radius: 999px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0 !important;
  overflow: visible !important;
  white-space: nowrap !important;
  font-size: 0 !important;
  line-height: 1 !important;
}

.top-bar .account-sync-btn span,
.top-bar .account-profile-trigger span {
  flex: 0 0 auto;
}

.top-bar .account-sync-btn span:not(.account-sync-avatar),
.top-bar .account-profile-trigger span:not(.account-sync-avatar) {
  display: none !important;
}

.top-bar .account-sync-avatar {
  width: 22px;
  min-width: 22px;
  height: 22px;
}

@media (max-width: 768px) {
  .top-bar .account-sync-btn,
  .top-bar .account-profile-trigger,
  .top-bar .settings-btn.account-profile-trigger,
  .top-bar .settings-btn.account-sync-btn {
    width: 42px !important;
    min-width: 42px !important;
    max-width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;
    padding: 0 !important;
    font-size: 0 !important;
  }

  .top-bar .account-sync-btn span:not(.account-sync-avatar),
  .top-bar .account-profile-trigger span:not(.account-sync-avatar) {
    display: none !important;
  }

  .top-bar .account-sync-avatar {
    width: 22px;
    min-width: 22px;
    height: 22px;
    font-size: 0.78rem;
  }
}
