/* ==========================================================================
   PHONE ADMIN (up to 767px)
   - Top bar wraps into rows; the right-hand tools scroll sideways, and the
     device switch sits on its own row.
   - The page drawer is a full-width panel; the inspector is a bottom sheet.
     They take turns, so the canvas is never hidden behind both.
   - Bigger tap targets and no text below 12px, and form fields at 16px so
     phones don't zoom in when a field is tapped.
   ========================================================================== */
@media (max-width: 767px) {
  .studio-topbar {
    height: auto !important;
    min-height: 0;
    flex-wrap: wrap;
    align-items: center;
    padding: 8px 10px !important;
    gap: 8px;
  }
  .topbar-left { flex: 1 1 auto; min-width: 0; gap: 8px; }
  .topbar-divider { display: none; }
  .topbar-center {
    order: 5;
    flex: 1 1 100%;
    width: 100%;
    display: flex;
    justify-content: center;
  }
  .topbar-right {
    order: 4;
    flex: 1 1 100%;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    justify-content: flex-start;
    gap: 8px;
    padding-bottom: 2px;
  }
  .topbar-right > * { flex: 0 0 auto; }
  .studio-topbar button,
  .studio-topbar .btn,
  .studio-topbar select,
  .version-select-pill { min-height: 38px; font-size: 12px !important; }

  .studio-canvas-viewport { padding: 0.75rem 0.5rem 7rem !important; }
  .canvas-device-frame { border-radius: 6px; }

  /* Drawer: full width beside the rail, with a close button you can hit */
  .studio-left-drawer {
    position: fixed !important;
    top: var(--topbar-h, 110px) !important;
    left: 46px !important;
    right: 0 !important;
    bottom: 0 !important;
    width: auto !important;
    max-width: none !important;
    z-index: 60;
  }
  .btn-drawer-close { width: 40px; height: 40px; }
  .drawer-title { font-size: 14px; }

  /* Inspector: bottom sheet, shown only when open */
  .studio-right-inspector { display: none !important; }
  .studio-right-inspector.is-open {
    display: flex !important;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    height: auto;
    max-height: 56vh;
    max-height: 56dvh;
    z-index: 70;
    flex-direction: column;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.18);
    background: #fff;
  }
  .phone-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px 6px;
    flex: 0 0 auto;
    border-bottom: 1px solid #e5e7eb;
  }
  .phone-sheet-steps { display: flex; gap: 6px; }
  .phone-sheet-step {
    width: 40px; height: 40px;
    border-radius: 999px;
    border: 1.5px solid #000;
    background: #fff;
    color: #000;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
  }
  .studio-right-inspector.is-open.is-dropped { max-height: 34dvh; }
  .studio-right-inspector.is-open.is-raised { max-height: 84dvh; }
  .phone-sheet-done {
    margin-left: auto;
    min-height: 40px;
    padding: 0 16px;
    border-radius: 999px;
    border: 0;
    background: #000;
    color: #fff;
    font-weight: 700;
    font-size: 13px;
  }
  .studio-right-inspector.is-open .inspector-tabs-bar { flex: 0 0 auto; }
  .inspector-tab-btn { min-height: 44px; font-size: 13px; }
  #inspectorBody { overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1 1 auto; min-height: 0; }

  /* Tap targets and readable text */
  .rail-btn { width: 44px; height: 44px; }
  .btn, .btn-xs, .btn-sm { min-height: 36px; }
  .btn-xs { font-size: 12px; padding: 0.3rem 0.55rem; }
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea, .ext-input { font-size: 16px !important; min-height: 40px; }
  input[type="checkbox"], input[type="radio"], input[type="range"] { font-size: inherit; }
  .ext-hint, .drawer-note-text, .sk-hint { font-size: 12px !important; line-height: 1.45; }
  .ext-title { font-size: 12px; }
  .ext-item, .media-row { min-height: 44px; }
  .section-wireframe-tile { min-height: 84px; }
  .modal-box { width: calc(100vw - 1.5rem) !important; }
}

@media (max-width: 767px) {
  .topbar-left * { font-size: 12px; }
  .btn-toggle-eye { min-height: 36px; min-width: 36px; font-size: 12px; }
}

@media (max-width: 767px) {
  .studio-left-drawer *, .studio-right-inspector * { font-size: 12.5px !important; }
  .studio-left-drawer h4, .studio-right-inspector h4, .drawer-title, .inspector-tab-btn { font-size: 13px !important; }
}

@media (max-width: 767px) {
  .studio-topbar > * { min-width: 0; }
  .version-select-pill { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (max-width: 767px) {
  .topbar-left { flex-wrap: wrap; row-gap: 6px; }
  .topbar-left > * { max-width: 46vw; min-width: 0; }
}
