/* Admin mode styles — loaded on every page, but most of the UI only shows
   after successful authentication, and inline-edit affordances only activate
   under [data-admin-mode="edit"]. */

/* ---------- Header controls ---------- */

.admin-button {
  appearance: none;
  border: 1px solid var(--line-soft);
  background: transparent;
  color: var(--text-soft);
  padding: 0.55rem;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.admin-button:hover {
  color: var(--text-main);
  border-color: var(--line-strong);
}

.admin-button:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 2px;
}

.admin-button.is-authed {
  color: var(--accent-gold);
  border-color: var(--accent-gold);
}

.admin-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-pill);
  padding: 3px;
  background: var(--bg-elevated);
  backdrop-filter: blur(8px);
}

.admin-toggle[hidden] {
  display: none !important;
}

.admin-toggle__option {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font-family: var(--font-sans);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 500;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease;
}

.admin-toggle__option:hover {
  color: var(--text-main);
}

.admin-toggle__option.is-active {
  background: var(--accent-dark);
  color: var(--bg-main);
}

/* Logout — consciously separated from Account/Settings/History triad so
   a fat-finger press doesn't log the owner out when she meant Settings.
   Double-gutter on the left + subtle "danger" hover. */
.admin-toggle__logout {
  appearance: none;
  border: 0;
  background: transparent;
  color: color-mix(in srgb, var(--text-muted) 80%, transparent);
  padding: 0.4rem 0.55rem 0.4rem 0.8rem;
  margin-left: 0.55rem;
  border-left: 1px solid color-mix(in srgb, var(--line-soft) 120%, transparent);
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  border-radius: var(--radius-pill);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  transition: color var(--transition-fast), background var(--transition-fast);
}
/* Subtle divider dot to visually break the pill into sections */
.admin-toggle__logout::before {
  content: "";
  display: inline-block;
  width: 0.25rem;
  height: 0.25rem;
  border-radius: 50%;
  background: var(--line-strong);
  margin-right: 0.55rem;
  margin-left: -0.35rem;
  opacity: 0.6;
}

.admin-toggle__logout:hover {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}
.admin-toggle__logout:hover::before {
  background: var(--danger);
  opacity: 0.8;
}

.admin-toggle__logout:focus-visible {
  outline: 2px solid var(--danger);
  outline-offset: 2px;
}

/* ---------- Login dialog ---------- */

.admin-login {
  border: none;
  padding: 0;
  background: transparent;
  max-width: 440px;
  width: calc(100% - 2rem);
}

.admin-login::backdrop {
  background: rgba(23, 20, 17, 0.55);
  backdrop-filter: blur(6px);
}

.admin-login__form {
  position: relative;
  background: var(--bg-main);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: var(--space-xl) var(--space-xl) var(--space-lg);
  box-shadow: var(--shadow-strong);
  display: grid;
  gap: var(--space-lg);
  font-family: var(--font-sans);
}

.admin-login__close {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 0.35rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color 160ms ease;
}

.admin-login__close:hover {
  color: var(--text-main);
}

.admin-login__header {
  display: grid;
  gap: 0.4rem;
}

.admin-login__title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  letter-spacing: -0.01em;
  color: var(--text-main);
  margin: 0;
  line-height: 1.15;
}

.admin-login__copy {
  color: var(--text-soft);
  font-size: 0.92rem;
  line-height: 1.5;
  margin: 0;
}

.admin-login__field {
  display: grid;
  gap: 0.4rem;
}

.admin-login__field > span {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
}

.admin-login__field input {
  appearance: none;
  border: 1px solid var(--line-soft);
  background: var(--bg-main);
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-xs);
  font: inherit;
  color: var(--text-main);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.admin-login__field input:focus {
  outline: none;
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-warm) 20%, transparent);
}

.admin-login__error {
  margin: 0;
  color: var(--danger);
  font-size: 0.85rem;
}

.admin-login__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}

/* ---------- Edit mode affordances (Phase 3 will extend these) ---------- */

html[data-admin-mode="edit"] {
  /* Visual marker: top gold stripe so editor always knows they're in edit mode */
  border-top: 3px solid var(--accent-gold);
  padding-top: 0;
}

html[data-admin-mode="edit"] body::before {
  content: "Edit mode — changes save as drafts until published";
  position: fixed;
  /* Reset all four insets — base.css's body::before uses inset: 0 for
     a full-viewport decorative grid pattern, which would cascade and
     stretch this pill to half the viewport if we only set top + left. */
  top: 0;
  right: auto;
  bottom: auto;
  left: 50%;
  width: auto;
  height: auto;
  transform: translateX(-50%);
  background: var(--accent-gold);
  color: var(--bg-main);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.3rem 0.9rem;
  border-radius: 0 0 var(--radius-xs) var(--radius-xs);
  /* Also null out the decorative grid pattern + mask from base.css */
  background-size: auto;
  mask-image: none;
  opacity: 1;
  z-index: 9999;
  pointer-events: none;
}

/* Responsive: mobile header is tight — progressively compress */
@media (max-width: 720px) {
  .admin-toggle__option {
    padding: 0.35rem 0.6rem;
    font-size: 0.65rem;
  }
}

/* At narrow mobile widths, collapse admin pill to icons only. View/Edit
   text labels become dots (filled = active), so the pill stays readable
   without text labels crowding out the header. */
@media (max-width: 600px) {
  .admin-button {
    padding: 0.45rem;
    width: 2rem;
    height: 2rem;
  }
  .admin-toggle {
    padding: 2px;
  }
  .admin-toggle__option {
    padding: 0.3rem 0.45rem;
    font-size: 0;            /* hide text */
    letter-spacing: 0;
    position: relative;
    min-width: 22px;
  }
  .admin-toggle__option::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.45;
    vertical-align: middle;
  }
  .admin-toggle__option.is-active::before {
    opacity: 1;
  }
  .admin-toggle__option[data-admin-mode-btn="edit"]::before {
    /* distinguish Edit from View by shape (pencil nib triangle) */
    clip-path: polygon(0 100%, 100% 0, 100% 100%);
  }
  .admin-toggle__icon-btn,
  .admin-toggle__logout {
    padding: 0.35rem 0.4rem;
  }
  .admin-toggle__icon-btn svg,
  .admin-toggle__logout svg {
    width: 12px;
    height: 12px;
  }
  /* Save-bar buttons: tighter padding */
  .admin-save-bar {
    bottom: 0.75rem;
    gap: 0.5rem;
    padding: 0.45rem 0.55rem 0.45rem 0.85rem;
    font-size: 0.78rem;
  }
  .admin-save-bar .button {
    padding: 0.4rem 0.7rem;
    font-size: 0.7rem;
  }
  /* History drawer full-width on mobile */
  .admin-history {
    width: 100%;
  }
}

/* Hide the public sticky CTA when admin is signed in — the save-bar takes
   the same screen real estate. */
html[data-admin-mode="edit"] .sticky-project-cta {
  display: none !important;
}

/* ---------- Editable affordances (edit mode only) ---------- */

/* CONTENT — fully editable. Gold (accent-warm) affordance says "you can type here". */
html[data-admin-mode="edit"] [data-editable],
html[data-admin-mode="edit"] [data-editable-rich] {
  cursor: text;
  transition: background 160ms ease, box-shadow 160ms ease, outline-color 160ms ease;
  border-radius: 3px;
  outline: 1px dashed transparent;
  outline-offset: 3px;
}

html[data-admin-mode="edit"] [data-editable]:hover,
html[data-admin-mode="edit"] [data-editable-rich]:hover {
  outline-color: color-mix(in srgb, var(--accent-warm) 50%, transparent);
  background: color-mix(in srgb, var(--accent-warm) 6%, transparent);
}

html[data-admin-mode="edit"] [data-editable][contenteditable]:focus,
html[data-admin-mode="edit"] [data-editable-rich][contenteditable]:focus {
  outline: 2px solid var(--accent-gold);
  outline-offset: 3px;
  background: color-mix(in srgb, var(--accent-warm) 8%, transparent);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent-warm) 8%, transparent);
}

html[data-admin-mode="edit"] .is-edited {
  background: color-mix(in srgb, var(--accent-warm) 12%, transparent);
  outline: 1px dashed color-mix(in srgb, var(--accent-warm) 70%, transparent);
  outline-offset: 3px;
}

/* LOCKED LABELS — data-content-key is NOT editable. Show a muted hover hint
   only. The note-pin sits inside as a child element (positioned absolutely).
   No gold underline — this is not clickable-to-edit. */
html[data-admin-mode="edit"] [data-content-key] {
  position: relative;
  transition: background 160ms ease, outline-color 160ms ease;
  border-radius: 3px;
  outline: 1px dashed transparent;
  outline-offset: 3px;
}

html[data-admin-mode="edit"] [data-content-key]:hover,
html[data-admin-mode="edit"] [data-content-key].admin-note-host:hover {
  outline-color: rgba(128, 132, 148, 0.35);
  background: rgba(128, 132, 148, 0.05);
}

/* Host with an existing note gets a subtle left-border tag */
html[data-admin-mode="edit"] [data-content-key].has-note {
  outline-color: color-mix(in srgb, var(--accent-warm) 55%, transparent);
  background: color-mix(in srgb, var(--accent-warm) 4%, transparent);
}

/* Keep empty editables clickable + hint what was there. ::before is purely
   visual (not saved) because the field uses textContent/innerHTML directly. */
html[data-admin-mode="edit"] [data-admin-instrumented]:empty::before {
  content: "(empty — click and type to restore)";
  color: var(--text-muted);
  font-style: italic;
  opacity: 0.7;
  pointer-events: none;
}

html[data-admin-mode="edit"] [data-admin-instrumented]:empty {
  min-height: 1.2em;
  min-width: 2rem;
  display: inline-block;
}

/* ---------- Note pins on locked labels + popover bubble ----------
 * ALL admin-note styling is scoped to [data-admin-mode="edit"] so that
 * even if a pin or bubble leaked into the DOM outside edit mode (e.g.
 * stale state, forgotten cleanup), nothing would render. JS already
 * prevents creation outside edit mode, but this is defense-in-depth.
 */

html:not([data-admin-mode="edit"]) .admin-note-pin,
html:not([data-admin-mode="edit"]) .admin-note-bubble {
  display: none !important;
}

.admin-note-pin {
  position: absolute;
  top: -0.55rem;
  right: -0.55rem;
  z-index: 4;
  appearance: none;
  border: 0;
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  background: rgba(23, 20, 17, 0.68);
  color: rgba(246, 239, 230, 0.85);
  cursor: pointer;
  opacity: 0;
  transform: scale(0.82);
  transition:
    opacity 160ms ease,
    transform 160ms cubic-bezier(0.2, 0.8, 0.2, 1),
    background 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease;
  box-shadow: 0 1px 2px rgba(17, 13, 9, 0.25);
  backdrop-filter: blur(4px);
}

.admin-note-host:hover > .admin-note-pin,
.admin-note-pin:focus-visible,
.admin-note-host.has-note > .admin-note-pin {
  opacity: 1;
  transform: scale(1);
}

.admin-note-pin:hover {
  background: var(--accent-warm, #b28b68);
  color: #fff;
  box-shadow: 0 2px 6px color-mix(in srgb, var(--accent-warm) 40%, transparent);
}

.admin-note-host.has-note > .admin-note-pin {
  background: var(--accent-warm, #b28b68);
  color: #fff;
  box-shadow: 0 1px 3px color-mix(in srgb, var(--accent-warm) 35%, transparent);
}

/* Touch-friendly note pin */
@media (pointer: coarse) {
  .admin-note-pin {
    width: 2rem;
    height: 2rem;
    top: -0.85rem;
    right: -0.85rem;
    /* Always visible on touch — no hover event to trigger visibility. */
    opacity: 1 !important;
    transform: scale(1) !important;
  }
}

/* Inline-level label hosts (nav links, breadcrumbs) — pin needs to attach
   to the top-right of the text box without disrupting flow. */
html[data-admin-mode="edit"] a[data-content-key],
html[data-admin-mode="edit"] span[data-content-key],
html[data-admin-mode="edit"] dt[data-content-key] {
  display: inline-block;
}

/* ── Note-bubble popover ── */

.admin-note-bubble {
  position: absolute;
  z-index: 9999;
  background: var(--bg-main, #f3efe8);
  color: var(--text-main, #1b1712);
  border: 1px solid color-mix(in srgb, var(--border-subtle, rgba(17, 13, 9, 0.14)) 90%, transparent);
  border-radius: var(--radius-md, 0.7rem);
  box-shadow:
    0 12px 32px rgba(17, 13, 9, 0.18),
    0 2px 8px rgba(17, 13, 9, 0.10);
  padding: 0.9rem 0.9rem 0.75rem;
  display: grid;
  gap: 0.55rem;
  font-family: var(--font-sans);
  animation: admin-note-bubble-in 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes admin-note-bubble-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.admin-note-bubble__header {
  display: grid;
  gap: 0.15rem;
  line-height: 1.25;
}

.admin-note-bubble__eyebrow {
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--accent-warm, #b28b68);
}

.admin-note-bubble__label {
  font-size: 0.8rem;
  color: var(--text-muted, rgba(68, 60, 50, 0.75));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-note-bubble__label em {
  color: var(--text-main, #1b1712);
  font-style: normal;
  font-weight: 500;
}

.admin-note-bubble__textarea {
  width: 100%;
  min-height: 3.5rem;
  max-height: 11rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid color-mix(in srgb, var(--border-subtle, rgba(17, 13, 9, 0.14)) 80%, transparent);
  border-radius: var(--radius-sm, 0.4rem);
  background: color-mix(in srgb, var(--surface, #f3efe8) 60%, transparent);
  color: var(--text-main, #1b1712);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  line-height: 1.5;
  resize: vertical;
  transition: border-color 150ms ease, box-shadow 150ms ease;
  box-sizing: border-box;
}

.admin-note-bubble__textarea:focus {
  outline: none;
  border-color: var(--accent-warm, #b28b68);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-warm, #b28b68) 18%, transparent);
}

.admin-note-bubble__footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: space-between;
  flex-wrap: wrap;
}

.admin-note-bubble__key {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.68rem;
  color: var(--text-muted, rgba(68, 60, 50, 0.6));
  padding: 0.12rem 0.4rem;
  background: color-mix(in srgb, var(--accent-warm, #b28b68) 8%, transparent);
  border-radius: 3px;
  letter-spacing: 0;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-note-bubble__actions {
  display: inline-flex;
  gap: 0.4rem;
  margin-left: auto;
}

.admin-note-bubble__btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-pill, 999px);
  padding: 0.35rem 0.85rem;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease, transform 120ms ease;
}

.admin-note-bubble__btn:active { transform: scale(0.97); }

.admin-note-bubble__btn--ghost {
  background: transparent;
  color: var(--text-muted, rgba(68, 60, 50, 0.8));
  border-color: color-mix(in srgb, var(--border-subtle, rgba(17, 13, 9, 0.14)) 60%, transparent);
}
.admin-note-bubble__btn--ghost:hover {
  color: var(--text-main, #1b1712);
  border-color: color-mix(in srgb, var(--border-subtle, rgba(17, 13, 9, 0.14)) 100%, transparent);
}

.admin-note-bubble__btn--primary {
  background: var(--accent-warm, #b28b68);
  color: #fff;
  border-color: var(--accent-warm, #b28b68);
}
.admin-note-bubble__btn--primary:hover {
  background: color-mix(in srgb, var(--accent-warm, #b28b68) 85%, #000);
  border-color: color-mix(in srgb, var(--accent-warm, #b28b68) 85%, #000);
}

.admin-note-bubble__btn--danger {
  background: transparent;
  color: var(--danger, #c04a3a);
  border-color: color-mix(in srgb, var(--danger, #c04a3a) 35%, transparent);
}
.admin-note-bubble__btn--danger:hover {
  background: color-mix(in srgb, var(--danger, #c04a3a) 10%, transparent);
  border-color: var(--danger, #c04a3a);
}

/* ---------- Save bar ---------- */

.admin-save-bar {
  position: fixed;
  /* Respect iOS home-indicator safe-area on devices with notches */
  bottom: max(1.25rem, env(safe-area-inset-bottom, 0) + 0.75rem);
  left: 50%;
  transform: translateX(-50%) translateY(calc(100% + 2rem));
  display: none;
  align-items: center;
  gap: var(--space-md);
  padding: 0.55rem 0.7rem 0.55rem 1.25rem;
  background: var(--text-main);
  color: var(--bg-main);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-strong);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  z-index: 9998;
  transition: transform 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
  max-width: calc(100% - 2rem);
}

html[data-admin-mode="edit"] .admin-save-bar {
  display: inline-flex;
  transform: translateX(-50%) translateY(0);
}

.admin-save-bar__count {
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.admin-save-bar.has-pending .admin-save-bar__count::before {
  content: "●";
  color: var(--accent-gold);
  margin-right: 0.4rem;
}

/* Subtle keyboard-shortcut hint between count and action buttons.
   Desktop only (hidden on narrow screens where pill wraps). */
.admin-save-bar__kbd {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0 0.6rem 0 0.2rem;
  font-size: 0.72rem;
  color: rgba(243, 239, 232, 0.55);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.admin-save-bar__kbd[hidden] { display: none; }

/* Offline chip — visible only when navigator.onLine === false. Inline in
   the save-bar, amber/warning color so the owner understands why her
   draft-save might be deferred. */
.admin-save-bar__offline {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0 0.5rem 0 0.2rem;
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
  background: color-mix(in srgb, var(--danger) 25%, transparent);
  color: #fff;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  animation: admin-offline-pulse 2s ease-in-out infinite;
}
.admin-save-bar__offline[hidden] { display: none; }
@keyframes admin-offline-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.78; }
}
@media (max-width: 560px) {
  .admin-save-bar__offline { display: none !important; }
}
.admin-save-bar__kbd kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.68rem;
  padding: 0.08rem 0.32rem;
  border-radius: 3px;
  background: rgba(243, 239, 232, 0.12);
  color: rgba(243, 239, 232, 0.9);
  border: 1px solid rgba(243, 239, 232, 0.2);
  line-height: 1;
}
@media (max-width: 680px) {
  .admin-save-bar__kbd { display: none !important; }
}

.admin-save-bar__actions {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
}

/* Save-button busy state (spinner-ish dot sequence) */
.admin-save-bar .button.is-busy {
  position: relative;
  color: rgba(255, 255, 255, 0.85);
  cursor: wait;
}
.admin-save-bar .button.is-busy::after {
  content: "";
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  animation: admin-btn-spin 700ms linear infinite;
  margin-left: 0.45rem;
  vertical-align: middle;
}
@keyframes admin-btn-spin {
  to { transform: rotate(360deg); }
}

.admin-save-bar .button {
  padding: 0.5rem 1rem;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  border-radius: var(--radius-pill);
}

.admin-save-bar .button--ghost {
  background: transparent;
  color: rgba(243, 239, 232, 0.7);
  border: 0;
}

.admin-save-bar .button--ghost:hover:not(:disabled) {
  color: var(--bg-main);
}

.admin-save-bar .button--secondary {
  background: rgba(243, 239, 232, 0.12);
  color: var(--bg-main);
  border: 0;
}

.admin-save-bar .button--secondary:hover:not(:disabled) {
  background: rgba(243, 239, 232, 0.22);
}

.admin-save-bar .button--primary {
  background: var(--accent-gold);
  color: var(--text-main);
  border: 0;
}

.admin-save-bar .button--primary:hover:not(:disabled) {
  background: #c89a75;
}

.admin-save-bar .button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ---------- Toast ---------- */

.admin-toast {
  position: fixed;
  top: 2.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(-2rem);
  background: var(--text-main);
  color: var(--bg-main);
  padding: 0.55rem 0.7rem 0.55rem 1.1rem;
  border-radius: var(--radius-pill);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  box-shadow: var(--shadow-medium);
  opacity: 0;
  transition: opacity 260ms ease, transform 260ms ease;
  z-index: 9999;
  max-width: calc(100% - 2rem);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.admin-toast--success { border-left: 4px solid var(--success); }
.admin-toast--danger  { border-left: 4px solid var(--danger); }
.admin-toast--info    { border-left: 4px solid var(--accent-warm); }

.admin-toast__msg {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.admin-toast__controls {
  display: inline-flex;
  gap: 0.2rem;
  align-items: center;
  flex-shrink: 0;
}

.admin-toast__copy,
.admin-toast__close {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.65);
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, transform 120ms ease;
}
.admin-toast__copy:hover,
.admin-toast__close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.admin-toast__copy:active,
.admin-toast__close:active { transform: scale(0.92); }
.admin-toast__copy.is-copied {
  color: var(--success);
}
.admin-toast__copy.is-copied::after {
  content: "✓";
  position: absolute;
  font-size: 0.95rem;
  line-height: 1;
}
.admin-toast__copy.is-copied svg { display: none; }

/* ---------- Password-change modal (shares shell with publish modal) ---------- */

.admin-password {
  border: none;
  padding: 0;
  background: transparent;
  max-width: 460px;
  width: calc(100% - 2rem);
}
.admin-password::backdrop {
  background: rgba(23, 20, 17, 0.55);
  backdrop-filter: blur(6px);
}
.admin-password__panel {
  position: relative;
  background: var(--bg-main);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: var(--space-xl);
  box-shadow: var(--shadow-strong);
  display: grid;
  gap: var(--space-sm);
  font-family: var(--font-sans);
}
.admin-password__close {
  position: absolute; top: 0.85rem; right: 0.85rem;
  appearance: none; border: 0; background: transparent;
  color: var(--text-muted); padding: 0.35rem;
  border-radius: var(--radius-pill); cursor: pointer;
}
.admin-password__title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin: 0;
  color: var(--text-main);
}
.admin-password__copy {
  color: var(--text-soft);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0 0 var(--space-xs);
}
.admin-password__field {
  display: grid;
  gap: 0.35rem;
}
.admin-password__field > span {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.admin-password__field input {
  appearance: none;
  border: 1px solid var(--line-soft);
  background: var(--bg-main);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-xs);
  font: inherit;
  color: var(--text-main);
}
.admin-password__field input:focus {
  outline: none;
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-warm) 20%, transparent);
}
.admin-password__error {
  margin: 0;
  color: var(--danger);
  font-size: 0.85rem;
}
.admin-password__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}
.admin-password__actions .button--ghost {
  background: transparent;
  border: 1px solid var(--line-soft);
  color: var(--text-soft);
  padding: 0.6rem 1rem;
}

/* ---------- Publish modal ---------- */

.admin-publish {
  border: none;
  padding: 0;
  background: transparent;
  max-width: 520px;
  width: calc(100% - 2rem);
}

.admin-publish::backdrop {
  background: rgba(23, 20, 17, 0.55);
  backdrop-filter: blur(6px);
}

.admin-publish__panel {
  position: relative;
  background: var(--bg-main);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: var(--space-xl);
  box-shadow: var(--shadow-strong);
  display: grid;
  gap: var(--space-md);
  font-family: var(--font-sans);
}

.admin-publish__close {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 0.35rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.admin-publish__title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin: 0;
  color: var(--text-main);
}

.admin-publish__copy {
  color: var(--text-soft);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0;
}

.admin-publish__copy code {
  background: var(--surface-2);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82em;
}

.admin-publish__copy--muted {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.admin-publish__field {
  display: grid;
  gap: 0.35rem;
  margin-top: var(--space-xs);
}

.admin-publish__field > span {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.admin-publish__field input {
  appearance: none;
  border: 1px solid var(--line-soft);
  background: var(--bg-main);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-xs);
  font: inherit;
  color: var(--text-main);
}

.admin-publish__field input:focus {
  outline: none;
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-warm) 20%, transparent);
}

.admin-publish__error {
  margin: 0;
  color: var(--danger);
  font-size: 0.85rem;
}

.admin-publish__actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  flex-wrap: wrap;
}
.admin-publish__spacer { flex: 1; }

.admin-publish__actions .button--ghost {
  background: transparent;
  border: 1px solid var(--line-soft);
  color: var(--text-soft);
  padding: 0.6rem 1rem;
}

/* "Start fresh from live" — tertiary, subtle, left-aligned. Non-destructive
   but scary-sounding, so we soften the look so the admin's eye goes to the
   primary Publish button first. */
.admin-publish__reset {
  appearance: none;
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--text-muted, #666) 35%, transparent);
  color: var(--text-muted, #666);
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-pill, 999px);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
}
.admin-publish__reset:hover {
  border-color: color-mix(in srgb, var(--text-main, #1b1712) 50%, transparent);
  color: var(--text-main, #1b1712);
  background: color-mix(in srgb, var(--surface, #f3efe8) 60%, transparent);
}
.admin-publish__reset:disabled,
.admin-publish__reset.is-busy {
  opacity: 0.5;
  cursor: wait;
}

/* Publish preview — list of pending commits */

.admin-publish__preview {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-xs);
  background: var(--surface);
  padding: var(--space-sm) var(--space-md);
  margin-top: 0.3rem;
  max-height: 320px;
  overflow-y: auto;
}

.admin-publish__preview-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-sm);
  margin-bottom: 0.4rem;
}

.admin-publish__preview-count {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.admin-publish__commits {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.admin-publish__commit {
  background: var(--bg-main);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-xs);
  padding: 0.55rem 0.75rem;
}

.admin-publish__commit-head {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  font-size: 0.74rem;
}

.admin-publish__commit-head code {
  background: var(--surface-2);
  padding: 0.08rem 0.35rem;
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.7rem;
  color: var(--text-main);
}

.admin-publish__commit-when {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.admin-publish__diff-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--accent-gold);
  font-size: 0.7rem;
  margin-left: auto;
  cursor: pointer;
  padding: 0;
}

.admin-publish__diff-btn:hover {
  text-decoration: underline;
}

.admin-publish__commit-subject {
  margin: 0.3rem 0 0;
  color: var(--text-main);
  font-size: 0.85rem;
  line-height: 1.4;
}

.admin-publish__commit-diff {
  margin: 0.4rem 0 0;
  padding: 0.5rem;
  background: var(--surface-2);
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.7rem;
  line-height: 1.4;
  max-height: 200px;
  overflow: auto;
  white-space: pre;
  color: var(--text-main);
}

.admin-publish__empty {
  list-style: none;
  padding: var(--space-sm);
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

.admin-publish__empty--error {
  color: var(--danger);
}

/* ---------- List-add tile + dialog (FAQ / timeline new items) ---------- */

.admin-list-add {
  display: none;
  appearance: none;
  border: 1px solid color-mix(in srgb, var(--accent-warm, #b28b68) 45%, transparent);
  background: color-mix(in srgb, var(--accent-warm, #b28b68) 9%, transparent);
  color: var(--accent-warm, #b28b68);
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius-pill, 999px);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  font-weight: 500;
  align-items: center;
  gap: 0.45rem;
  transition:
    background 180ms ease,
    color 180ms ease,
    border-color 180ms ease,
    transform 120ms ease,
    box-shadow 180ms ease;
  margin-top: var(--space-md, 1.25rem);
  box-shadow: 0 1px 0 rgba(17, 13, 9, 0.03);
}

html[data-admin-mode="edit"] .admin-list-add {
  display: inline-flex;
}

.admin-list-add:hover {
  color: #fff;
  background: var(--accent-warm, #b28b68);
  border-color: var(--accent-warm, #b28b68);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent-warm) 30%, transparent);
}
.admin-list-add:active {
  transform: translateY(0);
}

.admin-list-add__plus {
  font-size: 1.1rem;
  line-height: 1;
  font-weight: 400;
  color: currentColor;
}

.admin-list-add__label {
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  font-weight: 500;
}

/* Dialog */
.admin-list-add-dialog {
  border: none;
  padding: 0;
  background: transparent;
  max-width: 520px;
  width: calc(100% - 2rem);
}

.admin-list-add-dialog::backdrop {
  background: rgba(23, 20, 17, 0.55);
  backdrop-filter: blur(6px);
}

.admin-list-add-dialog__panel {
  position: relative;
  background: var(--bg-main);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: var(--space-xl);
  box-shadow: var(--shadow-strong);
  display: grid;
  gap: var(--space-sm);
  font-family: var(--font-sans);
}

.admin-list-add-dialog__close {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 0.35rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.admin-list-add-dialog__title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin: 0;
  color: var(--text-main);
}

.admin-list-add-dialog__fields {
  display: grid;
  gap: 0.8rem;
}

.admin-list-add-dialog__field {
  display: grid;
  gap: 0.35rem;
}

.admin-list-add-dialog__field > span {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.admin-list-add-dialog__field input,
.admin-list-add-dialog__field textarea {
  appearance: none;
  border: 1px solid var(--line-soft);
  background: var(--bg-main);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-xs);
  font: inherit;
  color: var(--text-main);
  resize: vertical;
}

.admin-list-add-dialog__field input:focus,
.admin-list-add-dialog__field textarea:focus {
  outline: none;
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-warm) 20%, transparent);
}

.admin-list-add-dialog__error {
  margin: 0;
  color: var(--danger);
  font-size: 0.85rem;
}

.admin-list-add-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  margin-top: var(--space-xs);
}

.admin-list-add-dialog__actions .button--ghost {
  background: transparent;
  border: 1px solid var(--line-soft);
  color: var(--text-soft);
  padding: 0.6rem 1rem;
}


/* ---------- Drag handle + Eye (admin card controls) ----------
 * Two buttons on every card / gallery item in edit mode:
 *   · drag handle — top-LEFT corner, accent-warm pill, grabbable
 *   · eye (visibility) — top-RIGHT corner, neutral → danger when hidden
 *
 * Both controls keep full opacity even when the card is hidden (ghosted),
 * so the owner can always reorder or un-hide.
 */

html[data-admin-mode="edit"] .project-card,
html[data-admin-mode="edit"] .gallery-masonry__item {
  position: relative;
}

/* Drop-line positions absolutely inside the drag container — guarantee it
   has a positioning context. */
html[data-admin-mode="edit"] [data-portfolio-grid],
html[data-admin-mode="edit"] [data-portfolio-list],
html[data-admin-mode="edit"] [data-project-gallery] {
  position: relative;
}

.admin-drag-handle,
.admin-eye {
  position: absolute;
  top: 0.75rem;
  display: none;
  appearance: none;
  border: 1px solid rgba(246, 239, 230, 0.15);
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border-radius: var(--radius-pill);
  align-items: center;
  justify-content: center;
  z-index: 5;
  box-shadow:
    0 2px 6px rgba(17, 13, 9, 0.25),
    0 0 0 1px rgba(17, 13, 9, 0.05);
  backdrop-filter: blur(6px);
  transition:
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease,
    opacity 160ms ease;
}

/* Touch-friendly: enlarge hit area on coarse pointers (mobile / tablet).
   iOS Human Interface Guidelines target 44pt minimum; Android Material 48dp. */
@media (pointer: coarse) {
  .admin-drag-handle,
  .admin-eye {
    width: 2.75rem;
    height: 2.75rem;
    top: 0.6rem;
  }
  .admin-drag-handle { left: 0.6rem; }
  .admin-eye { right: 0.6rem; }
}

/* Drag handle — TOP-LEFT */
.admin-drag-handle {
  left: 0.75rem;
  background: rgba(23, 20, 17, 0.82);
  color: rgba(246, 239, 230, 0.92);
  cursor: grab;
}
.admin-drag-handle:hover {
  background: var(--accent-warm, #b28b68);
  color: #fff;
  transform: scale(1.06);
  box-shadow:
    0 4px 10px color-mix(in srgb, var(--accent-warm) 35%, transparent),
    0 0 0 1px color-mix(in srgb, var(--accent-warm) 30%, transparent);
}
.admin-drag-handle:active {
  cursor: grabbing;
  transform: scale(0.96);
}

/* Eye — TOP-RIGHT */
.admin-eye {
  right: 0.75rem;
  background: rgba(23, 20, 17, 0.82);
  color: rgba(246, 239, 230, 0.92);
  cursor: pointer;
}
.admin-eye:hover {
  background: var(--accent-warm, #b28b68);
  color: #fff;
  transform: scale(1.06);
  box-shadow:
    0 4px 10px color-mix(in srgb, var(--accent-warm) 35%, transparent),
    0 0 0 1px color-mix(in srgb, var(--accent-warm) 30%, transparent);
}

html[data-admin-mode="edit"] .admin-drag-handle,
html[data-admin-mode="edit"] .admin-eye {
  display: inline-flex;
}

/*
 * Trash button — sits BELOW the eye icon (top-right column), red-tinted.
 * Only mounted on draft-project gallery items by visibility.js (see
 * isDraftProject check). Click → confirm → mutate images[] removing
 * the entry. Server's assertNoDeletes permits this when the project is
 * a draft in both prev and next states.
 */
.admin-trash {
  position: absolute;
  top: 3.4rem;
  right: 0.75rem;
  display: none;
  appearance: none;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  align-items: center;
  justify-content: center;
  z-index: 5;
  border: 1px solid color-mix(in srgb, var(--danger) 50%, transparent);
  border-radius: var(--radius-pill);
  /* Same dark base as the eye for visual consistency, but the trash icon
   * itself paints in --danger so the destructive intent is unmistakable. */
  background: rgba(23, 20, 17, 0.82);
  color: var(--danger);
  cursor: pointer;
  box-shadow:
    0 2px 6px rgba(17, 13, 9, 0.25),
    0 0 0 1px rgba(17, 13, 9, 0.05);
  backdrop-filter: blur(6px);
  transition:
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease;
}

@media (pointer: coarse) {
  .admin-trash {
    width: 2.75rem;
    height: 2.75rem;
    top: 4.05rem;
    right: 0.6rem;
  }
}

.admin-trash:hover {
  background: var(--danger);
  color: #fff;
  transform: scale(1.06);
  box-shadow:
    0 4px 10px color-mix(in srgb, var(--danger) 45%, transparent),
    0 0 0 1px color-mix(in srgb, var(--danger) 40%, transparent);
}

.admin-trash:focus-visible {
  outline: 2px solid var(--danger);
  outline-offset: 2px;
}

html[data-admin-mode="edit"] .admin-trash {
  display: inline-flex;
}

/* ── Hidden-card state ──
 * We DON'T opacity the whole card, because CSS opacity cascades and
 * would fade the drag handle + eye into invisibility — which caused
 * the "handle disappears after a few hides" bug. Instead, ghost just
 * the content children, keeping admin controls crisp at full opacity.
 */
html[data-admin-mode="edit"] .is-hidden-admin {
  background-image: repeating-linear-gradient(
    45deg,
    rgba(23, 20, 17, 0.08),
    rgba(23, 20, 17, 0.08) 8px,
    transparent 8px,
    transparent 16px
  );
}

html[data-admin-mode="edit"] .is-hidden-admin > *:not(.admin-drag-handle):not(.admin-eye) {
  opacity: 0.38;
  filter: saturate(0.55);
  transition: opacity 220ms ease, filter 220ms ease;
}

/* Hidden card: eye shifts to a clear "it's hidden" red, handle keeps neutral */
html[data-admin-mode="edit"] .is-hidden-admin .admin-eye {
  background: var(--danger, #c04a3a);
  color: #fff;
  border-color: color-mix(in srgb, var(--danger, #c04a3a) 35%, transparent);
}
html[data-admin-mode="edit"] .is-hidden-admin .admin-eye:hover {
  background: color-mix(in srgb, var(--danger, #c04a3a) 85%, #000);
}

/* ── SortableJS drop-drag visual states ──
 * ghostClass   → placeholder left behind in the flow where item will drop
 * chosenClass  → item actually grabbed (under the cursor), visible lift
 * dragClass    → clone flying with the cursor
 */
.admin-drag-ghost {
  opacity: 0.55;
  background: color-mix(in srgb, var(--accent-warm, #b28b68) 14%, transparent);
  outline: 2px dashed var(--accent-warm, #b28b68);
  outline-offset: -4px;
  border-radius: var(--radius-md, 0.7rem);
  animation: admin-drag-drop-pulse 1.4s ease-in-out infinite;
}
.admin-drag-ghost > * {
  opacity: 0.25;
  transition: opacity 180ms ease;
}

.admin-drag-chosen {
  box-shadow:
    0 0 0 2px var(--accent-warm, #b28b68),
    0 12px 30px rgba(17, 13, 9, 0.25),
    0 4px 12px color-mix(in srgb, var(--accent-warm) 35%, transparent);
  z-index: 10 !important;
  transition: transform 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
  transform: scale(1.02);
}

.admin-drag-drag {
  transform: scale(1.03) rotate(-0.6deg);
  filter: drop-shadow(0 12px 28px rgba(17, 13, 9, 0.3));
  cursor: grabbing;
}

@keyframes admin-drag-drop-pulse {
  0%, 100% {
    outline-color: var(--accent-warm, #b28b68);
    background: color-mix(in srgb, var(--accent-warm, #b28b68) 14%, transparent);
  }
  50% {
    outline-color: color-mix(in srgb, var(--accent-warm, #b28b68) 60%, transparent);
    background: color-mix(in srgb, var(--accent-warm, #b28b68) 22%, transparent);
  }
}

/* ── Grab animation ──
 * On onChoose (the moment the user holds down on a drag handle), ALL
 * sibling cards shrink by 4% — a subtle "I'm ready to receive you"
 * gesture. On onMove, the element we're hovering over also shifts by
 * 2% (half the shrink) away from the drop location — a clear physical
 * "make room" nudge. Matches Apple Photos / Finder icon-drag feel.
 *
 * States added by sortable-binder.js:
 *   body.admin-is-grabbed          — from onChoose to onUnchoose
 *   body.admin-is-dragging         — from onStart to onEnd (subset of above)
 *   .admin-drag-near + --before/--after + --vertical/--horizontal
 *                                  — applied to evt.related during onMove
 */
body.admin-is-grabbed .project-card:not(.admin-drag-chosen):not(.admin-drag-ghost),
body.admin-is-grabbed .gallery-masonry__item:not(.admin-drag-chosen):not(.admin-drag-ghost),
body.admin-is-dragging .project-card:not(.admin-drag-chosen):not(.admin-drag-ghost),
body.admin-is-dragging .gallery-masonry__item:not(.admin-drag-chosen):not(.admin-drag-ghost) {
  transform: scale(0.96);
  transition:
    transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1) !important,
    filter 260ms ease !important;
  filter: saturate(0.95);
}

/* The "near target" — where the drop will insert — shifts aside by ~2%
   of its own width (half the 4% shrink, per the UX spec) so the owner
   sees space opening up for the incoming card without feeling jarring.
   Horizontal axis (wide items) gets a slightly larger nudge because the
   percent is of a smaller dimension. */
.admin-drag-near {
  /* Will be combined with scale(0.96) above via transform composition. */
}
.admin-drag-near.admin-drag-near--horizontal.admin-drag-near--before {
  transform: scale(0.96) translateX(4%) !important;
}
.admin-drag-near.admin-drag-near--horizontal.admin-drag-near--after {
  transform: scale(0.96) translateX(-4%) !important;
}
.admin-drag-near.admin-drag-near--vertical.admin-drag-near--before {
  transform: scale(0.96) translateY(3%) !important;
}
.admin-drag-near.admin-drag-near--vertical.admin-drag-near--after {
  transform: scale(0.96) translateY(-3%) !important;
}
/* The near target gets a warm glow outline too — visual reinforcement
   that this is where the card will land. */
.admin-drag-near::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-warm) 55%, transparent);
  animation: admin-drag-near-pulse 1s ease-in-out infinite;
}
@keyframes admin-drag-near-pulse {
  0%, 100% { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-warm) 40%, transparent); }
  50%      { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-warm) 70%, transparent); }
}

/* Respect reduced-motion preferences. */
@media (prefers-reduced-motion: reduce) {
  body.admin-is-grabbed .project-card,
  body.admin-is-grabbed .gallery-masonry__item,
  body.admin-is-dragging .project-card,
  body.admin-is-dragging .gallery-masonry__item,
  .admin-drag-near {
    transform: none !important;
    filter: none !important;
  }
  .admin-drag-near::after { animation: none; }
}

/* Drop-line indicator — a thin accent line that sits between two items
   to clearly signal "drop happens here". Shown via the .admin-drop-line
   element inserted by sortable-binder.js's onMove. */
.admin-drop-line {
  position: absolute;
  background: var(--accent-warm, #b28b68);
  border-radius: 999px;
  z-index: 8;
  pointer-events: none;
  box-shadow:
    0 0 12px color-mix(in srgb, var(--accent-warm) 60%, transparent),
    0 0 0 1px rgba(255, 255, 255, 0.25);
  animation: admin-drop-line-pulse 1.1s ease-in-out infinite;
}

@keyframes admin-drop-line-pulse {
  0%, 100% { opacity: 0.85; transform: scale(1); }
  50%      { opacity: 1;    transform: scale(1.02); }
}

/* ---------- Add Image from Project — toolbar + dialog ---------- */

.admin-gallery-toolbar {
  display: none;
  align-items: center;
  gap: var(--space-md, 1.5rem);
  margin: 0 0 var(--space-md, 1.5rem);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md, 0.7rem);
  background: color-mix(in srgb, var(--accent-warm, #b28b68) 8%, transparent);
  border: 1px dashed color-mix(in srgb, var(--accent-warm, #b28b68) 45%, transparent);
  flex-wrap: wrap;
}

html[data-admin-mode="edit"] .admin-gallery-toolbar {
  display: flex;
}

.admin-gallery-toolbar__add {
  appearance: none;
  border: 0;
  background: var(--accent-warm, #b28b68);
  color: #fff;
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius-pill, 999px);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  box-shadow: 0 2px 6px color-mix(in srgb, var(--accent-warm) 30%, transparent);
  transition: background 150ms ease, transform 120ms ease, box-shadow 150ms ease;
}
.admin-gallery-toolbar__add:hover {
  background: color-mix(in srgb, var(--accent-warm, #b28b68) 88%, #000);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px color-mix(in srgb, var(--accent-warm) 40%, transparent);
}
.admin-gallery-toolbar__add:active {
  transform: translateY(0);
}

.admin-gallery-toolbar__hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted, rgba(68, 60, 50, 0.75));
  flex: 1 1 16rem;
  min-width: 0;
}

/* ── Dialog ── */
.admin-add-gallery {
  border: none;
  padding: 0;
  background: transparent;
  max-width: min(1100px, 94vw);
  width: calc(100% - 2rem);
}
.admin-add-gallery::backdrop {
  background: rgba(23, 20, 17, 0.6);
  backdrop-filter: blur(6px);
}

.admin-add-gallery__shell {
  background: var(--bg-main);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md, 0.7rem);
  box-shadow: var(--shadow-strong);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  max-height: 90vh;
  overflow: hidden;
  font-family: var(--font-sans);
}

.admin-add-gallery__header {
  display: flex;
  gap: 1rem;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--line-soft);
  align-items: flex-start;
}
.admin-add-gallery__header > div:first-child { flex: 1; min-width: 0; }
.admin-add-gallery__title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  line-height: 1.3;
  margin: 0.15rem 0 0.25rem;
  color: var(--text-main);
}
.admin-add-gallery__hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  max-width: 60ch;
}
.admin-add-gallery__close {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0.4rem;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}
.admin-add-gallery__close:hover { color: var(--text-main); background: var(--surface-2); }

.admin-add-gallery__toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  background: color-mix(in srgb, var(--surface, #f3efe8) 70%, transparent);
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.admin-add-gallery__project-label {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}
.admin-add-gallery__toolbar select {
  appearance: none;
  font: inherit;
  background: var(--bg-main);
  border: 1px solid var(--line-soft);
  color: var(--text-main);
  padding: 0.45rem 2rem 0.45rem 0.7rem;
  border-radius: var(--radius-sm);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
  max-width: 18rem;
}
.admin-add-gallery__legend {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}
.admin-add-gallery__dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 0.2rem;
}
.admin-add-gallery__dot--in { background: var(--accent-warm, #b28b68); }
.admin-add-gallery__dot--out { background: color-mix(in srgb, var(--text-muted, #888) 50%, transparent); }

.admin-add-gallery__grid {
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.6rem;
}

.admin-add-gallery__tile {
  appearance: none;
  margin: 0;
  border: 2px solid transparent;
  padding: 0;
  background: var(--surface);
  border-radius: var(--radius-sm);
  aspect-ratio: 4 / 3;
  overflow: hidden;
  position: relative;
  transition: transform 160ms cubic-bezier(0.2, 0.8, 0.2, 1), border-color 160ms ease, box-shadow 160ms ease;
}
.admin-add-gallery__tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 160ms ease, filter 160ms ease;
}
.admin-add-gallery__tile:hover {
  transform: scale(1.01);
  box-shadow: 0 6px 18px rgba(17, 13, 9, 0.12);
}
.admin-add-gallery__tile:focus-within {
  border-color: var(--accent-warm, #b28b68);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-warm, #b28b68) 25%, transparent);
}

/* Control row at the bottom of each tile — single Add/Added toggle */
.admin-add-gallery__tile-controls {
  position: absolute;
  left: 0.4rem;
  right: 0.4rem;
  bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  justify-content: flex-end;
}
.admin-add-gallery__ctl {
  appearance: none;
  border: 0;
  padding: 0.32rem 0.6rem;
  border-radius: var(--radius-pill, 999px);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: background 150ms ease, transform 120ms ease, box-shadow 150ms ease;
  backdrop-filter: blur(6px);
  line-height: 1;
}
.admin-add-gallery__ctl:active { transform: scale(0.96); }

.admin-add-gallery__ctl--primary {
  background: rgba(23, 20, 17, 0.7);
  color: #fff;
}
.admin-add-gallery__ctl--primary[aria-pressed="true"] {
  background: var(--accent-warm, #b28b68);
  color: #fff;
}
.admin-add-gallery__ctl--primary:hover {
  background: color-mix(in srgb, var(--accent-warm, #b28b68) 75%, #000);
}

/* Two-state tiles (v1.28.4): "in" = added (highlighted), "out" = not
 * added (dimmed). No "hidden" middle state any more. */
.admin-add-gallery__tile--in { border-color: var(--accent-warm, #b28b68); }
.admin-add-gallery__tile--out img { opacity: 0.55; }

.admin-add-gallery__badge {
  position: absolute;
  left: 0.4rem;
  bottom: 0.4rem;
  padding: 0.2rem 0.55rem;
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  border-radius: var(--radius-pill);
  color: #fff;
  backdrop-filter: blur(4px);
}
.admin-add-gallery__badge--in  { background: var(--accent-warm, #b28b68); }
.admin-add-gallery__badge--out { background: rgba(23, 20, 17, 0.68); }

.admin-add-gallery__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--line-soft);
  background: var(--bg-main);
  flex-wrap: wrap;
}
.admin-add-gallery__summary {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.admin-add-gallery__actions {
  display: inline-flex;
  gap: 0.5rem;
}
.admin-add-gallery__actions .button--ghost {
  background: transparent;
  border: 1px solid var(--line-soft);
  color: var(--text-soft);
  padding: 0.5rem 1rem;
}

/* Masonry layout is preserved in Edit mode — items keep their original
 * aspect ratios. Reordering is done via the click-arrow controls
 * (<, NN, >) rather than drag, for stability and predictability.
 * See .admin-reorder rules below. */

/* ──────────────────────────────────────────────────────────────
 * Gallery reorder pill — [<] [NN] [>]
 *
 * Sits in the top-left corner of every gallery item in Edit mode,
 * replacing the old drag handle for gallery images. Click arrow =
 * move one slot. Type a number + Enter = jump to that slot. Arrow
 * keys in the input also step. Works on both the /portfolio Gallery
 * view (cross-project via site.galleryOrder) and /projects/{slug}
 * masonry (via project.images[]).
 * ────────────────────────────────────────────────────────────── */

.admin-reorder {
  position: absolute;
  top: 0.7rem;
  left: 0.7rem;
  z-index: 5;
  display: none;
  align-items: stretch;
  height: 2rem;
  background: rgba(23, 20, 17, 0.84);
  color: rgba(246, 239, 230, 0.92);
  border: 1px solid rgba(246, 239, 230, 0.15);
  border-radius: var(--radius-pill);
  box-shadow:
    0 2px 6px rgba(17, 13, 9, 0.3),
    0 0 0 1px rgba(17, 13, 9, 0.05);
  backdrop-filter: blur(6px);
  overflow: hidden;
  font-family: var(--font-sans);
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

html[data-admin-mode="edit"] .admin-reorder { display: inline-flex; }
html:not([data-admin-mode="edit"]) .admin-reorder { display: none !important; }

.admin-reorder__arrow {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  width: 1.95rem;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition:
    color var(--transition-fast),
    background var(--transition-fast),
    transform 120ms ease;
}
.admin-reorder__arrow:hover:not(:disabled) {
  color: #fff;
  background: var(--accent-warm);
}
.admin-reorder__arrow:active:not(:disabled) {
  transform: scale(0.92);
}
.admin-reorder__arrow:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}
.admin-reorder__arrow:focus-visible {
  outline: 2px solid var(--accent-warm);
  outline-offset: -2px;
}

.admin-reorder__index {
  appearance: textfield;
  -moz-appearance: textfield;
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  width: 2.4rem;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0 0.15rem;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  transition: background var(--transition-fast);
}
.admin-reorder__index::-webkit-outer-spin-button,
.admin-reorder__index::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.admin-reorder__index:hover {
  background: rgba(255, 255, 255, 0.12);
}
.admin-reorder__index:focus {
  outline: none;
  background: var(--accent-warm);
  color: #fff;
}

/* Touch-friendly: grow to 44pt on coarse pointers */
@media (pointer: coarse) {
  .admin-reorder {
    height: 2.5rem;
    top: 0.55rem;
    left: 0.55rem;
  }
  .admin-reorder__arrow { width: 2.4rem; }
  .admin-reorder__index { width: 2.8rem; font-size: 0.85rem; }
}

/* Gentle transform transition on gallery items in edit mode so a
   reorder click settles smoothly instead of snapping. Only applies
   once masonry has laid out (is-laid-out) so the first render
   doesn't flash. */
html[data-admin-mode="edit"] .gallery-masonry.is-laid-out .gallery-masonry__item {
  transition: transform 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ---------- Rich-text toolbar ---------- */

.admin-rich-toolbar {
  position: absolute;
  z-index: 10000;
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--text-main);
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-medium);
  font-family: var(--font-sans);
}

.admin-rich-toolbar[hidden] { display: none !important; }

.admin-rich-toolbar button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--bg-main);
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.82rem;
  transition: background 140ms ease;
}

.admin-rich-toolbar button:hover { background: rgba(243, 239, 232, 0.15); }
.admin-rich-toolbar button:active { background: rgba(243, 239, 232, 0.28); }

html[data-admin-mode="edit"] [data-editable-rich][contenteditable]:focus {
  outline: 2px solid var(--accent-gold);
  outline-offset: 3px;
  background: color-mix(in srgb, var(--accent-warm) 8%, transparent);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent-warm) 8%, transparent);
}

/* ---------- Add-image tile ---------- */

.admin-add-image {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 200px;
  padding: var(--space-lg);
  appearance: none;
  border: 2px dashed var(--line-strong);
  background: var(--bg-elevated);
  color: var(--text-soft);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
  font-family: var(--font-sans);
}

html[data-admin-mode="edit"] .admin-add-image {
  display: flex;
}

.admin-add-image:hover {
  border-color: var(--accent-gold);
  background: color-mix(in srgb, var(--accent-warm) 8%, transparent);
  color: var(--accent-gold);
}

.admin-add-image__plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-pill);
  border: 1px solid currentColor;
}

.admin-add-image__label {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
}

.admin-add-image.is-uploading {
  opacity: 0.7;
  border-style: solid;
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  pointer-events: none;
}

/* ---------- Add new project tile (Projects view, Edit mode) ---------- */

/*
 * Mirrors .project-card layout (same min-height + border-radius) so it lives
 * naturally as the first item in a project-grid. Visible only when the owner
 * is in Edit mode. Click → POST /create-draft-project → redirect to
 * /projects/draft-N. See draft-mode.js.
 */
.admin-add-project {
  display: none;
  position: relative;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  min-height: 26rem;
  padding: var(--space-lg);
  appearance: none;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--accent-warm) 22%, transparent) 0%, transparent 55%),
    linear-gradient(135deg,
      color-mix(in srgb, var(--accent-warm) 18%, var(--bg-soft)) 0%,
      color-mix(in srgb, var(--text-main) 6%, var(--bg-soft)) 100%);
  color: var(--text-soft);
  cursor: pointer;
  transition: background 200ms ease, border-color 200ms ease, color 200ms ease, transform 200ms ease, box-shadow 200ms ease;
  font-family: var(--font-sans);
  text-align: center;
}

html[data-admin-mode="edit"] .admin-add-project {
  display: flex;
}

.admin-add-project:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  transform: translateY(-2px);
  box-shadow: var(--shadow-medium, 0 16px 32px rgba(23, 20, 17, 0.12));
}

.admin-add-project:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 4px;
}

.admin-add-project__plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-pill);
  border: 1.5px solid currentColor;
}

.admin-add-project__label {
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--text-main);
}

.admin-add-project__hint {
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--text-soft);
  max-width: 22ch;
  line-height: 1.45;
}

.admin-add-project.is-busy {
  opacity: 0.7;
  border-style: solid;
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  pointer-events: none;
  cursor: progress;
}

/* ---------- Draft image placeholders (hero + slot 2) ---------- */

/*
 * The hero/slot-2 figures get a `--placeholder` modifier when the entry
 * is the sentinel created by /create-draft-project. CSS draws a textured
 * gradient (no SVG file involved) and a click-to-upload CTA in the centre.
 * draft-mode.js wires click + drag-drop only in Edit mode.
 */

/*
 * Hero placeholder: do NOT override `position`. The base
 * `.detail-hero__image` is `position: absolute; inset: 0` which both
 * stretches the box to fill .page-hero__inner AND serves as the
 * containing block for the absolute-positioned .placeholder-cta inside.
 * Setting position:relative here would collapse the box to its content
 * height (which is 0 because the only child is the absolute CTA).
 */
.detail-hero__image--placeholder {
  background:
    radial-gradient(circle at 30% 22%, color-mix(in srgb, var(--accent-warm) 28%, transparent) 0%, transparent 55%),
    linear-gradient(135deg,
      color-mix(in srgb, var(--accent-warm) 28%, var(--bg-soft)) 0%,
      color-mix(in srgb, var(--text-main) 16%, var(--bg-soft)) 60%,
      color-mix(in srgb, var(--text-main) 28%, var(--bg-main)) 100%);
  overflow: hidden;
}

/*
 * Slot 2 (feature) placeholder: base `.project-narrative__feature-img`
 * is position:static (flex item with min-height: 16rem), so DOES need
 * `position: relative` here to anchor the absolute CTA overlay.
 */
.project-narrative__feature-img--placeholder {
  position: relative;
  background:
    radial-gradient(circle at 30% 22%, color-mix(in srgb, var(--accent-warm) 28%, transparent) 0%, transparent 55%),
    linear-gradient(135deg,
      color-mix(in srgb, var(--accent-warm) 28%, var(--bg-soft)) 0%,
      color-mix(in srgb, var(--text-main) 16%, var(--bg-soft)) 60%,
      color-mix(in srgb, var(--text-main) 28%, var(--bg-main)) 100%);
  overflow: hidden;
}

/* Subtle grid lines for visual texture (echoes the SVG version we replaced) */
.detail-hero__image--placeholder::before,
.project-narrative__feature-img--placeholder::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to right, color-mix(in srgb, var(--bg-main) 10%, transparent) 1px, transparent 1px) center / 50% 100% no-repeat,
    linear-gradient(to bottom, color-mix(in srgb, var(--bg-main) 10%, transparent) 1px, transparent 1px) center / 100% 50% no-repeat;
  pointer-events: none;
}

/* Centred upload CTA — visible in both modes; click handler is wired only in Edit mode */
.placeholder-cta {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.55rem;
  text-align: center;
  color: color-mix(in srgb, var(--bg-main) 88%, transparent);
  font-family: var(--font-sans);
  pointer-events: none;
}

.placeholder-cta__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 999px;
  border: 1.5px solid currentColor;
  margin-bottom: 0.25rem;
}

.placeholder-cta__label {
  font-size: 0.92rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 500;
}

.placeholder-cta__hint {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  opacity: 0.75;
}

/* Edit mode: enable interactivity (cursor, hover lift, drop highlight) */
html[data-admin-mode="edit"] .detail-hero__image--placeholder,
html[data-admin-mode="edit"] .project-narrative__feature-img--placeholder {
  cursor: pointer;
  transition: filter 200ms ease;
}

html[data-admin-mode="edit"] .detail-hero__image--placeholder:hover,
html[data-admin-mode="edit"] .project-narrative__feature-img--placeholder:hover {
  filter: brightness(1.1);
}

html[data-admin-mode="edit"] .detail-hero__image--placeholder.is-drag-over,
html[data-admin-mode="edit"] .project-narrative__feature-img--placeholder.is-drag-over {
  outline: 2px dashed var(--accent-gold);
  outline-offset: -10px;
  filter: brightness(1.15);
}

html[data-admin-mode="edit"] .detail-hero__image--placeholder.is-uploading,
html[data-admin-mode="edit"] .project-narrative__feature-img--placeholder.is-uploading {
  pointer-events: none;
  filter: brightness(0.85);
  cursor: progress;
}

/*
 * Draft hero with a real image already uploaded — show a hover-revealed
 * Replace overlay so the owner can swap the photo without losing the
 * upload affordance after first upload.
 *
 * IMPORTANT: do NOT add `position: relative` on the parent here. Base
 * `.detail-hero__image` is `position: absolute; inset:0` which already
 * serves as the containing block for the absolute overlay. Adding
 * relative collapses the hero box to the broken-img height (~26px) —
 * that's exactly the regression that made e6860b0 unusable.
 */
/* Hero replaceable — only cursor change. Base .detail-hero__image is
 * position:absolute; inset:0 and serves as containing block for the
 * absolute overlay. Adding position:relative here would collapse the
 * hero to broken-img height. */
html[data-admin-mode="edit"] .detail-hero__image--draft-replaceable {
  cursor: pointer;
}

/* Slot 2 replaceable — base .project-narrative__feature-img is static
 * (flex item with min-height:16rem), so we DO need a positioning context
 * to anchor the absolute Replace overlay. */
html[data-admin-mode="edit"] .project-narrative__feature-img--draft-replaceable {
  cursor: pointer;
  position: relative;
}

.placeholder-cta--replace {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.55rem;
  text-align: center;
  color: #fff;
  font-family: var(--font-sans);
  background: rgba(15, 12, 10, 0.55);
  opacity: 0;
  transition: opacity 200ms ease;
  pointer-events: none;
}

html[data-admin-mode="edit"] .detail-hero__image--draft-replaceable:hover .placeholder-cta--replace,
html[data-admin-mode="edit"] .detail-hero__image--draft-replaceable:focus-visible .placeholder-cta--replace,
html[data-admin-mode="edit"] .detail-hero__image--draft-replaceable.is-drag-over .placeholder-cta--replace,
html[data-admin-mode="edit"] .project-narrative__feature-img--draft-replaceable:hover .placeholder-cta--replace,
html[data-admin-mode="edit"] .project-narrative__feature-img--draft-replaceable:focus-visible .placeholder-cta--replace,
html[data-admin-mode="edit"] .project-narrative__feature-img--draft-replaceable.is-drag-over .placeholder-cta--replace {
  opacity: 1;
}

html[data-admin-mode="edit"] .detail-hero__image--draft-replaceable.is-drag-over,
html[data-admin-mode="edit"] .project-narrative__feature-img--draft-replaceable.is-drag-over {
  outline: 2px dashed var(--accent-gold);
  outline-offset: -10px;
}

html[data-admin-mode="edit"] .detail-hero__image--draft-replaceable.is-uploading .placeholder-cta--replace,
html[data-admin-mode="edit"] .project-narrative__feature-img--draft-replaceable.is-uploading .placeholder-cta--replace {
  opacity: 1;
}
html[data-admin-mode="edit"] .detail-hero__image--draft-replaceable.is-uploading,
html[data-admin-mode="edit"] .project-narrative__feature-img--draft-replaceable.is-uploading {
  pointer-events: none;
  cursor: progress;
}

/* ---------- Draft category picker ---------- */

/*
 * Replaces the inline category text span with a <select> in the hero meta
 * row for draft projects. Inherits the surrounding text style so it lines
 * up visually with the other meta items, plus a subtle chevron to signal
 * it's interactive. Only attached to drafts via draft-mode.js.
 */
.draft-category-picker {
  appearance: none;
  -webkit-appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, currentColor 50%) calc(100% - 0.55rem) 50% / 4px 4px no-repeat,
    linear-gradient(-45deg, transparent 50%, currentColor 50%) calc(100% - 0.25rem) 50% / 4px 4px no-repeat,
    color-mix(in srgb, var(--accent-warm) 8%, transparent);
  border: 1px dashed color-mix(in srgb, var(--accent-warm) 60%, transparent);
  border-radius: var(--radius-sm, 6px);
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  padding: 0.15rem 1.4rem 0.15rem 0.6rem;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.draft-category-picker:hover {
  border-color: var(--accent-gold);
  background-color: color-mix(in srgb, var(--accent-warm) 14%, transparent);
}

.draft-category-picker:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 2px;
}

.draft-category-picker option {
  /* Browser default <option> styling — readable on both light and dark themes */
  background: var(--bg-main);
  color: var(--text-main);
}

/* ---------- Publish button in toggle pill ---------- */

.admin-toggle .admin-toggle__publish {
  appearance: none;
  border: 0;
  background: var(--accent-gold);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 500;
  padding: 0.4rem 0.9rem;
  margin-left: 0.1rem;
  border-left: 1px solid var(--line-soft);
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.admin-toggle .admin-toggle__publish:hover {
  background: #c89a75;
}

.admin-toggle__icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 0.4rem 0.45rem;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  border-radius: var(--radius-pill);
  transition: color var(--transition-fast), background var(--transition-fast);
}
/* Only the FIRST icon-button in the group carries a divider from the
   View/Edit pill. Siblings just space naturally. */
.admin-toggle__icon-btn:first-of-type {
  margin-left: 0.35rem;
  padding-left: 0.6rem;
  border-left: 1px solid var(--line-soft);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.admin-toggle__icon-btn:hover {
  color: var(--accent-warm);
  background: color-mix(in srgb, var(--accent-warm) 8%, transparent);
}

.admin-toggle__icon-btn:focus-visible {
  outline: 2px solid var(--accent-warm);
  outline-offset: 2px;
}

/* ---------- History drawer ---------- */

.admin-history {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(540px, 100%);
  background: var(--bg-main);
  border-left: 1px solid var(--line-soft);
  box-shadow: var(--shadow-strong);
  z-index: 9997;
  transform: translateX(100%);
  transition: transform 320ms cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
}

.admin-history.is-open {
  transform: translateX(0);
}

.admin-history__header {
  position: relative;
  padding: var(--space-lg) var(--space-lg) var(--space-md);
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  gap: 0.3rem;
}

.admin-history__title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0;
  color: var(--text-main);
  line-height: 1.2;
}

.admin-history__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 0.35rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.admin-history__close:hover { color: var(--text-main); }

.admin-history__list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}

.admin-history__empty {
  padding: var(--space-xl);
  color: var(--text-muted);
  text-align: center;
  font-size: 0.9rem;
}

.admin-history__empty--error {
  color: var(--danger);
}

.admin-history__item {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  gap: 0.45rem;
}

.admin-history__meta {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.admin-history__author {
  font-weight: 500;
  color: var(--text-soft);
}

.admin-history__sha {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--surface-2);
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
  font-size: 0.7rem;
  color: var(--text-main);
}

.admin-history__subject {
  margin: 0;
  color: var(--text-main);
  font-size: 0.92rem;
  line-height: 1.4;
  word-break: break-word;
}

.admin-history__actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.4rem;
  flex-wrap: wrap;
}
.admin-history__actions-group {
  display: inline-flex;
  gap: 0.3rem;
}
.admin-history__actions-spacer { flex: 1; min-width: 0.5rem; }

.admin-history__btn {
  appearance: none;
  border: 1px solid transparent;
  padding: 0.38rem 0.7rem;
  border-radius: var(--radius-pill, 999px);
  font-family: inherit;
  font-size: 0.74rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease, transform 120ms ease;
}
.admin-history__btn:active { transform: scale(0.97); }

.admin-history__btn--ghost {
  background: transparent;
  color: var(--text-muted, rgba(68, 60, 50, 0.8));
  border-color: color-mix(in srgb, var(--line-soft, rgba(17,13,9,0.12)) 90%, transparent);
}
.admin-history__btn--ghost:hover {
  color: var(--text-main, #1b1712);
  background: var(--surface, #f3efe8);
  border-color: color-mix(in srgb, var(--line-soft, rgba(17,13,9,0.14)) 100%, transparent);
}

/* Restore — separated from the diff group via actions-spacer, and given a
   distinct visual weight so it's not confused with "View diff" or "Copy".
   It's a constructive action (non-destructive — creates a new commit) but
   consequential, so: accent-warm outline instead of filled. */
.admin-history__btn--restore {
  background: transparent;
  color: var(--accent-warm, #b28b68);
  border: 1px solid var(--accent-warm, #b28b68);
  font-weight: 500;
}
.admin-history__btn--restore:hover {
  background: var(--accent-warm, #b28b68);
  color: #fff;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent-warm) 30%, transparent);
}

.admin-history__diff {
  margin: 0.3rem 0 0;
  padding: var(--space-sm);
  background: var(--surface-2);
  border-radius: var(--radius-xs);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  line-height: 1.4;
  max-height: 280px;
  overflow: auto;
  white-space: pre;
  color: var(--text-main);
}

html.has-admin-history-open {
  overflow: hidden;
}

/* ──────────────────────────────────────────────────────────────
 * Stylized confirm dialog — replaces native confirm()
 * ────────────────────────────────────────────────────────────── */

.admin-confirm {
  border: none;
  padding: 0;
  background: transparent;
  max-width: min(440px, calc(100% - 2rem));
  width: 100%;
}
.admin-confirm::backdrop {
  background: rgba(23, 20, 17, 0.55);
  backdrop-filter: blur(4px);
}
.admin-confirm__shell {
  background: var(--bg-main, #f3efe8);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md, 0.7rem);
  box-shadow: var(--shadow-strong, 0 20px 50px rgba(17, 13, 9, 0.3));
  padding: 1.4rem 1.5rem 1.2rem;
  font-family: var(--font-sans);
  animation: admin-confirm-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes admin-confirm-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.admin-confirm__title {
  font-family: var(--font-display, serif);
  font-size: 1.2rem;
  line-height: 1.3;
  margin: 0 0 0.55rem;
  color: var(--text-main, #1b1712);
  font-weight: 400;
}
.admin-confirm__message {
  margin: 0 0 1.1rem;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--body-color, #4a4238);
  white-space: pre-line;
}
.admin-confirm__actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}
.admin-confirm__btn {
  appearance: none;
  border: 1px solid transparent;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-pill, 999px);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease, transform 120ms ease;
}
.admin-confirm__btn:active { transform: scale(0.97); }

.admin-confirm__btn--ghost {
  background: transparent;
  color: var(--text-muted, #666);
  border-color: color-mix(in srgb, var(--line-soft, rgba(17,13,9,0.14)) 70%, transparent);
}
.admin-confirm__btn--ghost:hover {
  color: var(--text-main, #1b1712);
  border-color: color-mix(in srgb, var(--line-soft, rgba(17,13,9,0.14)) 100%, transparent);
  background: color-mix(in srgb, var(--surface, #f3efe8) 70%, transparent);
}

.admin-confirm__btn--primary {
  background: var(--accent-warm, #b28b68);
  color: #fff;
  border-color: var(--accent-warm, #b28b68);
}
.admin-confirm__btn--primary:hover {
  background: color-mix(in srgb, var(--accent-warm, #b28b68) 88%, #000);
  border-color: color-mix(in srgb, var(--accent-warm, #b28b68) 88%, #000);
}
.admin-confirm__btn--primary.is-danger {
  background: var(--danger, #c04a3a);
  border-color: var(--danger, #c04a3a);
}
.admin-confirm__btn--primary.is-danger:hover {
  background: color-mix(in srgb, var(--danger, #c04a3a) 85%, #000);
}

/* ──────────────────────────────────────────────────────────────
 * Admin hints — contextual callouts that appear once, then
 * disappear forever until the user resets them in Settings.
 * ────────────────────────────────────────────────────────────── */

.admin-hint {
  position: absolute;
  z-index: 9999;
  max-width: 22rem;
  background: var(--bg-main, #f3efe8);
  color: var(--text-main, #1b1712);
  border: 1px solid color-mix(in srgb, var(--accent-warm, #b28b68) 35%, transparent);
  border-radius: var(--radius-md, 0.7rem);
  box-shadow:
    0 12px 30px rgba(17, 13, 9, 0.18),
    0 2px 8px rgba(17, 13, 9, 0.10),
    0 0 0 3px color-mix(in srgb, var(--accent-warm, #b28b68) 12%, transparent);
  padding: 0.8rem 0.85rem 0.7rem;
  display: grid;
  gap: 0.55rem;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  line-height: 1.45;
  animation: admin-hint-in 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.admin-hint.is-leaving {
  animation: admin-hint-out 200ms ease forwards;
}
@keyframes admin-hint-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes admin-hint-out {
  to { opacity: 0; transform: translateY(-4px); }
}

/* Centered variant — used for the welcome overlay */
.admin-hint--centered {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%);
  max-width: 30rem;
  width: calc(100% - 2rem);
  padding: 1.4rem 1.5rem 1.1rem;
  z-index: 10000;
  box-shadow:
    0 24px 60px rgba(17, 13, 9, 0.28),
    0 0 0 1px color-mix(in srgb, var(--accent-warm, #b28b68) 30%, transparent);
}

.admin-hint__body { min-width: 0; }
.admin-hint__body strong { color: var(--heading-color, #1b1712); }
.admin-hint__body small { color: var(--text-muted, rgba(68, 60, 50, 0.75)); }

.admin-hint__eyebrow {
  display: block;
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--accent-warm, #b28b68);
  margin-bottom: 0.3rem;
}
.admin-hint__title {
  font-family: var(--font-display, serif);
  font-size: 1.15rem;
  line-height: 1.3;
  margin: 0 0 0.6rem;
  font-weight: 400;
  color: var(--heading-color, #1b1712);
}
.admin-hint__list {
  list-style: none;
  margin: 0 0 0.7rem;
  padding: 0;
  display: grid;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--body-color, #4a4238);
}
.admin-hint__list li {
  padding-left: 1.1rem;
  position: relative;
}
.admin-hint__list li::before {
  content: "";
  position: absolute;
  top: 0.62em;
  left: 0.15rem;
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 50%;
  background: var(--accent-warm, #b28b68);
}
.admin-hint__list em { font-style: normal; font-weight: 500; }
.admin-hint__foot {
  margin: 0;
  font-size: 0.72rem;
  color: var(--text-muted, rgba(68, 60, 50, 0.7));
}

.admin-hint__actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
}
.admin-hint__btn {
  appearance: none;
  border: 0;
  background: var(--accent-warm, #b28b68);
  color: #fff;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-pill, 999px);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease, transform 120ms ease;
}
.admin-hint__btn:hover {
  background: color-mix(in srgb, var(--accent-warm, #b28b68) 88%, #000);
}
.admin-hint__btn:active { transform: scale(0.97); }
.admin-hint__close {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted, #666);
  width: 1.8rem;
  height: 1.8rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius-pill);
  cursor: pointer;
}
.admin-hint__close:hover {
  background: color-mix(in srgb, var(--text-muted, #888) 15%, transparent);
  color: var(--text-main);
}

/* Defensive scope: hints never render outside Edit mode */
html:not([data-admin-mode="edit"]) .admin-hint {
  display: none !important;
}

/* ──────────────────────────────────────────────────────────────
 * Settings dialog (tabs: Account + Help & hints)
 * ────────────────────────────────────────────────────────────── */

.admin-settings {
  border: none;
  padding: 0;
  background: transparent;
  max-width: min(560px, 94vw);
  width: calc(100% - 2rem);
}
.admin-settings::backdrop {
  background: rgba(23, 20, 17, 0.55);
  backdrop-filter: blur(6px);
}

.admin-settings__shell {
  background: var(--bg-main);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md, 0.7rem);
  box-shadow: var(--shadow-strong);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  max-height: 90vh;
  overflow: hidden;
  font-family: var(--font-sans);
}

.admin-settings__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--line-soft);
}
.admin-settings__title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  line-height: 1.3;
  margin: 0.15rem 0 0;
  color: var(--text-main);
  font-weight: 400;
}
.admin-settings__close {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0.4rem;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-pill);
}
.admin-settings__close:hover {
  color: var(--text-main);
  background: var(--surface-2, rgba(0,0,0,0.04));
}

.admin-settings__tabs {
  display: flex;
  gap: 0.3rem;
  padding: 0.6rem 1rem 0.3rem;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface, #f3efe8);
}
.admin-settings__tab {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 500;
  transition: background 150ms ease, color 150ms ease;
}
.admin-settings__tab:hover {
  color: var(--text-main);
  background: color-mix(in srgb, var(--accent-warm, #b28b68) 7%, transparent);
}
.admin-settings__tab.is-active {
  background: var(--accent-warm, #b28b68);
  color: #fff;
}

.admin-settings__content {
  overflow-y: auto;
  padding: 1rem 1.25rem 0.6rem;
}

.admin-settings__panel-head { margin-bottom: 0.9rem; }
.admin-settings__panel-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--text-main);
  margin: 0 0 0.3rem;
}
.admin-settings__panel-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
  max-width: 48ch;
}

.admin-settings__form {
  display: grid;
  gap: 0.75rem;
}
.admin-settings__field {
  display: grid;
  gap: 0.3rem;
}
.admin-settings__field > span {
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
}
.admin-settings__field input {
  appearance: none;
  font: inherit;
  border: 1px solid var(--line-soft);
  background: var(--bg-main);
  color: var(--text-main);
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.admin-settings__field input:focus {
  outline: none;
  border-color: var(--accent-warm, #b28b68);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-warm, #b28b68) 20%, transparent);
}
.admin-settings__actions {
  margin-top: 0.3rem;
  display: flex;
  justify-content: flex-end;
}

/* Password strength meter — unobtrusive two-line indicator under the
   "new password" field. Colour + label update together. */
.admin-pw-strength {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.4rem;
}
.admin-pw-strength[hidden] { display: none; }
.admin-pw-strength__track {
  height: 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-muted) 22%, transparent);
  overflow: hidden;
}
.admin-pw-strength__bar {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  transition: width 220ms cubic-bezier(0.2, 0.8, 0.2, 1), background-color var(--transition-fast);
  background: var(--danger);
}
.admin-pw-strength[data-score="1"] .admin-pw-strength__bar { background: var(--danger); }
.admin-pw-strength[data-score="2"] .admin-pw-strength__bar {
  background: color-mix(in srgb, var(--accent-warm) 70%, var(--danger));
}
.admin-pw-strength[data-score="3"] .admin-pw-strength__bar { background: var(--accent-warm); }
.admin-pw-strength[data-score="4"] .admin-pw-strength__bar { background: var(--success); }
.admin-pw-strength__label {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  font-weight: 500;
  min-width: 4.5rem;
  text-align: right;
}
.admin-pw-strength[data-score="0"] .admin-pw-strength__label,
.admin-pw-strength[data-score="1"] .admin-pw-strength__label {
  color: var(--danger);
}
.admin-pw-strength[data-score="4"] .admin-pw-strength__label {
  color: var(--success);
}

.admin-settings__switch-group {
  display: grid;
  gap: 0.8rem;
  margin-bottom: 1.1rem;
}

.admin-settings__switch {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.85rem;
  cursor: pointer;
  padding: 0.65rem 0.75rem;
  border: 1px solid color-mix(in srgb, var(--line-soft, rgba(17,13,9,0.12)) 80%, transparent);
  border-radius: var(--radius-sm);
  transition: border-color 150ms ease, background 150ms ease;
}
.admin-settings__switch:hover {
  border-color: color-mix(in srgb, var(--accent-warm, #b28b68) 35%, transparent);
  background: color-mix(in srgb, var(--accent-warm, #b28b68) 3%, transparent);
}
.admin-settings__switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.admin-settings__switch-track {
  position: relative;
  display: inline-block;
  width: 2.4rem;
  height: 1.25rem;
  background: color-mix(in srgb, var(--text-muted, #888) 35%, transparent);
  border-radius: 999px;
  transition: background 180ms ease;
  flex-shrink: 0;
}
.admin-settings__switch-thumb {
  position: absolute;
  top: 0.15rem;
  left: 0.15rem;
  width: 0.95rem;
  height: 0.95rem;
  background: #fff;
  border-radius: 50%;
  transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 1px 2px rgba(17, 13, 9, 0.2);
}
.admin-settings__switch input:checked ~ .admin-settings__switch-track {
  background: var(--accent-warm, #b28b68);
}
.admin-settings__switch input:checked ~ .admin-settings__switch-track .admin-settings__switch-thumb {
  transform: translateX(1.15rem);
}
.admin-settings__switch input:focus-visible ~ .admin-settings__switch-track {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-warm, #b28b68) 25%, transparent);
}
.admin-settings__switch-copy {
  display: grid;
  gap: 0.15rem;
}
.admin-settings__switch-copy strong {
  font-weight: 500;
  color: var(--text-main);
  font-size: 0.9rem;
}
.admin-settings__switch-copy small {
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.admin-settings__reset-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.85rem;
  border: 1px dashed color-mix(in srgb, var(--line-soft, rgba(17,13,9,0.14)) 80%, transparent);
  border-radius: var(--radius-sm);
  margin-bottom: 0.7rem;
  flex-wrap: wrap;
}
.admin-settings__reset-row strong {
  font-weight: 500;
  color: var(--text-main);
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
}

.admin-settings__foot {
  margin: 0;
  padding: 0 0 0.4rem;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.admin-settings__error {
  margin: 0;
  padding: 0.55rem 1.25rem 0.7rem;
  color: var(--danger, #c04a3a);
  font-size: 0.82rem;
  background: color-mix(in srgb, var(--danger, #c04a3a) 8%, transparent);
  border-top: 1px solid color-mix(in srgb, var(--danger, #c04a3a) 20%, transparent);
}
.admin-settings__error[hidden] { display: none; }

/* ---------- DRAFT badge on project cards ---------- */

/*
 * Marker pill on project cards whose entry has `draft: true`. Drafts live
 * with visible:false so the public renderer never reaches their cards;
 * the badge is admin-only by data-presence. Positioned top-LEFT so it
 * doesn't collide with the eye/trash icons (which live top-right).
 */
.project-card .draft-badge {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 4;
  background: var(--accent-gold);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-pill);
  box-shadow: 0 2px 6px rgba(17, 13, 9, 0.25);
  pointer-events: none;
}

/* ---------- Draft banner (fixed top, draft-page only) ---------- */

/*
 * Fixed banner that hosts the three lifecycle actions for a draft page:
 *   - Save draft (delegates to the existing save-bar)
 *   - Publish to live (publishDraftFlow)
 *   - Discard (discardDraftFlow)
 * Mounted by draft-mode.js when the current project is a draft. body
 * gets `has-draft-banner` so its padding-top makes room.
 */
.draft-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60; /* above header, below modal overlays (which sit at 9997+) */
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.55rem 1rem;
  background: var(--accent-warm);
  color: var(--bg-main);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  box-shadow: 0 2px 12px rgba(17, 13, 9, 0.18);
}

.draft-banner__label {
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.92;
  margin-right: 0.25rem;
  font-weight: 600;
}

.draft-banner__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.draft-banner__action {
  appearance: none;
  border: 1px solid color-mix(in srgb, var(--bg-main) 55%, transparent);
  background: transparent;
  color: inherit;
  padding: 0.35rem 0.9rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font: inherit;
  letter-spacing: 0.06em;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.draft-banner__action:hover {
  background: var(--bg-main);
  color: var(--accent-warm);
  border-color: var(--bg-main);
}

.draft-banner__action--publish {
  background: var(--bg-main);
  color: var(--accent-warm);
  border-color: var(--bg-main);
}

.draft-banner__action--publish:hover {
  background: var(--accent-gold);
  color: var(--text-main);
  border-color: var(--accent-gold);
}

.draft-banner__action--danger {
  border-color: color-mix(in srgb, var(--danger) 70%, transparent);
  color: color-mix(in srgb, var(--danger) 90%, var(--bg-main));
}

.draft-banner__action--danger:hover {
  background: var(--danger);
  color: var(--bg-main);
  border-color: var(--danger);
}

.draft-banner__action.is-busy {
  opacity: 0.6;
  pointer-events: none;
  cursor: progress;
}

body.has-draft-banner {
  padding-top: var(--draft-banner-height, 3rem);
}

@media (max-width: 640px) {
  .draft-banner {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
  .draft-banner__actions { justify-content: center; }
}

/* ---------- Publish-readiness modal ---------- */

/*
 * Dialog shown by publishDraftFlow when one or more required fields are
 * still empty / placeholder. Each row is clickable: dismisses the modal,
 * scrolls the offending field into view, and pulses .is-publish-highlight
 * so the owner finds it instantly.
 */
.draft-publish-modal {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: color-mix(in srgb, var(--text-main) 55%, transparent);
}

.draft-publish-modal__card {
  width: min(34rem, 96vw);
  max-height: 80vh;
  overflow-y: auto;
  background: var(--bg-main);
  color: var(--text-main);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(17, 13, 9, 0.45);
  padding: 1.4rem 1.5rem 1.25rem;
  font-family: var(--font-sans);
}

.draft-publish-modal__title {
  margin: 0 0 0.4rem;
  font-size: 1.1rem;
  font-family: var(--font-serif, var(--font-sans));
  letter-spacing: 0.01em;
}

.draft-publish-modal__intro {
  margin: 0 0 1rem;
  font-size: 0.86rem;
  color: var(--text-soft);
  line-height: 1.5;
}

.draft-publish-modal__missing-list {
  list-style: none;
  margin: 0 0 1.1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.draft-publish-modal__missing-row {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0.55rem 0.85rem;
  background: color-mix(in srgb, var(--danger) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}

.draft-publish-modal__missing-row:hover {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
}

.draft-publish-modal__missing-row::after {
  content: "↗";
  font-size: 0.92rem;
  opacity: 0.6;
}

.draft-publish-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.draft-publish-modal__btn {
  appearance: none;
  font: inherit;
  padding: 0.45rem 1.05rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.draft-publish-modal__btn:hover {
  background: var(--text-main);
  color: var(--bg-main);
}

/*
 * Pulse on the focused field after the owner clicks a missing-fields row.
 * The renderer scrolls the field into view; the class is added for 2s and
 * the keyframes draw attention via a gold outline + box-shadow throb.
 */
@keyframes draft-publish-highlight {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent-gold) 0%, transparent); }
  50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--accent-gold) 35%, transparent); }
}

.is-publish-highlight {
  outline: 2px solid var(--accent-gold);
  outline-offset: 4px;
  border-radius: 4px;
  animation: draft-publish-highlight 1s ease-in-out 2;
}

/* ---------- Floating "NEW PROJECT" watermark ---------- */

/*
 * Subtle reminder in the bottom-right corner of a draft page that the
 * current page is editing a draft. Rotated like a rubber stamp for
 * personality. pointer-events:none so it never blocks interactions.
 */
.draft-watermark {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 50;
  padding: 0.45rem 1.1rem;
  border: 1.5px solid var(--accent-gold);
  border-radius: 4px;
  color: var(--accent-gold);
  background: color-mix(in srgb, var(--bg-main) 70%, transparent);
  backdrop-filter: blur(6px);
  font-family: var(--font-sans);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  pointer-events: none;
  transform: rotate(-3deg);
  user-select: none;
  box-shadow: 0 4px 14px rgba(17, 13, 9, 0.18);
}

@media (max-width: 640px) {
  .draft-watermark {
    right: 1rem;
    bottom: 1rem;
    font-size: 0.62rem;
    padding: 0.35rem 0.85rem;
  }
}

/* ---------- Draft slug-input panel ---------- */

/*
 * Section between the hero and narrative that lets the owner finalise the
 * project's public URL slug before publish. Auto-fills from the title via
 * store.subscribe; manual keystroke freezes auto-fill (slugManuallyEdited
 * flag in localStorage). On blur the panel commits via /rename-draft and
 * syncs banner + URL bar + baseline.
 */
.draft-slug-panel {
  background: color-mix(in srgb, var(--bg-soft) 78%, var(--accent-warm) 22%);
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.draft-slug-panel__inner {
  width: min(72rem, calc(100% - 3rem));
  margin: 0 auto;
  padding: 1.5rem 0 1.75rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.9rem;
}

@media (min-width: 900px) {
  .draft-slug-panel__inner {
    grid-template-columns: minmax(0, 22rem) minmax(0, 1fr);
    align-items: center;
    gap: 2rem;
  }
}

.draft-slug-panel__header { display: grid; gap: 0.3rem; }

.draft-slug-panel__title {
  margin: 0;
  font-family: var(--font-serif, var(--font-sans));
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  color: var(--text-main);
}

.draft-slug-panel__help {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text-soft);
}

.draft-slug-panel__field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  font-family: var(--font-mono, monospace);
  font-size: 0.86rem;
  color: var(--text-main);
  transition: border-color 160ms ease, background 160ms ease;
}

.draft-slug-panel__prefix {
  color: var(--text-soft);
  user-select: none;
}

.draft-slug-panel__input {
  flex: 1 1 8rem;
  appearance: none;
  border: none;
  background: transparent;
  font: inherit;
  color: inherit;
  padding: 0.15rem 0;
  outline: none;
  min-width: 6rem;
}

.draft-slug-panel__input::placeholder { color: color-mix(in srgb, var(--text-soft) 70%, transparent); }

.draft-slug-panel__input:disabled {
  opacity: 0.55;
  cursor: progress;
}

.draft-slug-panel__status {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin-left: 0.4rem;
}

/* Validation states */
.draft-slug-panel.is-valid .draft-slug-panel__field {
  border-color: color-mix(in srgb, var(--accent-gold) 60%, transparent);
  background: color-mix(in srgb, var(--accent-gold) 5%, var(--bg-main));
}
.draft-slug-panel.is-valid .draft-slug-panel__status { color: var(--accent-gold); }

.draft-slug-panel.is-invalid .draft-slug-panel__field {
  border-color: color-mix(in srgb, var(--danger) 50%, transparent);
  background: color-mix(in srgb, var(--danger) 5%, var(--bg-main));
}
.draft-slug-panel.is-invalid .draft-slug-panel__status { color: var(--danger); }
