* {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    :root {
      --ink: #1a1714;
      --ink-soft: #5a5650;
      --ink-faint: #a09a93;
      --paper: #faf8f5;
      --paper-warm: #f2ede6;
      --paper-mid: #e8e0d5;
      --accent: #c8521a;
      --accent-light: #f5e8df;
      --accent-dark: #8f3610;
      --border: #d8d0c5;
      --radius: 10px;
      --radius-lg: 16px;
      --shadow: 0 2px 16px rgba(26, 23, 20, 0.08);
      --shadow-lg: 0 8px 40px rgba(26, 23, 20, 0.14);
    }

    body {
      font-family: 'DM Sans', sans-serif;
      background: var(--paper);
      color: var(--ink);
      min-height: 100vh;
      display: flex;
      flex-direction: column;
    }

    header {
      background: var(--ink);
      color: var(--paper);
      padding: 0.8rem 2rem;
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 10px;
    }

    .logo {
      font-family: 'DM Serif Display', serif;
      font-size: 1.3rem;
    }

    .header-sub a {
      color: rgb(213, 213, 213);
      text-decoration: none;
      font-size: 0.75rem;
    }

    .logo span {
      color: var(--accent);
      font-style: italic;
    }

    .app {
      display: grid;
      grid-template-columns: 260px 1fr 280px;
      gap: 0;
      flex: 1;
      min-height: 0;
    }

    /* SIDEBAR */
    .sidebar {
      background: #fff;
      border-right: 1px solid var(--border);
      overflow-y: auto;
      padding: 1.2rem 1rem;
      display: flex;
      flex-direction: column;
      gap: 1.2rem;
    }

    /* AÑADE sidebar-right */
    .sidebar-right {
      border-right: none;
      border-left: 1px solid var(--border);
    }

    .section-title {
      font-size: 0.65rem;
      font-weight: 600;
      letter-spacing: 0.1em;
      text-transform: uppercase;
      color: var(--ink-faint);
      margin-bottom: 0.6rem;
    }

    /* Vistas */
    .view-grid {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 6px;
    }

    .view-card {
      border: 2px solid var(--border);
      border-radius: var(--radius);
      cursor: pointer;
      background: var(--paper-warm);
      position: relative;
    }

    .view-card.active {
      border-color: var(--accent);
      background: var(--accent-light);
    }

    .view-card.active::after {
      content: '✓';
      position: absolute;
      top: 2px;
      right: 2px;
      background: var(--accent);
      color: white;
      width: 16px;
      height: 16px;
      border-radius: 50%;
      font-size: 9px;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .view-thumb {
      width: 100%;
      aspect-ratio: 3/4;
      object-fit: contain;
      padding: 6px;
      background: #fff;
    }

    .view-name {
      font-size: 0.65rem;
      text-align: center;
      padding: 4px;
      background: #fff;
      border-top: 1px solid var(--border);
    }

    /* Paleta colores */
    .paleta-grid {
      display: grid;
      grid-template-columns: repeat(6, 1fr);
      gap: 4px;
    }

    .color-btn {
      width: 30px;
      height: 30px;
      border-radius: 50%;
      border: 2px solid white;
      box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
      cursor: pointer;
    }

    .color-btn.active {
      border-color: var(--ink);
      box-shadow: 0 0 0 2px var(--accent);
    }

    /* Capas */
    .capas-list {
      max-height: 200px;
      overflow-y: auto;
      border: 1px solid var(--border);
      border-radius: var(--radius);
      background: var(--paper-warm);
    }

    .capa-item {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 8px 10px;
      border-bottom: 1px solid var(--border);
      background: white;
    }

    .capa-item:last-child {
      border-bottom: none;
    }

    .capa-visibilidad {
      cursor: pointer;
      font-size: 1.1rem;
      width: 24px;
      text-align: center;
    }

    .capa-info {
      flex: 1;
      font-size: 0.7rem;
      font-weight: 500;
    }

    .capa-actions {
      display: flex;
      gap: 6px;
    }

    .capa-actions button {
      background: none;
      border: none;
      cursor: pointer;
      font-size: 0.9rem;
      padding: 2px 6px;
      border-radius: 4px;
    }

    .capa-actions button:hover {
      background: var(--accent-light);
    }

    .btn-agregar {
      width: 100%;
      margin-top: 6px;
      padding: 6px;
      background: var(--accent-light);
      border: 1px dashed var(--accent);
      border-radius: 8px;
      cursor: pointer;
      font-size: 0.7rem;
      font-weight: 500;
    }

    /* Upload */
    .upload-area {
      border: 2px dashed var(--border);
      border-radius: var(--radius);
      padding: 0.8rem;
      text-align: center;
      cursor: pointer;
      background: var(--paper-warm);
      position: relative;
    }

    .upload-area input {
      position: absolute;
      inset: 0;
      opacity: 0;
      cursor: pointer;
    }

    .upload-icon {
      font-size: 1.4rem;
    }

    /* Texto personalizado */
    .texto-form {
      display: flex;
      flex-direction: column;
      gap: 8px;
      margin-top: 10px;
      padding: 10px;
      background: var(--paper-warm);
      border-radius: var(--radius);
    }

    .texto-form input,
    .texto-form select {
      padding: 6px 8px;
      border: 1px solid var(--border);
      border-radius: 6px;
      font-size: 0.7rem;
    }

    .texto-row {
      display: flex;
      gap: 6px;
      align-items: center;
    }

    .texto-row label {
      font-size: 0.65rem;
      width: 35px;
    }

    /* Sliders */
    .control-row {
      margin-bottom: 10px;
    }

    .control-label {
      display: flex;
      justify-content: space-between;
      font-size: 0.7rem;
      margin-bottom: 4px;
    }

    input[type=range] {
      width: 100%;
      height: 4px;
    }

    .blend-row,
    .tint-row {
      display: flex;
      gap: 5px;
      flex-wrap: wrap;
    }

    .blend-btn,
    .tint-swatch {
      border: 1px solid var(--border);
      border-radius: 6px;
      padding: 3px 6px;
      font-size: 0.6rem;
      cursor: pointer;
    }

    .blend-btn.active {
      background: var(--ink);
      color: white;
    }

    .tint-swatch {
      width: 24px;
      height: 24px;
      border-radius: 50%;
    }

    /* Canvas */
    .canvas-area {
      display: flex;
      flex-direction: column;
      background: #fff;
      overflow: hidden;
    }

    .canvas-toolbar {
      background: #fff;
      border-bottom: 1px solid var(--border);
      padding: 0.5rem 1rem;
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      align-items: center;
    }

    .toolbar-hint {
      font-size: 0.7rem;
      color: var(--ink-faint);
      flex: 1;
    }

    .btn {
      padding: 5px 12px;
      border-radius: 6px;
      font-size: 0.7rem;
      font-weight: 600;
      cursor: pointer;
      border: 1.5px solid transparent;
    }

    .btn-primary {
      background: var(--ink);
      color: white;
    }

    .btn-secondary {
      background: transparent;
      border-color: var(--border);
    }

    .btn-accent {
      background: var(--accent);
      color: white;
    }

    .canvas-wrapper {
      flex: 1;
      display: flex;
      align-items: flex-start;
      justify-content: center;
      padding: 1.5rem;
      overflow: auto;
      background: #fff;
    }

    #canvas-container {
      position: relative;
      box-shadow: var(--shadow-lg);
      border-radius: var(--radius);
      overflow: hidden;
      background: #fff;
      display: inline-block;
    }

    #garment-img {
      display: block;
      max-width: 500px;
      max-height: 500px;
      width: auto;
      height: auto;
      pointer-events: none;
      background: #fff;
    }

    .layer-overlay {
      position: absolute;
      cursor: grab;
    }

    .layer-overlay:active {
      cursor: grabbing;
    }

    .layer-overlay img,
    .layer-overlay div {
      display: block;
      width: 100%;
      height: 100%;
      pointer-events: none;
    }

    .layer-frame {
      position: absolute;
      inset: 0;
      display: none;
      pointer-events: none;
    }

    .empty-state {
      position: absolute;
      inset: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      background: rgba(255, 255, 255, 0.9);
      pointer-events: none;
    }

    .toast {
      position: fixed;
      bottom: 1rem;
      right: 1rem;
      background: var(--ink);
      color: white;
      padding: 8px 16px;
      border-radius: 8px;
      font-size: 0.75rem;
      z-index: 200;
      transform: translateY(60px);
      opacity: 0;
      transition: all 0.3s;
    }

    .toast.show {
      transform: translateY(0);
      opacity: 1;
    }

    .modal-backdrop {
      position: fixed;
      inset: 0;
      background: rgba(0, 0, 0, 0.5);
      z-index: 100;
      display: flex;
      align-items: center;
      justify-content: center;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.2s;
    }

    .modal-backdrop.open {
      opacity: 1;
      pointer-events: all;
    }

    .modal {
      background: white;
      border-radius: var(--radius-lg);
      padding: 1.2rem;
      max-width: 380px;
      width: 90%;
    }

    @media (max-width: 800px) {
      .app {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
      }

      /* En móvil el canvas va primero */
      .canvas-area {
        order: 1;
      }

      .sidebar {
        order: 2;
        border-right: none;
        border-bottom: 1px solid var(--border);
        flex-direction: column;
        padding: 1rem;
      }

      .sidebar-right {
        order: 3;
        border-left: none;
        border-top: 1px solid var(--border);
      }

      #canvas-container {
        width: 100% !important;
      }

      #garment-img {
        max-width: 100%;
        max-height: 70vw;
        width: auto;
        height: auto;
      }
    }
  