/* The downloads tray, shared by CrossSend and All files (downloads.js). Uses the
   page's palette tokens; a card in the corner on a computer, a strip above the
   home indicator on a phone. */
.dls {
  position: fixed; right: 16px; bottom: 16px; z-index: 35;
  width: 340px; max-height: min(60vh, 420px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 12px 32px rgba(22, 32, 51, 0.14), 0 2px 6px rgba(22, 32, 51, 0.06);
  overflow: hidden; color: var(--text); font-size: 13px;
}
.dls-head {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 44px; padding: 0 10px 0 14px;
  border: 0; background: transparent; text-align: left; flex-shrink: 0;
}
.dls-head:active { background: rgba(22, 32, 51, 0.04); }
.dls-icon { display: grid; place-items: center; color: var(--muted); }
.dls.going .dls-icon { color: var(--accent); }
.dls.going .dls-icon svg { animation: dls-dip 1.6s cubic-bezier(0.45, 0, 0.55, 1) infinite; }
@keyframes dls-dip { 50% { transform: translateY(2px); } }
.dls-title { font-weight: 600; }
.dls-sum { color: var(--muted); font-size: 12.5px; flex-grow: 1; text-align: right; font-variant-numeric: tabular-nums; }
.dls-fold { display: grid; place-items: center; color: var(--dim); transition: transform 220ms var(--ease-out); }
.dls.folded .dls-fold { transform: rotate(180deg); }
.dls.folded .dls-list { display: none; }

.dls-list { list-style: none; margin: 0; padding: 0 6px 6px; overflow-y: auto; overscroll-behavior: contain; }
.dl { padding: 8px 8px 9px; border-radius: 10px; }
.dl + .dl { border-top: 1px solid var(--border); border-radius: 0; }
.dl-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.dl-name { flex-grow: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.dl-x {
  width: 26px; height: 26px; flex-shrink: 0; display: grid; place-items: center; border: 0; border-radius: 8px;
  background: transparent; color: var(--dim); transition: background-color 160ms ease, color 160ms ease, transform 160ms var(--ease-out);
}
.dl-x:hover { background: rgba(22, 32, 51, 0.05); color: var(--text); }
.dl-x:active { transform: scale(0.9); }
.dl-x:disabled { opacity: 0.4; pointer-events: none; }

.dl-bar { position: relative; height: 4px; margin: 7px 0 6px; border-radius: 2px; background: var(--accent-soft); overflow: hidden; }
.dl-bar i { position: absolute; inset: 0; background: var(--accent); border-radius: inherit; transform-origin: left; transform: scaleX(0); transition: transform 700ms linear, background-color 200ms ease; }
.dl-bar.busy i { transform: none !important; width: 30%; animation: dls-slide 1.3s cubic-bezier(0.45, 0, 0.55, 1) infinite; transition: none; }
@keyframes dls-slide { from { translate: -100% 0; } to { translate: 340% 0; } }
.dl[data-state="done"] .dl-bar i { background: var(--success); }
.dl[data-state="failed"] .dl-bar i, .dl[data-state="lost"] .dl-bar i, .dl[data-state="unseen"] .dl-bar i { background: var(--danger); }
.dl[data-state="cancelled"] .dl-bar i { background: var(--dim); }
.dl[data-state="cancelled"] .dl-bar, .dl[data-state="failed"] .dl-bar, .dl[data-state="lost"] .dl-bar, .dl[data-state="unseen"] .dl-bar { opacity: 0.55; }
.dl-meta { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl[data-state="failed"] .dl-meta, .dl[data-state="lost"] .dl-meta, .dl[data-state="unseen"] .dl-meta { color: var(--danger); white-space: normal; }
.dl[data-state="done"] .dl-meta { color: var(--success); }

@media (max-width: 760px) {
  .dls {
    left: 8px; right: 8px; width: auto; bottom: max(8px, env(safe-area-inset-bottom));
    border-radius: 18px; max-height: 50dvh;
  }
  .dls-head { height: 48px; }
  .dl-x { width: 34px; height: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  .dls.going .dls-icon svg, .dl-bar.busy i { animation: none; }
  .dl-bar.busy i { width: 100%; opacity: 0.35; }
  .dl-bar i { transition: none; }
}

/* A toast on a phone rises above the tray rather than covering it. */
@media (max-width: 760px) {
  body:has(.dls:not([hidden])) .toast { bottom: calc(max(8px, env(safe-area-inset-bottom)) + 60px); }
}
