.account-sync-btn,
.account-profile-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-main, #1f2937);
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  order: 100;
  box-shadow: none;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.account-sync-btn:hover,
.account-profile-trigger:hover {
  background: rgba(0, 0, 0, 0.06);
  transform: scale(1.05);
}

.account-sync-btn.is-signed-in,
.account-profile-trigger.is-signed-in {
  color: inherit;
  border: none;
  background: transparent;
  box-shadow: none;
}

.account-sync-avatar {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(139, 92, 246, 0.12);
  color: #7c3aed;
  font-size: 0.78rem;
  font-weight: 800;
}

.account-sync-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000100;
  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: 10000120;
  left: 50%;
  top: 50%;
  width: min(92vw, 418px);
  max-height: min(86vh, 720px);
  overflow: auto;
  transform: translate(-50%, -50%);
  display: none;
  border: 1px solid var(--border-color, rgba(139, 92, 246, 0.16));
  border-radius: 20px;
  background: var(--panel-bg, #ffffff);
  color: var(--text-main, #111827);
  box-shadow: 0 24px 60px -12px rgba(124, 58, 237, 0.18), 0 12px 28px -6px rgba(0, 0, 0, 0.08);
}

.account-settings-modal {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: min(520px, calc(100vw - 48px)) !important;
  max-width: 540px !important;
  max-height: min(760px, 86vh) !important;
  border-radius: 22px !important;
  box-shadow: 0 24px 60px -12px rgba(124, 58, 237, 0.22), 0 12px 28px -6px rgba(0, 0, 0, 0.12) !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
  z-index: 10000110 !important;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.account-settings-modal:not(.active) {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: translate(-50%, -50%) scale(0.96) !important;
}

.account-settings-modal.active {
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: translate(-50%, -50%) scale(1) !important;
}

/* Hide legacy modal header */
.account-settings-modal .modal-header {
  display: none !important;
}

/* Apple-style circular close button */
.account-settings-modal .apple-modal-close-btn,
.account-settings-modal .modal-close-btn {
  position: absolute !important;
  top: 14px !important;
  right: 14px !important;
  width: 30px !important;
  height: 30px !important;
  border-radius: 50% !important;
  border: none !important;
  background: rgba(142, 142, 147, 0.16) !important;
  color: var(--text-muted, #64748b) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  padding: 0 !important;
  z-index: 100 !important;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
  -webkit-tap-highlight-color: transparent !important;
  outline: none !important;
}

.account-settings-modal .apple-modal-close-btn:hover,
.account-settings-modal .modal-close-btn:hover {
  background: rgba(142, 142, 147, 0.28) !important;
  color: var(--text-main, #1e293b) !important;
  transform: scale(1.06) !important;
}

.account-settings-modal .apple-modal-close-btn:active,
.account-settings-modal .modal-close-btn:active {
  background: rgba(142, 142, 147, 0.36) !important;
  transform: scale(0.92) !important;
}

.account-settings-modal .apple-modal-close-btn svg,
.account-settings-modal .modal-close-btn svg {
  width: 14px !important;
  height: 14px !important;
  stroke: currentColor !important;
  stroke-width: 2.4 !important;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
  display: block !important;
}

body.dark-theme .account-settings-modal .apple-modal-close-btn,
body.dark-theme .account-settings-modal .modal-close-btn,
body[data-theme="dark"] .account-settings-modal .apple-modal-close-btn,
body[data-theme="dark"] .account-settings-modal .modal-close-btn {
  background: rgba(255, 255, 255, 0.14) !important;
  color: rgba(255, 255, 255, 0.72) !important;
}

body.dark-theme .account-settings-modal .apple-modal-close-btn:hover,
body.dark-theme .account-settings-modal .modal-close-btn:hover,
body[data-theme="dark"] .account-settings-modal .apple-modal-close-btn:hover,
body[data-theme="dark"] .account-settings-modal .modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.24) !important;
  color: #ffffff !important;
}

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

.account-sync-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border-color, rgba(139, 92, 246, 0.1));
}

.account-sync-head h3 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 750;
  color: var(--text-main, #111827);
  letter-spacing: -0.01em;
}

.account-sync-close {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: var(--btn-ghost-bg, rgba(139, 92, 246, 0.08));
  color: var(--text-muted, #7c3aed);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.account-sync-close:hover {
  background: rgba(139, 92, 246, 0.18);
  color: #6d28d9;
  transform: rotate(90deg);
}

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

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

.account-sync-embedded {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  padding: 16px 16px 18px !important;
  border-radius: 22px 22px 16px 16px !important;
  background: linear-gradient(180deg, rgba(245, 243, 255, 0.9) 0%, rgba(255, 255, 255, 0.96) 100%) !important;
  border: 1px solid rgba(139, 92, 246, 0.15) !important;
  border-top: none !important;
  box-shadow: 0 4px 16px -4px rgba(124, 58, 237, 0.08) !important;
}

.account-settings-modal .modal-body {
  padding: 0 0 24px 0 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
}

.account-settings-modal .settings-card {
  padding: 14px 16px !important;
  margin: 0 16px !important;
  border-radius: 14px !important;
  background: var(--panel-bg, #ffffff) !important;
  border: 1px solid var(--border-color, rgba(139, 92, 246, 0.1)) !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02) !important;
}

@media (min-width: 769px) and (max-width: 1023px) {
  .account-settings-modal {
    width: min(480px, calc(100vw - 40px)) !important;
    max-width: 500px !important;
    max-height: min(740px, 85vh) !important;
    border-radius: 20px !important;
  }
}

@media (max-width: 768px) {
  .account-settings-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 100vw !important;
    height: 100% !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    min-height: 100dvh !important;
    margin: 0 !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    transform: none !important;
    background: var(--panel-bg, #ffffff) !important;
    display: none !important;
    flex-direction: column !important;
    overflow: hidden !important;
    z-index: 10000110 !important;
  }

  .account-settings-modal:not(.active) {
    transform: none !important;
  }

  .account-settings-modal.active {
    display: flex !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: none !important;
  }

  .account-settings-modal .apple-modal-close-btn,
  .account-settings-modal .modal-close-btn {
    top: calc(14px + env(safe-area-inset-top, 0px)) !important;
    right: 14px !important;
  }

  .account-settings-modal .account-sync-embedded {
    border-radius: 0 0 22px 22px !important;
    border-left: none !important;
    border-right: none !important;
    padding: calc(16px + env(safe-area-inset-top, 0px)) 16px 18px !important;
    margin: 0 !important;
  }

  .account-settings-modal .settings-card {
    margin: 0 14px !important;
  }
}

.account-sync-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-right: 38px;
}

.account-sync-head-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main, #1e293b);
}

.account-sync-head-title svg {
  color: #7c3aed;
}

.account-sync-head-title h4 {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 750;
  letter-spacing: -0.01em;
}

/* User Card when logged in */
.account-user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 13px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.08) 0%, rgba(124, 58, 237, 0.03) 100%);
  border: 1px solid rgba(139, 92, 246, 0.18);
}

.account-user-avatar-wrap {
  flex-shrink: 0;
}

.account-user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a78bfa 0%, #7c3aed 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.28);
}

.account-user-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.account-user-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-user-name {
  font-size: 0.98rem;
  font-weight: 750;
  color: var(--text-main, #111827);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(139, 92, 246, 0.14);
  color: #7c3aed;
  font-weight: 700;
  line-height: 1.4;
}

.account-user-email {
  font-size: 0.8rem;
  color: var(--text-muted, #64748b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  color: #7c3aed;
  margin-top: 2px;
  font-weight: 600;
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8b5cf6;
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.25);
}

.account-sync-status {
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(139, 92, 246, 0.08);
  color: #6d28d9;
  font-size: 0.84rem;
  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-form-fields {
  display: grid;
  gap: 8px;
}

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

.account-sync-form input {
  width: 100%;
  min-height: 38px;
  box-sizing: border-box;
  border: 1px solid var(--border-color, rgba(139, 92, 246, 0.18));
  border-radius: 10px;
  padding: 7px 11px;
  background: var(--input-bg, #ffffff);
  color: var(--text-main, #111827);
  font-size: 0.9rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.account-sync-form input:focus {
  outline: none;
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
  background: #ffffff;
}

.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.74rem;
  font-weight: 500;
  line-height: 1.4;
}

.account-sync-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.account-sync-actions button,
.account-sync-device-row button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0 14px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.account-sync-primary,
#account-sync-signin {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.26) !important;
}

.account-sync-primary:hover:not(:disabled),
#account-sync-signin:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.35) !important;
  filter: brightness(1.05);
}

.account-sync-primary:active:not(:disabled),
#account-sync-signin:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.22) !important;
}

/* 立即同步按钮: 丝缎薰衣草紫轻奢配色 */
#account-sync-sync {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.26) !important;
}

#account-sync-sync:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.35) !important;
  filter: brightness(1.05);
}

#account-sync-sync:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.22) !important;
}

.account-sync-main-btn {
  flex: 1 1 auto !important;
  min-height: 38px !important;
  font-size: 0.9rem !important;
}

.account-sync-main-btn.is-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
  border-color: #059669 !important;
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25) !important;
}

.account-sync-main-btn.is-loading {
  opacity: 0.85 !important;
  cursor: wait !important;
}

@keyframes account-sync-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.account-sync-spin {
  animation: account-sync-spin 0.75s linear infinite;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.account-sync-secondary,
.account-sync-device-row button {
  background: rgba(139, 92, 246, 0.06) !important;
  color: #6d28d9 !important;
  border: 1px solid rgba(139, 92, 246, 0.16) !important;
}

.account-sync-secondary:hover:not(:disabled),
.account-sync-device-row button:hover:not(:disabled) {
  background: rgba(139, 92, 246, 0.12) !important;
  color: #5b21b6 !important;
  border-color: rgba(139, 92, 246, 0.28) !important;
}

.account-sync-danger {
  background: rgba(239, 68, 68, 0.06) !important;
  color: #e11d48 !important;
  border: 1px solid rgba(239, 68, 68, 0.16) !important;
}

.account-sync-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.12) !important;
  border-color: rgba(239, 68, 68, 0.28) !important;
}

.account-sync-divider {
  height: 1px;
  margin: 6px 0;
  background: var(--border-color, rgba(139, 92, 246, 0.08));
}

.account-sync-devices {
  margin-top: 2px;
  display: grid;
  gap: 6px;
}

.account-sync-device-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.account-sync-device-title {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-main, #1e293b);
}

.account-sync-device-title svg {
  color: #7c3aed;
  flex-shrink: 0;
}

.account-sync-device-title h4 {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 750;
  color: var(--text-main, #1e293b);
}

.account-sync-note {
  margin: 0;
  color: var(--text-muted, #64748b);
  font-size: 0.76rem;
  line-height: 1.4;
}

.account-sync-device-list {
  display: grid;
  gap: 6px;
  margin-top: 2px;
}

.account-sync-device-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border-color, rgba(139, 92, 246, 0.1));
  border-radius: 9px;
  background: var(--panel-subtle, rgba(148, 163, 184, 0.06));
}

.account-sync-device-row.is-current {
  border-color: rgba(139, 92, 246, 0.28);
  background: rgba(139, 92, 246, 0.05);
}

.account-sync-device-evicted-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid rgba(217, 119, 6, 0.28);
  border-radius: 9px;
  background: rgba(245, 158, 11, 0.07);
}

.account-device-evicted-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.18);
  color: #b45309;
}

.account-device-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.account-device-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.account-device-name {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-main, #111827);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-device-current-badge {
  font-size: 0.68rem;
  font-weight: 750;
  padding: 1px 7px;
  border-radius: 4px;
  background: rgba(139, 92, 246, 0.14);
  color: #7c3aed;
  line-height: 1.3;
}

.account-device-time {
  font-size: 0.74rem;
  color: var(--text-muted, #64748b);
}

.account-device-empty {
  font-size: 0.78rem;
  color: var(--text-muted, #64748b);
  padding: 8px 10px;
  text-align: center;
  background: var(--panel-subtle, rgba(148, 163, 184, 0.04));
  border-radius: 8px;
}


/* Theme Card */
.study-theme-settings-card {
  display: grid;
  gap: 8px;
}

.study-theme-settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.study-theme-settings-title {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-main, #1e293b);
}

.study-theme-settings-title svg {
  color: #7c3aed;
  flex-shrink: 0;
}

.study-theme-settings-title h4 {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 700;
}

.study-theme-settings-value {
  font-size: 0.8rem;
  font-weight: 750;
  color: #7c3aed;
  background: rgba(139, 92, 246, 0.08);
  padding: 1px 8px;
  border-radius: 6px;
}

.study-theme-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.study-theme-option-btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border-color, rgba(17, 24, 39, 0.12));
  border-radius: 10px;
  background: var(--panel-bg, rgba(148, 163, 184, 0.06));
  color: var(--text-main, #1e293b);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
}

.study-theme-option-btn svg {
  flex-shrink: 0;
}

.study-theme-option-btn:hover {
  background: rgba(139, 92, 246, 0.08);
  border-color: rgba(139, 92, 246, 0.2);
}

.study-theme-option-btn.is-active {
  border-color: rgba(124, 58, 237, 0.35);
  background: rgba(139, 92, 246, 0.1);
  color: #7c3aed;
  box-shadow: inset 0 0 0 1.5px #7c3aed;
}

body.dark-theme .study-theme-settings-title,
body[data-theme="dark"] .study-theme-settings-title {
  color: #f8fafc;
}

body.dark-theme .study-theme-settings-value,
body[data-theme="dark"] .study-theme-settings-value {
  background: rgba(167, 139, 250, 0.18);
  color: #c4b5fd;
}

body.dark-theme .study-theme-option-btn,
body[data-theme="dark"] .study-theme-option-btn {
  background: #0f172a;
  border-color: rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
}

body.dark-theme .study-theme-option-btn:hover,
body[data-theme="dark"] .study-theme-option-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.2);
}

body.dark-theme .study-theme-option-btn.is-active,
body[data-theme="dark"] .study-theme-option-btn.is-active {
  background: rgba(139, 92, 246, 0.2);
  border-color: rgba(167, 139, 250, 0.45);
  color: #c4b5fd;
  box-shadow: inset 0 0 0 1.5px #a78bfa;
}

/* Zoom Card */
.study-page-zoom-card {
  display: grid;
  gap: 8px;
}

.study-page-zoom-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.study-page-zoom-title,
.pwa-install-card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-main, #1e293b);
}

.study-page-zoom-title svg,
.pwa-install-card-title svg {
  color: #7c3aed;
  flex-shrink: 0;
}

.study-page-zoom-title h4,
.pwa-install-card-title h4 {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 700;
}

.study-page-zoom-value {
  font-size: 0.8rem;
  font-weight: 750;
  color: #7c3aed;
  background: rgba(139, 92, 246, 0.08);
  padding: 1px 8px;
  border-radius: 6px;
}

.study-page-zoom-options {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.study-page-zoom-btn {
  min-height: 32px;
  border: 1px solid var(--border-color, rgba(17, 24, 39, 0.12));
  border-radius: 8px;
  background: var(--panel-subtle, rgba(148, 163, 184, 0.08));
  color: var(--text-main, #1f2937);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
}

.study-page-zoom-btn:hover {
  background: rgba(139, 92, 246, 0.12);
}

.study-page-zoom-btn.is-active {
  border-color: #7c3aed !important;
  background: linear-gradient(135deg, #8b5cf6, #7c3aed) !important;
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.28);
}

/* PWA Card & Device Guides */
.pwa-install-card {
  display: grid;
  gap: 8px;
}

.pwa-install-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pwa-quick-install-btn {
  font-size: 0.78rem !important;
  min-height: 28px !important;
  padding: 0 9px !important;
  border-radius: 7px !important;
}

.pwa-device-guide-list {
  display: grid;
  gap: 5px;
}

.pwa-guide-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 9px;
  border-radius: 8px;
  background: var(--panel-subtle, rgba(148, 163, 184, 0.06));
  border: 1px solid var(--border-color, rgba(17, 24, 39, 0.06));
}

.pwa-guide-tag {
  font-size: 0.72rem;
  font-weight: 750;
  color: var(--text-main, #1e293b);
  white-space: nowrap;
  flex-shrink: 0;
}

.pwa-guide-desc {
  font-size: 0.76rem;
  color: var(--text-muted, #64748b);
  line-height: 1.35;
}

.pwa-guide-desc strong {
  color: var(--text-main, #1e293b);
}

/* Cache & Recovery Card */
.study-cache-settings-card {
  display: grid;
  gap: 8px;
}

.study-cache-settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.study-cache-settings-title {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-main, #1e293b);
}

.study-cache-settings-title svg {
  color: #7c3aed;
  flex-shrink: 0;
}

.study-cache-settings-title h4 {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 700;
}

.study-cache-version-badge {
  font-size: 0.8rem;
  font-weight: 750;
  color: #7c3aed;
  background: rgba(139, 92, 246, 0.08);
  padding: 1px 8px;
  border-radius: 6px;
}

.study-cache-settings-desc {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted, #64748b);
  line-height: 1.45;
}

.study-cache-settings-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 2px;
}

.study-refresh-cache-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem !important;
  font-weight: 600 !important;
  min-height: 30px !important;
  padding: 0 12px !important;
  border-radius: 8px !important;
  cursor: pointer;
  white-space: nowrap;
  background: rgba(139, 92, 246, 0.08) !important;
  color: #6d28d9 !important;
  border: 1px solid rgba(139, 92, 246, 0.2) !important;
  transition: all 0.2s ease;
}

.study-refresh-cache-btn:hover:not(:disabled) {
  background: rgba(139, 92, 246, 0.16) !important;
  color: #5b21b6 !important;
  border-color: rgba(139, 92, 246, 0.35) !important;
}
  align-items: center;
  gap: 6px;
  font-size: 0.8rem !important;
  font-weight: 600 !important;
  min-height: 30px !important;
  padding: 0 12px !important;
  border-radius: 7px !important;
  cursor: pointer;
  white-space: nowrap;
}

.study-refresh-cache-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.study-cache-status-text {
  font-size: 0.76rem;
  color: var(--text-muted, #64748b);
  line-height: 1.35;
}

.study-cache-status-text.is-error {
  color: #dc2626;
  font-weight: 600;
}

.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-sm {
  font-size: 0.8rem !important;
  min-height: 32px !important;
  padding: 0 10px !important;
}

.account-sync-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9600;
  max-width: min(92vw, 360px);
  display: none;
  padding: 12px 16px;
  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;
}

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

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

  .account-sync-panel {
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100% !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
    transform: none !important;
    display: none;
    flex-direction: column;
    overflow: hidden;
  }

  .account-sync-panel.active {
    display: flex !important;
  }

  .account-sync-head {
    padding-top: max(16px, env(safe-area-inset-top));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: 14px;
    flex: 0 0 auto;
  }

  .account-sync-body {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: 14px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }

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

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

/* v238: keep the account pill readable in 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: 40px !important;
  min-width: 40px !important;
  max-width: 40px !important;
  height: 40px !important;
  min-height: 40px !important;
  max-height: 40px !important;
  aspect-ratio: 1 / 1 !important;
  flex: 0 0 40px !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 50% !important;
  background: transparent !important;
  box-shadow: none !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;
  box-sizing: border-box !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: 32px !important;
  min-width: 32px !important;
  max-width: 32px !important;
  height: 32px !important;
  min-height: 32px !important;
  max-height: 32px !important;
  border-radius: 50% !important;
  flex: 0 0 32px !important;
  font-size: 1.05rem !important;
  font-weight: 850 !important;
  display: inline-grid !important;
  place-items: center !important;
}

@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: 36px !important;
    min-width: 36px !important;
    max-width: 36px !important;
    height: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;
    aspect-ratio: 1 / 1 !important;
    flex: 0 0 36px !important;
    padding: 0 !important;
    font-size: 0 !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !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: 30px !important;
    min-width: 30px !important;
    height: 30px !important;
    min-height: 30px !important;
    font-size: 0.96rem !important;
  }
}

/* Dark Theme Support */
body.dark-theme .account-sync-panel,
body[data-theme="dark"] .account-sync-panel {
  background: #161224;
  color: #f1f5f9;
  border-color: rgba(167, 139, 250, 0.18);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(167, 139, 250, 0.12);
}

body.dark-theme .account-sync-head,
body[data-theme="dark"] .account-sync-head {
  border-bottom-color: rgba(167, 139, 250, 0.1);
}

body.dark-theme .account-sync-head h3,
body[data-theme="dark"] .account-sync-head h3 {
  color: #f8fafc;
}

body.dark-theme .account-sync-close,
body[data-theme="dark"] .account-sync-close {
  background: rgba(167, 139, 250, 0.1);
  color: #c4b5fd;
}

body.dark-theme .account-sync-close:hover,
body[data-theme="dark"] .account-sync-close:hover {
  background: rgba(167, 139, 250, 0.2);
  color: #ffffff;
}

body.dark-theme .account-sync-head-title,
body[data-theme="dark"] .account-sync-head-title {
  color: #f8fafc;
}

body.dark-theme .account-sync-head-title svg,
body.dark-theme .account-sync-device-title svg,
body.dark-theme .study-theme-settings-title svg,
body.dark-theme .study-page-zoom-title svg,
body.dark-theme .pwa-install-card-title svg,
body.dark-theme .study-cache-settings-title svg,
body[data-theme="dark"] .account-sync-head-title svg,
body[data-theme="dark"] .account-sync-device-title svg,
body[data-theme="dark"] .study-theme-settings-title svg,
body[data-theme="dark"] .study-page-zoom-title svg,
body[data-theme="dark"] .pwa-install-card-title svg,
body[data-theme="dark"] .study-cache-settings-title svg {
  color: #a78bfa;
}

body.dark-theme .account-sync-embedded,
body[data-theme="dark"] .account-sync-embedded {
  background: linear-gradient(180deg, rgba(30, 25, 46, 0.8) 0%, rgba(20, 17, 32, 0.9) 100%) !important;
  border-color: rgba(167, 139, 250, 0.18) !important;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.4) !important;
}

body.dark-theme .account-user-card,
body[data-theme="dark"] .account-user-card {
  background: rgba(139, 92, 246, 0.1);
  border-color: rgba(167, 139, 250, 0.2);
}

body.dark-theme .account-user-name,
body[data-theme="dark"] .account-user-name {
  color: #f8fafc;
}

body.dark-theme .account-badge,
body[data-theme="dark"] .account-badge {
  background: rgba(139, 92, 246, 0.25);
  color: #c4b5fd;
}

body.dark-theme .account-sync-pill,
body[data-theme="dark"] .account-sync-pill {
  color: #c4b5fd;
}

body.dark-theme .sync-dot,
body[data-theme="dark"] .sync-dot {
  background: #a78bfa;
  box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.3);
}

body.dark-theme .account-sync-form input,
body[data-theme="dark"] .account-sync-form input {
  background: #110e1c;
  border-color: rgba(167, 139, 250, 0.16);
  color: #f8fafc;
}

body.dark-theme .account-sync-form input:focus,
body[data-theme="dark"] .account-sync-form input:focus {
  border-color: #a78bfa;
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.2);
  background: #141022;
}

body.dark-theme .account-sync-secondary,
body[data-theme="dark"] .account-sync-secondary,
body.dark-theme .account-sync-device-row button,
body[data-theme="dark"] .account-sync-device-row button {
  background: rgba(167, 139, 250, 0.1) !important;
  color: #e9d5ff !important;
  border-color: rgba(167, 139, 250, 0.2) !important;
}

body.dark-theme .account-sync-secondary:hover:not(:disabled),
body[data-theme="dark"] .account-sync-secondary:hover:not(:disabled),
body.dark-theme .account-sync-device-row button:hover:not(:disabled),
body[data-theme="dark"] .account-sync-device-row button:hover:not(:disabled) {
  background: rgba(167, 139, 250, 0.18) !important;
  color: #ffffff !important;
  border-color: rgba(167, 139, 250, 0.35) !important;
}

body.dark-theme .account-settings-modal .settings-card,
body[data-theme="dark"] .account-settings-modal .settings-card {
  background: #1d182e !important;
  border-color: rgba(167, 139, 250, 0.12) !important;
}

body.dark-theme .account-sync-embedded,
body[data-theme="dark"] .account-sync-embedded {
  background: linear-gradient(180deg, rgba(30, 27, 75, 0.65) 0%, rgba(15, 23, 42, 0.85) 100%) !important;
  border-bottom: 1px solid rgba(139, 92, 246, 0.25) !important;
}

body.dark-theme .account-sync-device-row,
body[data-theme="dark"] .account-sync-device-row {
  border-color: rgba(167, 139, 250, 0.12);
  background: rgba(167, 139, 250, 0.05);
}

body.dark-theme .account-sync-device-row.is-current,
body[data-theme="dark"] .account-sync-device-row.is-current {
  border-color: rgba(167, 139, 250, 0.3);
  background: rgba(167, 139, 250, 0.1);
}

body.dark-theme .account-device-current-badge,
body[data-theme="dark"] .account-device-current-badge {
  background: rgba(167, 139, 250, 0.25);
  color: #c4b5fd;
}

body.dark-theme .study-page-zoom-title,
body.dark-theme .pwa-install-card-title,
body[data-theme="dark"] .study-page-zoom-title,
body[data-theme="dark"] .pwa-install-card-title {
  color: #f8fafc;
}

body.dark-theme .study-page-zoom-btn,
body[data-theme="dark"] .study-page-zoom-btn {
  background: #110e1c;
  border-color: rgba(167, 139, 250, 0.14);
  color: #cbd5e1;
}

body.dark-theme .study-page-zoom-btn:hover,
body[data-theme="dark"] .study-page-zoom-btn:hover {
  background: rgba(167, 139, 250, 0.15);
  color: #ffffff;
}

body.dark-theme .study-page-zoom-btn.is-active,
body[data-theme="dark"] .study-page-zoom-btn.is-active {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed) !important;
  border-color: #a78bfa !important;
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.35);
}

body.dark-theme .pwa-guide-item,
body[data-theme="dark"] .pwa-guide-item {
  background: #110e1c;
  border-color: rgba(167, 139, 250, 0.1);
}

body.dark-theme .pwa-guide-tag,
body[data-theme="dark"] .pwa-guide-tag {
  color: #f1f5f9;
}

body.dark-theme .pwa-guide-desc,
body[data-theme="dark"] .pwa-guide-desc {
  color: #94a3b8;
}

body.dark-theme .pwa-guide-desc strong,
body[data-theme="dark"] .pwa-guide-desc strong {
  color: #f8fafc;
}

body.dark-theme .study-cache-settings-title,
body[data-theme="dark"] .study-cache-settings-title {
  color: #f8fafc;
}

body.dark-theme .study-cache-version-badge,
body[data-theme="dark"] .study-cache-version-badge {
  background: rgba(167, 139, 250, 0.18);
  color: #c4b5fd;
}

body.dark-theme .study-refresh-cache-btn,
body[data-theme="dark"] .study-refresh-cache-btn {
  background: rgba(167, 139, 250, 0.12) !important;
  color: #e9d5ff !important;
  border-color: rgba(167, 139, 250, 0.25) !important;
}

body.dark-theme .study-refresh-cache-btn:hover:not(:disabled),
body[data-theme="dark"] .study-refresh-cache-btn:hover:not(:disabled) {
  background: rgba(167, 139, 250, 0.22) !important;
  color: #ffffff !important;
}
