/**
 * Generador Keko — responsive / móvil
 */

/* Tablet y móvil: columna única; opciones antes del armario */
@media (max-width: 960px) {
  body[data-vibra-section="kekoSection"] #kekoSection.kg-page {
    overflow-x: hidden;
  }

  .kg-app {
    grid-template-columns: 1fr;
    grid-template-areas:
      "cats"
      "stage"
      "actions"
      "wardrobe";
    gap: 0.65rem;
    max-width: min(100%, 520px);
    margin: 0 auto;
    width: 100%;
    min-width: 0;
  }

  .kg-panel {
    min-width: 0;
    max-width: 100%;
  }

  .kg-panel--categories {
    grid-area: cats;
    position: static;
    max-height: none;
    overflow: hidden;
    padding: 0;
  }

  .kg-panel--categories .kg-panel__title {
    display: none;
  }

  .kg-panel--preview {
    display: contents;
    max-height: none;
    overflow: visible;
    padding: 0;
  }

  .kg-preview-card {
    grid-area: stage;
  }

  .kg-panel--actions {
    grid-area: actions;
    position: static;
    max-height: none;
    overflow-x: hidden;
  }

  .kg-panel--actions .kg-panel__title {
    text-align: center;
  }

  .kg-wardrobe {
    grid-area: wardrobe;
    min-width: 0;
  }

  .kg-panel--preview > .kg-meta {
    display: none !important;
  }

  .kg-categories {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: none;
    max-width: 100%;
    padding: 0.5rem 0.65rem;
    gap: 0.35rem;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
  }

  .kg-categories::-webkit-scrollbar {
    display: none;
  }

  .kg-category,
  .keko-tab {
    flex: 0 0 auto;
    width: auto;
    min-width: 3rem;
    min-height: 3rem;
    scroll-snap-align: center;
    padding: 0.5rem 0.55rem;
  }

  .kg-action-stack .kg-btn {
    width: 100%;
    white-space: normal;
    text-align: center;
  }

  .kg-toggle-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem;
  }

  .kg-accordion {
    margin-bottom: 0.3rem;
  }

  .kg-accordion__summary {
    padding: 0.7rem 0.75rem;
  }

  .kg-pose-block .kg-subtitle {
    margin-bottom: 0.45rem;
    text-align: center;
  }

  .kg-toggle-btn {
    flex: none;
    width: 100%;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .kg-wardrobe-toolbar,
  .keko-wardrobe-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
  }

  .kg-wardrobe-toolbar .kg-search,
  .keko-wardrobe-toolbar .kg-search {
    flex: none;
    width: 100%;
    max-width: none;
  }

  .kg-filters,
  .keko-wardrobe-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    padding-bottom: 0.2rem;
    gap: 0.4rem;
  }

  .kg-filters::-webkit-scrollbar,
  .keko-wardrobe-filters::-webkit-scrollbar {
    display: none;
  }

  .kg-filter,
  .keko-wardrobe-filter {
    flex: 0 0 auto;
    min-height: 2.25rem;
    padding: 0.4rem 0.75rem;
  }

  .keko-colors-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
  }

  .keko-colors-row__swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: flex-start;
  }

  .keko-color-swatch {
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
  }

  .kg-stage-hint__desktop {
    display: none;
  }

  .kg-stage-hint__mobile {
    display: inline;
  }
}

@media (max-width: 640px) {
  .kg-page {
    padding: 0 max(0.5rem, env(safe-area-inset-right)) 1.25rem max(0.5rem, env(safe-area-inset-left));
  }

  .kg-panel__title {
    padding: 0.65rem 0.75rem;
    font-size: 0.72rem;
  }

  .kg-preview-card {
    border-radius: var(--kg-radius-sm);
  }

  .kg-stage-wrap {
    padding: 0.4rem;
  }

  .kg-stage {
    min-height: max(210px, 34dvh);
    height: max(210px, 34dvh);
  }

  .kg-stage.keko-room--has-effect,
  .kg-stage.keko-room--tall-sprite {
    min-height: max(250px, 40dvh);
    height: max(250px, 40dvh);
  }

  .kg-stage-footer {
    padding: 0.45rem 0.5rem;
    gap: 0.4rem;
    flex-direction: column;
    align-items: center;
  }

  .kg-stage-tool-btn {
    width: 2.35rem;
    height: 2.35rem;
  }

  .kg-stage-hint {
    font-size: 0.68rem;
    line-height: 1.35;
    padding: 0 0.25rem;
    text-align: center;
  }

  .kg-wardrobe {
    min-height: 0;
    height: auto;
    max-height: none;
    padding: 0.45rem;
  }

  .kg-wardrobe > .kg-panels,
  .kg-wardrobe > .keko-tab-panels {
    min-height: 200px;
    max-height: min(42dvh, 340px);
  }

  .keko-wardrobe-grid {
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
    gap: 0.4rem;
    padding: 0.4rem;
  }

  .keko-wardrobe-item {
    min-height: 4.5rem;
    padding: 0.35rem 0.3rem 0.4rem;
  }

  .keko-wardrobe-item__thumb-wrap {
    min-height: 2.75rem;
  }

  .kg-btn {
    min-height: 44px;
    font-size: 0.88rem;
  }

  .kg-action-block,
  .kg-action-stack,
  .kg-pose-block,
  .kg-download-block {
    padding: 0.55rem 0.65rem;
  }

  .kg-toggle-btn {
    font-size: 0.72rem;
    min-height: 2.35rem;
    padding: 0.4rem 0.45rem;
  }

  .kg-field-row {
    flex-direction: column;
  }

  .kg-btn--secondary {
    width: 100%;
  }

  .kg-input,
  .kg-search {
    min-height: 44px;
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  body[data-vibra-section="kekoSection"] #kekoSection.kg-page {
    max-width: 100%;
  }

  .keko-tab__label {
    display: none;
  }

  .kg-category,
  .keko-tab {
    min-width: 2.75rem;
    justify-content: center;
    padding: 0.45rem;
  }

  .kg-stage {
    min-height: max(190px, 30dvh);
    height: max(190px, 30dvh);
  }

  .keko-wardrobe-grid {
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  }

  .kg-toggle-group {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 360px) {
  .kg-stage {
    min-height: max(170px, 28dvh);
    height: max(170px, 28dvh);
  }

  .keko-wardrobe-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
