    * { margin: 0; padding: 0; box-sizing: border-box; }
    html { touch-action: pan-x pan-y; }

    :root {
      --bg: #fafafa;
      --card-bg: #fff;
      --text: #262626;
      --text-muted: #8e8e8e;
      --border: #dbdbdb;
      --accent: #0095f6;
      --danger: #ed4956;
      --bar-h: 60px;
    }

    body {
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
      background: var(--bg);
      color: var(--text);
      min-height: 100vh;
      overflow-x: hidden;
      padding-bottom: calc(var(--bar-h) + 8px);
    }

    /* ---- Header ---- */
    .header {
      position: sticky;
      top: 0;
      z-index: 100;
      display: flex;
      align-items: center;
      justify-content: center;
      height: 44px;
      background: var(--card-bg);
      border-bottom: 1px solid var(--border);
    }
    .header h1 { font-size: 16px; font-weight: 700; }

    /* ---- Bottom Bar ---- */
    .bottom-bar {
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      z-index: 100;
      display: flex;
      align-items: center;
      justify-content: space-around;
      height: var(--bar-h);
      background: var(--card-bg);
      border-top: 1px solid var(--border);
      padding: 4px 8px;
      padding-bottom: max(4px, env(safe-area-inset-bottom));
    }
    .bar-btn {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 2px;
      border: none;
      background: none;
      cursor: pointer;
      font-size: 10px;
      font-weight: 600;
      color: var(--text-muted);
      padding: 4px 8px;
      border-radius: 8px;
      transition: all .15s;
      min-width: 52px;
    }
    .bar-btn .icon { font-size: 22px; }
    .bar-btn:active { transform: scale(0.9); }
    .bar-btn.active { color: var(--accent); }
    .bar-btn.danger-active { color: var(--danger); }
    .bar-btn.reorder-active { color: #ff9500; background: rgba(255,149,0,0.1); }

    /* ---- Grid ---- */
    .gallery-container {
      position: relative;
      max-width: 960px;
      margin: 0 auto;
      padding: 4px;
      padding-bottom: calc(var(--bar-h) + 56px);
    }
    .text-layer {
      position: absolute;
      inset: 0;
      pointer-events: none;
      z-index: 10;
    }
    .text-layer .text-element { pointer-events: auto; }
    .gallery-grid {
      display: grid;
      gap: 3px;
      grid-template-columns: repeat(2, 1fr);
    }

    .gallery-grid.cols-1 { grid-template-columns: 1fr; }
    .gallery-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

    .gallery-item {
      position: relative;
      aspect-ratio: 1 / 1;
      overflow: hidden;
      cursor: pointer;
      background: #f0f0f0;
      touch-action: auto;
      user-select: none;
      -webkit-user-select: none;
    }
    .gallery-item.adjust-mode {
      touch-action: none;
      cursor: move;
    }
    .img-layer {
      position: absolute;
      inset: 0;
      background-size: contain;
      background-position: center center;
      background-repeat: no-repeat;
      transform-origin: center center;
      will-change: transform;
      pointer-events: none;
      transition: filter .3s;
    }
    .gallery-item.agotado .img-layer {
      filter: grayscale(100%) brightness(0.6);
    }

    /* Sold-out overlay */
    .sold-overlay {
      position: absolute;
      inset: 0;
      display: none;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      pointer-events: none;
    }
    .gallery-item.agotado .sold-overlay {
      display: flex;
    }

    /* X that covers the whole photo */
    .sold-x {
      position: absolute;
      inset: 0;
    }
    .sold-x::before,
    .sold-x::after {
      content: '';
      position: absolute;
      top: 50%;
      left: 50%;
      width: 141%;
      height: 4px;
      background: rgba(237, 73, 86, 0.7);
      transform-origin: center;
    }
    .sold-x::before { transform: translate(-50%, -50%) rotate(45deg); }
    .sold-x::after { transform: translate(-50%, -50%) rotate(-45deg); }

    .sold-badge {
      position: relative;
      z-index: 2;
      background: var(--danger);
      color: #fff;
      padding: 6px 18px;
      border-radius: 4px;
      font-size: 14px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 1px;
      box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    }

    /* ---- Upload area ---- */
    .upload-zone {
      max-width: 960px;
      margin: 20px auto;
      padding: 40px;
      border: 2px dashed var(--border);
      border-radius: 12px;
      text-align: center;
      cursor: pointer;
      transition: border-color .2s, background .2s;
    }
    .upload-zone:hover,
    .upload-zone.dragover {
      border-color: var(--accent);
      background: rgba(0,149,246,0.04);
    }
    .upload-zone p { color: var(--text-muted); margin-top: 8px; }
    .upload-zone .icon { font-size: 40px; }
    #file-input { display: none; }

    /* ---- Empty state ---- */
    .empty-state {
      text-align: center;
      padding: 80px 20px;
      color: var(--text-muted);
    }
    .empty-state .icon { font-size: 64px; margin-bottom: 16px; }

    /* ---- Loading ---- */
    .loading {
      text-align: center;
      padding: 40px;
      color: var(--text-muted);
    }

    /* ---- Toast ---- */
    .toast {
      position: fixed;
      bottom: 20px;
      left: 50%;
      transform: translateX(-50%) translateY(100px);
      background: #333;
      color: #fff;
      padding: 12px 24px;
      border-radius: 8px;
      font-size: 14px;
      z-index: 1000;
      transition: transform .3s ease;
      pointer-events: none;
    }
    .toast.show { transform: translateX(-50%) translateY(0); }

    /* ---- Upload Loader ---- */
    .loader-overlay {
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,.55);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 2000;
      opacity: 0;
      pointer-events: none;
      transition: opacity .25s ease;
    }
    .loader-overlay.show {
      opacity: 1;
      pointer-events: auto;
    }
    .loader-box {
      background: #fff;
      border-radius: 16px;
      padding: 32px 36px;
      text-align: center;
      min-width: 260px;
      box-shadow: 0 12px 40px rgba(0,0,0,.25);
    }
    .loader-spinner {
      width: 48px;
      height: 48px;
      border: 4px solid #e0e0e0;
      border-top-color: var(--accent, #0095f6);
      border-radius: 50%;
      margin: 0 auto 16px;
      animation: spin .8s linear infinite;
    }
    @keyframes spin { to { transform: rotate(360deg); } }
    .loader-text {
      font-size: 15px;
      font-weight: 600;
      color: #262626;
      margin-bottom: 12px;
    }
    .loader-progress-bar {
      height: 6px;
      background: #e0e0e0;
      border-radius: 3px;
      overflow: hidden;
      margin-bottom: 8px;
    }
    .loader-progress-fill {
      height: 100%;
      width: 0%;
      background: var(--accent, #0095f6);
      border-radius: 3px;
      transition: width .3s ease;
    }
    .loader-count {
      font-size: 13px;
      color: #8e8e8e;
    }

    /* ---- Floating text elements ---- */
    .text-element {
      position: absolute;
      z-index: 10;
      cursor: grab;
      touch-action: none;
      user-select: none;
      -webkit-user-select: none;
      transform-origin: center center;
    }
    .text-element.dragging { cursor: grabbing; }
    .text-element-content {
      background: #fff;
      color: #000;
      font-style: italic;
      font-size: 14px;
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
      padding: 6px 14px;
      border-radius: 20px;
      white-space: pre-wrap;
      word-break: break-word;
      max-width: 250px;
      text-align: center;
      box-shadow: 0 2px 8px rgba(0,0,0,.12);
      pointer-events: none;
    }
    .text-element-controls {
      position: absolute;
      top: -32px;
      left: 50%;
      transform: translateX(-50%);
      display: none;
      gap: 4px;
      background: rgba(0,0,0,.7);
      border-radius: 8px;
      padding: 3px 4px;
      z-index: 20;
    }
    .text-element.selected .text-element-controls {
      display: flex;
    }
    .text-ctrl-btn {
      width: 26px;
      height: 26px;
      border: none;
      background: none;
      color: #fff;
      cursor: pointer;
      border-radius: 4px;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0;
    }
    .text-ctrl-btn:active { background: rgba(255,255,255,.2); }
    .text-ctrl-btn svg { width: 16px; height: 16px; }
    .text-element .rotate-handle {
      position: absolute;
      bottom: -24px;
      left: 50%;
      transform: translateX(-50%);
      width: 20px;
      height: 20px;
      background: var(--accent);
      border-radius: 50%;
      cursor: pointer;
      display: none;
      align-items: center;
      justify-content: center;
      box-shadow: 0 2px 6px rgba(0,0,0,.2);
    }
    .text-element.selected .rotate-handle { display: flex; }
    .text-element .rotate-handle svg { width: 12px; height: 12px; stroke: #fff; }

    .add-text-fab {
      position: fixed;
      top: 52px;
      right: 16px;
      width: 48px;
      height: 48px;
      border-radius: 50%;
      background: var(--accent);
      color: #fff;
      border: none;
      font-size: 22px;
      font-weight: bold;
      cursor: pointer;
      box-shadow: 0 4px 12px rgba(0,0,0,.2);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 101;
      transition: transform .15s;
    }
    .add-text-fab:active { transform: scale(.9); }
    .add-text-fab svg { width: 24px; height: 24px; }

    /* ---- Auth overlay ---- */
    .auth-overlay {
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,.6);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 3000;
      opacity: 0;
      pointer-events: none;
      transition: opacity .25s ease;
    }
    .auth-overlay.show {
      opacity: 1;
      pointer-events: auto;
    }
    .auth-box {
      background: #fff;
      border-radius: 16px;
      padding: 32px 28px 24px;
      width: 300px;
      max-width: 90vw;
      text-align: center;
      box-shadow: 0 12px 40px rgba(0,0,0,.25);
    }
    .auth-icon {
      font-size: 40px;
      margin-bottom: 8px;
    }
    .auth-title {
      font-size: 17px;
      font-weight: 700;
      color: #262626;
      margin-bottom: 16px;
    }
    .auth-error {
      color: var(--danger);
      font-size: 13px;
      min-height: 18px;
      margin-bottom: 8px;
    }
    .auth-box input {
      width: 100%;
      padding: 12px 14px;
      border: 1.5px solid var(--border);
      border-radius: 8px;
      font-size: 15px;
      outline: none;
      margin-bottom: 10px;
      transition: border-color .2s;
      box-sizing: border-box;
    }
    .auth-box input:focus {
      border-color: var(--accent);
    }
    .auth-btn {
      width: 100%;
      padding: 12px;
      background: var(--accent);
      color: #fff;
      border: none;
      border-radius: 8px;
      font-size: 15px;
      font-weight: 600;
      cursor: pointer;
      transition: opacity .2s;
    }
    .auth-btn:active { opacity: .8; }
    .auth-btn:disabled { opacity: .5; cursor: not-allowed; }

    /* ---- Reorder mode ---- */
    .gallery-item.reorder-mode {
      cursor: grab;
      outline: 2px dashed #ff9500;
      outline-offset: -2px;
    }
    .gallery-item.reorder-mode:active { cursor: grabbing; }
    .gallery-item.reorder-dragging {
      opacity: 0.3;
      outline: 2px solid #ff9500;
    }
    .gallery-item.reorder-over {
      outline: 3px dashed #ff9500;
      outline-offset: -3px;
      transform: scale(0.95);
      transition: transform 0.15s;
    }
    .reorder-ghost {
      position: fixed;
      pointer-events: none;
      z-index: 9999;
      opacity: 0.85;
      border-radius: 8px;
      box-shadow: 0 8px 24px rgba(0,0,0,0.4);
      transform: scale(1.05);
      transition: transform 0.1s;
    }
    .gallery-item .order-badge {
      display: none;
      position: absolute;
      top: 4px;
      left: 4px;
      background: #ff9500;
      color: #fff;
      width: 24px; height: 24px;
      border-radius: 50%;
      font-size: 12px;
      font-weight: 700;
      align-items: center;
      justify-content: center;
      z-index: 5;
      pointer-events: none;
    }
    .gallery-item.reorder-mode .order-badge { display: flex; }

    /* ---- Pagination ---- */
    .pagination {
      position: fixed;
      bottom: var(--bar-h);
      left: 0;
      right: 0;
      z-index: 99;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 12px;
      padding: 10px 16px;
      background: var(--bg);
      border-top: 1px solid var(--border);
    }
    .pg-btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 40px;
      padding: 8px 14px;
      border: 1px solid var(--border);
      border-radius: 8px;
      background: var(--card-bg);
      font-size: 13px;
      font-weight: 600;
      cursor: pointer;
    }
    .pg-btn:disabled { opacity: 0.4; cursor: default; }
    .page-info {
      font-size: 14px;
      color: var(--text-muted);
      font-weight: 600;
    }

    /* ---- Modal ---- */
    .modal-overlay {
      position: fixed;
      inset: 0;
      z-index: 500;
      background: rgba(0,0,0,0.55);
      display: flex;
      align-items: center;
      justify-content: center;
      opacity: 0;
      visibility: hidden;
      transition: opacity .2s, visibility .2s;
    }
    .modal-overlay.show { opacity: 1; visibility: visible; }
    .modal-box {
      background: var(--card-bg);
      border-radius: 14px;
      width: min(90vw, 340px);
      overflow: hidden;
      box-shadow: 0 8px 40px rgba(0,0,0,0.25);
      transform: scale(0.9);
      transition: transform .2s;
    }
    .modal-overlay.show .modal-box { transform: scale(1); }
    .modal-body {
      padding: 24px 20px 16px;
      text-align: center;
    }
    .modal-icon { font-size: 40px; margin-bottom: 12px; }
    .modal-title {
      font-size: 17px;
      font-weight: 700;
      margin-bottom: 8px;
    }
    .modal-msg {
      font-size: 14px;
      color: var(--text-muted);
      line-height: 1.4;
    }
    .modal-actions {
      display: flex;
      border-top: 1px solid var(--border);
    }
    .modal-btn {
      flex: 1;
      padding: 14px;
      border: none;
      background: none;
      font-size: 15px;
      font-weight: 600;
      cursor: pointer;
      transition: background .15s;
    }
    .modal-btn:active { background: #f0f0f0; }
    .modal-btn + .modal-btn { border-left: 1px solid var(--border); }
    .modal-btn.cancel { color: var(--accent); }
    .modal-btn.confirm-danger { color: var(--danger); }
    .modal-btn.confirm-ok { color: var(--accent); }

    /* ---- Responsive ---- */
    @media (max-width: 600px) {
      .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 2px; }
      .sold-badge { font-size: 11px; padding: 4px 10px; }
      .sold-x::before, .sold-x::after { height: 3px; }
      .bar-btn { font-size: 9px; min-width: 44px; }
      .bar-btn .icon { font-size: 20px; }
    }