/* ═══════════════════════════════════════════════════════════════════════════
   PROFILE SIDE DRAWER (js/profile-drawer.js)
   Right slide-in panel · clean graphite surface · unified neutral icons.
   ═══════════════════════════════════════════════════════════════════════════ */
.pd-scrim,
.pd-panel { --pd-accent: #4338ca; }
body.dark .pd-panel { --pd-accent: #4f46e5; }

/* Scrim */
.pd-scrim {
  position: fixed; inset: 0; z-index: 6000;
  background: rgba(15, 23, 42, .45);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .22s var(--ease, ease), visibility 0s linear .22s;
}
.pd-scrim.is-open {
  opacity: 1; visibility: visible; pointer-events: auto;
  transition: opacity .22s var(--ease, ease), visibility 0s;
}

/* Panel */
.pd-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 6001;
  width: min(86vw, 380px);
  display: flex; flex-direction: column;
  background: var(--surface-solid, #fff); color: var(--tx, #111827);
  border-radius: 16px 0 0 16px;
  border-left: 1px solid rgba(15, 23, 42, .08);
  box-shadow: -12px 0 36px rgba(15, 23, 42, .14);
  transform: translateX(104%);
  visibility: hidden;
  transition: transform .28s var(--ease, cubic-bezier(.22,.61,.36,1)), visibility 0s linear .28s;
  padding-top: env(safe-area-inset-top, 0px);
  outline: none; overflow: hidden;
  font-family: inherit;
}
.pd-panel.is-open {
  transform: translateX(0); visibility: visible;
  transition: transform .28s var(--ease, cubic-bezier(.22,.61,.36,1)), visibility 0s;
}
body.dark .pd-panel {
  background: #141417;
  border-left-color: rgba(255, 255, 255, .08);
  box-shadow: -16px 0 40px rgba(0, 0, 0, .55);
}
body.qmt-drawer-open { overflow: hidden; }
body.qmt-drawer-open #toast { z-index: 6100; }

/* Top bar */
.pd-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 8px 20px; flex-shrink: 0;
}
.pd-top-title {
  font-size: 13px; font-weight: 600; letter-spacing: 0; text-transform: none;
  color: var(--tx-2, #4b5563);
}
.pd-close {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid rgba(15, 23, 42, .08); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  background: #f3f4f6; color: #4b5563;
  transition: background .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
}
.pd-close:hover { background: #e5e7eb; color: #111827; }
.pd-close:active { transform: scale(.94); }
.pd-close svg { width: 16px; height: 16px; }
body.dark .pd-close { background: #222228; border-color: rgba(255,255,255,.08); color: #a1a1aa; }
body.dark .pd-close:hover { background: #2a2a32; color: #f4f4f5; }

.pd-scroll {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 4px 16px calc(24px + env(safe-area-inset-bottom, 0px));
  scrollbar-width: thin;
}

/* ── Profile card ── */
.pd-profile {
  position: relative; display: flex; align-items: center; gap: 16px;
  padding: 16px; margin: 4px 0; border-radius: 12px; overflow: hidden;
  background: #f8f9fb;
  border: 1px solid rgba(15,23,42,.08);
  box-shadow: none;
}
body.dark .pd-profile {
  background: #18181c; border-color: rgba(255, 255, 255, .08);
  box-shadow: none;
}
.pd-avatar {
  position: relative; flex: 0 0 auto; width: 56px; height: 56px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--pd-accent); color: #ffffff;
  font-size: 22px; font-weight: 600; line-height: 1;
  box-shadow: none;
  overflow: hidden;
}
body.dark .pd-avatar { box-shadow: none; }
.pd-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pd-profile-info { position: relative; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.pd-name {
  max-width: 100%; font-size: 16px; font-weight: 600; letter-spacing: -.015em; line-height: 1.25;
  color: var(--tx, #111827); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pd-email {
  max-width: 100%; font-size: 12.5px; font-weight: 400; color: var(--tx-2, #4b5563);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pd-badge {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 4px;
  font-size: 11px; font-weight: 500; letter-spacing: 0; color: #059669;
}
body.dark .pd-badge { color: #34d399; }
.pd-badge-dot { width: 6px; height: 6px; border-radius: 50%; background: #10b981; }
.pd-edit {
  margin-top: 10px; display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--pd-accent); color: #fff; font: inherit; font-size: 12.5px; font-weight: 600;
  box-shadow: none;
  transition: background-color .15s ease, transform .12s ease;
  -webkit-tap-highlight-color: transparent;
}
.pd-edit svg { width: 14px; height: 14px; }
.pd-edit:hover { background: #3730a3; }
body.dark .pd-edit:hover { background: #4338ca; }
.pd-edit:active { transform: scale(.97); }

/* ── Sections ── */
.pd-section { margin-top: 20px; }
.pd-section-title {
  margin: 0 0 8px 4px; font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform: none;
  color: var(--tx-3, #6b7280);
}
.pd-group {
  border-radius: 12px; overflow: hidden;
  background: #ffffff;
  border: 1px solid rgba(15,23,42,.08);
}
body.dark .pd-group { background: #18181c; border-color: rgba(255, 255, 255, .08); }

/* ── Rows ── */
.pd-row {
  position: relative; width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 0; background: transparent; text-align: left; cursor: pointer;
  font: inherit; color: var(--tx, #111827); min-height: 52px;
  transition: background-color .14s;
  -webkit-tap-highlight-color: transparent;
}
.pd-row[hidden] { display: none !important; }
.pd-row + .pd-row::before {
  content: ""; position: absolute; top: 0; left: 58px; right: 0; height: 1px;
  background: rgba(15,23,42,.06);
}
body.dark .pd-row + .pd-row::before { background: rgba(255, 255, 255, .06); }
.pd-row:hover { background: #f8f9fb; }
.pd-row:active { background: #f3f4f6; }
body.dark .pd-row:hover { background: #202026; }
body.dark .pd-row:active { background: #26262e; }
.pd-row--static { cursor: default; }
.pd-row--static:hover, .pd-row--static:active { background: transparent; }
.pd-row:focus-visible,
.pd-close:focus-visible, .pd-edit:focus-visible, .pd-step:focus-visible {
  outline: 2px solid #4338ca; outline-offset: -2px; border-radius: 8px;
}

.pd-ic {
  flex: 0 0 auto; width: 32px; height: 32px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #f3f4f6; color: #4b5563; border: 1px solid rgba(15, 23, 42, .06);
}
.pd-ic svg { width: 16px; height: 16px; }
body.dark .pd-ic { background: #222228; color: #a1a1aa; border-color: rgba(255, 255, 255, .06); }

[data-row="logout"] .pd-ic { background: rgba(225, 29, 72, .08); color: #e11d48; border-color: rgba(225, 29, 72, .16); }
body.dark [data-row="logout"] .pd-ic { background: rgba(244, 63, 94, .12); color: #fb7185; border-color: rgba(244, 63, 94, .2); }

.pd-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.pd-label { font-size: 14px; font-weight: 500; line-height: 1.3; }
.pd-sub { font-size: 12px; font-weight: 400; color: var(--tx-3, #6b7280); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pd-plan-sub { font-variant-numeric: tabular-nums; font-weight: 500; }
.pd-plan-sub.is-paid { color: #059669; }
body.dark .pd-plan-sub.is-paid { color: #34d399; }
.pd-chev { flex: 0 0 auto; width: 16px; height: 16px; color: var(--tx-3, #9ca3af); transition: transform .15s; }
.pd-row:hover .pd-chev { transform: translateX(2px); color: #4338ca; }
body.dark .pd-row:hover .pd-chev { color: #818cf8; }

/* Danger row */
.pd-row--danger .pd-label { color: #e11d48; }
body.dark .pd-row--danger .pd-label { color: #fb7185; }
.pd-row--danger:hover { background: rgba(244, 63, 94, .06); }

/* Switch */
.pd-switch {
  flex: 0 0 auto; position: relative; width: 44px; height: 24px; border-radius: 999px;
  background: #d1d5db; transition: background .2s var(--ease, ease);
}
body.dark .pd-switch { background: #3a3a44; }
.pd-switch-knob {
  position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(15,23,42,.2);
  transition: transform .2s var(--ease, ease);
}
.pd-row.is-on .pd-switch { background: var(--pd-accent); }
.pd-row.is-on .pd-switch-knob { transform: translateX(20px); }

/* Zoom stepper */
.pd-stepper {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 2px; padding: 2px; border-radius: 8px;
  background: #f3f4f6; border: 1px solid rgba(15,23,42,.08);
}
body.dark .pd-stepper { background: #121215; border-color: rgba(255,255,255,.08); }
.pd-step {
  width: 28px; height: 28px; border: 0; border-radius: 6px; cursor: pointer;
  font: inherit; font-size: 16px; font-weight: 600; line-height: 1;
  background: transparent; color: #374151;
  transition: background .14s;
}
body.dark .pd-step { color: #d4d4d8; }
.pd-step:hover:not(:disabled) { background: rgba(15, 23, 42, .06); color: #111827; }
body.dark .pd-step:hover:not(:disabled) { background: rgba(255, 255, 255, .08); color: #ffffff; }
.pd-step:disabled { opacity: .35; cursor: default; }
.pd-zoom-val { min-width: 44px; text-align: center; font-size: 12.5px; font-weight: 600; font-family: 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }

/* Footer */
.pd-foot { margin-top: 20px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.pd-version { font-size: 11.5px; font-weight: 500; color: var(--tx-2, #4b5563); }
.pd-credit { font-size: 11px; font-weight: 400; color: var(--tx-3, #6b7280); }

.hm-avatar { transition: border-color .15s; }

@media (min-width: 861px) {
  .pd-panel { width: 400px; }
}
@media (prefers-reduced-motion: reduce) {
  .pd-scrim, .pd-panel, .pd-switch, .pd-switch-knob, .pd-row, .pd-chev { transition-duration: .01ms !important; }
}
@media print { .pd-scrim, .pd-panel { display: none !important; } }
