/* Hallmark · pre-emit critique: P4 H5 E4 S4 R5 V4
   RJ Uploads r2 — warm graphite, one periwinkle accent, labelled controls,
   thumb-zone action dock on phone, places rail on desktop. */
:root {
  color-scheme: dark;
  /* surfaces */
  --paper: #141517;
  --paper-2: #1b1c1f;
  --raised: #222428;
  --hover: #2a2c31;
  --rule: #2d3035;
  --rule-2: #3a3d43;
  /* ink */
  --ink: #edebe7;
  --ink-2: #aeaba5;
  --ink-3: #85827c;
  /* the one accent */
  --accent: #a3b6ff;
  --accent-ink: #10162b;
  --accent-soft: color-mix(in srgb, var(--accent) 14%, var(--paper-2));
  --accent-line: color-mix(in srgb, var(--accent) 45%, transparent);
  /* red is spent on destruction only */
  --danger: #ff8f84;
  --danger-soft: color-mix(in srgb, var(--danger) 12%, var(--paper-2));
  /* file-type tints: muted, used only inside the type tile */
  --t-img: #86c9b7; --t-vid: #bba9f2; --t-aud: #e3b57c; --t-pdf: #ee938a; --t-zip: #cdbd88; --t-txt: #a3b8cc;
  --ok: #86c9b7;
  --warn: #e3b57c;

  --font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px; --space-6: 24px; --space-8: 32px;
  --text-xs: 12px; --text-sm: 13.5px; --text-md: 16px; --text-lg: 18px; --text-xl: 24px;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 24px; --r-pill: 999px;
  --tap: 44px;
  --dock-h: 76px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 220ms;
  font-family: var(--font-body);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); overflow-x: clip; }
html { scrollbar-width: thin; scrollbar-color: var(--rule-2) transparent; }
body { font-size: var(--text-md); line-height: 1.45; -webkit-tap-highlight-color: transparent; min-height: 100dvh; }
[hidden] { display: none !important; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; display: block; }
button { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip { position: fixed; left: var(--space-3); top: -60px; z-index: 100; padding: var(--space-3) var(--space-4); border-radius: var(--r-md); background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none; }
.skip:focus { top: var(--space-3); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 48px; padding: 0 var(--space-5); border-radius: var(--r-pill); border: 1px solid transparent; background: var(--raised); color: var(--ink); cursor: pointer; font-weight: 600; font-size: var(--text-md); white-space: nowrap; line-height: 1; }
.btn svg { width: 20px; height: 20px; color: currentColor; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary svg { stroke-width: 2; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, white); }
.btn.quiet { background: var(--paper-2); border-color: var(--rule-2); }
.btn.quiet:hover { background: var(--hover); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.danger.solid { background: var(--danger); color: #2a0a06; border-color: var(--danger); }
.btn.sm { min-height: var(--tap); padding: 0 var(--space-4); font-size: 15px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); border-radius: var(--r-pill); border: 0; background: transparent; cursor: pointer; color: var(--ink-2); flex: none; padding: 0; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); padding: 0 14px 0 12px; border-radius: var(--r-pill); border: 1px solid var(--rule-2); background: transparent; color: var(--ink); cursor: pointer; font-size: 15px; font-weight: 500; white-space: nowrap; }
.chip svg { width: 18px; height: 18px; color: var(--ink-2); }
.chip:hover { background: var(--hover); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-line); }
.chip.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: var(--space-6); }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: var(--space-2); }
.login-card img { border-radius: 16px; margin-bottom: var(--space-4); }
.login-card h1 { margin: 0; font-size: 30px; font-weight: 650; letter-spacing: -.02em; }
.login-card p { margin: 0 0 var(--space-5); color: var(--ink-2); }
.login-card label { font-size: 14px; color: var(--ink-2); font-weight: 500; }
.login-card input { min-height: 52px; padding: 0 var(--space-4); border-radius: var(--r-md); border: 1px solid var(--rule-2); background: var(--paper-2); color: var(--ink); font: inherit; margin-bottom: var(--space-3); }
.login-card input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.err { color: var(--danger); min-height: 1.4em; margin: var(--space-1) 0 0 !important; }

/* ---------- shell ---------- */
.shell { min-height: 100dvh; }
.rail { display: none; }
.pane { min-width: 0; }

/* header */
.top { position: sticky; top: 0; z-index: 20; background: var(--paper); padding: env(safe-area-inset-top, 0px) var(--space-4) var(--space-2); }
.appbar { display: flex; align-items: center; gap: var(--space-1); min-height: 60px; margin: 0 calc(var(--space-2) * -1); }
.title { flex: 1; min-width: 0; margin: 0 0 0 var(--space-2); font-size: var(--text-xl); font-weight: 650; letter-spacing: -.02em; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appbar #backBtn:not([hidden]) + .title { margin-left: 0; }
.crumbs { display: flex; align-items: center; gap: 2px; margin: -6px calc(var(--space-2) * -1) var(--space-2); overflow-x: auto; scrollbar-width: none; white-space: nowrap; }
.crumbs:empty { display: none; }
.crumbs::-webkit-scrollbar { display: none; }
.crumbs a, .crumbs span.cur { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--space-2); border-radius: var(--r-sm); color: var(--ink-2); text-decoration: none; font-size: 14.5px; }
.crumbs a:hover { background: var(--hover); color: var(--ink); }
.crumbs span.cur { color: var(--ink); font-weight: 600; }
.crumbs .sep { color: var(--ink-3); display: inline-grid; place-items: center; }
.crumbs .sep svg { width: 14px; height: 14px; }
.search { display: flex; align-items: center; gap: var(--space-3); min-height: 50px; padding: 0 var(--space-4); background: var(--paper-2); border: 1px solid var(--rule); border-radius: var(--r-pill); color: var(--ink-3); }
.search:focus-within { border-color: var(--accent-line); background: var(--raised); }
.search svg { width: 20px; height: 20px; }
.search input { flex: 1; min-width: 0; height: 46px; border: 0; background: transparent; color: var(--ink); font: inherit; outline: none; }
.search input::placeholder { color: var(--ink-3); }
.toolbar { display: flex; align-items: center; gap: var(--space-2); padding-top: var(--space-3); }
.toolbar .sp { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--rule-2); border-radius: var(--r-pill); padding: 0; overflow: hidden; }
.seg button { display: grid; place-items: center; width: 48px; height: 44px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--ink-3); cursor: pointer; padding: 0; }
.seg button svg { width: 19px; height: 19px; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.seg { min-height: var(--tap); align-items: center; }
body.trash .toolbar > :not(#emptyTrash):not(.sp) { display: none; }

/* selection header: replaces the app bar while picking */
.selbar { position: fixed; top: 0; left: 0; right: 0; z-index: 26; display: flex; align-items: center; gap: var(--space-2); min-height: 64px; padding: env(safe-area-inset-top, 0px) var(--space-3) 0 var(--space-2); background: var(--raised); border-bottom: 1px solid var(--rule); }
.sel-count { flex: 1; font-weight: 600; font-size: var(--text-lg); font-variant-numeric: tabular-nums; }

/* ---------- list ---------- */
.main { padding: var(--space-1) var(--space-2) calc(var(--dock-h) + 40px + var(--safe-b) + var(--tray-h, 0px)); outline: none; }
.list-head { display: none; }
.list { display: flex; flex-direction: column; }
.row { position: relative; display: grid; grid-template-columns: 48px minmax(0, 1fr) var(--tap); align-items: center; column-gap: var(--space-4); min-height: 68px; padding: var(--space-2) 0 var(--space-2) var(--space-2); border-radius: var(--r-md); cursor: pointer; user-select: none; -webkit-user-select: none; }
.row::after { content: ""; position: absolute; left: 72px; right: var(--space-2); bottom: 0; height: 1px; background: var(--rule); }
.row:last-child::after { display: none; }
.row:hover { background: var(--paper-2); }
.row:focus-visible { outline-offset: -2px; }
.row.sel { background: var(--accent-soft); }
.row.sel::after { opacity: 0; }

/* type tile */
.ic { width: 48px; height: 48px; display: grid; place-items: center; border-radius: var(--r-md); background: var(--paper-2); border: 1px solid var(--rule); color: var(--ink-2); overflow: hidden; position: relative; }
.ic svg { width: 24px; height: 24px; }
.ic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; }
.ic.thumb img { opacity: 1; }
.ic.thumb > svg, .ic.thumb > .ext { visibility: hidden; }
.ic .ext { position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; font-size: 9px; font-weight: 700; letter-spacing: .04em; line-height: 1; }
.ic.has-ext svg { transform: translateY(-4px); width: 22px; height: 22px; }
.row.dir .ic { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.row.dir .ic svg { fill: color-mix(in srgb, var(--accent) 28%, transparent); }
.t-img .ic { color: var(--t-img); } .t-img-x .ic { color: var(--t-img); } .t-vid .ic { color: var(--t-vid); } .t-aud .ic { color: var(--t-aud); }
.t-pdf .ic { color: var(--t-pdf); } .t-zip .ic { color: var(--t-zip); } .t-txt .ic { color: var(--t-txt); }
.ic.thumb { border-color: transparent; background: var(--raised); }
.ic.has-ext .play { display: none; }
.ic .play { position: absolute; right: 4px; bottom: 4px; width: 18px; height: 18px; border-radius: 50%; background: #000b; display: grid; place-items: center; }
.ic .play svg { width: 9px !important; height: 9px !important; fill: #fff; stroke: none; transform: none !important; }

.nm { min-width: 0; }
.nm b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-weight: 550; font-size: var(--text-md); line-height: 1.3; overflow: hidden; overflow-wrap: anywhere; }
.nm small { display: flex; gap: 6px; align-items: center; min-width: 0; color: var(--ink-2); font-size: var(--text-sm); font-variant-numeric: tabular-nums; margin-top: 2px; }
.nm small .mtxt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nm small .lk { flex: none; color: var(--accent); display: inline-flex; align-items: center; gap: 3px; }
.nm small .lk svg { width: 14px; height: 14px; }
.row .c-size, .row .c-date { display: none; color: var(--ink-2); font-size: 14px; font-variant-numeric: tabular-nums; }
.row .more { color: var(--ink-2); }

/* selection check sits on the tile */
.chk { display: none; position: absolute; left: calc(var(--space-2) + 12px); top: 50%; margin-top: -12px; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--ink-2); background: var(--paper); z-index: 2; }
.selecting .row .chk { display: block; }
.row.sel .chk { background: var(--accent); border-color: var(--accent); }
.row.sel .chk::after { content: ""; position: absolute; left: 6.5px; top: 2.5px; width: 5px; height: 10px; border: solid var(--accent-ink); border-width: 0 2.4px 2.4px 0; transform: rotate(45deg); }
.selecting .row .more { visibility: hidden; }
.selecting .row .ic > :not(.chk) { opacity: .28; }
.selecting .row.sel .ic { background: var(--accent-soft); }

/* ---------- grid ---------- */
.grid .list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); padding: var(--space-2) var(--space-1) 0; }
.grid .row { grid-template-columns: minmax(0, 1fr) var(--tap); grid-template-rows: auto auto; column-gap: 0; row-gap: var(--space-1); padding: 0 0 var(--space-1); min-height: 0; background: var(--paper-2); border: 1px solid var(--rule); border-radius: var(--r-lg); overflow: hidden; }
.grid .row::after { display: none; }
.grid .row:hover { border-color: var(--rule-2); background: var(--paper-2); }
.grid .row.sel { border-color: var(--accent-line); background: var(--accent-soft); }
.grid .row .ic { grid-column: 1 / -1; width: 100%; height: auto; aspect-ratio: 1 / 1; border-radius: 0; border: 0; border-bottom: 1px solid var(--rule); }
.grid .row .ic svg { width: 40px; height: 40px; }
.grid .row .ic.has-ext svg { width: 40px; height: 40px; transform: translateY(-6px); }
.grid .row .ic .ext { bottom: 22%; font-size: 12px; }
.grid .row .ic .play { width: 26px; height: 26px; right: 8px; bottom: 8px; }
.grid .row .ic .play svg { width: 12px !important; height: 12px !important; }
.grid .row .nm { grid-column: 1; padding: var(--space-1) 0 var(--space-1) var(--space-3); }
.grid .row .nm b { font-size: 15px; }
.grid .row .nm small { font-size: 12.5px; }
.grid .row .more { grid-column: 2; grid-row: 2; }
.grid .row .c-size, .grid .row .c-date { display: none !important; }
.grid .chk { left: var(--space-3); top: var(--space-3); margin-top: 0; }
.grid .row .nm b { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; line-height: 1.3; }
.grid .row .mdt { display: none; }
.nm small .mdt { flex: none; }
/* folders in grid: compact cards, like Drive — the square is for things you can see */
.grid .row.dir { grid-column: 1 / -1; grid-template-columns: 40px minmax(0, 1fr) var(--tap); grid-template-rows: auto; column-gap: var(--space-3); padding: var(--space-2) 0 var(--space-2) var(--space-3); min-height: 64px; }
.grid .row.dir .ic { grid-column: auto; width: 40px; height: 40px; aspect-ratio: auto; border-radius: 10px; border: 0; }
.grid .row.dir .ic svg { width: 22px; height: 22px; }
.grid .row.dir .nm { grid-column: auto; padding: 0; }
.grid .row.dir .nm b { -webkit-line-clamp: 1; }
.grid .row.dir .more { grid-column: auto; grid-row: auto; }
.grid .row.dir .chk { left: calc(var(--space-3) + 8px); top: 50%; margin-top: -12px; }
.grid .row:not(.dir) .ic { aspect-ratio: 4 / 3; }
.band { grid-column: 1 / -1; padding: var(--space-3) var(--space-1) 0; color: var(--ink-2); font-size: 14px; font-weight: 600; }
.band:first-child { padding-top: var(--space-1); }
.grid .list { align-items: start; }

/* ---------- empty ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 12vh var(--space-6) var(--space-8); max-width: 420px; margin: 0 auto; }
.empty .em-ic { width: 72px; height: 72px; border-radius: 22px; display: grid; place-items: center; background: var(--paper-2); border: 1px solid var(--rule); color: var(--ink-2); margin-bottom: var(--space-5); }
.empty .em-ic svg { width: 32px; height: 32px; }
.empty h2 { margin: 0 0 var(--space-2); font-size: 20px; font-weight: 650; letter-spacing: -.01em; }
.empty p { margin: 0; color: var(--ink-2); }
.empty ul { list-style: none; padding: 0; margin: var(--space-6) 0 0; display: grid; gap: var(--space-3); text-align: left; color: var(--ink-2); font-size: 14.5px; }
.empty li { display: flex; gap: var(--space-3); align-items: flex-start; }
.empty li svg { width: 18px; height: 18px; color: var(--accent); margin-top: 2px; }
.loading { padding: var(--space-8) var(--space-4); text-align: center; color: var(--ink-2); display: grid; gap: var(--space-3); justify-items: center; }

/* ---------- phone dock ---------- */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); gap: var(--space-3); padding: var(--space-3) var(--space-4) calc(var(--space-3) + var(--safe-b)); background: color-mix(in srgb, var(--paper) 92%, transparent); border-top: 1px solid var(--rule); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.dock .btn { min-height: 52px; }
.dock.sel { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); background: var(--raised); }

/* ---------- upload sheet ---------- */
.tray { position: fixed; z-index: 35; left: var(--space-2); right: var(--space-2); bottom: calc(var(--dock-h) + var(--safe-b) + var(--space-2)); background: var(--raised); border: 1px solid var(--rule-2); border-radius: var(--r-xl); box-shadow: 0 16px 40px #000a; max-height: 55dvh; display: flex; flex-direction: column; overflow: hidden; }
.tray-head { display: grid; grid-template-columns: minmax(0, 1fr) var(--tap); align-items: center; gap: var(--space-1) var(--space-2); padding: var(--space-3) var(--space-2) var(--space-3) var(--space-5); border: 0; background: transparent; cursor: pointer; text-align: left; width: 100%; }
.tray-txt { min-width: 0; display: flex; flex-direction: column; }
.tray-txt b { font-weight: 650; font-variant-numeric: tabular-nums; }
.tray-txt small { color: var(--ink-2); font-size: var(--text-sm); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray .chev { justify-self: center; transition: transform var(--dur) var(--ease-out); color: var(--ink-2); }
.tray.min .chev { transform: rotate(180deg); }
.tray-bar { grid-column: 1 / -1; height: 4px; background: var(--rule); border-radius: 4px; overflow: hidden; margin-right: var(--space-3); }
.tray-bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width .3s linear; }
.tray.min .tray-list, .tray.min .tray-foot { display: none; }
.tray-list { overflow-y: auto; padding: 0 var(--space-2); border-top: 1px solid var(--rule); }
.up { display: grid; grid-template-columns: 40px minmax(0, 1fr) var(--tap); column-gap: var(--space-3); row-gap: 3px; align-items: center; padding: var(--space-3) 0 var(--space-3) var(--space-2); }
.up + .up { border-top: 1px solid var(--rule); }
.up .ic { width: 40px; height: 40px; grid-row: 1 / span 3; border-radius: 10px; }
.up .ic svg { width: 20px; height: 20px; }
.up .un { grid-column: 2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 550; }
.up .us { grid-column: 2; color: var(--ink-2); font-size: var(--text-xs); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up .ub { grid-column: 2; height: 3px; background: var(--rule); border-radius: 3px; overflow: hidden; }
.up .ub i { display: block; height: 100%; background: var(--accent); width: 0; }
.up.done .ub i { background: var(--ok); }
.up.done .us { color: var(--ok); }
.up.err .us { color: var(--danger); }
.up.wait .us { color: var(--warn); }
.up .ux { grid-column: 3; grid-row: 1 / span 3; }
.tray-foot { padding: var(--space-2) var(--space-3) var(--space-3); display: flex; justify-content: flex-end; border-top: 1px solid var(--rule); }

/* ---------- drop overlay ---------- */
.drop { position: fixed; inset: 0; z-index: 50; background: color-mix(in srgb, var(--paper) 90%, transparent); display: grid; place-items: center; pointer-events: none; }
.drop > div { border: 2px dashed var(--accent-line); border-radius: var(--r-xl); padding: 48px 56px; text-align: center; display: grid; justify-items: center; }
.drop svg { width: 44px; height: 44px; color: var(--accent); }
.drop p { margin: var(--space-3) 0 0; font-size: var(--text-lg); }

/* ---------- dialogs ---------- */
dialog { color: var(--ink); }
dialog::backdrop { background: #000000b0; }
.dlg { width: min(440px, calc(100% - 32px)); border: 1px solid var(--rule-2); border-radius: var(--r-xl); background: var(--raised); padding: var(--space-6); }
.dlg h3 { margin: 0 0 var(--space-2); font-size: 20px; font-weight: 650; letter-spacing: -.01em; overflow-wrap: anywhere; }
.dlg p { margin: 0 0 var(--space-4); color: var(--ink-2); overflow-wrap: anywhere; }
.dlg input[type=text] { width: 100%; min-height: 52px; padding: 0 var(--space-4); border-radius: var(--r-md); border: 1px solid var(--rule-2); background: var(--paper-2); color: var(--ink); font: inherit; margin-bottom: var(--space-1); }
.dlg input[type=text]:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.dlg .dlg-err { color: var(--danger); min-height: 1.3em; font-size: 14px; margin: 0 0 var(--space-1); }
.dlg .acts { display: flex; gap: var(--space-2); justify-content: flex-end; margin-top: var(--space-3); flex-wrap: wrap; }
.dlg .acts .left { margin-right: auto; }
.dlg .linkbox { display: flex; gap: var(--space-2); margin-bottom: var(--space-3); align-items: center; }
.dlg .linkbox input { flex: 1; min-width: 0; font-size: 14px; font-family: var(--font-mono); margin: 0; }
.picker { max-height: 46dvh; overflow-y: auto; border: 1px solid var(--rule); border-radius: var(--r-md); margin: var(--space-2) 0; background: var(--paper-2); }
.picker button { display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: 52px; padding: 0 var(--space-4); border: 0; border-bottom: 1px solid var(--rule); background: transparent; text-align: left; cursor: pointer; }
.picker button:last-child { border-bottom: 0; }
.picker button:hover { background: var(--hover); }
.picker button svg { color: var(--accent); width: 20px; height: 20px; }
.picker .none { padding: var(--space-4); color: var(--ink-2); }
.pick-path { font-size: 14px; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: var(--space-1); align-items: center; }
.pick-path button { min-height: var(--tap); border: 0; background: transparent; border-radius: var(--r-sm); padding: 0 var(--space-2); cursor: pointer; color: var(--ink-2); }
.pick-path button:last-child { color: var(--ink); font-weight: 600; }

/* ---------- action sheet ---------- */
.sheet { margin: auto auto 0; width: 100%; max-width: 560px; max-height: 88dvh; border: 1px solid var(--rule-2); border-bottom: 0; border-radius: var(--r-xl) var(--r-xl) 0 0; background: var(--raised); padding: var(--space-2) var(--space-3) calc(var(--space-3) + var(--safe-b)); }
.sheet[open] { animation: sheet-in var(--dur) var(--ease-out); }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
.sheet .grab { width: 36px; height: 4px; border-radius: 4px; background: var(--rule-2); margin: 2px auto var(--space-3); }
.sheet .sh-head { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: var(--space-3); padding: 0 var(--space-2) var(--space-4); }
.sheet .sh-head .ic { width: 44px; height: 44px; }
.sheet .sh-head b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; font-weight: 600; }
.sheet .sh-head small { display: block; color: var(--ink-2); font-size: var(--text-sm); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet .quick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); padding: 0 var(--space-1) var(--space-3); }
.sheet .quick button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 72px; border-radius: var(--r-lg); border: 1px solid var(--rule-2); background: var(--paper-2); cursor: pointer; font-size: 14.5px; font-weight: 550; }
.sheet .quick button svg { color: var(--accent); }
.sheet .quick button:hover { background: var(--hover); }
.sheet .group { border-top: 1px solid var(--rule); padding: var(--space-1) 0; }
.sheet button.it { display: flex; align-items: center; gap: var(--space-4); width: 100%; min-height: 52px; padding: 0 var(--space-3); border: 0; border-radius: var(--r-md); background: transparent; text-align: left; cursor: pointer; font-size: var(--text-md); }
.sheet button.it:hover { background: var(--hover); }
.sheet button.it svg { color: var(--ink-2); }
.sheet button.it.on svg { color: var(--accent); }
.sheet button.it.danger, .sheet button.it.danger svg { color: var(--danger); }

/* ---------- viewer ---------- */
.viewer { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #0b0b0c; }
.viewer[open] { display: flex; flex-direction: column; }
.v-top { display: flex; align-items: center; gap: var(--space-1); padding: calc(6px + env(safe-area-inset-top, 0px)) var(--space-2) 6px; border-bottom: 1px solid #ffffff14; }
.v-top b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 560; }
.v-body { flex: 1; min-height: 0; display: grid; place-items: center; position: relative; }
.v-body img, .v-body video { max-width: 100%; max-height: 100%; object-fit: contain; }
.v-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.v-body pre { align-self: stretch; justify-self: stretch; margin: 0; padding: var(--space-4); overflow: auto; white-space: pre-wrap; word-break: break-word; font: 14px/1.5 var(--font-mono); color: var(--ink); }
.v-body audio { width: min(520px, 90%); }
.v-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 64px; border: 0; border-radius: var(--r-md); background: #0009; color: #fff; cursor: pointer; display: grid; place-items: center; }
.v-nav.prev { left: var(--space-2); } .v-nav.next { right: var(--space-2); }
.v-nav svg { width: 26px; height: 26px; }
.v-msg { color: var(--ink-2); text-align: center; padding: var(--space-5); }

/* ---------- toast ---------- */
.toast { position: fixed; left: var(--space-3); right: var(--space-3); bottom: calc(var(--dock-h) + var(--safe-b) + var(--space-3)); z-index: 60; display: flex; align-items: center; gap: var(--space-3); min-height: 52px; padding: var(--space-1) var(--space-1) var(--space-1) var(--space-4); background: var(--ink); color: var(--paper); border-radius: var(--r-md); font-weight: 550; box-shadow: 0 10px 30px #000a; }
.toast span { flex: 1; min-width: 0; }
.toast button { flex: none; min-height: var(--tap); padding: 0 var(--space-4); border: 0; border-radius: var(--r-sm); background: transparent; color: #3049b0; font-weight: 700; cursor: pointer; }
.toast button:hover { background: #0000000f; }
body.tray-open .toast { bottom: calc(var(--dock-h) + var(--safe-b) + var(--tray-h, 0px) + var(--space-4)); }
body.trash .toast, body.selecting-mode .toast { bottom: calc(var(--dock-h) + var(--safe-b) + var(--space-3)); }

/* ---------- desktop ---------- */
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 256px minmax(0, 1fr); }
  .rail { display: flex; flex-direction: column; gap: var(--space-2); position: sticky; top: 0; height: 100dvh; padding: var(--space-5) var(--space-4); border-right: 1px solid var(--rule); background: var(--paper); }
  .brand { display: flex; align-items: center; gap: var(--space-3); min-height: var(--tap); padding: 0 var(--space-2); margin-bottom: var(--space-4); text-decoration: none; font-weight: 650; font-size: 17px; letter-spacing: -.01em; }
  .brand img { border-radius: 8px; }
  .places { display: grid; gap: 2px; margin-top: var(--space-5); }
  .places a, .place-btn { display: flex; align-items: center; gap: var(--space-3); min-height: var(--tap); padding: 0 var(--space-3); border-radius: var(--r-pill); color: var(--ink-2); text-decoration: none; border: 0; background: transparent; cursor: pointer; font-size: 15px; text-align: left; width: 100%; }
  .places a:hover, .place-btn:hover { background: var(--hover); color: var(--ink); }
  .places a[aria-current="page"] { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
  .places a[aria-current="page"] svg { color: var(--accent); }
  .places svg, .place-btn svg { width: 20px; height: 20px; }
  #railFolder { margin-top: auto; }
  .dock, #moreBtn { display: none !important; }
  .top { padding: var(--space-4) var(--space-8) var(--space-3); border-bottom: 1px solid var(--rule); display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 420px); column-gap: var(--space-6); align-items: center; }
  .appbar { grid-column: 1; min-height: 52px; }
  .title { font-size: 26px; }
  .crumbs { grid-column: 1; grid-row: 2; margin-bottom: 0; }
  .search { grid-column: 2; grid-row: 1; }
  .toolbar { grid-column: 1 / -1; padding-top: var(--space-3); }
  .selbar { left: 256px; padding-left: var(--space-6); }
  .main { padding: var(--space-3) var(--space-8) 120px; }
  .list-head { display: grid; grid-template-columns: 48px minmax(0, 1fr) 110px 150px var(--tap); column-gap: var(--space-4); padding: var(--space-2) 0 var(--space-2) var(--space-2); color: var(--ink-3); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; border-bottom: 1px solid var(--rule); }
  .grid .list-head { display: none; }
  body:not(.grid) .list .row { grid-template-columns: 48px minmax(0, 1fr) 110px 150px var(--tap); min-height: 60px; }
  body:not(.grid) .row .ic { width: 40px; height: 40px; border-radius: 10px; }
  body:not(.grid) .row .ic .ext { display: none; }
  body:not(.grid) .row .ic.has-ext svg { transform: none; }
  body:not(.grid) .chk { left: calc(var(--space-2) + 8px); }
  .row::after { left: 64px; }
  .row .c-size, .row .c-date { display: block; }
  .row .nm small.m-meta { display: none; }
  .row .nm small.m-meta.has-link { display: flex; }
  .row .nm small.m-meta.has-link .mtxt, .row .nm small.m-meta.has-link .mdt { display: none; }
  .grid .row .nm small.m-meta, .grid .row .nm small.m-meta .mtxt { display: flex; }
  .grid .list { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--space-4); }
  .grid .row.dir { grid-column: auto; }
  .tray { left: auto; right: var(--space-6); bottom: var(--space-6); width: 420px; }
  .toast, body.tray-open .toast, body.trash .toast, body.selecting-mode .toast { left: 50%; right: auto; transform: translateX(-50%); bottom: var(--space-8); max-width: 480px; min-width: 320px; }
  body.tray-open .toast { left: calc(50% + 128px - 210px); }
  .sheet { margin: auto; border-radius: var(--r-xl); border-bottom: 1px solid var(--rule-2); max-width: 400px; padding-bottom: var(--space-3); }
  .sheet .grab { display: none; }
  .sheet .sh-head { padding-top: var(--space-3); }
}
@media (min-width: 900px) and (max-width: 1100px) { .top { grid-template-columns: minmax(0, 1fr); } .search { grid-column: 1; grid-row: auto; margin-top: var(--space-2); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
