/* Slide-Over Account & Settings Drawer Styles */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.drawer-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.account-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 100vw;
  background: var(--bg-surface, #12141c);
  border-left: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  box-shadow: none;
  z-index: 2000;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
  color: var(--text-primary, #ffffff);
  font-family: var(--font-sans);
  overflow: hidden;
}

.account-drawer.active,
.account-drawer.open {
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.5);
}

/* Smooth theme color morphing for drawer controls while preserving slide transform */
.account-drawer {
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease, background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

.drawer-header,
.drawer-view,
.setting-row,
.setting-control select,
.setting-control input {
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

@media (max-width: 767.98px) {
  .account-drawer {
    width: 85vw;
  }
}

.account-drawer.active,
.account-drawer.open {
  transform: translateX(0);
}

/* Drawer Views Container for Drill-Down */
.drawer-views-container {
  display: flex;
  width: 300%;
  height: 100%;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.account-drawer.show-account .drawer-views-container {
  transform: translateX(-33.333%);
}

.account-drawer.show-settings .drawer-views-container {
  transform: translateX(-66.666%);
}

.drawer-view {
  width: 33.333%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drawer-back-btn {
  background: transparent;
  border: none;
  color: var(--accent-flight, #00f2fe);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--border-radius-sm, 6px);
  transition: var(--transition-smooth, all 0.2s ease);
  display: flex;
  align-items: center;
  gap: 6px;
}

.drawer-back-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Drawer Header */
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(20px, calc(12px + env(safe-area-inset-top, 0px))) 24px 20px;
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  background: var(--drawer-header-bg);
}

/* Main view identity: mark + name + handle chip, matching the My Account
   panel so the same value doesn't get two treatments across the two views. */
.drawer-header-identity {
  gap: 12px;
}

.account-avatar.drawer-avatar {
  width: 36px;
  height: 36px;
}

.drawer-profile-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

.drawer-user-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-user-email {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--border-radius-sm, 6px);
  transition: var(--transition-smooth, all 0.2s ease);
}

.drawer-close-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

/* Drawer Content Scroll Container */
.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  background: var(--card-ground);
}

/* Progressive Inline Naming Banner */
.onboarding-card {
  display: block;
  width: 100%;
  height: auto !important;
  padding: 16px;
  margin-bottom: 16px;
  box-sizing: border-box;
  background: var(--bg-surface-elevated, #1a1d29);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  border-radius: var(--border-radius-md, 10px);
}

.onboarding-card.hidden {
  display: none !important;
}

.onboarding-header {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  display: block;
  color: var(--text-primary, #fff);
}

.onboarding-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  width: 100%;
}

#display-name-input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  box-sizing: border-box;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#display-name-input:focus {
  border-color: var(--accent-flight, #00f2fe);
  box-shadow: 0 0 0 2px rgba(0, 242, 254, 0.2);
}

#btn-save-name {
  height: 38px;
  padding: 0 16px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent-flight, #00f2fe);
  color: #0b0e14;
  border: none;
  font-family: var(--font-sans);
  transition: var(--transition-smooth, all 0.2s ease);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

#btn-save-name:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

#btn-save-name:active {
  transform: translateY(0);
}

#btn-save-name:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Drawer Sections */
.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.drawer-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin: 0 0 4px 0;
}

.drawer-sublabel {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin: 0 0 8px 0;
}

/* Navigation Cards */
.drawer-nav-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-surface-elevated, #1a1d29);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  border-radius: var(--border-radius-md, 10px);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: var(--transition-smooth, all 0.2s ease);
  box-sizing: border-box;
  /* The Staff card is an <a> (it navigates to /admin) while the rest are
     <button>s — without this it renders with the default link underline. */
  text-decoration: none;
}

.drawer-nav-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent-flight, #00f2fe);
  transform: translateY(-1px);
}

.drawer-nav-icon {
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drawer-nav-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.drawer-nav-text strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.drawer-nav-text span {
  font-size: 11px;
  color: var(--text-muted);
}

/* Settings Form Controls */
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  transition: opacity 0.2s ease;
  box-sizing: border-box;
}

.setting-row.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.setting-label {
  flex: 1;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.quick-capture-bookmarklet-btn {
  cursor: grab;
  text-decoration: none;
  display: inline-flex;
}

/* Quick Capture popover — opened by #btn-quick-capture in the Account
   drawer. z-index sits above .account-drawer (2000) since it needs to
   render on top of the open drawer, not behind it. */
.quick-capture-popover {
  position: fixed;
  z-index: 2100;
  width: 280px;
  max-width: calc(100vw - 16px);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 14px;
  font-family: var(--font-sans);
  color: var(--text-primary);
}

.qc-popover-hint {
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-primary);
  margin: 0 0 12px 0;
}

.qc-popover-btn-row {
  display: flex;
}

.qc-popover-btn-row .btn {
  width: 100%;
  justify-content: center;
}

.segmented-control,
.setting-select,
.toggle-switch {
  flex-shrink: 0;
  margin-left: 16px;
}

/* Segmented Control */
.segmented-control {
  display: inline-flex;
  background: var(--bg-card, rgba(0, 0, 0, 0.25));
  padding: 3px;
  border-radius: var(--border-radius-sm, 6px);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
}

.segmented-control input[type="radio"] {
  display: none;
}

.segmented-control label {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.segmented-control label:hover {
  color: var(--text-primary);
}

.segmented-control input[type="radio"]:checked+label {
  background: var(--bg-surface-elevated, #242938);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
}

/* Settings Select Dropdown */
.setting-select {
  background: var(--bg-card, rgba(0, 0, 0, 0.25));
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
  border-radius: var(--border-radius-sm, 6px);
  color: var(--text-primary);
  padding: 6px 12px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.setting-select option {
  background: var(--bg-surface, #12141c);
  color: var(--text-primary);
  font-family: var(--font-sans);
}

.setting-select:focus,
.setting-select:hover {
  border-color: var(--accent-flight, #00f2fe);
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-switch .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--bg-card, rgba(255, 255, 255, 0.15));
  border-radius: 24px;
  transition: 0.3s ease;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
}

.toggle-switch .slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: -6px;
  top: -2px;
  background-color: var(--text-primary, #ffffff);
  border-radius: 50%;
  transition: 0.3s ease;
}

.toggle-switch input:checked+.slider {
  background-color: var(--accent-flight, #00f2fe);
  border-color: var(--accent-flight, #00f2fe);
}

.toggle-switch input:checked+.slider::before {
  transform: translateX(20px);
  background-color: var(--bg-surface, #0b0e14);
}

.toggle-switch input:disabled+.slider {
  cursor: not-allowed;
  opacity: 0.5;
}

/* Security & Action Buttons */
.drawer-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--border-radius-md, 8px);
  cursor: pointer;
  transition: var(--transition-smooth, all 0.2s ease);
  box-sizing: border-box;
}

.drawer-btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
  color: var(--text-primary);
}

.drawer-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

.drawer-btn-logout {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  color: var(--text-secondary);
}

.drawer-btn-logout:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.drawer-btn-danger {
  background: color-mix(in srgb, var(--danger) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  color: var(--danger);
}

.drawer-btn-danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

/* ─── Account Panel ──────────────────────────────────────────────────────
   The account view used to be styled with inline `style=` attributes carrying
   hardcoded dark-theme fallbacks, which is why it never themed correctly.
   Everything below is token-driven; see --card-* in base.css. */

.account-content {
  gap: 20px;
}

.drawer-header-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.account-subsection {
  margin-bottom: 12px;
}

.account-btn-block {
  width: 100%;
  margin: 0;
}

.account-btn-spaced {
  margin-top: 10px;
}

.account-recovery-warning {
  margin: 10px 0 0 0;
}

.account-card {
  padding: 14px 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-md);
  box-shadow: var(--card-shadow);
}

/* ── Profile card: mark + identity ── */
.account-profile {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.account-avatar {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  line-height: 0;
}

.account-avatar svg {
  width: 100%;
  height: 100%;
  display: block;
}

.account-profile-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding-top: 2px;
}

.account-profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.account-profile-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-profile-edit {
  display: flex;
  gap: 8px;
  width: 100%;
  align-items: center;
}

/* The handle is assigned, not typed — a chip keeps it visibly a different kind
   of thing from the display name above it. */
.account-handle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  padding: 2px 3px 2px 9px;
  border-radius: 999px;
  background: var(--card-inset);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Display-only variant: no trailing shuffle button to make room for. */
.account-handle-static {
  padding: 2px 9px;
}

.account-handle-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-handle-shuffle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  /* Interactive, so it holds to the 3:1 non-text minimum on every theme. */
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease, transform 0.4s ease;
}

.account-handle-shuffle svg {
  flex: none;
  width: 13px;
  height: 13px;
}

.account-handle-shuffle:hover {
  color: var(--text-primary);
  background: var(--card-bg);
}

.account-handle-shuffle:active {
  transform: rotate(180deg);
}

@media (prefers-reduced-motion: reduce) {
  .account-handle-shuffle {
    transition: color 0.2s ease, background-color 0.2s ease;
  }

  .account-handle-shuffle:active {
    transform: none;
  }
}

/* ── Shared account controls ── */
.account-input {
  flex: 1;
  min-width: 0;
  padding: 6px 12px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--card-border);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  outline: none;
}

.account-input:focus {
  border-color: var(--border-focus);
}

.account-btn-sm {
  width: auto;
  height: auto;
  margin: 0;
  padding: 5px 12px;
  font-size: 12px;
  flex-shrink: 0;
}

.account-hint {
  margin: 8px 0 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.account-disclosure {
  margin: -4px 0 10px 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.account-disclosure summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-secondary);
  list-style: none;
}

.account-disclosure summary::-webkit-details-marker {
  display: none;
}

.account-disclosure summary::after {
  content: ' ›';
  display: inline-block;
  transition: transform 0.2s ease;
}

.account-disclosure[open] summary::after {
  transform: rotate(90deg);
}

.account-disclosure p {
  margin: 6px 0 0 0;
}

.account-badge {
  flex-shrink: 0;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--card-inset);
  border: 1px solid var(--card-border);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* ── Passkey list: one bordered list with dividers, not four stacked cards ── */
.passkeys-list {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-md);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.passkeys-list-empty {
  padding: 14px 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.passkey-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  font-size: 13px;
}

.passkey-item+.passkey-item {
  border-top: 1px solid var(--card-divider);
}

.passkey-item-icon {
  flex-shrink: 0;
  display: inline-flex;
  color: var(--text-muted);
}

.passkey-item-icon svg {
  flex: none;
  width: 16px;
  height: 16px;
}

.passkey-item-name {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-width: 0;
}

.passkey-item-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.passkey-label-text {
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.passkey-item-meta {
  font-size: 12px;
  color: var(--text-secondary);
}

.passkey-inline-input {
  flex: 1;
  min-width: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-focus);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  padding: 2px 6px;
  font-size: 12px;
  font-family: var(--font-sans);
  outline: none;
}

.passkey-item-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.btn-rename-passkey,
.btn-delete-passkey {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: var(--border-radius-sm);
  /* --text-secondary, not --text-muted: these sit on a card surface and were
     the least legible thing in the panel. */
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.btn-rename-passkey svg,
.btn-delete-passkey svg {
  flex: none;
  width: 15px;
  height: 15px;
}

.btn-rename-passkey:hover {
  color: var(--text-primary);
  background: var(--card-inset);
}

.btn-delete-passkey:hover {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

/* ── Recovery key ── */
.account-recovery-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#recovery-status-badge {
  font-size: 12px;
  font-weight: 600;
}

/* ── Danger zone ── */
.danger-zone-container {
  margin-top: auto;
  padding: 14px 16px;
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  background: color-mix(in srgb, var(--danger) 6%, transparent);
  border-radius: var(--border-radius-md);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.danger-zone-container .drawer-section-title {
  margin: 0;
  color: var(--danger);
}


/* ─── Account Drawer: Recovery Status Badge ────────────────────────────── */
.recovery-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.recovery-badge.warning {
  color: #f59e0b;
  /* Soft Amber */
  border-color: rgba(245, 158, 11, 0.25);
  background: rgba(245, 158, 11, 0.08);
}

.recovery-badge.active {
  color: #10b981;
  /* Soft Green */
  border-color: rgba(16, 185, 129, 0.25);
  background: rgba(16, 185, 129, 0.08);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.warning {
  background-color: #f59e0b;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.5);
}

.status-dot.active {
  background-color: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.drawer-footer {
  margin-top: auto;
  padding: 16px 24px max(20px, calc(16px + env(safe-area-inset-bottom, 0px)));
  border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  background: var(--bg-surface, #12141c);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.drawer-footer-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drawer-copyright {
  font-size: 11px;
  color: var(--text-muted, rgba(255, 255, 255, 0.5));
  text-align: center;
}

.drawer-copyright a {
  color: inherit;
  text-decoration: none;
}

.drawer-copyright a:hover {
  text-decoration: underline;
  cursor: pointer;
}