/* Android app mode (Material 3 look). Every rule is scoped to html.android,
   so the browser and iOS looks are untouched. Picture surfaces, colours, the
   tick and the cheer stay as in app.css. */

html.android {
  --md-scrim: rgba(0, 0, 0, 0.32);
  --md-handle: rgba(74, 90, 114, 0.4);
  --md-switch-on-track: var(--filled);
  --md-switch-on-thumb: #fff;
  --md-switch-off-thumb: #7a8799;
  --md-snack-bg: #2f3a4d;
  --md-snack-ink: #fff;
  --md-snack-action: #8fe3ea;
  --md-ease: cubic-bezier(0.2, 0, 0, 1);
  --md-sheet-h: min(92dvh, calc(100dvh - var(--safe-t) - 24px));
}
@media (prefers-color-scheme: dark) {
  html.android {
    --md-scrim: rgba(0, 0, 0, 0.6);
    --md-handle: rgba(169, 182, 201, 0.5);
    --md-switch-on-track: #4fd1dc;
    --md-switch-on-thumb: #00363b;
    --md-switch-off-thumb: #8b99ae;
    --md-snack-bg: #dfe3ec;
    --md-snack-ink: #0f1724;
    --md-snack-action: #00606a;
  }
}

/* Pressed-state ripple (layer added by app.js) */
html.android .rpl { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; pointer-events: none; }
html.android .rpl i { position: absolute; border-radius: 50%; background: currentColor; opacity: 0.16; transform: scale(0); animation: md-ripple 0.55s var(--md-ease) forwards; }
@keyframes md-ripple { 0% { transform: scale(0); opacity: 0.16; } 60% { transform: scale(1); opacity: 0.12; } 100% { transform: scale(1); opacity: 0; } }
html.android .btn:active, html.android .fab:active { filter: none; }
html.android .icon-btn:not(.round):active, html.android .menu-item:active, html.android .menu-cancel:active,
html.android .lopen:active, html.android .text-btn:active { background: transparent; }
html.android .btn { font-weight: 700; letter-spacing: 0.01em; }

/* Top app bar */
html.android .listbar { min-height: calc(64px + var(--safe-t)); padding: calc(var(--safe-t) + 8px) 4px 8px; gap: 0; }
html.android .listbar-title { margin: 0 auto 0 8px; font-size: calc(22 * var(--ts)); font-weight: 700; }
html.android .t-prog { font-size: calc(20 * var(--ts)); }

/* Segmented buttons: selected = tonal with a check */
html.android .seg button { border-color: var(--outline-strong); font-weight: 700; }
html.android .seg button[aria-checked="true"] { background: var(--tonal); border-color: var(--outline-strong); color: var(--ink); }
html.android .seg button[aria-checked="true"] + button { border-left-color: var(--outline-strong); }

/* Switches */
html.android .switch input {
  width: 52px; height: 32px; border-radius: 16px; background: transparent; border: 2px solid var(--outline-strong);
  transition: background 0.2s, border-color 0.2s;
}
html.android .switch input::after {
  top: 6px; left: 6px; width: 16px; height: 16px; background: var(--md-switch-off-thumb); box-shadow: none;
  transition: left 0.2s var(--md-ease), top 0.2s var(--md-ease), width 0.2s var(--md-ease), height 0.2s var(--md-ease), background 0.2s;
}
html.android .switch input:checked { background: var(--md-switch-on-track); border-color: var(--md-switch-on-track); }
html.android .switch input:checked::after { left: 20px; top: 2px; width: 24px; height: 24px; background: var(--md-switch-on-thumb); transform: none; }
html.android .switch input:active::after { top: 0; width: 28px; height: 28px; left: 4px; }
html.android .switch input:checked:active::after { left: 18px; }

/* Text fields */
html.android .form-input, html.android .search-row, html.android .field textarea { border-radius: 4px; }
html.android .form-input:focus, html.android .search-row:focus-within, html.android .field textarea:focus { box-shadow: 0 0 0 1px var(--accent); }

/* Extended FAB on the docked bar */
html.android .dock {
  border-top: 0; padding: 12px calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
}
html.android .fab { border-radius: 16px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 4px 8px 3px rgba(0, 0, 0, 0.15); }

/* Modal bottom sheets */
html.android dialog.sheet {
  margin: auto auto 0; max-width: 640px; max-height: var(--md-sheet-h); border-radius: 28px 28px 0 0; box-shadow: none;
}
html.android dialog.sheet.tall { height: var(--md-sheet-h); }
html.android dialog.sheet[open] { animation: md-sheet-in 0.3s var(--md-ease); }
html.android dialog.sheet::backdrop { background: var(--md-scrim); }
html.android .sheet-grab { width: 32px; height: 4px; margin: 12px auto 8px; background: var(--md-handle); }
html.android .sheet-body { padding: 8px calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l)); }
html.android dialog.sheet.center { margin: auto; width: 200px; max-width: 80vw; border-radius: 28px; height: fit-content; }
@keyframes md-sheet-in { from { transform: translateY(32px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Material dialogs (confirmations) */
html.android dialog.sheet.alert {
  margin: auto; width: min(560px, calc(100% - 48px - 2 * max(var(--safe-l), var(--safe-r)))); min-width: 280px; height: fit-content;
  max-height: calc(100dvh - var(--safe-t) - var(--safe-b) - 48px); border-radius: 28px;
}
html.android dialog.sheet.alert[open] { animation: md-fade 0.2s var(--md-ease); }
html.android dialog.sheet.alert .sheet-grab { display: none; }
html.android dialog.sheet.alert .sheet-body { padding: 24px; }
html.android dialog.sheet.alert h2 { margin: 0 0 16px; font-size: calc(24 * var(--ts)); font-weight: 700; }
html.android dialog.sheet.alert .dialog-actions { margin-top: 24px; gap: 8px; }
html.android dialog.sheet.alert .dialog-actions .btn { min-width: 64px; padding: 0 12px; background: transparent; color: var(--accent-text); }
@keyframes md-fade { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }

/* Snackbars and messages */
html.android .snack, html.android .toast {
  left: calc(16px + var(--safe-l)); right: calc(16px + var(--safe-r)); bottom: calc(16px + var(--safe-b)); width: auto;
  max-width: 600px; margin: 0 auto; border-radius: 4px; background: var(--md-snack-bg); color: var(--md-snack-ink);
  font-weight: 600; text-align: left; box-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
}
html.android .snack { min-height: 48px; padding: 0 8px 0 16px; }
html.android .toast { min-height: 48px; padding: 14px 16px; transform: translateY(12px); }
html.android .toast.show { transform: none; }
html.android .snack-undo { color: var(--md-snack-action); text-transform: none; letter-spacing: 0.01em; font-weight: 700; }
html.android body:has(#dock:not([hidden])) .snack:not(dialog .snack), html.android body:has(#dock:not([hidden])) .toast { bottom: calc(96px + var(--safe-b)); }

/* Cheer overlay and confetti respect the insets */
html.android .cheer { padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); }

/* Action sheet below 600 px: modal bottom sheet with a handle */
@media (max-width: 599px) {
  html.android .menu-scrim { background: var(--md-scrim); }
  html.android .menu {
    max-width: 640px; gap: 0; padding: 0 var(--safe-r) calc(8px + var(--safe-b)) var(--safe-l); background: var(--surface);
    border-radius: 28px 28px 0 0; animation: md-sheet-in 0.3s var(--md-ease);
  }
  html.android .menu::before { content: ""; align-self: center; width: 32px; height: 4px; margin: 16px 0 8px; border-radius: 2px; background: var(--md-handle); }
  html.android .menu-group { border-radius: 0; background: none; }
  html.android .menu-item { justify-content: flex-start; gap: 16px; padding: 0 24px; border-top: 0; color: var(--ink); font-size: calc(16 * var(--ts)); }
  html.android .menu-item .ic { color: var(--ink-soft); }
  html.android .menu-cancel { display: none; }
}

/* The status-bar strip sits under the scrim */
html.android body::before { z-index: 3; }

/* Tagline hidden on phones, as on iPhone */
@media (max-width: 479px) {
  html.android .tagline { display: none; }
  html.android .lists-btn { margin-left: auto; }
}

/* Large system text: rows and bars grow instead of overlapping */
html.android .appbar { flex-wrap: wrap; }
html.android .srow .pill { height: auto; min-height: 34px; }
html.android .pick-tools .btn { white-space: normal; text-align: center; flex: 1 1 140px; }

/* Compose: add buttons, picture area and photo choice */
html.android .add-btn, html.android .cat-tile { border-radius: 12px; }
html.android .cat-tile { overflow: hidden; }
html.android .cat-tile.has { box-shadow: none; border-width: 2px; padding: 11px 5px 9px; }
html.android .cat-tile.has:not(.cat-new) { box-shadow: var(--stack); }
html.android .pick-head { min-height: 64px; padding-block: 8px; padding-inline: 4px 16px; gap: 4px; }
html.android .pick-back { background: transparent; }
html.android .pick-cat-title { font-size: calc(22 * var(--ts)); font-weight: 700; }
html.android .photo-opts { gap: 0; margin: 8px -16px 0; }
html.android .photo-opt { border: 0; border-radius: 0; background: transparent; min-height: 72px; padding: 8px 24px; overflow: hidden; }
html.android .photo-opt:active { background: transparent; }

/* Touch targets: 48 px */
html.android .lact, html.android .seg button, html.android .about-list a { min-height: 48px; }
html.android .lact { min-width: 48px; width: 48px; height: 48px; }
