.drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  justify-content: flex-end;
  background: rgba(0, 0, 0, 0.6);
  animation: drawer-scrim-in var(--dur) var(--ease);
}

.drawer-scrim--out {
  animation: drawer-scrim-out var(--dur) var(--ease) forwards;
}

.drawer {
  width: min(420px, 100vw);
  height: 100%;
  padding-top: var(--safe-top);
  padding-right: var(--safe-right);
  display: flex;
  flex-direction: column;
  background: var(--surface-1);
  border-left: 1px solid var(--border-strong);
  box-shadow: -16px 0 48px rgba(0, 0, 0, 0.5);
  transform: translateX(100%);
  transition: transform var(--dur) var(--ease);
}

.drawer--in {
  transform: translateX(0);
}

.drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.drawer__title {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--text);
}

.drawer__close {
  flex-shrink: 0;
  display: flex;
  color: var(--text-muted);
  padding: var(--s-1);
  border-radius: var(--r-sm);
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

.drawer__close:hover {
  color: var(--text);
  background: var(--surface-3);
}

.drawer__close:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.drawer__body {
  flex: 1;
  padding: var(--s-5);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.drawer__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-2);
  padding: var(--s-4) var(--s-5);
  padding-bottom: calc(var(--s-4) + var(--safe-bottom));
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

@keyframes drawer-scrim-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes drawer-scrim-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .drawer-scrim, .drawer {
    transition: none;
    animation: none;
  }
}

@media (max-width: 480px) {
  .drawer {
    width: 100vw;
  }
}
