/* Lavender night. One dark theme by design; the sleepy cat is the one loud thing.
   The reasons behind each choice are in DESIGN.md. */

/* Nunito (SIL OFL 1.1, see /static/fonts/OFL.txt), self-hosted so every device gets the
   same rounded letters that match the cat. Variable weight, Latin and Latin Extended only. */
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-display: swap;
  font-weight: 200 1000;
  src: url(/static/fonts/nunito-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-display: swap;
  font-weight: 200 1000;
  src: url(/static/fonts/nunito-latin-ext-wght-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #24213a;
  --side: #1c1a2e;
  --card: #302c4d;
  --card-hi: #3a3560;
  --line: #3d3862;
  --field-edge: #7d76a8; /* 3.7:1 on the page, so text fields have a visible edge */
  --ink: #ece8ff;
  --muted: #a59ed0;
  --accent: #c4b5ff;
  --accent-ink: #241f45;
  --accent-soft: #3e3766;
  --accent-text: #ddd4ff;
  --folder: #a996ff;
  --folder-front: #c4b5ff;
  /* Three supporting colours, each taken from the cat, plus the lilac accent. */
  --blush: #ff9fc4; /* cheeks: errors, delete, PDFs */
  --danger: var(--blush);
  --ok: #8fe3cf;    /* mint: finished uploads, audio */
  --moon: #ffd98a;  /* the moon on the "gone" page: archives and installers */
  /* Shape says what a thing does: a full pill is something you press (buttons, choices,
     the small "shared" tag), 12px is somewhere you type or read a message, 18 to 22px holds content. */
  --r: 18px;
  --r-sm: 12px;
  --font: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  --glow: 0 0 18px rgba(196, 181, 255, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
/* No rubber-band bounce of the whole page (iOS home-screen apps drag the entire app around without this).
   Lists that scroll inside the page still scroll normally. */
html, body { overscroll-behavior: none; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; border-radius: 999px; padding: 8px 15px;
  background: var(--card); color: var(--ink); font-weight: 700; font-size: 13px; white-space: nowrap;
}
.btn:hover { background: var(--card-hi); }
.btn.primary { background: var(--accent); color: var(--accent-ink); font-weight: 800; box-shadow: var(--glow); }
.btn.primary:hover { background: #d3c7ff; }
.btn.danger { background: var(--danger); color: #2a1020; font-weight: 800; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--accent-soft); color: var(--ink); }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--accent-soft); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: 230px minmax(0, 1fr); height: 100%; }
.side {
  background: var(--side); padding: 18px 12px 14px; display: flex; flex-direction: column; gap: 8px;
  min-height: 0; overflow: hidden;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 17px; padding: 0 6px 8px; text-decoration: none; color: var(--ink); }
.brand .logo { width: auto; height: 42px; flex-shrink: 0; }
.tree { flex: 1; overflow: auto; min-height: 0; padding-right: 2px; }
.side-foot { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  border: 0; background: var(--card); color: var(--muted); border-radius: var(--r-sm); padding: 9px 11px; font-size: 13px;
}
.nav-item:hover { color: var(--ink); }
.nav-item.on { background: var(--accent-soft); color: var(--accent-text); font-weight: 700; }
.nav-item svg { width: 15px; height: 15px; }
.folders-toggle { display: none; }

/* tree rows */
.tree-row {
  display: flex; align-items: center; gap: 4px; border-radius: var(--r-sm); padding: 3px 6px 3px 0;
  font-size: 13px; color: var(--ink); cursor: pointer; user-select: none; min-width: 0;
}
.tree-row:hover { background: rgba(196, 181, 255, .07); }
.tree-row.on { background: var(--accent-soft); color: var(--accent-text); font-weight: 700; }
.tree-row.drop { outline: 2px dashed var(--accent); outline-offset: -2px; }
.tree-caret {
  width: 20px; height: 20px; border: 0; background: none; color: var(--muted); padding: 0; flex-shrink: 0;
  display: grid; place-items: center; border-radius: 6px; transition: transform .15s;
}
.tree-caret.open { transform: rotate(90deg); }
.tree-caret.leaf { visibility: hidden; }
.tree-caret svg { width: 10px; height: 10px; }
.tree-dot { width: 13px; height: 10px; border-radius: 3px; background: var(--folder); flex-shrink: 0; margin-right: 4px; }
.tree-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 3px 0; }
.tree-kids { margin-left: 12px; }

/* ---------- main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.top {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 16px 22px 12px;
}
.crumbs { flex: 1; min-width: 160px; display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px; font-size: 19px; font-weight: 800; }
.crumbs a { color: var(--muted); font-weight: 600; text-decoration: none; border-radius: 6px; padding: 0 2px; }
.crumbs a:hover { color: var(--ink); }
.crumbs .sep { color: var(--muted); padding: 0 3px; font-weight: 500; }
.crumbs .here { padding: 0 2px; overflow-wrap: anywhere; }
.search {
  display: flex; align-items: center; gap: 6px; background: var(--card); border-radius: var(--r-sm); padding: 0 12px; width: 220px;
  box-shadow: inset 0 0 0 1px var(--field-edge);
}
.search svg { width: 15px; height: 15px; color: var(--muted); flex-shrink: 0; }
.search input { border: 0; background: transparent; padding: 8px 0; width: 100%; outline: none; font-size: 13px; }
.search input::placeholder { color: var(--muted); }
.search:focus-within { box-shadow: 0 0 0 2px var(--accent); }
.content { flex: 1; overflow: auto; padding: 4px 22px 40px; min-height: 0; }
/* The file area is only a landing spot for focus (tabindex -1, never in the tab order), not a control,
   so it gets no ring. Cards and buttons inside keep theirs. */
.content:focus { outline: none; }

/* ---------- storage bar ---------- */
.storage { display: flex; align-items: center; gap: 10px; padding: 12px 22px 0; font-size: 12px; color: var(--muted); }
.storage-label { font-weight: 800; color: var(--ink); }
.storage-track { flex: 0 1 260px; min-width: 80px; height: 8px; border-radius: 999px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.storage-fill { height: 100%; border-radius: 999px; background: var(--accent); min-width: 4px; }
.storage.warn .storage-fill { background: var(--moon); }
.storage.full .storage-fill { background: var(--danger); }
.storage.full .storage-text { color: var(--danger); font-weight: 800; }
.storage-text { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- who can see this ---------- */
.people-checks { border: 0; margin: 0 0 6px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.check { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--r-sm); background: var(--card); cursor: pointer; font-weight: 700; min-height: 44px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; margin: 0; }
.check:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.check.perm { background: var(--card-hi); font-size: 13px; padding: 6px 12px; }
.check:has(input:disabled) input { cursor: not-allowed; }
.status { color: var(--muted); font-size: 13px; padding: 0 2px 12px; }

/* ---------- cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.card {
  position: relative; background: var(--card); border-radius: var(--r); overflow: hidden;
  box-shadow: 0 0 0 1px var(--line); cursor: pointer; outline: none; min-width: 0;
}
.card:hover { box-shadow: 0 0 0 1px var(--accent); }
.card:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.card.drop { box-shadow: 0 0 0 2px var(--accent); transform: scale(1.02); }
.card.dragging { opacity: .45; }
.thumb {
  height: 104px; background: var(--card-hi); display: grid; place-items: center; overflow: hidden; position: relative;
}
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .ext { font-weight: 900; font-size: 17px; letter-spacing: .04em; }
.thumb .play {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
}
.thumb .play span {
  width: 34px; height: 34px; border-radius: 50%; background: rgba(36, 33, 58, .7); display: grid; place-items: center; color: #fff;
}
.thumb .play svg { width: 14px; height: 14px; margin-left: 2px; }
.folder-shape { width: 62px; height: 46px; border-radius: 9px; background: var(--folder); position: relative; }
.folder-shape::before { content: ""; position: absolute; top: -8px; left: 5px; width: 26px; height: 12px; border-radius: 6px 6px 0 0; background: var(--folder); }
.folder-shape::after { content: ""; position: absolute; inset: 10px 0 0 0; border-radius: 9px; background: var(--folder-front); }
.meta { padding: 9px 11px 11px; }
.name { font-size: 13px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; display: flex; justify-content: space-between; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; min-width: 0; }
.sub .where { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pills { display: flex; gap: 4px; flex-shrink: 0; }
.hidden-pill { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--field-edge); }
.mine { font-size: 10px; font-weight: 800; color: var(--accent-text); margin-left: 4px; }
.pill { font-size: 10px; background: var(--accent-soft); color: var(--accent-text); border-radius: 999px; padding: 1px 8px; font-weight: 800; flex-shrink: 0; }
.card .more {
  position: absolute; top: 7px; right: 7px; width: 30px; height: 30px; border-radius: 50%; border: 0;
  background: rgba(28, 26, 46, .72); color: var(--ink); display: grid; place-items: center; opacity: 0; transition: opacity .12s;
}
.card:hover .more, .card:focus-within .more, .card .more:focus-visible { opacity: 1; }
@media (hover: none) { .card .more { opacity: 1; } }
.card .more svg { width: 16px; height: 16px; }

/* ---------- picking several things, and dragging them ---------- */
/* A press-and-hold on a phone lifts the card, so it must not select text or pop up "save image". */
.card { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.thumb img, .thumb video { -webkit-user-drag: none; }
.card .tick {
  position: absolute; top: 8px; left: 8px; z-index: 1; width: 26px; height: 26px; border-radius: 50%;
  display: none; place-items: center; background: rgba(28, 26, 46, .72); box-shadow: inset 0 0 0 2px var(--ink); color: var(--accent-ink);
}
.card .tick svg { width: 16px; height: 16px; opacity: 0; }
.grid.picking .card .tick { display: grid; }
.card.picked { box-shadow: 0 0 0 3px var(--accent); }
.card.picked .tick { background: var(--accent); box-shadow: none; }
.card.picked .tick svg { opacity: 1; }
.grid.picking .card[data-locked] { opacity: .45; cursor: not-allowed; }
.grid.picking .card[data-locked] .tick { display: none; }
.card.lifted { transform: scale(.95); box-shadow: 0 0 0 3px var(--accent), 0 14px 32px rgba(0, 0, 0, .5); transition: transform .12s ease-out; }
.drag-ghost {
  position: fixed; z-index: 80; pointer-events: none; transform: translate(-50%, calc(-100% - 30px));
  background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 13px; padding: 8px 14px; border-radius: var(--r-sm);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .45); max-width: 60vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.crumbs a.drop { outline: 2px dashed var(--accent); outline-offset: 2px; color: var(--ink); }
.selbar {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 42;
  display: flex; align-items: center; gap: 6px; padding: 6px; max-width: calc(100vw - 32px);
  background: #2b2747; border-radius: var(--r); box-shadow: 0 0 0 1px var(--line), 0 20px 50px rgba(0, 0, 0, .5);
}
.sel-count { font-weight: 800; padding: 0 8px 0 2px; white-space: nowrap; }
.selbar .sel-delete { color: var(--blush); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
body.picking .content { padding-bottom: 110px; }
body.picking .toast { bottom: calc(90px + env(safe-area-inset-bottom, 0px)); }

/* ---------- empty + gone ---------- */
.empty { display: grid; justify-items: center; align-content: center; gap: 10px; text-align: center; padding: 60px 16px; color: var(--muted); }
.empty svg { width: 140px; height: 140px; }
.empty .btn svg { width: 16px; height: 16px; }
.empty h2 { margin: 0; color: var(--ink); font-size: 18px; }
.empty p { margin: 0; max-width: 40ch; }

/* ---------- shared links list ---------- */
.share-list { display: flex; flex-direction: column; gap: 10px; max-width: 860px; }
.share-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center;
  background: var(--card); border-radius: var(--r); padding: 12px 14px; box-shadow: 0 0 0 1px var(--line);
}
.share-row .kind { width: 38px; height: 38px; border-radius: 12px; background: var(--card-hi); display: grid; place-items: center; }
.share-row .kind .folder-shape { transform: scale(.45); }
.share-row .kind .ext { font-weight: 900; font-size: 11px; }
.share-row .info { min-width: 0; }
.share-row .info .name { font-size: 14px; }
.share-row .info .sub { justify-content: flex-start; flex-wrap: wrap; }
.share-row .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- people and activity ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; max-width: 860px; margin-bottom: 14px; }
.page-head p { margin: 0; color: var(--muted); flex: 1 1 260px; }
.page-head .choices { flex-basis: 100%; }
.share-row .kind .initial { color: var(--accent-text); font-size: 15px; }
.share-row .kind svg { width: 17px; height: 17px; color: var(--muted); }
.activity-row { grid-template-columns: auto minmax(0, 1fr); }
.activity-row .name { white-space: normal; overflow-wrap: anywhere; font-weight: 600; }
.activity-row .sub a { color: var(--accent-text); }
.whoami { margin: 0 0 6px; padding: 0 10px; font-size: 13px; font-weight: 800; color: var(--ink); }
.whoami span { display: block; font-weight: 600; font-size: 12px; color: var(--muted); }
.whoami a { color: var(--accent-text); }
.hint { font-size: 12px; color: var(--muted); }
.field .label { font-size: 12px; color: var(--muted); font-weight: 700; }
.person-form { display: flex; flex-direction: column; gap: 14px; }
.person-form .err { color: var(--blush); min-height: 1.2em; margin: 0; }

/* ---------- menus, modals, toast ---------- */
.menu {
  position: fixed; z-index: 50; min-width: 180px; background: #2b2747; border-radius: 14px; padding: 6px;
  box-shadow: 0 0 0 1px var(--line), 0 18px 40px rgba(0, 0, 0, .45);
}
.menu button {
  display: flex; align-items: center; gap: 9px; width: 100%; border: 0; background: none; text-align: left;
  padding: 8px 10px; border-radius: 9px; font-size: 13px;
}
.menu button:hover, .menu button:focus-visible { background: var(--accent-soft); }
.menu button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 9px; }
.menu button.danger { color: var(--danger); }
.menu button svg { width: 15px; height: 15px; color: var(--muted); }
.menu button.danger svg { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }

.scrim {
  position: fixed; inset: 0; z-index: 60; background: rgba(14, 12, 26, .72); display: grid; place-items: center;
  padding: 16px; animation: fade .12s ease-out;
}
.modal {
  width: min(440px, 100%); background: var(--bg); border-radius: 22px; padding: 22px;
  box-shadow: 0 0 0 1px var(--line), 0 30px 60px rgba(0, 0, 0, .5); display: flex; flex-direction: column; gap: 14px;
  max-height: calc(100vh - 32px); overflow: auto;
}
.modal h2 { margin: 0; font-size: 18px; }
.modal p { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 700; }
.input {
  width: 100%; border: 0; border-radius: 12px; background: var(--card); padding: 10px 12px; outline: none;
  box-shadow: 0 0 0 1px var(--field-edge);
}
.input:focus { box-shadow: 0 0 0 2px var(--accent); }
.choices { display: flex; gap: 6px; flex-wrap: wrap; }
.choice { border: 0; border-radius: 999px; padding: 7px 13px; background: var(--card); font-size: 13px; font-weight: 700; }
.choice[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.linkbox { display: flex; gap: 8px; }
.linkbox .input { font-size: 12.5px; }
.picker { max-height: 300px; overflow: auto; background: var(--side); border-radius: 14px; padding: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70;
  background: var(--accent); color: var(--accent-ink); font-weight: 800; border-radius: var(--r-sm); padding: 10px 18px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .45); max-width: calc(100vw - 32px); animation: rise .18s ease-out;
}
.toast.bad { background: var(--danger); color: #2a1020; }

/* ---------- preview ---------- */
.preview { position: fixed; inset: 0; z-index: 55; background: rgba(14, 12, 26, .92); display: flex; flex-direction: column; animation: fade .12s ease-out; }
.preview-bar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; }
.preview-bar .title { flex: 1; min-width: 0; }
.preview-bar .title .name { font-size: 15px; }
.preview-bar .title .sub { justify-content: flex-start; }
/* One row and column that exactly fill the space, so "100% tall" means the screen, not the picture. */
.preview-body {
  flex: 1; min-height: 0; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center;
  padding: 0 16px 16px; position: relative;
}
.preview-body img, .preview-body video { max-width: 100%; max-height: 100%; border-radius: 14px; }
.preview-body iframe { width: min(1000px, 100%); height: 100%; border: 0; border-radius: 14px; background: #fff; }
.preview-body pre {
  width: min(1000px, 100%); height: 100%; margin: 0; overflow: auto; background: var(--side); border-radius: 14px;
  padding: 16px; font: 13px/1.5 ui-monospace, "Cascadia Code", Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere;
}
.preview-body audio { width: min(520px, 100%); }
.preview-nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border-radius: 50%; border: 0;
  background: rgba(48, 44, 77, .85); color: var(--ink); display: grid; place-items: center;
}
.preview-nav.prev { left: 20px; }
.preview-nav.next { right: 20px; }
.preview-nav svg { width: 18px; height: 18px; }
.nopreview { display: grid; justify-items: center; gap: 14px; text-align: center; color: var(--muted); }
.nopreview .bigbadge { width: 120px; height: 120px; border-radius: 28px; background: var(--card); display: grid; place-items: center; font-weight: 900; font-size: 26px; }

/* ---------- uploads tray ---------- */
.tray {
  position: fixed; right: 18px; bottom: 18px; z-index: 40; width: min(360px, calc(100vw - 36px));
  background: #2b2747; border-radius: 20px; box-shadow: 0 0 0 1px var(--line), 0 20px 50px rgba(0, 0, 0, .5); overflow: hidden;
}
.tray-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 10px 14px; }
.tray-head .tray-logo { width: auto; height: 30px; flex-shrink: 0; transform-origin: 50% 85%; }
/* A little wiggle while files are sending; it stops when they're done (and for reduced motion). */
.tray.busy .tray-logo { animation: jiggle 1.4s ease-in-out infinite; }
@keyframes jiggle {
  0%, 55%, 100% { transform: rotate(0); }
  12% { transform: rotate(-7deg); }
  26% { transform: rotate(6deg); }
  40% { transform: rotate(-3deg); }
}
.tray-head .t { flex: 1; min-width: 0; }
.tray-head .t b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tray-head .t b.typing::after {
  content: ""; display: inline-block; width: 2px; height: 1em; margin-left: 2px; vertical-align: -2px;
  background: var(--accent); border-radius: 1px; animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.tray-head .t span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: inherit; width: 0; transition: width .2s; }
.tray-overall { padding: 0 14px 10px; }
.tray-list { max-height: 240px; overflow: auto; border-top: 1px solid var(--line); padding: 6px 8px 8px; }
.up { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; align-items: center; padding: 7px 6px; border-radius: 10px; }
.up .n { font-size: 12.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up .s { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.up .bar { grid-column: 1 / -1; height: 4px; }
.up.done .bar i { background: var(--ok); }
.up.failed .s { color: var(--danger); }
.up button { border: 0; background: none; color: var(--muted); font-size: 12px; padding: 2px 6px; border-radius: 6px; }
.up button:hover { color: var(--ink); background: var(--accent-soft); }

/* ---------- drop overlay ---------- */
.dropzone {
  position: fixed; inset: 12px; z-index: 45; border-radius: 26px; border: 3px dashed var(--accent);
  background: rgba(36, 33, 58, .86); display: grid; place-items: center; text-align: center; pointer-events: none;
}
.dropzone div { display: grid; justify-items: center; gap: 8px; font-size: 18px; font-weight: 800; }
.dropzone svg { width: 120px; height: 120px; }
.dropzone span { font-size: 13px; color: var(--muted); font-weight: 600; }

/* ---------- login + share page ---------- */
.center-page { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(360px, 100%); display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center;
}
.login-logo { width: min(220px, 70vw); height: auto; }
.login-card h1 { margin: 0; font-size: 24px; }
.login-card p { margin: 0; color: var(--muted); }
.login-card form { width: 100%; display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.login-card .btn { justify-content: center; padding: 11px 16px; font-size: 14px; }
.login-card .err { color: var(--blush); min-height: 1.4em; font-size: 13px; }

.share-shell { min-height: 100%; display: flex; flex-direction: column; }
.share-top { display: flex; align-items: center; gap: 10px; padding: 14px 20px; background: var(--side); flex-wrap: wrap; }
.share-top .brand { padding: 0; }
.share-top .grow { flex: 1; }
.share-body { flex: 1; display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 0; }
.share-body.single { grid-template-columns: minmax(0, 1fr); }
.share-file { display: grid; justify-items: center; gap: 16px; padding: 28px 16px 40px; }
.share-file .frame {
  width: min(900px, 100%); height: min(70vh, 640px); background: var(--side); border-radius: 22px; display: grid; place-items: center; overflow: hidden;
}
.share-file .frame { grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
.share-file .frame img, .share-file .frame video { max-width: 100%; max-height: 100%; }

/* ---------- zoomable pictures (zoom.js) ---------- */
.zoomer { position: relative; width: 100%; height: 100%; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.zoomer img, .preview-body .zoomer img, .share-file .frame .zoomer img {
  position: absolute; left: 0; top: 0; transform-origin: 0 0; max-width: none; max-height: none; border-radius: 0;
}
/* Hidden until it has loaded and been fitted, so it never flashes at full size. Kept apart from the
   rule above, whose longer selectors would otherwise keep it hidden on share pages. */
.zoomer:not(.ready) img { visibility: hidden; }
.zoomer.can-drag { cursor: grab; }
.zoomer.can-drag:active { cursor: grabbing; }
.zoom-bar {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; align-items: center; gap: 2px;
  padding: 4px; border-radius: 999px; background: rgba(28, 26, 46, .88); box-shadow: 0 0 0 1px var(--line);
}
.zoom-bar .icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.zoom-pct {
  min-width: 58px; height: 36px; border: 0; border-radius: 999px; background: none; color: var(--ink);
  font-weight: 800; font-size: 12.5px; font-variant-numeric: tabular-nums;
}
.zoom-pct:hover { background: var(--accent-soft); }
.share-file .frame iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.share-file .frame pre { width: 100%; height: 100%; margin: 0; overflow: auto; padding: 16px; font: 13px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; }
.share-file h1 { margin: 0; font-size: 20px; text-align: center; overflow-wrap: anywhere; }
.share-file .sub { justify-content: center; font-size: 13px; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }
@keyframes breathe { 50% { transform: scale(1.03); } }
/* Two slow breaths (4.8 s), then the cat lies still: motion stays under 5 seconds. */
.cat-breathe { transform-origin: 50% 80%; animation: breathe 2.4s ease-in-out 2; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- touch: every control at least 44px for a thumb ---------- */
@media (max-width: 720px), (pointer: coarse) {
  .btn, .nav-item, .choice, .menu button, .input { min-height: 44px; }
  .search { min-height: 44px; }
  .search input { padding: 0; min-height: 44px; }
  .icon-btn, .preview-nav { width: 44px; height: 44px; }
  .card .more { width: 44px; height: 44px; top: 2px; right: 2px; }
  .tree-row { min-height: 44px; }
  .tree-caret { width: 44px; height: 44px; }
  .crumbs { align-items: center; }
  .crumbs a { display: inline-flex; align-items: center; min-height: 44px; }
  .up button { min-height: 44px; padding: 0 12px; }
  .brand { min-height: 44px; }
}

/* ---------- phones ---------- */
@media (max-width: 720px) {
  /* The whole page scrolls, so the header moves out of the way instead of
     holding a third of the screen. */
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; height: auto; min-height: 100%; }
  .main { min-height: auto; }
  .content { overflow: visible; }
  .side { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 6px; overflow: visible; }
  .brand { padding: 0; flex: 1; }
  .brand .logo { height: 34px; }
  .folders-toggle { display: inline-flex; }
  .tree { display: none; flex-basis: 100%; max-height: 45vh; }
  .side.show-tree .tree { display: block; }
  .side-foot { flex-direction: row; flex-wrap: wrap; }
  .side-foot .nav-item { width: auto; white-space: nowrap; }
  .side-foot .whoami { flex-basis: 100%; }
  .top { padding: 12px 14px 8px; }
  .search { width: 100%; order: 5; }
  .content { padding: 4px 14px 90px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
  .thumb { height: 92px; }
  .share-body { grid-template-columns: minmax(0, 1fr); }
  .share-body .side { display: none; }
  .share-row { grid-template-columns: auto minmax(0, 1fr); }
  .share-row .acts { grid-column: 1 / -1; justify-content: flex-start; }
  /* Two rows on a phone: what's picked on top, the two big actions side by side below. */
  .selbar { left: 12px; right: 12px; transform: none; max-width: none; flex-wrap: wrap; }
  .sel-count { flex: 1; }
  .selbar #sel-move, .selbar .sel-delete { flex: 1 1 calc(50% - 3px); justify-content: center; }
  body.picking .content { padding-bottom: 150px; }
  body.picking .toast { bottom: calc(140px + env(safe-area-inset-bottom, 0px)); }
}
