/* SHUNLP_MOBILE_SIMPLE_BUILDER_V23_61
   Mobile-only presentation layer. Desktop declarations remain untouched. */
@media (max-width: 760px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  body {
    min-width: 0 !important;
  }

  .app-shell {
    min-height: 100dvh;
  }

  /* User top bar: stack project controls and actions without changing desktop. */
  .topbar,
  .topbar.collapsed {
    position: sticky;
    top: var(--shell-banner-offset, 0px);
    z-index: 24;
    width: 100% !important;
    height: auto;
    min-height: 56px;
    margin-left: 0 !important;
    padding: 8px 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .topbar-left,
  .topbar-right,
  .active-project-indicator {
    width: 100%;
    min-width: 0;
  }

  .topbar-left,
  .topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .topbar-right {
    justify-content: stretch;
  }

  .topbar-right .btn,
  .topbar-right button[data-action="new-project"],
  .topbar-right button[data-action="logout"] {
    flex: 1 1 0;
    min-width: 0 !important;
  }

  .active-project-indicator {
    margin-left: 0 !important;
    flex-wrap: wrap;
    gap: 8px !important;
  }

  .active-project-indicator > div,
  #topbarProjectSelector {
    min-width: 0;
    max-width: 100%;
  }

  /* Keep the same workspace and data, but expose navigation as a touch-friendly strip. */
  .workspace,
  .workspace.collapsed,
  .workspace.demo-mode-workspace {
    display: block !important;
    min-height: 0 !important;
  }

  .workspace .sidebar,
  .workspace .sidebar.collapsed {
    position: relative !important;
    inset: auto !important;
    display: flex !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: visible;
    z-index: 18;
  }

  .sidebar-header,
  .sidebar-footer {
    display: none !important;
  }

  .admin-view-switch {
    padding: 10px 12px 0 !important;
  }

  .sidebar-nav {
    display: flex;
    flex-direction: row;
    gap: 8px;
    padding: 10px 12px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar-nav::-webkit-scrollbar {
    display: none;
  }

  .sidebar-nav-item {
    flex: 0 0 auto;
    width: auto;
    min-width: max-content;
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #ffffff;
    scroll-snap-align: start;
    white-space: nowrap;
  }

  .sidebar-nav-item.active {
    border-color: var(--line-strong);
    background: #f1f5f9;
  }

  .sidebar-edge-toggle,
  .sidebar-edge-toggle.collapse,
  .sidebar-edge-toggle.reveal {
    display: none !important;
  }

  .main-pane,
  .workspace.collapsed .main-pane {
    grid-column: auto !important;
    width: 100%;
    min-width: 0;
    padding: 12px !important;
    overflow: visible !important;
  }

  .workspace-content,
  .panel,
  .panel-body,
  .settings-stack,
  .settings-block {
    min-width: 0;
    max-width: 100%;
  }

  .panel {
    margin-bottom: 14px;
    border-radius: 10px;
  }

  .panel-head,
  .pane-head,
  .block-title,
  .canvas-toolbar,
  .top-actions,
  .email-card-head,
  .email-card-actions,
  .lp-copy-engine-actions,
  .lp-copy-review-head,
  .lp-copy-inline-head,
  .lp-placement-planner-head {
    height: auto;
    min-height: 52px;
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .panel-head,
  .pane-head {
    padding: 12px 14px;
  }

  .panel-body,
  .settings-stack,
  .settings-block {
    padding: 14px;
  }

  /* One-column editing flow for the simple mobile experience. */
  .grid-2,
  .form-design-grid,
  .field-palette,
  .reminder-options,
  .lp-start-options,
  .lp-material-split-grid,
  .lp-composition-mode-grid,
  .lp-composition-custom-grid,
  .lp-placement-asset-fields,
  .metric-grid,
  .history-grid,
  .modal-body {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .selected-field,
  .question-design-row,
  .lp-flow-item,
  .lp-data-field,
  .lp-data-row,
  .lp-placement-asset-card {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .selected-field-actions,
  .image-actions,
  .lp-copy-engine-actions,
  .email-card-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .selected-field-actions .btn,
  .image-actions .btn,
  .lp-copy-engine-actions .btn,
  .email-card-actions .btn {
    flex: 1 1 140px;
  }

  .assets-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .assets-grid .image-item {
    padding: 9px;
  }

  .assets-grid .thumb {
    height: auto;
    aspect-ratio: 4 / 3;
  }

  .canvas-stack {
    width: 100%;
    max-width: 100%;
    margin-bottom: 24px;
    gap: 12px;
  }

  .canvas-card {
    border-radius: 8px;
  }

  .image-canvas {
    cursor: default;
    touch-action: pan-y;
  }

  /* CTA region drawing remains a desktop detail editor in the first mobile release. */
  .workspace.submode-builder .workspace-content::before {
    content: "スマホ簡易編集モード\A CTA範囲の描画・移動・サイズ調整はPCで行えます。ここまでの内容は同じプロジェクトに保存され、PCで続きから編集できます。";
    display: block;
    margin: 0 0 12px;
    padding: 12px 14px;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    background: #eff6ff;
    color: #1e3a8a;
    font-size: 13px;
    line-height: 1.65;
    white-space: pre-line;
  }

  .workspace.submode-builder .image-canvas {
    pointer-events: none;
  }

  .workspace.submode-builder .link-pop,
  .workspace.submode-builder .resize-handle,
  .workspace.submode-builder .drawing-area {
    display: none !important;
  }

  /* Touch targets and iOS zoom prevention. */
  .btn,
  button,
  [role="button"] {
    min-height: 44px;
  }

  .btn.small,
  .panel-head .btn.small {
    min-height: 40px;
    min-width: 0;
  }

  input[type="text"],
  input[type="url"],
  input[type="tel"],
  input[type="number"],
  input[type="time"],
  input[type="email"],
  input[type="password"],
  select,
  textarea,
  .control {
    min-height: 44px;
    font-size: 16px !important;
  }

  textarea {
    line-height: 1.55;
  }

  .lp-production-table-wrap,
  .table-wrap,
  .analytics-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .custom-confirm-card,
  .lp-production-progress-card,
  .modal-card {
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
  }

  .custom-confirm-btn-row {
    flex-wrap: wrap;
  }

  .custom-confirm-btn-row .custom-confirm-btn {
    flex: 1 1 120px;
    min-height: 44px;
  }

  .demo-navigator {
    position: static !important;
    width: auto !important;
    max-width: none !important;
    margin: 0 12px 16px !important;
    border-left: 0 !important;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 420px) {
  .assets-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .topbar-right,
  .custom-confirm-btn-row {
    flex-direction: column;
  }

  .topbar-right .btn,
  .custom-confirm-btn-row .custom-confirm-btn {
    width: 100%;
  }
}
