/* Mobile showcase; desktop retains its review and generation controls. */
.mobile-brand-header,
.mobile-card-caption,
.mobile-sync-footer,
#mobile-category-count {
  display: none;
}

@media (max-width: 620px) {
  :root {
    --mobile-paper: #f6f5f2;
    --mobile-card: #fff;
    --mobile-line: #e7e6e1;
    --mobile-olive: #5f6743;
    --mobile-gap: 6px;
    --mobile-inset: 8px;
  }

  html {
    width: 100%;
    scroll-padding-top: 122px;
  }

  body {
    width: 100%;
    min-width: 0;
    background: var(--mobile-paper);
    color: #111;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    -webkit-text-size-adjust: 100%;
  }

  .app-shell {
    width: 100%;
    min-width: 0;
    overflow-x: clip;
  }

  .masthead,
  .sidebar,
  .content-heading,
  .category-progress-strip,
  .import-review-note,
  .footer,
  #review-toolbar > .toolbar-reset,
  #unlock-ready,
  #toggle-all {
    display: none !important;
  }

  .mobile-brand-header {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    min-height: 72px;
    padding: calc(14px + env(safe-area-inset-top, 0px)) 17px 17px;
  }

  .mobile-brand-title {
    min-width: 0;
    font-size: 24px;
    font-weight: 850;
    line-height: 1.1;
    letter-spacing: -.06em;
    white-space: nowrap;
  }

  .mobile-brand-project {
    font-size: 14px;
    font-weight: 400;
    line-height: 1;
    letter-spacing: -.03em;
    white-space: nowrap;
  }

  #mobile-search-toggle {
    display: grid;
    place-items: center;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    min-width: 40px;
    margin-left: auto;
    padding: 0;
    color: #171717;
    background: transparent;
    border: 1px solid #deded9;
    border-radius: 9px;
    -webkit-tap-highlight-color: transparent;
  }

  #mobile-search-toggle svg {
    display: block;
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
  }

  #mobile-search-toggle[aria-expanded="true"] {
    background: #ebece1;
    border-color: #cfd3bc;
  }

  #review-toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: stretch;
    flex-wrap: wrap;
    gap: 12px;
    width: 100%;
    min-width: 0;
    padding: 0 var(--mobile-inset) 10px;
    background: rgba(246, 245, 242, .96);
    border: 0;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  #review-toolbar .mobile-category-control {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1 0 100%;
    order: 0;
    width: 100%;
    min-width: 0;
    height: 46px;
    padding: 0 62px 0 13px;
    background: rgba(255, 255, 255, .94);
    border: 1px solid var(--mobile-line);
    border-radius: 10px;
  }

  #review-toolbar .mobile-category-control > span:not(#mobile-category-count) {
    display: none;
  }

  #review-toolbar #category-filter {
    width: 100%;
    min-width: 0;
    max-width: none;
    min-height: 44px;
    margin: 0;
    padding: 0 21px 0 0;
    border: 0;
    background: transparent;
    color: #141414;
    font: 700 20px/1.35 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    letter-spacing: -.04em;
    text-overflow: ellipsis;
  }

  #mobile-category-count {
    position: absolute;
    right: 14px;
    top: 50%;
    display: block;
    transform: translateY(-50%);
    color: #92928e;
    font-size: 14px;
    font-weight: 400;
    line-height: 1;
    white-space: nowrap;
    pointer-events: none;
  }

  #review-toolbar .mobile-secondary-controls {
    display: none;
  }

  body[data-mobile-search-open="true"] #review-toolbar .mobile-secondary-controls,
  body[data-mobile-search-open="1"] #review-toolbar .mobile-secondary-controls,
  body[data-mobile-search-open=""] #review-toolbar .mobile-secondary-controls {
    display: flex;
    order: 1;
    flex: 1 0 100%;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 0 12px;
    background: #fff;
    border: 1px solid var(--mobile-line);
    border-radius: 10px;
  }

  #review-toolbar .search-wrap input,
  #review-toolbar .mobile-secondary-controls select {
    width: 100%;
    min-width: 0;
    max-width: none;
    min-height: 44px;
    padding: 9px 0;
    font-size: 16px;
    line-height: 1.4;
  }

  #review-toolbar .search-icon {
    color: #7a7a73;
    font-size: 22px;
  }

  #review-toolbar .select-wrap.mobile-secondary-controls {
    display: none !important;
  }

  #review-toolbar .status-tabs {
    display: flex;
    align-items: stretch;
    flex: 1 0 100%;
    order: 2;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    margin: 0;
    padding: 0;
    gap: 0;
    overflow: hidden;
    background: transparent;
    border: 1px solid var(--mobile-line);
    border-radius: 9px;
  }

  #review-toolbar .status-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 0;
    min-width: 0;
    min-height: 43px;
    padding: 8px 4px;
    border: 0;
    border-radius: 0;
    color: #81817d;
    background: transparent;
    box-shadow: none;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.4;
    -webkit-tap-highlight-color: transparent;
  }

  #review-toolbar .status-tab[data-status="APPROVED"] { order: 0; }
  #review-toolbar .status-tab[data-status="REVIEW"] { order: 1; }
  #review-toolbar .status-tab[data-status="REJECTED"] { order: 2; }
  #review-toolbar .status-tab[data-status="REVIEW"],
  #review-toolbar .status-tab[data-status="REJECTED"] { border-left: 1px solid #eae9e4; }

  #review-toolbar .status-tab[data-status="GENERATED"],
  #review-toolbar .status-tab[data-status="ALL"],
  #review-toolbar .status-tab b,
  #review-toolbar > .review-sync-state {
    display: none;
  }

  #review-toolbar .status-tab.is-active {
    color: var(--mobile-olive);
    background: #e7e8dd;
    border-radius: 8px;
    font-weight: 700;
  }

  .layout {
    display: block;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 10px var(--mobile-inset) 0;
  }

  .content {
    width: 100%;
    min-width: 0;
  }

  #gallery {
    width: 100%;
    min-width: 0;
    column-count: 2;
    column-gap: var(--mobile-gap);
  }

  /* The JS grid path keeps row-reading order while sizing each card separately. */
  #gallery[data-mobile-layout="masonry"] {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: 1px;
    align-items: start;
    gap: 0 var(--mobile-gap);
    column-count: auto;
  }

  /* Optional explicit-column path, used only if the root renderer supplies it. */
  #gallery[data-mobile-layout="columns"] {
    display: flex;
    align-items: flex-start;
    gap: var(--mobile-gap);
    column-count: auto;
  }

  #gallery .masonry-column {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    width: calc((100% - var(--mobile-gap)) / 2);
    min-width: 0;
  }

  #gallery .shoe-card,
  #gallery .mason-card {
    display: inline-block;
    width: 100%;
    min-width: 0;
    margin: 0 0 var(--mobile-gap);
    padding: 0;
    overflow: hidden;
    break-inside: avoid;
    border: 1px solid #efeeea;
    border-radius: 12px;
    background: var(--mobile-card);
    box-shadow: none;
    transform: none;
    transition: none;
    vertical-align: top;
  }

  #gallery .shoe-card.is-selected,
  #gallery .shoe-card:hover,
  #gallery .shoe-card:focus-within {
    border-color: #efeeea;
    box-shadow: none;
    transform: none;
  }

  #gallery .shoe-visual,
  #gallery .driving-diversity-card .shoe-visual {
    display: block;
    width: 100%;
    height: auto;
    min-height: 0;
    aspect-ratio: var(--mobile-visual-ratio, .835);
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #fff;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
  }

  #gallery .shoe-visual img,
  #gallery .shoe-card:hover .shoe-visual img {
    display: block;
    width: 100%;
    height: 100%;
    min-width: 0;
    aspect-ratio: auto;
    object-fit: contain;
    object-position: center;
    background: #fff;
    transform: none;
    transition: none;
  }

  #gallery .status-pill,
  #gallery .shoe-number,
  #gallery .shoe-info {
    display: none !important;
  }

  .mobile-card-caption {
    display: flex;
    align-items: flex-start;
    width: 100%;
    min-width: 0;
    min-height: 63px;
    gap: 9px;
    padding: 10px 12px 11px;
    background: #fff;
    color: #111;
    text-align: left;
    border: 0;
  }

  .mobile-card-check {
    display: grid;
    place-items: center;
    flex: 0 0 19px;
    width: 19px;
    height: 19px;
    margin-top: 1px;
    border: 0;
    border-radius: 50%;
    background: var(--mobile-olive);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
  }

  .mobile-card-check svg {
    width: 13px;
    height: 13px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mobile-card-check[data-status="REJECTED"] { background: #a26356; }
  .mobile-card-check[data-status="PENDING_REVIEW"],
  .mobile-card-check[data-status="MANUAL_REVIEW"] { background: #a38d61; }

  .mobile-card-copy {
    flex: 1 1 auto;
    min-width: 0;
  }

  .mobile-card-id {
    display: block;
    margin: 0 0 4px;
    color: #94958f;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.1;
    letter-spacing: -.03em;
  }

  .mobile-card-name {
    display: block;
    margin: 0;
    color: #101010;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -.035em;
    overflow-wrap: anywhere;
  }

  .mobile-sync-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 104px;
    gap: 8px;
    padding: 30px 16px calc(28px + env(safe-area-inset-bottom, 0px));
    color: #858780;
    font-size: 13px;
    font-weight: 500;
  }

  .mobile-sync-footer::before {
    content: "";
    flex: 0 0 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--mobile-olive);
  }

  .mobile-sync-footer.is-warning { color: #a26356; }
  .mobile-sync-footer.is-warning::before { background: #a26356; }
  .mobile-sync-footer .review-sync-state { color: inherit; font: inherit; white-space: normal; }

  .empty-state {
    width: 100%;
    min-width: 0;
    padding: 60px 16px;
  }

  .detail-drawer {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    min-width: 0;
    overflow: hidden;
    background: var(--mobile-paper);
  }

  .drawer-head {
    flex: 0 0 auto;
    align-items: center;
    min-width: 0;
    gap: 12px;
    padding: calc(16px + env(safe-area-inset-top, 0px)) 16px 14px;
    background: #fff;
  }

  .drawer-head > div { min-width: 0; }
  .drawer-head .section-kicker { display: none; }
  .drawer-head h2 { margin: 0 0 5px; font-size: 21px; line-height: 1.25; overflow-wrap: anywhere; }
  .drawer-head p { font-family: inherit; font-size: 13px; }
  #drawer-close { flex: 0 0 42px; width: 42px; height: 42px; font-size: 32px; }

  .drawer-body {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    padding: 16px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .drawer-hero { margin-bottom: 18px; background: #fff; }
  .mobile-detail-information { border-top: 1px solid var(--mobile-line); }
  .mobile-detail-information > summary { min-height: 48px; padding: 14px 0; color: var(--mobile-olive); font-size: 14px; cursor: pointer; }
  .drawer-hero img { width: 100%; max-height: 56vh; height: auto; aspect-ratio: auto; object-fit: contain; background: #fff; }
  .drawer-section { padding: 17px 0; min-width: 0; }
  .drawer-section h3 { color: #777a6f; font-family: inherit; font-size: 13px; font-weight: 600; line-height: 1.45; letter-spacing: 0; text-transform: none; }
  .drawer-section h4 { font-size: 14px; line-height: 1.5; }
  .drawer-section p,
  .drawer-section li { font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
  .drawer-section a { color: var(--mobile-olive); overflow-wrap: anywhere; }
  .drawer-section img { max-width: 100%; }
  .drawer-section ul { padding-left: 19px; }
  .drawer-section summary { min-height: 44px; padding: 10px 0; font-size: 14px; line-height: 1.5; }
  .drawer-ref { display: block; min-width: 0; }
  .drawer-ref strong { font-size: 16px; }
  .drawer-ref a { display: inline-block; margin: 5px 0; font-size: 14px; }
  .detail-grid { min-width: 0; gap: 8px; }
  .detail-cell { min-width: 0; padding: 10px; }
  .detail-cell strong { font-size: 13px; overflow-wrap: anywhere; }
  .feedback-label { font-family: inherit; font-size: 13px; letter-spacing: 0; text-transform: none; }
  .feedback-section textarea,
  .drawer-body input,
  .drawer-body select { font-size: 16px; }
  .feedback-section textarea { min-height: 130px; line-height: 1.65; background: #fff; }
  .feedback-section textarea:focus { border-color: #8a9470; box-shadow: 0 0 0 3px rgba(95, 103, 67, .12); }

  .drawer-actions {
    position: static;
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, .97);
  }

  .drawer-actions .button,
  .drawer-actions #drawer-generate {
    min-width: 0;
    min-height: 44px;
    margin: 0;
    padding: 10px 5px;
    border-radius: 9px;
    box-shadow: none;
    font-size: 13px;
    line-height: 1.4;
    white-space: normal;
  }

  .drawer-actions .button-primary { background: var(--mobile-olive); }
  .drawer-actions .button-primary:hover { background: #6c7550; transform: none; }
  .drawer-actions .button-danger { background: #f0e2de; color: #93594b; }
  .drawer-actions .button-outline { border-color: #d8d9cd; }
  .toast { max-width: calc(100% - 32px); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); white-space: normal; font-size: 13px; text-align: center; }

  button:focus-visible,
  select:focus-visible,
  input:focus-visible {
    outline: 2px solid #7b8660;
    outline-offset: 2px;
  }
}

@media (max-width: 359px) {
  .mobile-brand-header { padding-left: 14px; padding-right: 14px; gap: 7px; }
  .mobile-brand-title { font-size: 21px; }
  .mobile-brand-project { font-size: 13px; }
  .mobile-card-caption { gap: 7px; padding-left: 9px; padding-right: 9px; }
  .mobile-card-name { font-size: 14px; }
}

@media (max-width: 620px) and (prefers-reduced-motion: reduce) {
  .detail-drawer,
  .toast { transition: none; }
}

/* The public phone view is a compact, read-only image gallery. */
@media (max-width: 620px) {
  html { scroll-padding-top: 110px; }
  .mobile-brand-header {
    min-height: 50px;
    gap: 7px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 10px 10px;
  }
  .mobile-brand-title { font-size: 22px; }
  #mobile-search-toggle,
  #review-toolbar .status-tabs,
  #review-sync-state,
  .mobile-sync-footer,
  .mobile-card-caption,
  .drawer-actions,
  .drawer-head #drawer-title { display: none !important; }
  #review-toolbar { gap: 6px; padding-bottom: 8px; }
  #review-toolbar > .search-wrap.mobile-secondary-controls {
    display: flex !important;
    flex: 1 1 calc(50% - 3px);
    order: 0;
    width: calc(50% - 3px);
    min-width: 0;
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid var(--mobile-line);
    border-radius: 9px;
    background: #fff;
  }
  #review-toolbar .mobile-category-control { order: 1; height: 42px; flex: 1 1 calc(50% - 3px); width: calc(50% - 3px); min-width: 0; padding-right: 43px; padding-left: 10px; }
  #review-toolbar #category-filter { min-height: 40px; font-size: 14px; }
  #review-toolbar .search-wrap input::placeholder { font-size: 14px; }
  #mobile-category-count { right: 9px; font-size: 11px; }
  #gallery .shoe-card { margin-bottom: 6px; border-radius: 8px; }
  #gallery .shoe-visual { position: relative; }
  .mobile-shoe-number {
    position: absolute;
    left: 6px;
    bottom: 4px;
    color: #777;
    font-size: 10px;
    font-weight: 400;
    line-height: 1.4;
    pointer-events: none;
  }
  .drawer-head { padding: calc(10px + env(safe-area-inset-top, 0px)) 10px 8px; }
  .drawer-head #drawer-id { margin: 0; font-size: 13px; }
  .drawer-body { padding: 6px; }
  .mobile-showcase-hero { display: flex; align-items: center; height: 100%; min-height: 0; margin: 0; }
  .mobile-showcase-hero img { display: block; width: 100%; height: 100%; max-height: calc(100dvh - 80px); object-fit: contain; }
}
