/* Phone layout (mobile-first polish, 2026-11-24). Loaded after styles.css; only phones and small tablets are affected, desktop keeps styles.css.
   Aims: one thumb does everything (primary actions low on the screen, a 64 px tab bar with safe areas, 48 px targets), 16 px form text so iOS does not zoom,
   details tucked behind a tap, no clutter. Same ids and classes as before, so nothing in the scripts changes. */
/* Base rules for the new icon markup: these apply at every width (desktop keeps the plain look, just with correctly sized icons). */
.big-btn .icon svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.upload-link { display: inline-flex; align-items: center; gap: 8px; color: var(--accent); font-weight: 650; text-decoration: none; margin: 6px 0; }
.upload-link svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
/* On a wide screen the optional fields and the filters are always open and need no toggle (app.js opens them); the filters join the search row as before. */
@media (min-width: 960px) {
  details.more-fields > summary, details.filters > summary { display: none; }
  details.filters { display: contents; }
  details.filters::details-content { display: contents; }
  details.more-fields { display: grid; gap: 14px; margin-bottom: 14px; }
}
@media (max-width: 959px) {
  :root { --tabs-h: calc(64px + env(safe-area-inset-bottom)); --gap: 14px; }
  html { scroll-padding-bottom: calc(var(--tabs-h) + 140px); }
  body { padding-bottom: calc(var(--tabs-h) + 28px); -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
  main { padding: 16px 16px 8px; }
  h2 { font-size: 24px; }

  /* top bar: compact, notch-safe, the case switcher gets the room it needs */
  .top { padding: calc(8px + env(safe-area-inset-top)) 14px 8px; gap: 8px; min-height: 56px; }
  .top h1 { font-size: 17px; }
  .top h1::before { width: 24px; height: 24px; border-radius: 7px; }
  .case-select { flex: 1 1 auto; max-width: none; min-width: 0; min-height: 44px; font-size: 16px; text-overflow: ellipsis; }

  /* every control at least 48 px, text 16 px (iOS zooms below that) */
  input, select, textarea { font-size: 16px; min-height: 48px; border-radius: 12px; }
  textarea { min-height: 96px; }
  button, .big-btn, .link-btn, summary { min-height: 48px; }
  .thumbs .rm { min-height: 0; } /* the small round remove button on a thumbnail keeps its size */
  .more-menu button { min-height: 48px; }
  .big-btn { border-radius: 16px; font-size: 16px; }
  .link-btn { display: inline-flex; align-items: center; color: var(--accent); font-weight: 650; }

  /* capture: one large primary action, two beside it, each an icon card */
  .capture-buttons { grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
  .capture-buttons .big-btn { flex-direction: column; gap: 8px; min-height: 92px; padding: 14px 8px; text-align: center; line-height: 1.2; }
  .capture-buttons .big-btn:first-child { grid-column: 1 / -1; flex-direction: row; min-height: 72px; font-size: 18px; }
  .big-btn .icon { display: grid; place-items: center; font-size: 0; }
  .big-btn .icon svg { width: 28px; height: 28px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .capture-buttons .big-btn:first-child .icon svg { width: 30px; height: 30px; }
  #page-count { margin: 6px 2px 12px; }

  /* the details form: one tap to open, the save button always in thumb reach above the tab bar */
  #doc-form { padding: 6px 16px 16px; gap: 10px; }
  details.more-fields > summary, details.filters > summary {
    list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px;
    font-weight: 650; padding: 4px 0;
  }
  details.more-fields > summary .muted { margin-right: auto; }
  details.more-fields > summary::-webkit-details-marker, details.filters > summary::-webkit-details-marker { display: none; }
  details.more-fields > summary::after, details.filters > summary::after { content: ""; width: 10px; height: 10px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin-right: 4px; transition: transform .15s; }
  details[open] > summary::after { transform: rotate(-135deg); }
  details.more-fields[open] > label, details.more-fields[open] > summary + label { margin-top: 10px; }
  details.more-fields > label { margin-bottom: 12px; }
  .savebar { position: sticky; bottom: calc(var(--tabs-h) + 8px); z-index: 3; display: grid; gap: 8px; padding-top: 8px;
    background: linear-gradient(to bottom, transparent, var(--surface) 28%); }
  .savebar .msg:empty { display: none; }
  .savebar .big-btn { box-shadow: var(--shadow-up); min-height: 56px; }

  /* library: search stays in view, filters tucked away, bigger rows, a real upload action */
  .search { position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 3; grid-template-columns: 1fr; background: var(--bg); padding: 8px 0 6px; margin: 0 0 6px; }
  .search input[type="search"] { min-height: 52px; }
  details.filters { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px; display: block; }
  details.filters[open] { padding-bottom: 12px; display: grid; gap: 10px; }
  details.filters select { width: 100%; }
  .upload-link { display: flex; align-items: center; gap: 10px; min-height: 52px; margin: 8px 0 14px; padding: 0 14px; border: 1px dashed var(--line); border-radius: 14px; color: var(--accent); font-weight: 650; text-decoration: none; background: var(--surface); }
  .upload-link svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
  .list li { padding: 16px; min-height: 64px; border-radius: 16px; }
  .list li.muted { padding: 36px 16px; font-size: 15px; }

  /* the tab bar: 64 px, a pill behind the active icon, 12 px labels */
  .tabs { min-height: var(--tabs-h); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); box-shadow: 0 -1px 0 var(--line); }
  .tabs button { font-size: 12px; padding: 8px 0 6px; gap: 2px; min-height: 56px; }
  .tabs button span { width: 54px; height: 30px; border-radius: 999px; transition: background .15s; }
  .tabs button.active span { background: var(--accent-soft); }

  /* cards and the More menu: roomier, scrolling pills with big targets */
  .card { border-radius: 18px; padding: 16px; }
  .more-menu { padding: 2px 0 12px; gap: 8px; scroll-snap-type: x proximity; }
  .more-menu button { min-height: 48px; padding: 0 16px; scroll-snap-align: start; }
  .ver { opacity: 1; font-size: 11px; text-align: center; margin: 28px 0 8px; }
}
@media (max-width: 380px) { .capture-buttons .big-btn:not(:first-child) { font-size: 14px; } .top h1 { font-size: 16px; } }
