:root {
  --bg: #f7f4ef;
  --surface: #ffffff;
  --ink: #1d2a30;
  --muted: #5f6d73;
  --accent: #2f6f83;
  --accent2: #e8a838;
  --border: #d4dee1;
  --border-strong: #c3d0d4;
  --focus: #2f6f83;
  --shadow-soft: 0 10px 28px rgba(29, 42, 48, 0.06);
  --font-ui: "Manrope", "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-display: "Merriweather", "Iowan Old Style", "Georgia", serif;
}

* {
  box-sizing: border-box;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  background: radial-gradient(1200px 800px at 10% 0%, #fff6dc, var(--bg));
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px;
}

h1 {
  margin: 0;
  font-size: 1.8rem;
}

.subtitle {
  color: var(--muted);
  margin-top: 6px;
}

.brand-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  padding-bottom: 2px;
  margin-bottom: 0;
}

.brand-logo {
  width: min(280px, 100%);
  height: auto;
  display: block;
}

.grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 16px;
  margin-top: 12px;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

input,
select,
textarea,
button {
  width: 100%;
  font: inherit;
  border-radius: 10px;
  border: 1.5px solid #2a3942;
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

button {
  background: linear-gradient(130deg, var(--accent), #265d6e);
  color: #fff;
  border: 0;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

button:not(:disabled):hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 24px rgba(29, 42, 48, 0.28);
}

button:not(:disabled):active {
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 6px 14px rgba(29, 42, 48, 0.2);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button.secondary {
  background: #f3f6f7;
  color: var(--ink);
  border: 1.5px solid #2a3942;
}

button.secondary:not(:disabled):hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 24px rgba(29, 42, 48, 0.28);
  border-color: #8ea4ad;
  background: #ffffff;
}

button.secondary:not(:disabled):active {
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 6px 14px rgba(29, 42, 48, 0.2);
}

.stack {
  display: grid;
  gap: 10px;
  align-content: start;
}

.small {
  font-size: 0.9rem;
  color: var(--muted);
}

.is-hidden {
  display: none !important;
}

.carousel-workspace {
  margin-bottom: 20px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.carousel-workspace-header,
.carousel-actions,
.carousel-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.carousel-workspace-header h2 {
  margin: 4px 0 0;
}

.carousel-status-badge {
  flex: 0 0 auto;
  padding: 7px 12px;
  border-radius: 999px;
  background: #eaf0ff;
  color: #155eef;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.carousel-fingerprint {
  overflow-wrap: anywhere;
}

.carousel-slide-editor {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.carousel-slide-card {
  display: grid;
  gap: 9px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f9fbfc;
}

.carousel-slide-card h3 {
  margin: 0;
  font-size: 1rem;
}

.carousel-slide-card textarea {
  min-height: 74px;
}

.carousel-actions {
  flex-wrap: wrap;
  justify-content: flex-start;
}

.carousel-actions button {
  width: auto;
  min-width: 145px;
}

.carousel-progress {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.carousel-progress-row {
  padding: 10px 12px;
  border-radius: 10px;
  background: #f3f6f7;
  font-size: 0.9rem;
}

.carousel-progress-state {
  font-weight: 700;
}

.carousel-progress-preview {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  grid-column: 1 / -1;
}

@media (max-width: 860px) {
  .carousel-slide-editor {
    grid-template-columns: 1fr;
  }
}

hr {
  margin: 4px 0;
  width: 100%;
  height: 0;
  border: 0;
  border-top: 1px solid var(--border);
}

/* Collapsible Section Styles */
.section-group {
  display: grid;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}

.section-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #f7fafb;
  color: #4a6a77;
  border: 0;
  border-radius: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease;
  min-height: 44px;
}

.section-header:hover {
  background: #edf2f4;
}

.section-header:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 1;
}

.section-icon {
  display: inline-flex;
  font-size: 0.7rem;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

@media (prefers-reduced-motion: reduce) {
  .section-icon {
    transition: none;
  }
}

.section-content {
  padding: 14px;
  display: grid;
  gap: 12px;
  max-height: 2000px;
  overflow: hidden;
  transition: max-height 0.2s ease-in-out, padding 0.2s ease-in-out;
}

@media (prefers-reduced-motion: reduce) {
  .section-content {
    transition: none;
  }
}

.section-content.section-collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
}

.section-subsection {
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: 2px;
}

.gemini-key-form {
  display: grid;
  gap: 10px;
}

.gemini-key-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f7fafb;
  color: var(--ink);
  border: 1px solid var(--border);
  font-weight: 600;
}

.gemini-key-row.is-ok {
  border-color: #a9d9b8;
}

.gemini-key-row.is-warn {
  border-color: #e7c56d;
}

.gemini-key-indicator {
  display: inline-flex;
  width: 22px;
  height: 22px;
}

.health {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: #f8fbfc;
}

.health-summary {
  display: flex;
  align-items: center;
  gap: 8px;
}

.health-icon {
  display: inline-flex;
  width: 22px;
  height: 22px;
}

.health-ok #stackHealthTitle {
  color: #1f6b41;
}

.health-warn #stackHealthTitle {
  color: #7a5b00;
}

.health-error #stackHealthTitle {
  color: #9b2226;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(245px, 1fr));
  gap: 14px;
}

.img-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: #edf2f4;
}

.img-meta {
  padding: 10px;
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.img-meta-top {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-start;
}

.img-meta-date {
  color: var(--muted);
}

.img-meta-actions {
  margin-top: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 24, 28, 0.64);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 50;
}

.modal.active {
  display: flex;
}

.modal-content {
  width: min(1100px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 20px 38px rgba(15, 24, 28, 0.18);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.modal-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.modal-icon-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 10px;
  background: #f3f6f7;
  color: var(--ink);
  border: 1px solid var(--border);
  font-size: 1.2rem;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease, border-color 0.16s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-icon-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.modal-icon-btn .canva-logo-icon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  object-fit: cover;
}

.modal-icon-btn .canva-fallback-icon {
  display: none;
}

.modal-icon-btn.canva-btn {
  background: #edf5f8;
}

.modal-icon-btn:not(:disabled):hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 12px 24px rgba(29, 42, 48, 0.28);
  border-color: #8ea4ad;
  background: #ffffff;
}

.modal-icon-btn.is-busy {
  animation: spin 0.9s linear infinite;
}

.modal-icon-btn.state-working {
  background: #fff2d6;
  color: #8d5a00;
  border-color: #e8c77b;
}

.modal-icon-btn.state-success {
  background: #e8f6ee;
  color: #2f6b45;
  border-color: #8fc7a4;
}

.modal-icon-btn.state-error {
  background: #fdeaea;
  color: #9b2f2f;
  border-color: #e4aaaa;
}

.modal-icon-btn.delete-btn {
  background: #fdeaea;
  color: #9b2f2f;
  border-color: #e4aaaa;
}

.modal-icon-btn.delete-btn:not(:disabled):hover {
  background: #fff1f1;
  border-color: #cf7f7f;
  box-shadow: 0 12px 24px rgba(155, 47, 47, 0.26);
}

.modal-icon-btn:not(:disabled):active {
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 6px 14px rgba(29, 42, 48, 0.2);
}

.modal-icon-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.modal-close {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 10px;
  background: #f3f6f7;
  color: var(--ink);
  border: 1px solid var(--border);
  font-size: 1.5rem;
  line-height: 1;
}

.modal-body {
  display: block;
  padding: 0;
}

.modal-image-wrap {
  width: 100%;
  background: #f2f5f7;
  padding: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-image {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 62vh;
  object-fit: contain;
  border-radius: 10px;
}

.modal-meta {
  min-width: 0;
  padding: 22px;
}

.detail-section {
  margin-bottom: 16px;
}

.detail-section:last-child {
  margin-bottom: 0;
}

.detail-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #4a6a77;
  margin-bottom: 7px;
}

.prompt-box {
  position: relative;
}

.copy-prompt-icon-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid transparent;
  background: rgba(74, 106, 119, 0.08);
  color: #5c7985;
  font-size: 0.9rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.75;
}

.copy-prompt-icon-btn:hover {
  background: rgba(74, 106, 119, 0.14);
  border-color: rgba(74, 106, 119, 0.25);
  opacity: 1;
}

.copy-prompt-icon-btn.copied {
  color: #2f6b45;
  background: rgba(47, 107, 69, 0.14);
  border-color: rgba(47, 107, 69, 0.3);
  opacity: 1;
}

.detail-value {
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.5;
  background: #f7fafb;
  border: 1px solid var(--border);
  border-left: 3px solid #4f798b;
  border-radius: 10px;
  padding: 10px 12px;
}

#modalTargetTerm,
#modalFilename,
#modalFileSize {
  font-size: 1.05rem;
  line-height: 1.3;
  font-weight: 600;
  color: #21343b;
}

.modal-prompt {
  margin: 0;
  white-space: pre-wrap;
  font: inherit;
  padding-right: 38px;
}

.generate-help-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.help-icon-btn {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  padding: 0;
  border: 1.5px solid #2a3942;
  background: #f3f6f7;
  color: #2a3942;
  font-weight: 700;
  font-size: 0.86rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.help-icon-btn:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(29, 42, 48, 0.18);
}

.modal-content-help {
  width: min(760px, 100%);
}

.help-modal-meta {
  padding-top: 14px;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.badge {
  display: inline-block;
  font-size: 0.77rem;
  font-weight: 700;
  background: #e9f2f5;
  color: #295263;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.01em;
}

.badge-owner {
  margin-left: 6px;
  background: #f4ece0;
  color: #6b4c16;
}

.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: grid;
  gap: 8px;
  width: min(420px, calc(100vw - 28px));
}

.toast {
  background: #10242d;
  color: #f5fbfe;
  border: 1px solid #3f5965;
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 14px 28px rgba(16, 36, 45, 0.35);
}

.toast.error {
  background: #4f1f24;
  border-color: #9b404a;
}

@media (max-width: 900px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .modal-image-wrap {
    padding: 16px;
  }

  .modal-meta {
    padding: 16px;
  }

  .modal-image {
    max-height: 52vh;
  }

  .toast-container {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
  }
}

/* ============================================
   Gallery Redesign Styles
   ============================================ */

/* Gallery Header */
.gallery-header {
  margin-bottom: 24px;
}

.gallery-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.gallery-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #1a2b3c;
  margin: 0;
}

.result-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e9f2f5;
  color: #4a6a77;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 12px;
  min-width: 28px;
}



/* Gallery Toolbar */
.gallery-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: #f7fafb;
  border-radius: 6px;
  margin-bottom: 20px;
  min-height: 44px;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gallery-filter,
.gallery-sort,
.gallery-columns {
  padding: 6px 12px;
  border: 1.5px solid #2a3942;
  border-radius: 4px;
  background: white;
  font-size: 0.9rem;
  min-width: 140px;
  /* Slightly reduced to fit better */
}

@media (max-width: 600px) {

  .gallery-filter,
  .gallery-sort,
  .gallery-columns {
    min-width: 120px;
    /* Smaller min-width on very small screens */
  }
}

/* Hide column selector on mobile/tablet where grid columns are auto */
@media (max-width: 900px) {
  .gallery-columns {
    display: none;
  }
}

/* Responsive Grid Layout */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

/* Grid Column Override Classes (Desktop Only) */
@media (min-width: 900px) {
  .image-grid.grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
  }

  .image-grid.grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
  }

  .image-grid.grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
  }

  /* Hide grid columns selector on mobile */
  .gallery-columns {
    display: block;
  }
}

/* Hide grid column selector on mobile */
@media (max-width: 899px) {
  .gallery-columns {
    display: none;
  }
}

@media (min-width: 1400px) {
  .image-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 1200px) and (max-width: 1399px) {
  .image-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 900px) and (max-width: 1199px) {
  .image-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 899px) {
  .image-grid {
    grid-template-columns: 1fr;
  }

  .gallery-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-left,
  .toolbar-right {
    justify-content: stretch;
  }

  .gallery-filter,
  .gallery-sort {
    width: 100%;
  }
}

/* Enhanced Image Cards */
.img-card {
  position: relative;
  border: 1px solid #e0e6ea;
  border-radius: 8px;
  overflow: hidden;
  background: white;
  transition: transform 0.12s ease-out, box-shadow 0.12s ease-out;
  cursor: pointer;
}

.img-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
}

.img-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card-image {
  width: 100%;
  height: auto;
  display: block;
  background: #f0f4f7;
}

/* Card Overlay */
.card-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.08s ease-out;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px;
  pointer-events: none;
  z-index: 10;
}

.img-card:hover .card-overlay,
.img-card:focus-within .card-overlay {
  opacity: 1;
  pointer-events: auto;
}

/* Load More Button */
.load-more-container {
  display: flex;
  justify-content: center;
  margin-top: 32px;
  margin-bottom: 24px;
}

.load-more-btn {
  width: auto;
  min-width: 200px;
  background: white;
  color: var(--ink);
  border: 1px solid var(--border);
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-action-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.card-action-btn .canva-logo-icon {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  object-fit: cover;
}

.card-action-btn .canva-fallback-icon {
  width: 18px;
  height: 18px;
  display: none;
}

.load-more-btn:hover {
  background: #f7fafb;
  border-color: #b6c7cc;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
  transform: translateY(-1px);
}

.load-more-btn:active {
  transform: translateY(0);
  box-shadow: none;
}

/* Quick Actions */
.card-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.card-action-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.15s ease;
  font-size: 1.1rem;
  color: #10242d;
  /* Ensure icons are dark */
}

.card-action-btn:hover {
  background: white;
  transform: scale(1.1);
}

.card-action-btn:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}

/* Card Metadata */
.card-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.card-badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  background: rgba(59, 126, 161, 0.9);
  color: white;
  white-space: nowrap;
}

.card-badge.badge-type {
  background: rgba(107, 124, 141, 0.9);
}

.card-badge.badge-owner {
  background: rgba(139, 92, 246, 0.9);
}

.card-date {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.9);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state-image {
  max-width: 300px;
  margin: 0 auto 24px;
  opacity: 0.8;
}

.empty-state-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1a2b3c;
  margin: 0 0 8px 0;
}

.empty-state-text {
  font-size: 0.95rem;
  color: #6b7c8d;
  margin: 0 0 20px 0;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.empty-state-cta {
  display: inline-block;
  padding: 10px 20px;
  background: var(--accent);
  color: white;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 500;
  transition: background 0.2s ease;
}

.empty-state-cta:hover {
  background: #2d5f7a;
}

/* Loading Skeleton */
.skeleton-card {
  border: 1px solid #e0e6ea;
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

.skeleton-image {
  width: 100%;
  aspect-ratio: 16/9;
  background: linear-gradient(90deg,
      #f0f4f7 0%,
      #e0e6ea 50%,
      #f0f4f7 100%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-image {
    animation: none;
  }

  .img-card {
    transition: none;
  }

  .card-overlay {
    transition: none;
  }

  .card-action-btn {
    transition: none;
  }
}

/* Screen Reader Only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Bulk Action Bar */
.bulk-action-bar {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  min-width: 320px;
}

.bulk-action-bar.is-hidden {
  transform: translateX(-50%) translateY(100px);
  opacity: 0;
  pointer-events: none;
}

.bulk-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.bulk-count {
  font-weight: 600;
  color: var(--ink);
  font-size: 1rem;
}

.bulk-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bulk-btn {
  padding: 8px 16px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bulk-clear-btn {
  color: #2a3942;
  font-weight: 500;
  transition: all 0.2s ease;
  padding: 8px 16px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bulk-clear-btn:hover {
  color: #ffffff;
  background: #2a3942;
}

/* Card Checkbox - keep wrapper small and non-blocking when hidden so overlay can receive hover */
.card-select-wrapper {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 20;
  width: max-content;
  max-width: 40px;
  height: max-content;
  max-height: 40px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.08s ease-out;
}

.card-checkbox {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--accent);
  transform: scale(1.2);
}

/* Show checkbox on hover or when selected; restore pointer-events so it can be clicked */
.img-card:hover .card-select-wrapper,
.img-card.selected .card-select-wrapper,
.card-select-wrapper:focus-within {
  opacity: 1;
  pointer-events: auto;
}

/* Selected Card State */
.img-card.selected .card-image {
  transform: scale(0.96);
  border-radius: 8px;
}

.img-card.selected {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
  border-radius: 8px;
}

@media (max-width: 600px) {
  .bulk-action-bar {
    width: 90%;
    min-width: auto;
    bottom: 20px;
  }

  .card-select-wrapper {
    opacity: 1;
  }
}

/* Touch/mobile devices do not have reliable hover; keep overlay controls visible. */
@media (hover: none), (pointer: coarse) {
  .card-overlay {
    opacity: 1;
    pointer-events: auto;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0.28));
  }
}

/* ============================================
   Toggle Switch Control
   ============================================ */
.toggle-control {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.toggle-label {
  font-size: 0.95rem;
  color: var(--ink);
  font-weight: 500;
  flex: 0 0 auto;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
  cursor: pointer;
}

.toggle-switch input[type="checkbox"] {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #cbd5db;
  border-radius: 26px;
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
  border: 1.5px solid #9fb0ba;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background: white;
  border-radius: 50%;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background: linear-gradient(130deg, var(--accent), #2f5f70);
  border-color: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

.toggle-switch input:focus-visible + .toggle-slider {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.toggle-switch:has(input:disabled) {
  cursor: not-allowed;
}

.toggle-state-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  min-width: 32px;
  flex-shrink: 0;
}

.inline-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--ink);
}

.inline-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.angle-panel {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f7fafb;
}

.angle-list {
  display: grid;
  gap: 6px;
  max-height: 230px;
  overflow: auto;
  padding-right: 2px;
}

.angle-item {
  display: grid;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.angle-item-title {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-weight: 700;
  color: #223842;
}

.angle-item-title input[type="checkbox"] {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.angle-item-meta {
  font-size: 0.87rem;
  color: var(--muted);
}
