/* Mobile Studio shell. Load after studio.css, app.css and flow.css.
   State belongs to mobile.js; this file never changes workflow controls or APIs. */

/* Author display:flex/grid rules must not defeat the hidden attribute used by UI. */
[hidden] { display: none !important; }

.mobile-quicknav,
.mobile-section-title,
.mobile-action-dock { display: none; }

.mobile-advanced {
  grid-column: 1 / -1;
  min-width: 0;
  border-top: 1px solid var(--line);
}
.mobile-advanced > summary {
  min-height: 44px;
  padding: 12px 0;
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  list-style-position: inside;
}
.mobile-advanced > summary::marker { color: var(--signal); }
.mobile-advanced > summary:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}
.advanced-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 20px;
  padding-top: 8px;
}
.advanced-fields > .trait { min-width: 0; }
.advanced-fields > .trait-wide { grid-column: 1 / -1; }

/* The old wrapped header retained a 56px flex-basis. Its navigation needs to
   contribute to its actual block height before the guest banner is laid out. */
@media (max-width: 1100px) {
  .topbar {
    position: relative;
    height: auto;
    min-height: 64px;
    flex: 0 0 auto;
    flex-wrap: wrap;
    padding-top: 10px;
    padding-bottom: 10px;
    row-gap: 8px;
  }
  .tophav {
    display: flex;
    order: 10;
    flex: 0 0 100%;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    padding-top: 4px;
    scrollbar-width: thin;
  }
  .tophav .nav-item {
    flex: 0 0 auto;
    white-space: nowrap;
  }
}

@media (min-width: 621px) and (max-width: 980px) {
  .auto-opts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auto-opts > .trait { min-width: 0; }
  .auto-opts select { min-width: 0; max-width: 100%; }
  .result-acts { flex-wrap: wrap; }
}

@media (max-width: 620px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; min-height: 100svh; }
  .views { flex: 1 0 auto; overflow: visible; min-width: 0; }
  .view { padding: 18px 12px 36px; min-width: 0; }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 8px 6px;
    flex: 0 0 auto;
    height: auto;
    min-height: 0;
    padding: 10px max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left));
  }
  .topbar .brand { grid-column: 1; grid-row: 1; min-width: 0; gap: 7px; }
  .topbar .brand > span:last-child { min-width: 0; }
  .topbar .brand-meter { width: 18px; flex: 0 0 18px; }
  .topbar .brand-name {
    display: block;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar .brand-sub,
  .topbar-spacer { display: none; }
  .topbar .acct {
    grid-column: 2;
    grid-row: 1;
    min-height: 44px;
    max-width: 90px;
    padding: 7px 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
  }
  .topbar .status {
    grid-column: 3;
    grid-row: 1;
    gap: 5px;
    max-width: 96px;
    padding: 6px;
    font-size: 10.5px;
    line-height: 1.4;
  }

  .mobile-quicknav {
    display: grid;
    grid-column: 1 / -1;
    grid-row: 2;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, .7fr);
    gap: 6px;
    min-width: 0;
  }
  .mobile-quicknav > a,
  .mobile-quicknav > button {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 44px;
    margin: 0;
    padding: 9px 7px;
    border: 1px solid var(--line-hi);
    border-radius: var(--r-sm);
    background: var(--panel);
    color: var(--text-soft);
    font: 500 13px/1.3 var(--font);
    text-align: center;
    text-decoration: none;
    cursor: pointer;
  }
  .mobile-quicknav > .is-on,
  .mobile-quicknav > [aria-current="page"],
  .mobile-quicknav > [aria-expanded="true"] {
    border-color: var(--signal-mid);
    background: var(--signal-lo);
    color: var(--signal);
  }
  #nav {
    display: none;
    grid-column: 1 / -1;
    grid-row: 3;
    order: initial;
    flex: none;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 8px 0 0;
    overflow: visible;
    border-top: 1px solid var(--line);
  }
  body.mobile-menu-open #nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  #nav .nav-item {
    display: flex;
    align-items: center;
    min-width: 0;
    min-height: 44px;
    padding: 10px 12px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  #nav .nav-item.is-on { color: var(--signal); background: var(--signal-lo); }

  .banner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    align-items: center;
    gap: 6px 10px;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.6;
  }
  .banner > span { grid-column: 1 / -1; overflow-wrap: anywhere; }
  .banner-btn { justify-self: start; min-height: 44px; padding: 9px 12px; }
  .banner-x { width: 44px; min-height: 44px; margin: 0; font-size: 16px; }

  .view-head { margin-bottom: 16px; gap: 8px; }
  .view-title { font-size: 24px; line-height: 1.4; }
  .view-sub { font-size: 14px; line-height: 1.65; }
  .mobile-section-title {
    display: block;
    margin: 22px 0 10px;
    color: var(--text-soft);
    font-size: 16px;
    font-weight: 600;
    line-height: 1.5;
  }
  .mobile-section-title:first-child { margin-top: 0; }
  .drop-bulk { padding: 18px 12px; font-size: 14px; line-height: 1.6; }
  .drop-bulk b { display: block; font-size: 18px; line-height: 1.45; }
  .drop-bulk span { font-size: 12px; overflow-wrap: anywhere; }
  .drop-bulk-ic { width: 44px; height: 44px; margin-bottom: 9px; }

  .auto-opts { grid-template-columns: minmax(0, 1fr); gap: 18px; padding: 14px; margin-top: 0; }
  .auto-opts > .trait { min-width: 0; }
  .advanced-fields { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .mobile-advanced > summary { font-size: 15px; }
  .trait label { font-family: var(--font); font-size: 13px; letter-spacing: 0; text-transform: none; }
  .views input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]),
  .views select,
  .views textarea,
  .modal input {
    min-width: 0;
    max-width: 100%;
    min-height: 44px;
    font-size: 16px;
  }
  .range-full { min-height: 44px; margin-top: 0; }
  .seg-b { min-height: 44px; font-size: 14px; }
  .sub-swatch { min-height: 44px; }
  .subtitle-size-heading { gap: 8px; align-items: center; }
  .subtitle-size-heading label,
  .subtitle-size-heading output { font-size: 14px; }
  .trait .subtitle-size-auto { min-height: 44px; margin: 3px 0 5px; font-size: 14px; }
  .subtitle-size-auto input { width: 20px; height: 20px; }
  .subtitle-size-inputs { gap: 8px; }
  .subtitle-size-inputs input[type="number"] { min-height: 44px; font-size: 16px; }
  .subtitle-size-hint,
  .subtitle-batch-note { font-size: 13px; line-height: 1.6; }

  .auto-bar { gap: 10px; }
  .auto-bar > .go { flex: 1 0 100%; min-height: 48px; margin-top: 0; }
  .auto-bar .btn-quiet,
  .auto-bar .link-btn { min-height: 44px; }
  .auto-count { margin-left: 0; width: 100%; font-size: 12px; overflow-wrap: anywhere; }
  .result-acts { flex-wrap: wrap; align-items: center; }
  .result-acts > label { flex: 1 0 100%; font-size: 14px; }
  .result-acts > select { flex: 1 0 100%; width: 100%; }
  .result-acts > .btn-quiet { min-height: 44px; flex: 1 1 130px; }
  .cinputs,
  .cvoices { min-width: 0; }
  .cinput,
  .cvoice { min-width: 0; max-width: 100%; flex-wrap: wrap; overflow-wrap: anywhere; }
  .cinput .cx { min-width: 44px; min-height: 44px; font-size: 16px; }
  .qrow { grid-template-columns: 56px minmax(0, 1fr); gap: 10px; padding: 10px; }
  .qthumb { width: 56px; height: 56px; }
  .qname { white-space: normal; overflow-wrap: anywhere; font-size: 14px; }
  .qmeta { display: block; margin: 3px 0 0; }
  .qmsg { flex-wrap: wrap; gap: 4px 7px; font-size: 13px; overflow-wrap: anywhere; }
  .qmsg > * { min-width: 0; }
  .qacts { gap: 6px; }
  .qacts .btn-quiet,
  .qacts a.btn-quiet,
  .qacts .qx { min-height: 44px; padding: 10px; font-size: 13px; }
  .qacts .qx { min-width: 44px; }
  .qrecipe,
  .qscript { overflow-wrap: anywhere; }
  .qpreview video { max-height: 65vh; max-height: 65svh; }

  body[data-mobile-flow="auto"] #views,
  body[data-mobile-flow="autocute"] #views {
    padding-bottom: calc(112px + env(safe-area-inset-bottom));
  }
  body[data-mobile-flow="auto"] .mobile-action-dock,
  body[data-mobile-flow="autocute"] .mobile-action-dock {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    position: fixed;
    z-index: 20;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 10px max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    border-top: 1px solid var(--line-hi);
    background: rgba(14, 15, 20, .97);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, .2);
  }
  .mobile-action-dock .go,
  .mobile-action-dock .btn-quiet {
    min-width: 0;
    min-height: 48px;
    margin: 0;
    padding: 10px 14px;
    font-size: 15px;
    line-height: 1.4;
  }
  .mobile-action-dock .go { width: 100%; justify-content: center; }
  .mobile-action-dock .btn-quiet { max-width: 122px; font-size: 13px; }
  body.mobile-keyboard-open .mobile-action-dock { display: none !important; }

  .mobile-quicknav > :focus-visible,
  #nav .nav-item:focus-visible,
  .mobile-action-dock > :focus-visible,
  .drop-bulk:focus-visible {
    outline: 2px solid var(--signal);
    outline-offset: 3px;
  }
}
