/* ================================================================
   PosterBD — styles.css   |   Material Design 3 dark theme
================================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Light theme (default / system light) ── */
:root {
  --md-primary:          #6750A4;
  --md-on-primary:       #FFFFFF;
  --md-primary-container:#EADDFF;
  --md-on-primary-cont:  #21005D;
  --md-bg:               #FFFBFE;
  --md-surface:          #FFFBFE;
  --md-surface1:         #F3EDF7;
  --md-surface2:         #ECE6F0;
  --md-surface3:         #E6DFF0;
  --md-surface5:         #DDD8EB;
  --md-on-surface:       #1C1B1F;
  --md-on-surface-var:   #49454F;
  --md-outline:          #79747E;
  --md-outline-var:      #CAC4D0;
  --md-secondary:        #625B71;
  --md-secondary-cont:   #E8DEF8;
  --md-error:            #B3261E;
  --md-error-cont:       #F9DEDC;
  --md-success:          #146C2E;
  --md-success-cont:     #C8F0D0;
  --canvas-check1:       #e8e0ee;
  --canvas-check2:       #f3edf7;
  --sidebar-w: 240px;
  --topbar-h:  56px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-xl: 28px;
  --radius-full: 9999px;
  --elev1: 0 1px 3px rgba(0,0,0,.12);
  --elev2: 0 3px 8px rgba(0,0,0,.16);
  --elev3: 0 6px 20px rgba(0,0,0,.20);
  --t: .22s cubic-bezier(.2,0,0,1);
}

/* ── Dark theme via system preference ── */
@media (prefers-color-scheme: dark) {
  :root {
    --md-primary:          #A78BFA;
    --md-on-primary:       #1A0A3A;
    --md-primary-container:#4C1D95;
    --md-on-primary-cont:  #EDE9FE;
    --md-bg:               #0D0A1A;
    --md-surface:          #0D0A1A;
    --md-surface1:         #160F2A;
    --md-surface2:         #1E1535;
    --md-surface3:         #271C42;
    --md-surface5:         #332550;
    --md-on-surface:       #EDE9FE;
    --md-on-surface-var:   #C4B5FD;
    --md-outline:          #6D5FA0;
    --md-outline-var:      #3B2D60;
    --md-secondary:        #C4B5FD;
    --md-secondary-cont:   #3D1F8C;
    --md-error:            #F2B8B5;
    --md-error-cont:       #8C1D18;
    --md-success:          #6DD58C;
    --md-success-cont:     #0A3818;
    --canvas-check1:       #160F2A;
    --canvas-check2:       #100B1E;
    --elev1: 0 1px 3px rgba(0,0,0,.5);
    --elev2: 0 3px 8px rgba(0,0,0,.55);
    --elev3: 0 6px 20px rgba(0,0,0,.65);
  }
}

@media (prefers-color-scheme: dark) {
  body {
    background:
      radial-gradient(ellipse 70% 50% at 15% 0%, rgba(124,58,237,.2) 0%, transparent 50%),
      radial-gradient(ellipse 60% 50% at 85% 100%, rgba(76,29,149,.25) 0%, transparent 50%),
      #0D0A1A;
  }
}

/* ── Manual light override (overrides media query) ── */
html.theme-light {
  --md-primary:          #6750A4;
  --md-on-primary:       #FFFFFF;
  --md-primary-container:#EADDFF;
  --md-on-primary-cont:  #21005D;
  --md-bg:               #FFFBFE;
  --md-surface:          #FFFBFE;
  --md-surface1:         #F3EDF7;
  --md-surface2:         #ECE6F0;
  --md-surface3:         #E6DFF0;
  --md-surface5:         #DDD8EB;
  --md-on-surface:       #1C1B1F;
  --md-on-surface-var:   #49454F;
  --md-outline:          #79747E;
  --md-outline-var:      #CAC4D0;
  --md-secondary:        #625B71;
  --md-secondary-cont:   #E8DEF8;
  --md-error:            #B3261E;
  --md-error-cont:       #F9DEDC;
  --md-success:          #146C2E;
  --md-success-cont:     #C8F0D0;
  --canvas-check1:       #e8e0ee;
  --canvas-check2:       #f3edf7;
  --elev1: 0 1px 3px rgba(0,0,0,.12);
  --elev2: 0 3px 8px rgba(0,0,0,.16);
  --elev3: 0 6px 20px rgba(0,0,0,.20);
}

/* ── Manual dark override (overrides media query) ── */
html.theme-dark {
  --md-primary:          #A78BFA;
  --md-on-primary:       #1A0A3A;
  --md-primary-container:#4C1D95;
  --md-on-primary-cont:  #EDE9FE;
  --md-bg:               #0D0A1A;
  --md-surface:          #0D0A1A;
  --md-surface1:         #160F2A;
  --md-surface2:         #1E1535;
  --md-surface3:         #271C42;
  --md-surface5:         #332550;
  --md-on-surface:       #EDE9FE;
  --md-on-surface-var:   #C4B5FD;
  --md-outline:          #6D5FA0;
  --md-outline-var:      #3B2D60;
  --md-secondary:        #C4B5FD;
  --md-secondary-cont:   #3D1F8C;
  --md-error:            #F2B8B5;
  --md-error-cont:       #8C1D18;
  --md-success:          #6DD58C;
  --md-success-cont:     #0A3818;
  --canvas-check1:       #160F2A;
  --canvas-check2:       #100B1E;
  --elev1: 0 1px 3px rgba(0,0,0,.5);
  --elev2: 0 3px 8px rgba(0,0,0,.55);
  --elev3: 0 6px 20px rgba(0,0,0,.65);
}
html.theme-dark body {
  background:
    radial-gradient(ellipse 70% 50% at 15% 0%, rgba(124,58,237,.2) 0%, transparent 50%),
    radial-gradient(ellipse 60% 50% at 85% 100%, rgba(76,29,149,.25) 0%, transparent 50%),
    #0D0A1A;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Roboto', system-ui, sans-serif;
  background: var(--md-bg);
  color: var(--md-on-surface);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

img { display: block; }

/* ── Remove tap delay on buttons / links ── */
button, a, label {
  touch-action: manipulation;          /* pan-x pan-y pinch-zoom, no double-tap-zoom */
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
/* Cards: explicitly allow pan-y so vertical page scroll propagates
   through horizontal scroll strip ancestors (pan-x pan-y intersects to pan-y) */
.category-card, .frame-card, .suggestion-card {
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  user-select: none;
}

/* ================================================================
   SIDEBAR  — always a slide-in drawer
   JS adds/removes class "sb-open" on <body>
================================================================ */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--md-surface1);
  border-right: 1px solid var(--md-outline-var);
  display: flex;
  flex-direction: column;
  z-index: 600;
  transform: translateX(-100%);
  transition: transform var(--t);
  will-change: transform;
}

body.sb-open .sidebar {
  transform: translateX(0);
  box-shadow: var(--elev3);
}

/* Brand row at top of sidebar */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--md-outline-var);
  min-height: 68px;
}
.sidebar-logo { height: 30px; width: auto; object-fit: contain; }
.sidebar-brand-name {
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 18px; font-weight: 700;
  color: var(--md-primary);
}

.sidebar-nav {
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.sidebar-section-label {
  font-size: 11px; font-weight: 700;
  letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--md-on-surface-var);
  padding: 10px 12px 4px;
}
.sidebar-divider {
  height: 1px;
  background: var(--md-outline-var);
  margin: 4px 4px 6px;
}

.sidebar-item {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px; height: 52px;
  border: none; border-radius: var(--radius-xl);
  background: transparent;
  color: var(--md-on-surface-var);
  font-family: inherit; font-size: 14px; font-weight: 500;
  text-align: left;
  transition: background var(--t), color var(--t);
  position: relative;
}
.sidebar-item:hover  { background: rgba(167,139,250,.08); }
.sidebar-item:active { background: rgba(167,139,250,.14); }
.sidebar-item.active {
  background: var(--md-primary-container);
  color: var(--md-on-primary-cont);
}

.sidebar-icon { font-size: 20px; width: 24px; text-align: center; }
.sidebar-label { flex: 1; }
.sidebar-badge {
  font-size: 10px; font-weight: 700;
  letter-spacing: .4px; text-transform: uppercase;
  background: rgba(167,139,250,.15);
  color: var(--md-primary);
  padding: 2px 7px; border-radius: var(--radius-full);
}
.sidebar-item.active .sidebar-badge {
  background: rgba(255,255,255,.15);
  color: var(--md-on-primary-cont);
}

/* ── Sidebar bottom (theme picker pinned to bottom) ── */
.sidebar-bottom {
  margin-top: auto;
  padding: 8px;
  border-top: 1px solid var(--md-outline-var);
}
.sidebar-bottom .sidebar-section-label {
  padding: 8px 8px 6px;
}

.theme-picker {
  display: flex;
  gap: 4px;
  padding: 2px 4px 6px;
}
.theme-chip {
  flex: 1;
  padding: 7px 4px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--md-outline-var);
  background: transparent;
  color: var(--md-on-surface-var);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
  transition: background var(--t), color var(--t), border-color var(--t);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  line-height: 1;
}
.theme-chip:hover  { background: rgba(103,80,164,.08); }
.theme-chip:active { opacity: .75; }
.theme-chip.active {
  background: var(--md-primary-container);
  border-color: transparent;
  color: var(--md-on-primary-cont);
}
.theme-chip-icon { font-size: 16px; }

/* ── Backdrop ── */
.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 590;
  opacity: 0;
  pointer-events: none;           /* blocks nothing when sidebar is closed */
  transition: opacity var(--t);
}
body.sb-open .sidebar-backdrop {
  opacity: 1;
  pointer-events: auto;           /* tappable only when sidebar is open */
}

/* ================================================================
   MAIN WRAPPER  — always full width; on desktop shift right when open
================================================================ */
.main-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--t);
}

@media (min-width: 900px) {
  body.sb-open .main-wrapper { margin-left: var(--sidebar-w); }
}

/* ================================================================
   TOP BAR  (used in all views)
================================================================ */
.top-bar {
  position: sticky; top: 0; z-index: 300;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 4px;
  padding: 0 8px;
  background: var(--md-surface2);
  border-bottom: 1px solid var(--md-outline-var);
}

.hamburger-btn {
  flex-shrink: 0;
  background: none; border: none;
  width: 44px; height: 44px;
  border-radius: var(--radius-full);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 5px;
  transition: background var(--t);
}
.hamburger-btn:hover  { background: rgba(255,255,255,.08); }
.hamburger-btn:active { background: rgba(255,255,255,.14); }
.hamburger-btn span {
  display: block; width: 20px; height: 2px;
  background: var(--md-on-surface);
  border-radius: 2px;
}

.back-btn {
  flex-shrink: 0;
  background: none; border: none;
  color: var(--md-on-surface);
  font-size: 0;          /* hide any text fallback */
  width: 44px; height: 44px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--t);
}
/* Material Design "arrow_back" rendered as a CSS mask so it inherits the theme colour */
.back-btn::before {
  content: '';
  display: block;
  width: 22px; height: 22px;
  background-color: var(--md-on-surface);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z'/%3E%3C/svg%3E") center/contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z'/%3E%3C/svg%3E") center/contain no-repeat;
}
.back-btn:hover  { background: rgba(255,255,255,.08); }
.back-btn:active { background: rgba(255,255,255,.14); }

.top-bar-brand {
  display: flex; align-items: center; gap: 8px;
}
.top-bar-logo {
  height: 26px; width: auto; object-fit: contain;
}
.top-bar-name {
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 18px; font-weight: 700;
  color: var(--md-primary);
}
.top-bar-title {
  flex: 1;
  font-size: 20px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding-left: 4px;
}

/* ================================================================
   VIEW ROUTER  +  TRANSITIONS
================================================================ */
.view        { display: none; }
.view.active { display: block; animation: viewEnter .22s ease; }
.view-editor.active { display: flex; flex-direction: column; min-height: 100vh; }

@keyframes viewEnter {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ================================================================
   SEARCH BAR
================================================================ */
.search-bar-wrapper {
  padding: 12px 16px 4px;
  background: var(--md-bg);
}
.search-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--md-surface2);
  border: 1px solid var(--md-outline-var);
  border-radius: var(--radius-xl);
  padding: 0 14px; height: 44px;
  transition: border-color var(--t), box-shadow var(--t);
}
.search-bar:focus-within {
  border-color: var(--md-primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--md-primary) 20%, transparent);
}
.search-icon { font-size: 16px; color: var(--md-on-surface-var); flex-shrink: 0; }
.search-input {
  flex: 1; border: none; background: transparent;
  font-family: inherit; font-size: 14px;
  color: var(--md-on-surface); outline: none;
}
.search-input::placeholder { color: var(--md-on-surface-var); }
.search-clear {
  background: none; border: none;
  color: var(--md-on-surface-var);
  font-size: 14px; cursor: pointer;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  transition: background var(--t);
}
.search-clear:hover { background: rgba(0,0,0,.08); }

.search-empty {
  text-align: center; padding: 52px 20px;
  color: var(--md-on-surface-var);
}
.search-empty-icon { font-size: 38px; margin-bottom: 10px; }
.search-empty-text { font-size: 14px; }

/* ================================================================
   HOME HERO
================================================================ */
.home-hero {
  background: var(--md-surface1);
  border-bottom: 1px solid var(--md-outline-var);
  padding: 20px 20px 18px;
}
.hero-subtitle {
  font-size: 14px; color: var(--md-on-surface-var); line-height: 1.55;
}

/* ================================================================
   CATEGORY SECTIONS
================================================================ */
.category-section { padding: 22px 0 0; }

.section-label {
  padding: 0 16px; margin-bottom: 12px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--md-on-surface-var);
}

.category-scroll {
  display: flex; gap: 10px;
  overflow-x: auto;
  padding: 4px 16px 18px;
  scrollbar-width: none; -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
}
.category-scroll::-webkit-scrollbar { display: none; }

.category-card {
  flex: 0 0 auto; width: 110px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--md-surface2);
  border: 1px solid var(--md-outline-var);
  transition: box-shadow var(--t), border-color var(--t);
  user-select: none;
}
.category-card:hover  { border-color: var(--md-primary); box-shadow: var(--elev2); }
.category-card:active { opacity: .85; }

.category-thumb {
  width: 100%; aspect-ratio: 1/1;
  object-fit: cover; background: var(--md-surface3);
  pointer-events: none;
}
.category-name {
  padding: 7px 6px 9px;
  font-size: 12px; font-weight: 500;
  text-align: center; line-height: 1.3;
  color: var(--md-on-surface);
  pointer-events: none;
}

/* ================================================================
   SKELETON SHIMMER
================================================================ */
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}
.skeleton {
  background: linear-gradient(
    90deg,
    var(--md-surface2) 25%,
    var(--md-surface3) 50%,
    var(--md-surface2) 75%
  );
  background-size: 1200px 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: var(--radius-sm);
}
.skeleton-card {
  flex: 0 0 auto; width: 110px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--md-surface2);
  border: 1px solid var(--md-outline-var);
}
.skeleton-thumb {
  width: 100%; aspect-ratio: 1/1;
}
.skeleton-name {
  height: 13px;
  margin: 8px 10px 11px;
}
.skeleton-label {
  height: 10px; width: 72px;
  margin: 0 16px 14px;
}

.error-banner {
  margin: 16px; padding: 14px 16px;
  background: var(--md-error-cont); border: 1px solid var(--md-error);
  border-radius: var(--radius-md);
  font-size: 14px; color: var(--md-error); line-height: 1.5;
}
.error-banner small { font-size: 12px; opacity: .7; }

/* ================================================================
   AD UNITS
================================================================ */
.ad-unit {
  padding: 0 16px 8px;
  width: 100%;
}
.ad-unit ins.adsbygoogle {
  display: block;
  border-radius: var(--radius-md);
  overflow: hidden;
}

/* Test mode placeholder */
.ad-placeholder {
  width: 100%; min-height: 90px;
  border: 1.5px dashed var(--md-outline-var);
  border-radius: var(--radius-md);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  color: var(--md-outline);
  font-size: 11px; font-weight: 600;
  letter-spacing: 1px; text-transform: uppercase;
  background: var(--md-surface1);
  user-select: none; pointer-events: none;
}
.ad-placeholder-label { font-size: 10px; opacity: .6; letter-spacing: .5px; }

/* ================================================================
   BUTTONS
================================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 22px; border: none;
  border-radius: var(--radius-xl);
  font-family: inherit; font-size: 14px; font-weight: 500;
  white-space: nowrap;
  transition: opacity var(--t), box-shadow var(--t);
}
.btn:active { opacity: .82; }

.btn-primary { background: var(--md-primary); color: var(--md-on-primary); box-shadow: var(--elev1); }
.btn-primary:hover { box-shadow: var(--elev2); }

.btn-save  { background: var(--md-success-cont); color: var(--md-success); padding: 8px 14px; font-size: 13px; }
.btn-share { background: var(--md-secondary-cont); color: var(--md-secondary); padding: 8px 14px; font-size: 13px; }

.btn-ghost { background: transparent; color: var(--md-primary); border: 1px solid var(--md-outline); }

/* ================================================================
   FRAME SELECTION
================================================================ */
.type-tabs {
  display: flex; gap: 8px;
  padding: 12px 16px 4px;
  overflow-x: auto;
  scrollbar-width: none; -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
}
.type-tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  flex: 0 0 auto; padding: 8px 20px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--md-outline);
  background: transparent;
  color: var(--md-on-surface-var);
  font-family: inherit; font-size: 14px; font-weight: 500;
  transition: background var(--t), color var(--t), border-color var(--t);
}
.tab-btn:active { opacity: .8; }
.tab-btn.active {
  background: var(--md-secondary-cont);
  border-color: transparent;
  color: var(--md-secondary);
}

.frames-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px; padding: 12px 16px 32px;
}

.frame-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--md-surface2);
  border: 1px solid var(--md-outline-var);
  aspect-ratio: 1/1;
  display: flex; align-items: center; justify-content: center;
  padding: 8px;
  transition: border-color var(--t), box-shadow var(--t);
  user-select: none;
}
.frame-card[data-ftype="portrait"]  { aspect-ratio: 3/4; }
.frame-card[data-ftype="landscape"] { aspect-ratio: 4/3; }
.frame-card:hover  { border-color: var(--md-primary); box-shadow: var(--elev2); }
.frame-card:active { opacity: .82; }

.frame-thumb {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.empty-state {
  grid-column: 1/-1; text-align: center;
  padding: 52px 20px; color: var(--md-on-surface-var);
}
.empty-icon { font-size: 38px; margin-bottom: 10px; }
.empty-text { font-size: 14px; }

/* ================================================================
   EDITOR
================================================================ */
.editor-body {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; background: var(--md-surface);
}
@media (min-width: 768px) {
  .editor-body { flex-direction: row; align-items: flex-start; justify-content: center; padding: 20px; }
}

.editor-main {
  display: flex; flex-direction: column;
  align-items: center; gap: 16px;
  padding: 20px 16px; width: 100%; max-width: 500px;
}

.canvas-wrapper {
  position: relative; width: 100%; max-width: 460px;
  border-radius: var(--radius-md); overflow: hidden;
  background: repeating-conic-gradient(var(--canvas-check1) 0% 25%, var(--canvas-check2) 0% 50%) 0 0/18px 18px;
  box-shadow: var(--elev3);
  touch-action: none;
}
#photo-canvas { display: block; width: 100%; height: auto; }

.canvas-hint {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  pointer-events: none;
  color: var(--md-on-surface-var);
  gap: 6px; text-align: center; padding: 20px;
}
.hint-icon { font-size: 34px; margin-bottom: 4px; }
.canvas-hint div   { font-size: 14px; font-weight: 500; }
.canvas-hint small { font-size: 12px; opacity: .65; }

.editor-controls {
  display: flex; flex-wrap: wrap; gap: 10px;
  justify-content: center; align-items: center;
}
#file-input { display: none; }

.zoom-bar {
  display: flex; align-items: center; gap: 2px;
  background: var(--md-surface3); border: 1px solid var(--md-outline-var);
  border-radius: var(--radius-xl); padding: 4px 10px; height: 40px;
}
.zoom-btn {
  background: none; border: none; color: var(--md-on-surface);
  font-size: 18px; width: 28px; height: 28px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--t);
}
.zoom-btn:hover  { background: rgba(255,255,255,.08); }
.zoom-btn:active { background: rgba(255,255,255,.15); }
.zoom-label {
  font-size: 13px; font-weight: 500;
  color: var(--md-on-surface-var);
  min-width: 44px; text-align: center;
}

/* ================================================================
   TEXT OVERLAY PANEL
================================================================ */
.text-panel {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--md-outline-var);
  background: var(--md-surface2);
  overflow: hidden;
}
.text-panel-toggle-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: transparent; border: none;
  color: var(--md-on-surface); font-family: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: background var(--t);
}
.text-panel-toggle-btn:hover { background: rgba(255,255,255,.05); }

.text-panel-body {
  padding: 4px 16px 16px;
  border-top: 1px solid var(--md-outline-var);
  display: flex; flex-direction: column; gap: 12px;
}
.text-input {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--md-outline-var); border-radius: var(--radius-md);
  background: var(--md-surface3); color: var(--md-on-surface);
  font-family: inherit; font-size: 14px; outline: none;
  transition: border-color var(--t);
}
.text-input:focus { border-color: var(--md-primary); }

.text-options { display: flex; flex-direction: column; gap: 10px; }
.text-option-row { display: flex; align-items: center; gap: 12px; }
.text-opt-label {
  font-size: 12px; color: var(--md-on-surface-var);
  width: 44px; flex-shrink: 0;
}
.text-color-input {
  width: 38px; height: 30px;
  border: 1px solid var(--md-outline-var); border-radius: var(--radius-sm);
  padding: 2px; background: var(--md-surface3); cursor: pointer;
}
.text-size-controls {
  display: flex; align-items: center; gap: 6px;
  background: var(--md-surface3); border: 1px solid var(--md-outline-var);
  border-radius: var(--radius-xl); padding: 3px 10px; height: 34px;
}
.text-size-btn {
  background: none; border: none; color: var(--md-on-surface);
  font-family: inherit; font-size: 13px; font-weight: 700;
  padding: 2px 6px; cursor: pointer; border-radius: var(--radius-sm);
  transition: background var(--t);
}
.text-size-btn:hover { background: rgba(255,255,255,.1); }
.text-size-val {
  font-size: 13px; font-weight: 500; color: var(--md-on-surface-var);
  min-width: 26px; text-align: center;
}
.text-style-btn {
  padding: 6px 14px; border-radius: var(--radius-xl);
  border: 1px solid var(--md-outline-var); background: transparent;
  color: var(--md-on-surface-var); font-family: inherit;
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all var(--t);
}
.text-style-btn.active {
  background: var(--md-primary-container);
  border-color: transparent; color: var(--md-on-primary-cont);
}
.text-hint {
  font-size: 11px; color: var(--md-on-surface-var);
  text-align: center; opacity: .65;
}

/* ================================================================
   REMOVE BACKGROUND VIEW
================================================================ */
.rbg-body {
  display: flex; flex-direction: column; align-items: center;
  gap: 20px; padding: 20px 16px 40px;
  min-height: calc(100vh - 56px);
}
/* upload area reuses .crop-upload-label from crop tool */
.rbg-upload { display: flex; align-items: center; justify-content: center; width: 100%; flex: 1; }
#rbg-file-input { display: none; }

.rbg-processing {
  display: flex; align-items: center; justify-content: center;
  width: 100%; flex: 1; padding: 20px;
}
.rbg-processing-card {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  background: var(--md-surface2);
  border: 1px solid var(--md-outline-var);
  border-radius: var(--radius-md);
  padding: 36px 28px; width: 100%; max-width: 340px; text-align: center;
}
.rbg-spinner {
  width: 48px; height: 48px;
  border: 3px solid var(--md-outline-var);
  border-top-color: var(--md-primary);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
.rbg-status { font-size: 14px; font-weight: 500; color: var(--md-on-surface); }
.rbg-progress-bar {
  width: 100%; height: 6px;
  background: var(--md-outline-var);
  border-radius: var(--radius-full); overflow: hidden;
}
.rbg-progress-fill {
  height: 100%; background: var(--md-primary);
  border-radius: var(--radius-full);
  transition: width .25s ease;
}
.rbg-progress-label {
  font-size: 13px; font-weight: 700;
  color: var(--md-primary); font-variant-numeric: tabular-nums;
}
.rbg-hint { font-size: 11px; color: var(--md-on-surface-var); opacity: .65; line-height: 1.5; }

.rbg-result {
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; width: 100%;
}
.rbg-preview-wrapper {
  width: 100%; max-width: 500px;
  border-radius: var(--radius-md); overflow: hidden;
  background: repeating-conic-gradient(var(--canvas-check1) 0% 25%, var(--canvas-check2) 0% 50%) 0 0 / 18px 18px;
  box-shadow: var(--elev3);
}
.rbg-result-img { display: block; width: 100%; height: auto; }

/* ================================================================
   CROP TOOL
================================================================ */
.crop-body {
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; padding: 16px 16px 32px;
  min-height: calc(100vh - 56px);
}
.crop-upload {
  display: flex; align-items: center; justify-content: center;
  width: 100%; flex: 1;
}
.crop-upload-label {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 52px 32px;
  border: 2px dashed var(--md-outline);
  border-radius: var(--radius-md);
  color: var(--md-on-surface-var);
  cursor: pointer; width: 100%; max-width: 400px; text-align: center;
  font-size: 14px; transition: border-color var(--t), background var(--t);
}
.crop-upload-label:hover { border-color: var(--md-primary); background: rgba(103,80,164,.05); }
.crop-upload-label small { font-size: 12px; opacity: .65; }
.crop-upload-icon { font-size: 52px; }
#crop-file-input { display: none; }

.crop-canvas-wrapper {
  width: 100%; max-width: 520px;
  border-radius: var(--radius-md); overflow: hidden;
  box-shadow: var(--elev3);
}
#crop-canvas {
  display: block; width: 100%; height: auto;
  touch-action: none; cursor: crosshair;
}

.crop-info-bar {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; max-width: 520px;
  background: var(--md-surface2);
  border: 1px solid var(--md-outline-var);
  border-radius: var(--radius-md);
  padding: 8px 14px;
}
.crop-dimensions {
  font-size: 13px; font-weight: 600;
  color: var(--md-primary); letter-spacing: .4px;
  font-variant-numeric: tabular-nums;
}
.crop-reset-btn {
  background: none; border: none;
  color: var(--md-on-surface-var); font-family: inherit;
  font-size: 13px; font-weight: 500; cursor: pointer;
  padding: 4px 10px; border-radius: var(--radius-xl);
  border: 1px solid var(--md-outline-var);
  transition: background var(--t), color var(--t);
}
.crop-reset-btn:hover  { background: rgba(255,255,255,.07); color: var(--md-on-surface); }
.crop-reset-btn:active { opacity: .75; }

.crop-ratios {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
}
.ratio-btn {
  padding: 8px 18px; border-radius: var(--radius-xl);
  border: 1px solid var(--md-outline); background: transparent;
  color: var(--md-on-surface-var); font-family: inherit;
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all var(--t);
}
.ratio-btn.active {
  background: var(--md-secondary-cont);
  border-color: transparent; color: var(--md-secondary);
}

/* ── Save button success animation ── */
@keyframes saveFlash {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.1); }
  100% { transform: scale(1); }
}
.btn-save-anim {
  animation: saveFlash .35s ease;
  background: var(--md-success-cont) !important;
  color: var(--md-success) !important;
}

/* ── Crop browse frames section ── */
.crop-browse-title {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 16px 4px;
  font-size: 13px; font-weight: 700; letter-spacing: .5px;
  color: var(--md-on-surface);
}
.crop-browse-link {
  font-size: 12px; font-weight: 500;
  color: var(--md-primary); cursor: pointer;
  background: none; border: none; font-family: inherit;
  padding: 4px 8px; border-radius: var(--radius-xl);
  transition: background var(--t);
}
.crop-browse-link:hover { background: rgba(103,80,164,.1); }

/* ================================================================
   SUGGESTIONS
================================================================ */
.suggestions-section {
  border-top: 1px solid var(--md-outline-var);
  background: var(--md-surface1);
  padding: 14px 16px 20px; flex-shrink: 0;
}
.suggestions-title {
  font-size: 11px; font-weight: 700;
  letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--md-on-surface-var); margin-bottom: 10px;
}
.suggestions-scroll {
  display: flex; gap: 10px;
  overflow-x: auto; padding-bottom: 2px;
  scrollbar-width: none; -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y;
}
.suggestions-scroll::-webkit-scrollbar { display: none; }

.suggestion-card {
  flex: 0 0 auto; width: 72px; height: 72px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  background: var(--md-surface3);
  display: flex; align-items: center; justify-content: center;
  padding: 4px;
  transition: border-color var(--t);
  user-select: none;
}
.suggestion-card:active { opacity: .8; }
.suggestion-card.active-sug { border-color: var(--md-primary); }
.suggestion-thumb { max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; }

/* ================================================================
   LOADING OVERLAY
================================================================ */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(28,27,31,.85);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px;
  z-index: 9000; backdrop-filter: blur(4px);
}
.spinner {
  width: 46px; height: 46px;
  border: 3px solid var(--md-outline-var);
  border-top-color: var(--md-primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 14px; color: var(--md-on-surface-var); }

/* ================================================================
   TOAST
================================================================ */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(14px);
  background: var(--md-surface5); color: var(--md-on-surface);
  padding: 11px 22px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 9999; box-shadow: var(--elev3);
  max-width: calc(100vw - 40px); white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-success { background: var(--md-success-cont); color: var(--md-success); }
.toast.toast-error   { background: var(--md-error-cont);   color: var(--md-error);   }

/* ================================================================
   COMING SOON MODAL
================================================================ */
.cs-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 8000;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.cs-card {
  background: var(--md-surface3);
  border: 1px solid var(--md-outline-var);
  border-radius: var(--radius-md);
  padding: 32px 24px;
  max-width: 320px; width: 100%;
  text-align: center; box-shadow: var(--elev3);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.cs-icon { font-size: 44px; }
.cs-title { font-size: 20px; font-weight: 700; color: var(--md-primary); }
.cs-body  { font-size: 14px; color: var(--md-on-surface-var); line-height: 1.55; }
.cs-close-btn {
  margin-top: 6px; padding: 10px 28px;
  border-radius: var(--radius-xl); border: none;
  background: var(--md-primary); color: var(--md-on-primary);
  font-family: inherit; font-size: 14px; font-weight: 600;
  transition: opacity var(--t);
}
.cs-close-btn:active { opacity: .8; }

/* ================================================================
   ABOUT PAGE
================================================================ */
.about-body {
  padding: 0 0 40px;
  max-width: 560px;
  margin: 0 auto;
}
.about-hero {
  display: flex; flex-direction: column;
  align-items: center; gap: 10px;
  padding: 36px 24px 28px;
  text-align: center;
}
.about-logo {
  width: 72px; height: 72px;
  object-fit: contain;
  border-radius: var(--radius-md);
}
.about-app-name {
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 26px; font-weight: 700;
  color: var(--md-primary);
}
.about-tagline {
  font-size: 13px; color: var(--md-on-surface-var); line-height: 1.5;
}

.about-section { padding: 0 16px 8px; }
.about-section-title {
  font-size: 11px; font-weight: 700;
  letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--md-on-surface-var);
  padding: 8px 4px 10px;
}
.about-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--md-surface2);
  border: 1px solid var(--md-outline-var);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--md-on-surface);
  transition: background var(--t), border-color var(--t);
  margin-bottom: 8px;
}
.about-card:hover  { background: var(--md-surface3); border-color: var(--md-primary); }
.about-card:active { opacity: .8; }
.about-card-icon {
  font-size: 22px; width: 40px; height: 40px;
  border-radius: var(--radius-md);
  background: var(--md-primary-container);
  color: var(--md-on-primary-cont);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.about-card-text { flex: 1; }
.about-card-title { font-size: 14px; font-weight: 500; margin-bottom: 2px; }
.about-card-sub   { font-size: 12px; color: var(--md-on-surface-var); }
.about-card-arrow { font-size: 18px; color: var(--md-on-surface-var); flex-shrink: 0; }

.about-footer {
  text-align: center; padding: 24px 16px 0;
  font-size: 12px; color: var(--md-on-surface-var);
}

/* ================================================================
   TEXT PANEL — Done button
================================================================ */
.text-done-btn {
  align-self: flex-end;
  padding: 8px 22px;
  border-radius: var(--radius-xl); border: none;
  background: var(--md-primary); color: var(--md-on-primary);
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: opacity var(--t);
}
.text-done-btn:active { opacity: .8; }

/* ================================================================
   EDITOR PANELS  (Filter + Adjust — generic container)
================================================================ */
.editor-panel {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--md-outline-var);
  background: var(--md-surface2);
  overflow: hidden;
}
.editor-panel-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: transparent; border: none;
  color: var(--md-on-surface); font-family: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: background var(--t);
}
.editor-panel-toggle:hover { background: rgba(255,255,255,.05); }
.editor-panel-body {
  padding: 4px 16px 16px;
  border-top: 1px solid var(--md-outline-var);
  display: flex; flex-direction: column; gap: 12px;
}

/* ── Filter strip ── */
.filter-strip {
  display: flex; gap: 8px;
  overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: none; -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y;
}
.filter-strip::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: 0 0 auto; padding: 7px 16px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--md-outline-var); background: transparent;
  color: var(--md-on-surface-var); font-family: inherit;
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all var(--t); white-space: nowrap;
}
.filter-chip.active {
  background: var(--md-secondary-cont);
  border-color: transparent; color: var(--md-secondary);
}
.filter-chip:active { opacity: .75; }

/* ── Adjust sliders ── */
.adjust-row {
  display: flex; align-items: center; gap: 10px;
}
.adjust-label {
  font-size: 12px; color: var(--md-on-surface-var);
  width: 76px; flex-shrink: 0;
}
.adjust-slider {
  flex: 1;
  -webkit-appearance: none; appearance: none;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--md-outline-var);
  outline: none; cursor: pointer;
}
.adjust-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--md-primary);
  cursor: pointer; box-shadow: var(--elev1);
}
.adjust-slider::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--md-primary);
  cursor: pointer; border: none; box-shadow: var(--elev1);
}
.adjust-val {
  font-size: 12px; font-weight: 700;
  color: var(--md-primary);
  width: 32px; text-align: right; flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* ================================================================
   CONFIRM MODAL  (two-button variant)
================================================================ */
.modal-btn-row {
  display: flex; gap: 10px; width: 100%;
  justify-content: center; flex-wrap: wrap;
  margin-top: 4px;
}
.modal-btn-row .btn {
  flex: 1; min-width: 110px; justify-content: center;
}

/* ================================================================
   RESIZE VIEW
================================================================ */
.resize-body {
  display: flex; flex-direction: column; align-items: center;
  gap: 20px; padding: 20px 16px 40px;
  min-height: calc(100vh - 56px);
}
.resize-upload {
  display: flex; align-items: center; justify-content: center;
  width: 100%; flex: 1;
}
#resize-file-input { display: none; }

.resize-editor {
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; width: 100%;
}
.resize-preview-wrapper {
  width: 100%; max-width: 500px;
  border-radius: var(--radius-md); overflow: hidden;
  background: repeating-conic-gradient(var(--canvas-check1) 0% 25%, var(--canvas-check2) 0% 50%) 0 0 / 18px 18px;
  box-shadow: var(--elev3);
}
.resize-preview-img { display: block; width: 100%; height: auto; }

.resize-controls {
  display: flex; flex-direction: column;
  gap: 14px; width: 100%; max-width: 500px;
  background: var(--md-surface2);
  border: 1px solid var(--md-outline-var);
  border-radius: var(--radius-md); padding: 16px;
}
.resize-info {
  font-size: 12px; color: var(--md-on-surface-var); font-weight: 500;
}
.resize-input-row {
  display: flex; align-items: flex-end; gap: 10px;
}
.resize-field {
  flex: 1; display: flex; flex-direction: column; gap: 5px;
}
.resize-field-label {
  font-size: 11px; color: var(--md-on-surface-var);
  font-weight: 600; letter-spacing: .3px; text-transform: uppercase;
}
.resize-input {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--md-outline-var); border-radius: var(--radius-md);
  background: var(--md-surface3); color: var(--md-on-surface);
  font-family: inherit; font-size: 16px; font-weight: 700; outline: none;
  transition: border-color var(--t); text-align: center;
}
.resize-input:focus { border-color: var(--md-primary); }
.resize-lock-btn {
  padding: 9px 11px; border-radius: var(--radius-md);
  border: 1px solid var(--md-outline-var); background: transparent;
  color: var(--md-on-surface-var); font-size: 17px;
  cursor: pointer; transition: all var(--t);
  flex-shrink: 0; line-height: 1;
}
.resize-lock-btn.active {
  background: var(--md-primary-container);
  border-color: transparent; color: var(--md-on-primary-cont);
}
.resize-lock-btn:hover { background: rgba(103,80,164,.1); }
.resize-presets {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.resize-preset-btn {
  flex: 1; min-width: 100px; padding: 7px 8px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--md-outline-var); background: transparent;
  color: var(--md-on-surface-var); font-family: inherit;
  font-size: 12px; font-weight: 500; cursor: pointer;
  transition: all var(--t); white-space: nowrap;
}
.resize-preset-btn:hover  { background: rgba(103,80,164,.08); border-color: var(--md-primary); color: var(--md-primary); }
.resize-preset-btn:active { opacity: .75; }

/* ================================================================
   COLLAGE VIEW
================================================================ */
.collage-body {
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; padding: 16px 16px 32px;
  min-height: calc(100vh - 56px);
}
.collage-layout-bar {
  display: flex; gap: 8px;
  overflow-x: auto; padding: 2px 0;
  scrollbar-width: none; -ms-overflow-style: none;
  touch-action: pan-x pan-y; width: 100%;
}
.collage-layout-bar::-webkit-scrollbar { display: none; }
.collage-layout-btn {
  flex: 0 0 auto; padding: 8px 18px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--md-outline); background: transparent;
  color: var(--md-on-surface-var); font-family: inherit;
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all var(--t);
}
.collage-layout-btn.active {
  background: var(--md-secondary-cont);
  border-color: transparent; color: var(--md-secondary);
}
.collage-layout-btn:active { opacity: .8; }
.collage-canvas-wrapper {
  width: 100%; max-width: 500px;
  border-radius: var(--radius-md); overflow: hidden;
  box-shadow: var(--elev3);
}
#collage-canvas {
  display: block; width: 100%; height: auto;
  cursor: pointer; touch-action: manipulation;
}
.collage-hint {
  font-size: 12px; color: var(--md-on-surface-var);
  text-align: center; opacity: .7;
}

/* ── Collage controls panel ── */
.collage-controls {
  width: 100%; max-width: 500px;
  background: var(--md-surface2);
  border: 1px solid var(--md-outline-var);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 14px;
}
.collage-ctrl-row {
  display: flex; align-items: center; gap: 12px;
}
.collage-ctrl-label {
  font-size: 11px; font-weight: 700;
  letter-spacing: .8px; text-transform: uppercase;
  color: var(--md-on-surface-var);
  width: 52px; flex-shrink: 0;
}
.collage-chip-group {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.collage-chip {
  padding: 6px 15px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--md-outline-var); background: transparent;
  color: var(--md-on-surface-var); font-family: inherit;
  font-size: 12px; font-weight: 500; cursor: pointer;
  transition: all var(--t); white-space: nowrap;
}
.collage-chip.active {
  background: var(--md-secondary-cont);
  border-color: transparent; color: var(--md-secondary);
}
.collage-chip:active { opacity: .75; }

/* ── Colour swatches ── */
.collage-swatch-row {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.collage-swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  cursor: pointer; flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
  transition: transform var(--t), border-color var(--t);
}
.collage-swatch.active {
  border-color: var(--md-primary);
  transform: scale(1.2);
}
.collage-swatch:active { opacity: .75; }
.collage-swatch-picker {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px dashed var(--md-outline) !important;
  background: var(--md-surface3) !important;
  box-shadow: none !important;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; cursor: pointer;
  position: relative;
}
.collage-swatch-picker input[type="color"] {
  position: absolute; opacity: 0;
  width: 100%; height: 100%;
  cursor: pointer; border: none;
  padding: 0; margin: 0;
}

/* ================================================================
   REMOVE BG — mode tabs + manual erase
================================================================ */

/* Mode tabs (Auto / Manual) */
.rbg-tabs {
  display: flex; gap: 0;
  background: var(--md-surface2);
  border-bottom: 1px solid var(--md-outline-var);
  padding: 0 16px;
}
.rbg-tab {
  flex: 1; padding: 12px 8px;
  background: transparent; border: none; border-bottom: 2.5px solid transparent;
  color: var(--md-on-surface-var); font-family: inherit;
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: color var(--t), border-color var(--t);
  letter-spacing: .3px;
}
.rbg-tab.active {
  color: var(--md-primary);
  border-bottom-color: var(--md-primary);
}
.rbg-tab:active { opacity: .75; }

/* Mode bodies */
.rbg-mode-body { width: 100%; }

/* Download progress inside modal */
.rbg-dl-progress-wrap {
  width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.rbg-dl-bar-track {
  width: 100%; height: 8px;
  border-radius: var(--radius-full);
  background: var(--md-outline-var); overflow: hidden;
}
.rbg-dl-bar-fill {
  height: 100%; width: 0%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--md-primary), var(--md-secondary));
  transition: width .15s linear;
}
.rbg-dl-pct {
  font-size: 22px; font-weight: 700;
  color: var(--md-primary); font-variant-numeric: tabular-nums;
}
.rbg-dl-label {
  font-size: 13px; color: var(--md-on-surface-var); text-align: center;
}

/* Manual erase canvas area */
.rbg-manual-wrapper {
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; padding: 16px;
}
.rbg-manual-canvas-wrap {
  width: 100%; max-width: 500px; position: relative;
  border-radius: var(--radius-md); overflow: hidden;
  background: repeating-conic-gradient(var(--canvas-check1) 0% 25%, var(--canvas-check2) 0% 50%) 0 0 / 18px 18px;
  box-shadow: var(--elev3);
  cursor: crosshair;
}
#rbg-manual-canvas {
  display: block; width: 100%; height: auto;
  touch-action: none;
}
.rbg-manual-controls {
  width: 100%; max-width: 500px;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--md-surface2); border: 1px solid var(--md-outline-var);
  border-radius: var(--radius-md); padding: 14px 16px;
}
.rbg-brush-row {
  display: flex; align-items: center; gap: 10px;
}
.rbg-brush-label {
  font-size: 12px; color: var(--md-on-surface-var);
  width: 72px; flex-shrink: 0;
}
.rbg-brush-slider {
  flex: 1;
  -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: var(--radius-full);
  background: var(--md-outline-var); outline: none; cursor: pointer;
}
.rbg-brush-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--md-primary); cursor: pointer; box-shadow: var(--elev1);
}
.rbg-brush-slider::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--md-primary); cursor: pointer; border: none; box-shadow: var(--elev1);
}
.rbg-brush-val {
  font-size: 12px; font-weight: 700; color: var(--md-primary);
  width: 32px; text-align: right; flex-shrink: 0;
}
.rbg-manual-btn-row {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.rbg-manual-btn-row .btn {
  flex: 1; min-width: 90px; justify-content: center;
  font-size: 13px; padding: 9px 12px;
}

/* ================================================================
   RESPONSIVE TWEAKS
================================================================ */
@media (max-width: 420px) {
  .frames-grid { grid-template-columns: repeat(2, 1fr); }
  .category-card, .skeleton-card { width: 95px; }
}
@media (min-width: 1100px) {
  .category-scroll { padding-left: 32px; padding-right: 32px; }
  .section-label   { padding-left: 32px; }
  .frames-grid     { padding-left: 32px; padding-right: 32px; }
  .type-tabs       { padding-left: 32px; }
}
