/* Phone and installed-app polish: thumb-sized targets, room for the status and gesture bars, and a chat box
   that sits on the keyboard. Loaded after styles.css so these win at the same specificity. */
@media (max-width: 860px) {
  .main { padding-top: calc(20px + env(safe-area-inset-top)); }
  .toasts { top: calc(18px + env(safe-area-inset-top)); }

  /* The bar grows by the gesture-bar inset instead of losing that much of its own height to it. */
  .bnav { height: calc(74px + env(safe-area-inset-bottom)); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--card); }
  .shell { padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
  .composer-wrap { bottom: calc(86px + env(safe-area-inset-bottom)); }
  /* Eight links share the bar equally, so a 360px phone fits them all without the bar overflowing. */
  .bnav a { position: relative; flex: 1 1 0; width: auto; min-width: 0; max-width: 76px; height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 0 2px; text-decoration: none; }
  .bnav-label { font-size: 11px; font-weight: 500; line-height: 1; white-space: nowrap; }
  .bnav a.active .bnav-label { font-weight: 600; }
  .bnav .badge { position: absolute; top: 3px; left: calc(50% + 6px); margin: 0; padding: 1px 6px; font-size: 11px; }
  /* Below this the longest labels ("Routines", "Settings") would touch their neighbours at 11px. */
  @media (max-width: 430px) {
    .bnav { padding-left: 4px; padding-right: 4px; }
    .bnav a { padding: 0; }
    .bnav-label { font-size: 10px; letter-spacing: -0.02em; }
  }

  .composer { gap: 8px; padding-left: 18px; }
  .composer .send, .note-own .send, .icon-btn { width: 44px; height: 44px; }
  .chip-btn, .filter { min-height: 44px; }
  /* Reading a long paste takes the whole screen on a phone. */
  .paste-viewer { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  .paste-head { padding-top: calc(12px + env(safe-area-inset-top)); }
  .paste-body { padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
  /* With nothing typed or attached the mic is the way in, so the send arrow steps aside and the box gets wider. */
  .composer-wrap:has(.tray:empty) .composer:has(textarea:placeholder-shown) .send[type="submit"] { display: none; }

  /* While he types, the bottom bar hides so the chat box sits right on the keyboard. */
  .shell:has(.composer textarea:focus) { padding-bottom: 0; }
  .shell:has(.composer textarea:focus) .bnav { display: none; }
  .shell:has(.composer textarea:focus) .composer-wrap { bottom: calc(10px + env(safe-area-inset-bottom)); }
}

/* Small text buttons keep their look but get a finger-sized hit area. */
@media (max-width: 860px) and (pointer: coarse) {
  .fold-btn, .undo, .brief-last, .switch { position: relative; }
  .fold-btn::after, .undo::after, .brief-last::after, .switch::after { content: ''; position: absolute; inset: -8px -4px; }
}

/* Shown by update.js when a new version is out but something is still being typed. */
/* Centred with auto margins, not a transform, because the rise animation sets transform. */
.update-bar { position: fixed; left: 0; right: 0; margin: 0 auto; width: fit-content; white-space: nowrap; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 95; display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px); background: var(--ink); color: var(--on-ink); padding: 6px 6px 6px 18px; border-radius: 999px; font-size: 14px; box-shadow: 0 16px 30px -16px rgba(29,26,22,.6); animation: rise .5s var(--ease) both; }
.update-bar button { min-height: 44px; border: 0; border-radius: 999px; padding: 0 18px; background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
@media (max-width: 860px) {
  .update-bar { bottom: calc(160px + env(safe-area-inset-bottom)); }
}
