/* ─────────────────────────────────────────────────────────────────
   Settings drawer — modern minimal app UI
   ───────────────────────────────────────────────────────────────── */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 320ms ease;
  z-index: 800;
}
.drawer-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 96vw;
  background: var(--surface);
  box-shadow:
    -1px 0 0 var(--hairline),
    -20px 0 60px rgba(0, 0, 0, 0.12);
  transform: translateX(100%);
  transition: transform 420ms cubic-bezier(0.32, 0.72, 0.18, 1);
  z-index: 850;
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  color: var(--ink);
}
.drawer.open { transform: translateX(0); }

/* ── Header ────────────────────────────────────────────────── */

.drawer-head {
  padding: 22px 28px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--hairline);
}
.drawer-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.drawer-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  transition: background 160ms ease, color 160ms ease;
}
.drawer-close:hover { background: rgba(0, 0, 0, 0.06); color: var(--ink); }

/* ── Body ──────────────────────────────────────────────────── */

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.18) transparent;
}
.drawer-body::-webkit-scrollbar { width: 6px; }
.drawer-body::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

.ds-section {
  padding: 18px 28px 22px;
}
.ds-section + .ds-section {
  border-top: 1px solid var(--hairline);
}

.ds-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.ds-section-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.ds-section-meta {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-mute);
}

/* ── Segmented control ─────────────────────────────────────── */

.ds-segmented {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 3px;
  border: 1px solid var(--hairline);
}
.ds-segmented button {
  flex: 1;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--ink-soft);
  border-radius: 6px;
  transition: background 180ms ease, color 180ms ease, box-shadow 180ms ease;
  white-space: nowrap;
}
.ds-segmented button:hover { color: var(--ink); }
.ds-segmented button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow:
    0 0 0 1px var(--hairline),
    0 1px 2px rgba(0, 0, 0, 0.04);
}

.ds-segmented-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 3px;
  width: 100%;
}
.ds-segmented-grid button { flex: none; }

/* ── Palette swatches ──────────────────────────────────────── */

.ds-swatches {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
}
.ds-swatch {
  aspect-ratio: 1;
  background: var(--c, #ccc);
  border-radius: 50%;
  border: 1px solid var(--hairline);
  position: relative;
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.ds-swatch:hover { transform: scale(1.08); }
.ds-swatch.active {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink);
}
.ds-swatch[data-palette="white"] {
  border-color: rgba(0, 0, 0, 0.15);
}
.ds-swatch-rotate {
  background:
    conic-gradient(
      from 0deg,
      var(--p-red)    0%   14.3%,
      var(--p-orange) 14.3% 28.6%,
      var(--p-yellow) 28.6% 42.9%,
      var(--p-green)  42.9% 57.1%,
      var(--p-blue)   57.1% 71.4%,
      var(--p-violet) 71.4% 85.7%,
      var(--p-white)  85.7% 100%
    );
}

/* ── Toggles (iOS-style switches) ───────────────────────────── */

.ds-toggles {
  display: flex;
  flex-direction: column;
}
.ds-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  cursor: pointer;
  border-top: 1px solid var(--hairline);
}
.ds-toggle:first-child { border-top: none; }
.ds-toggle-label {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--ink);
}

.ds-toggle-switch {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}
.ds-toggle-switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.ds-toggle-track {
  width: 40px;
  height: 24px;
  background: #d0cfca;
  border-radius: 100px;
  position: relative;
  transition: background 220ms ease;
}
.ds-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow:
    0 1px 1px rgba(0, 0, 0, 0.05),
    0 2px 4px rgba(0, 0, 0, 0.15);
  transition: transform 220ms cubic-bezier(0.3, 1.4, 0.4, 1);
}
.ds-toggle-switch input:checked + .ds-toggle-track {
  background: #1a8e3e;
}
.ds-toggle-switch input:checked + .ds-toggle-track .ds-toggle-thumb {
  transform: translateX(16px);
}

/* ── Footer ────────────────────────────────────────────────── */

.drawer-foot {
  padding: 18px 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid var(--hairline);
  background: var(--surface-2);
}
.kbd-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  font-family: var(--mono);
  font-weight: 500;
  color: var(--ink-mute);
}
.kbd-row kbd {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--ink);
  line-height: 1.2;
  min-width: 18px;
  text-align: center;
}
.kbd-row span:not(:last-child)::after {
  content: '·';
  margin-left: 6px;
  opacity: 0.5;
}

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