/* pCloud Browser Ultra: design tokens, base and the app shell (sidebar, toolbar + header, inspector,
   phone drawer / bottom sheet / bottom bar, menus, help overlay). Values come from the design board
   (docs/design-board/*.dc.html). Component styles: css/grid.css, css/viewer.css, css/search.css,
   css/features.css, and one file per builder of the power pass (css/actions.css, nav, tabs, peek, sizes, links,
   canvas, collections, pureref; ARCHITECTURE.md "CSS files"). Fluid from 360 px to 2560 px; phones below 768 px. */

:root {
  --bg: #141517;            /* centre */
  --bg-head: #16171a;
  --pane: #17181b;          /* sidebar, inspector */
  --panel: #1d1e22;         /* fields, cards, tiles */
  --panel-2: #1a1b1e;
  --sheet: #1b1c20;
  --sunk: #0f1012;          /* preview wells */
  --canvas: #181818;        /* a canvas's default background: PureRef's own dark grey */
  --mosaic: #0e0f11;
  --hover: #222327;
  --raised: #26272c;
  --raised-2: #2c2d33;
  --line: #25262b;          /* pane borders */
  --line-2: #2a2b30;        /* control borders */
  --line-3: #34353b;
  --text: #ececee;
  --text-2: #d4d5da;
  --muted: #a1a2a8;
  --faint: #8b8c93;
  --dim: #5c5d63;
  --accent: #3b82f6;
  --accent-strong: #2563eb;
  --accent-soft: rgba(59, 130, 246, .16);
  --accent-sel: rgba(59, 130, 246, .14);
  --accent-text: #93c5fd;
  --accent-ink: #dbeafe;
  --accent-icon: #60a5fa;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef7d72;
  --ph: #1d1e22;            /* thumbnail placeholder */
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --sb-w: 232px;            /* sidebar; a width the owner dragged is set on <html> (shell/panes.js) */
  --ins-w: 300px;           /* inspector (floating); docked: --ins-dock-w when dragged, else this */
  --tabs-h: 34px;           /* the in-app tab strip (desktop, 2+ tabs) */
  --pad: 24px;              /* centre side padding */
  --radius: 10px;
  --tb-top: 0px;            /* sticky offset of the toolbar (phones: below the top bar) */
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* stable gutter: opening the viewer (overflow hidden) must not change the grid's width */
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; scrollbar-color: #2c2d33 transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 13px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}
html.noscroll, html.noscroll body { overflow: hidden; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
::selection { background: rgba(59, 130, 246, .35); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ic.i12, .ic.i13, .ic.i14, .ic.i15, .ic.i16, .ic.i18, .ic.i20, .ic.i22, .ic.i26 { stroke-width: 1.6; }
.ic.i12 { width: 12px; height: 12px; stroke-width: 1.8; }
.ic.i13 { width: 13px; height: 13px; }
.ic.i14 { width: 14px; height: 14px; stroke-width: 1.7; }
.ic.i15 { width: 15px; height: 15px; }
.ic.i16 { width: 16px; height: 16px; }
.ic.i18 { width: 18px; height: 18px; }
.ic.i20 { width: 20px; height: 20px; }
.ic.i22 { width: 22px; height: 22px; stroke-width: 1.5; }
.ic.i26 { width: 26px; height: 26px; stroke-width: 1.4; }
.ic.big { width: 56px; height: 56px; stroke-width: 1.2; color: var(--dim); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 18px; }

/* ---------- buttons, inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--line-2);
  background: var(--panel); color: var(--text-2); cursor: pointer; text-decoration: none; white-space: nowrap; font-weight: 500;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--raised); color: var(--text); }
.btn.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #3474f0; }
.btn:disabled { opacity: .45; cursor: default; }
.ibtn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none; padding: 0;
  border: none; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; text-decoration: none;
  transition: background .12s, color .12s;
}
.ibtn:hover { background: var(--raised); color: var(--text); }
.ibtn:disabled { color: var(--dim); background: transparent; cursor: default; }
.ibtn.sm { width: 28px; height: 28px; border-radius: 7px; }
.ibtn.lg { width: 44px; height: 44px; border-radius: 12px; color: var(--text); }
.ibtn.filled { background: var(--panel); }
.ibtn.tog { width: 34px; height: 34px; border-radius: 9px; }
.ibtn.tog[aria-pressed=true] { background: var(--accent-soft); color: var(--accent-text); }
.kbd { flex: none; font: 500 11px/1.3 var(--font); color: var(--faint); border: 1px solid var(--line-3); border-radius: 5px; padding: 1px 5px; }
input[type=search] { -webkit-appearance: none; appearance: none; }
input[type=search]::-webkit-search-cancel-button { filter: invert(.7); }
select { height: 34px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--panel); padding: 0 8px; outline: none; }
select:focus { border-color: var(--accent); }
.pill { display: inline-block; font-size: 9.5px; font-weight: 700; letter-spacing: .14em; color: var(--accent-text); background: var(--accent-soft); border-radius: 999px; padding: 2px 7px; line-height: 1.3; }
.tag { font-size: 10px; font-weight: 600; color: var(--accent-text); background: var(--accent-soft); border-radius: 5px; padding: 1px 6px; }

/* ---------- full-page screens ---------- */
.screen { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(900px 500px at 70% -10%, rgba(59,130,246,.10), transparent 60%), var(--bg); }
.card { width: 100%; max-width: 520px; background: var(--pane); border: 1px solid var(--line-2); border-radius: 16px;
  padding: 28px 22px; box-shadow: 0 30px 80px rgba(0,0,0,.4); }
.card h1 { font-size: 21px; font-weight: 650; margin: 18px 0 8px; letter-spacing: -.01em; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13.5px; }
.brand b { color: var(--text); font-weight: 650; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent-strong); color: #fff; display: grid; place-items: center; flex: none; }

/* ---------- three panes ---------- */
.app { display: grid; grid-template-columns: var(--sb-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
body.ins-docked .app { grid-template-columns: var(--sb-w) minmax(0, 1fr) var(--ins-dock-w, var(--ins-w)); }
.centre { grid-column: 2; grid-row: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }

/* ---------- pane resize handles (shell/panes.js) ---------- */
.pane-resize { position: fixed; top: 0; bottom: 0; z-index: 30; width: 7px; cursor: col-resize; touch-action: none; outline: none; }
.sb-resize { left: calc(var(--sb-w) - 4px); }
.ins-resize { right: calc(var(--ins-dock-w, var(--ins-w)) - 3px); display: none; }
body.ins-docked .ins-resize { display: block; }
.pane-resize::after { content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 1px; background: transparent; transition: background .12s; }
.pane-resize:hover::after { background: var(--accent); width: 2px; left: 2.5px; transition-delay: .12s; }
.pane-resize.drag::after, .pane-resize:focus-visible::after { background: var(--accent); width: 2px; left: 2.5px; transition-delay: 0s; }
body.pane-dragging, body.pane-dragging * { cursor: col-resize !important; user-select: none !important; -webkit-user-select: none !important; }
body.pane-dragging .vgrid { pointer-events: none; }

/* ---------- in-app tab strip (slot; js/features/tabs.js and css/tabs.css draw it) ---------- */
.tabstrip { position: sticky; top: 0; z-index: 26; height: var(--tabs-h); display: flex; align-items: stretch; min-width: 0; background: var(--pane); border-bottom: 1px solid var(--line); }
body.has-tabs { --tb-top: var(--tabs-h); }

/* ---------- sidebar ---------- */
.sidebar { grid-column: 1; grid-row: 1; align-self: start; position: sticky; top: 0; height: 100vh; height: 100dvh; z-index: 20;
  display: flex; flex-direction: column; background: var(--pane); border-right: 1px solid var(--line); }
.sb-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 12px 12px; display: flex; flex-direction: column; gap: 20px; scrollbar-width: none; }
.sb-scroll::-webkit-scrollbar { display: none; }   /* the tree keeps its full width; wheel and touch still scroll */
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 2px 0 2px 6px; }
.sb-name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sb-name > span:first-child { font-size: 13.5px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.sb-name .pill { align-self: flex-start; }
.sb-brand .ibtn { color: var(--faint); }
.sb-sec { display: flex; flex-direction: column; gap: 2px; }
.sb-title { display: flex; align-items: center; justify-content: space-between; min-height: 18px; font-size: 11px; font-weight: 600; letter-spacing: .08em; color: var(--faint); padding: 0 8px 6px; }
.sb-act { display: grid; place-items: center; width: 22px; height: 22px; margin: -4px -4px -4px 0; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--faint); cursor: pointer; }
.sb-act:hover { background: var(--raised); color: var(--text); }
.sb-tools { display: flex; align-items: center; gap: 2px; margin: -4px -4px -4px auto; }
.sb-tools:empty { display: none; }
.sb-sections { display: contents; }
.sb-body { display: flex; flex-direction: column; gap: 2px; }
.navrow { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 7px; color: var(--text-2); text-decoration: none; min-width: 0; }
.navrow:hover { background: var(--hover); }
.navrow .nl { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.navrow .nn { color: var(--faint); font-variant-numeric: tabular-nums; }
.navrow.on { background: var(--accent-sel); color: var(--accent-ink); }
.navrow.on .ic { color: var(--accent-icon); }
.sb-folders { gap: 1px; }
.tree { display: flex; flex-direction: column; gap: 1px; overflow-anchor: none; }   /* virtual rows: no scroll anchoring on them */
.trow { display: flex; align-items: center; gap: 7px; padding: 6px 8px 6px calc(8px + var(--depth, 0) * 14px); border-radius: 7px;
  color: var(--text-2); text-decoration: none; min-width: 0; }
.trow:hover { background: var(--hover); }
.trow .tw { display: grid; place-items: center; width: 16px; height: 16px; margin: -2px -2px -2px -2px; border-radius: 4px; color: var(--faint); cursor: pointer; flex: none; }
.trow .tw:hover { background: var(--raised); color: var(--text); }
.trow .tw.none { opacity: 0; pointer-events: none; }
.trow .tw .ic { transition: transform .15s; }
.trow .tw.open .ic { transform: rotate(90deg); }
.trow .fic { color: var(--faint); }
.trow .tname { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trow .tcount { color: var(--faint); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.trow .tcount.partial { color: var(--dim); }
.trow .tcount.linked { color: var(--accent-icon); }
.trow.on { background: var(--accent-sel); color: var(--accent-ink); }
.trow.on .fic { color: var(--accent-icon); }

.engine { margin: 0 12px 12px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; padding: 12px;
  display: flex; flex-direction: column; gap: 8px; flex: none; }
.eng-head { display: flex; align-items: center; gap: 8px; }
.eng-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--faint); box-shadow: 0 0 0 3px rgba(139,140,147,.18); }
.engine[data-state=awake] .eng-dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
.engine[data-state=waking] .eng-dot { background: var(--warn); box-shadow: 0 0 0 3px rgba(245,158,11,.22); animation: pulse 1.4s ease-in-out infinite; }
.engine[data-state=error] .eng-dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(239,125,114,.2); }
@keyframes pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
.eng-title { font-weight: 600; }
.eng-text { color: var(--muted); font-size: 12px; }
.eng-stats { display: flex; flex-direction: column; gap: 4px; padding-top: 8px; border-top: 1px solid var(--line-2); color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.eng-stat { display: flex; justify-content: space-between; gap: 8px; }
.eng-stat b { color: var(--text-2); font-weight: 400; }

/* ---------- toolbar ---------- */
.toolbar { position: sticky; top: var(--tb-top); z-index: 25; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; container-type: inline-size;
  min-height: 59px; padding: 12px 20px; background: rgba(20, 21, 23, .92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); }
.tb-nav { display: flex; gap: 2px; }
.crumbs { flex: 1 1 120px; min-width: 0; display: flex; align-items: center; gap: 6px; overflow-x: auto; white-space: nowrap; color: var(--muted);
  scrollbar-width: none; mask-image: linear-gradient(90deg, transparent, #000 12px); -webkit-mask-image: linear-gradient(90deg, transparent, #000 12px); padding-left: 2px; }
.crumbs::-webkit-scrollbar { display: none; }
.crumb { flex: none; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; padding: 4px 2px; border: none; background: none; color: var(--muted);
  text-decoration: none; cursor: pointer; border-radius: 5px; }
a.crumb:hover, button.crumb:hover { color: var(--text); }
.crumb.cur { color: var(--text); font-weight: 600; cursor: default; }
.crumbs .sep { color: var(--dim); flex: none; }
.tb-slot { display: contents; }
.namefield { position: relative; display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; flex: 1 1 200px; min-width: 160px; max-width: 300px;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 9px; color: var(--faint); cursor: text; }
.namefield:focus-within { border-color: var(--accent); }
.namefield input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: var(--text); padding: 0; }
.namefield input::placeholder { color: var(--faint); }
.namefield:focus-within .kbd { display: none; }
.tb-btn { height: 34px; display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; flex: none; background: transparent; border: 1px solid var(--line-2);
  border-radius: 9px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.tb-btn:hover { background: var(--hover); }
.tb-btn[aria-pressed=true] { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.tb-btn.sm { height: 32px; font-size: 12px; gap: 4px; }
.tb-btn.sq { width: 32px; padding: 0; justify-content: center; }
.seg { display: flex; flex: none; padding: 3px; gap: 2px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 9px; }
.seg button { width: 30px; height: 26px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--faint); cursor: pointer; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed=true] { background: var(--raised-2); color: var(--text); }
.sizer { display: flex; align-items: center; gap: 8px; flex: none; color: var(--faint); }
.sizer input { width: 84px; margin: 0; accent-color: var(--accent); cursor: pointer; }
/* A toolbar too narrow for one row: the breadcrumb gets the first row, the controls the second (only with
   the name filter: a view with fewer controls keeps one row). */
@container (max-width: 860px) {
  body[data-controls~=filter] .crumbs { flex-basis: calc(100% - 114px); }
  /* rows break on the flex basis: a small one keeps the controls (Filter, Play videos, inspector) on one row */
  .namefield { flex-basis: 130px; min-width: 130px; max-width: none; }
}
/* narrower still (1100-1220 px windows with the inspector docked): the name filter takes a row of its own,
   so the controls stay together on the next one instead of leaving one button alone on a third row */
@container (max-width: 680px) {
  .namefield { flex-basis: 100%; }
}
@container (max-width: 600px) {
  .namefield { min-width: 120px; }
  .sizer .ic { display: none; }
  .sizer input { width: 56px; }
}
/* controls the active view does not use (toolbar.setControls) */
body:not([data-controls~=filter]) .c-filter,
body:not([data-controls~=sort]) .c-sort,
body:not([data-controls~=layout]) .c-layout,
body:not([data-controls~=size]) .c-size { display: none !important; }

/* ---------- header ---------- */
main { flex: 1; padding: 0 var(--pad) 40px; min-width: 0; }
.vhead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 24px 0 20px; }
.vhead-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.vtitle-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; min-width: 0; }
.vtitle-row:has(> h1:empty):has(> .vchips:empty) { display: none; }
.vhead h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; overflow-wrap: anywhere; min-width: 0; }
.vhead h1:empty { display: none; }
.vchips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.vchips:empty { display: none; }
.vmeta { color: var(--muted); font-variant-numeric: tabular-nums; min-height: 18px; }
.vtools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.vtools:empty { display: none; }
.ptop, .prow, .bnav { display: none; }

/* ---------- inspector ---------- */
.inspector { display: none; flex-direction: column; background: var(--pane); border-left: 1px solid var(--line); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
body.ins-docked .inspector { display: flex; grid-column: 3; grid-row: 1; align-self: start; position: sticky; top: 0; height: 100vh; height: 100dvh; }
body.ins-float .inspector { display: flex; position: fixed; top: 0; right: 0; bottom: 0; width: var(--ins-w); z-index: 35; box-shadow: -24px 0 60px rgba(0,0,0,.5); }
.ins-grip, .ins-close { display: none; }
body.ins-float .ins-close { display: grid; position: absolute; top: 14px; right: 14px; z-index: 1; }
.ins-body { flex: 1 0 auto; display: flex; flex-direction: column; gap: 18px; padding: 20px; }
.ins-sec { display: flex; flex-direction: column; gap: 18px; }
.ins-sec:empty { display: none; }
.ins-sec:has(> .ins-actions) { margin-top: auto; }
.ins-label { font-size: 11px; font-weight: 600; letter-spacing: .08em; color: var(--faint); }
.ins-mosaic { display: grid; gap: 2px; aspect-ratio: 1; width: 100%; border-radius: 14px; overflow: hidden; background: var(--mosaic); }
.ins-mosaic.n0 { place-items: center; }
.ins-mosaic.n2 { grid-template-columns: 1fr 1fr; }
.ins-mosaic.n3 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.ins-mosaic.n3 img:first-child { grid-row: span 2; }
.ins-mosaic.n4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.ins-mosaic img { width: 100%; height: 100%; min-height: 0; display: block; object-fit: cover; opacity: 0; transition: opacity .2s; }
.ins-mosaic img.ld { opacity: 1; }
.ins-mosaic .folder-ic { width: 56px; height: 56px; color: var(--dim); stroke-width: 1.1; }
.ins-title { display: flex; flex-direction: column; gap: 4px; }
.ins-name { font-size: 15px; font-weight: 650; overflow-wrap: anywhere; word-break: break-word; }
.ins-name.big { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.ins-path { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; text-decoration: none; }
a.ins-path:hover { color: var(--accent-text); }
.ins-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ins-stat { background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.ins-stat .k { color: var(--faint); font-size: 11.5px; }
.ins-stat .n { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.ins-preview { position: relative; display: flex; align-items: center; justify-content: center; height: 300px; padding: 12px;
  background: var(--sunk); border: 1px solid var(--line); border-radius: 14px; }
.ins-preview img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; display: block; opacity: 0; transition: opacity .2s; }
.ins-preview img.ld { opacity: 1; }
.ins-play { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(0,0,0,.55); color: #fff; pointer-events: none; }
.ins-play .ic { margin-left: 2px; }
.ins-rows { display: flex; flex-direction: column; gap: 9px; font-size: 12.5px; }
.ins-row { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); }
.ins-row .v { color: var(--text); font-variant-numeric: tabular-nums; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.ins-actions { display: flex; flex-direction: column; gap: 10px; }
.ins-btn { height: 40px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--panel); color: var(--text-2); font-weight: 500; text-decoration: none; cursor: pointer; min-width: 0; white-space: nowrap; }
.ins-btn span { overflow: hidden; text-overflow: ellipsis; }
.ins-btn:hover { background: var(--raised); color: var(--text); }
.ins-btn.primary { height: 42px; background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; font-weight: 600; }
.ins-btn.primary:hover { background: #3474f0; }
.ins-grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ins-grid3 .ins-btn { height: 38px; gap: 6px; font-size: 12.5px; padding: 0 4px; }
.ins-grid3 .ic { width: 14px; height: 14px; }
.ins-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 11.5px; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; color: var(--muted); cursor: pointer; }
.chip:hover { color: var(--text); }
.chip[aria-pressed=true] { background: var(--accent-soft); border-color: transparent; color: #bfdbfe; }
.ins-hint { color: var(--muted); font-size: 12.5px; line-height: 1.5; padding: 4px 2px; }

/* ---------- menus, scrim, help, toast, drop ---------- */
.pmenu { position: fixed; z-index: 80; min-width: 190px; max-width: calc(100vw - 16px); padding: 6px; background: #202125; border: 1px solid var(--line-3);
  border-radius: 12px; box-shadow: 0 18px 50px rgba(0,0,0,.55); display: flex; flex-direction: column; gap: 1px; }
.pm-item { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 10px 0 6px; border: 0; border-radius: 8px; background: none;
  color: var(--text-2); text-align: left; cursor: pointer; white-space: nowrap; }
.pm-item:hover, .pm-item:focus-visible { background: var(--raised); color: var(--text); outline: none; }
.pm-item:disabled { opacity: .45; cursor: default; }
.pm-check { width: 16px; display: grid; place-items: center; color: var(--accent-text); flex: none; }
.pm-label { flex: 1; }
.pm-hint { color: var(--faint); font-size: 11.5px; }
.pm-text { padding: 6px 10px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.pm-text:empty { display: none; }
.pm-sep { height: 1px; margin: 4px 2px; background: var(--line-2); }
.scrim { position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.5); }
.kb-scrim { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px; background: rgba(8,8,10,.6); }
.kb-dialog { width: min(760px, 100%); max-height: min(86vh, 900px); overflow-y: auto; background: var(--pane); border: 1px solid var(--line-2); border-radius: 16px;
  box-shadow: 0 30px 90px rgba(0,0,0,.6); padding: 18px 20px 22px; }
.kb-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.kb-head h2 { margin: 0; font-size: 17px; font-weight: 650; }
.kb-groups { columns: 2 300px; column-gap: 28px; }
.kb-group { break-inside: avoid; padding-top: 12px; }
.kb-group h3 { margin: 0 0 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.kb-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 5px 0; color: var(--text-2); }
.kb-keys { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.kb-combo { display: inline-flex; gap: 3px; }
.kb-combo kbd { min-width: 22px; text-align: center; font: 500 11px/1.5 var(--font); color: var(--text-2); background: var(--panel); border: 1px solid var(--line-3);
  border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; }
.drop-hint { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(15,15,17,.7); pointer-events: none; }
.drop-hint div { border: 2px dashed var(--accent); color: var(--accent-ink); padding: 36px 56px; border-radius: 18px; font-size: 18px; background: rgba(0,0,0,.4); }
.toast { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 70;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px; background: var(--raised); border: 1px solid var(--line-3);
  box-shadow: 0 16px 40px rgba(0,0,0,.5); font-size: 13px; }
.spin { width: 18px; height: 18px; flex: none; border-radius: 50%; border: 2px solid rgba(255,255,255,.18); border-top-color: var(--accent);
  animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- widths ---------- */
@media (max-width: 1279px) and (min-width: 768px) {
  :root { --pad: 20px; }
}
@media (min-width: 1800px) {
  :root { --sb-w: 248px; --ins-w: 320px; --pad: 28px; }
}

/* ---------- phones: drawer, top bar, bottom sheet, bottom bar ---------- */
@media (max-width: 767px) {
  :root { --pad: 16px; --tb-top: calc(62px + env(safe-area-inset-top)); }
  body { font-size: 13px; }
  .app { display: block; }
  .pane-resize, .tabstrip { display: none !important; }
  body.has-tabs { --tb-top: calc(62px + env(safe-area-inset-top)); }
  /* align-self: stretch undoes the desktop's start: Chrome aligns positioned boxes too, and "start" made the fixed
     drawer as tall as its content (it could not scroll, and its virtual folder tree mounted every row) */
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: min(304px, 86vw); height: auto; align-self: stretch; z-index: 60;
    transform: translateX(-102%); visibility: hidden; transition: transform .24s cubic-bezier(.2,.8,.2,1), visibility 0s .24s;
    padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); box-shadow: 18px 0 50px rgba(0,0,0,.5); }
  body.drawer-open .sidebar { transform: none; visibility: visible; transition: transform .24s cubic-bezier(.2,.8,.2,1); }
  .navrow, .trow { min-height: 44px; }
  .ptop { display: flex; position: sticky; top: 0; z-index: 30; align-items: center; gap: 6px;
    padding: calc(10px + env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left));
    background: rgba(20, 21, 23, .94); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
  .ptitle { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .pparent { color: var(--faint); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pparent:empty { display: none; }
  /* the parent's name goes up (phones have no Up button or Backspace): a 44 px tall target over the bar's padding */
  button.pparent { position: relative; z-index: 1; align-self: flex-start; max-width: 100%; border: 0; background: none; font: inherit;
    font-size: 11.5px; color: var(--faint); text-align: left; padding: 15px 8px 15px 0; margin: -15px 0 -15px; cursor: pointer;
    -webkit-tap-highlight-color: transparent; }
  button.pparent:not(:disabled)::before { content: '‹'; display: inline-block; margin-right: 4px; font-size: 15px; line-height: 0; color: var(--muted); }
  button.pparent:not(:disabled):active { color: var(--text); }
  button.pparent:disabled { cursor: default; }
  .pname { font-size: 20px; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ibtn.lg[aria-pressed=true] { background: var(--accent-soft); color: var(--accent-text); }
  .toolbar { display: none; }
  body.ph-search .toolbar { display: flex; min-height: 0; padding: 0 var(--pad) 10px; border: 0; background: rgba(20, 21, 23, .94); }
  body.ph-search .toolbar > :not(.namefield) { display: none; }
  body.ph-search .namefield { flex: 1 1 auto; height: 44px; border-radius: 12px; }
  .namefield .kbd { display: none; }
  .vhead { padding: 0; }
  .vhead-text { display: none; }
  .vtools:not(:empty) { padding: 0 0 12px; }
  .prow { display: flex; align-items: center; gap: 6px; padding: 2px 0 12px; }
  .pmeta { flex: 1; min-width: 0; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #phLayout .ic { display: none; }
  #phLayout[data-layout=waterfall] .lay-waterfall, #phLayout[data-layout=justified] .lay-justified,
  #phLayout[data-layout=square] .lay-square, #phLayout[data-layout=list] .lay-list { display: block; }
  main { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }

  .inspector { display: flex; position: fixed; left: 0; right: 0; bottom: 0; top: auto; max-height: min(80vh, 760px); z-index: 58;
    background: var(--sheet); border: 0; border-top: 1px solid #2f3036; border-radius: 22px 22px 0 0; box-shadow: 0 -18px 50px rgba(0,0,0,.55);
    transform: translateY(104%); visibility: hidden; transition: transform .26s cubic-bezier(.2,.8,.2,1), visibility 0s .26s;
    padding-bottom: env(safe-area-inset-bottom); }
  body.sheet-open .inspector { transform: none; visibility: visible; transition: transform .26s cubic-bezier(.2,.8,.2,1); }
  .ins-grip { display: block; flex: none; align-self: center; width: 64px; height: 22px; margin: 4px 0 -6px; padding: 0; border: 0; background: none; cursor: pointer; position: relative; }
  .ins-grip::before { content: ""; position: absolute; left: 13px; right: 13px; top: 8px; height: 5px; border-radius: 999px; background: #3a3b41; }
  .ins-body { padding: 12px 16px 26px; gap: 14px; }
  .ins-sec { gap: 14px; }
  .ins-preview { height: 220px; }
  .ins-mosaic { width: min(100%, 220px); align-self: center; }
  .ins-btn { height: 46px; border-radius: 12px; }
  .ins-btn.primary { height: 48px; font-size: 14px; }
  .ins-grid3 .ins-btn { height: 46px; }
  .chip { padding: 8px 12px; font-size: 12.5px; }

  .bnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; align-items: flex-start; justify-content: space-around;
    height: calc(76px + env(safe-area-inset-bottom)); padding: 10px max(8px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(8px, env(safe-area-inset-left));
    background: rgba(20, 21, 23, .94); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
  .bn { width: 88px; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 500; padding-top: 2px; }
  .bn[aria-current=page] { color: var(--accent-text); font-weight: 600; }
  .bn-find { width: 60px; height: 60px; margin-top: -26px; border: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
    background: var(--accent-strong); color: #fff; box-shadow: 0 10px 26px rgba(37,99,235,.45), 0 0 0 5px var(--bg); }
  .bn-find:active { transform: scale(.96); }
  body.drawer-open .bnav, body.sheet-open .bnav { visibility: hidden; }
  .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
}

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

/* Touch screens: 44 px hit areas for the small sidebar controls (a positioned ::before; the look stays):
   the section "+" buttons and the folder tree's disclosure triangles */
@media (pointer: coarse) {
  .sb-act { position: relative; }
  .sb-act::before { content: ""; position: absolute; inset: -11px; }
  .trow .tw { position: relative; }
  .trow .tw::before { content: ""; position: absolute; inset: -14px; }
  button.pparent { min-width: 44px; }
}
