:root {
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --sunk: #F3F5F7;
  --ink: #16232B;
  --ink-2: #2A3A44;
  --muted: #5D6B74;
  --line: #E3E7EB;
  --hover: #EEF1F4;
  --select: #DCE8F5;
  --accent: #E0A21A;
  --danger: #B4372F;
  --focus: #2F6DA8;
  --smart: #D98E04;
  --archive: #6AA9C9;
  --cold: #2F6DA8;
  --deep: #1E2D5C;
  --held: #9AA6AD;
  --primary: #16232B;
  --primary-hover: #2A3A44;
  --on-primary: #FFFFFF;
  --on-danger: #FFFFFF;
  --warn-bg: #FBF1DC;
  --warn-fg: #5A3E00;
  --ok-bg: #E3F3E6;
  --ok-fg: #23683A;
  --bad-bg: #FBE3E1;
  --info-bg: #E2ECF6;
  --custom-fg: #7A5300;
  --shadow: rgba(22, 35, 43, .16);
  --radius: 12px;
  --side: 256px;
  color-scheme: light;
  font-family: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.45;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0F1519;
  --surface: #172026;
  --sunk: #1E2930;
  --ink: #E4EAEE;
  --ink-2: #C9D3D8;
  --muted: #96A4AC;
  --line: #2B3840;
  --hover: #25323A;
  --select: #1D3954;
  --accent: #E0A21A;
  --danger: #F07A70;
  --focus: #6FA8E8;
  --smart: #E7A22A;
  --archive: #7DB9D9;
  --cold: #5E9DE2;
  --deep: #8FA1EC;
  --held: #7E8B92;
  --primary: #E4EAEE;
  --primary-hover: #FFFFFF;
  --on-primary: #10181D;
  --on-danger: #1A0F0E;
  --warn-bg: #3A2F14;
  --warn-fg: #F0CF88;
  --ok-bg: #16311E;
  --ok-fg: #7FD49C;
  --bad-bg: #3D1E1C;
  --info-bg: #1B2F45;
  --custom-fg: #F0CF88;
  --shadow: rgba(0, 0, 0, .45);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0F1519;
    --surface: #172026;
    --sunk: #1E2930;
    --ink: #E4EAEE;
    --ink-2: #C9D3D8;
    --muted: #96A4AC;
    --line: #2B3840;
    --hover: #25323A;
    --select: #1D3954;
    --accent: #E0A21A;
    --danger: #F07A70;
    --focus: #6FA8E8;
    --smart: #E7A22A;
    --archive: #7DB9D9;
    --cold: #5E9DE2;
    --deep: #8FA1EC;
    --held: #7E8B92;
    --primary: #E4EAEE;
    --primary-hover: #FFFFFF;
    --on-primary: #10181D;
    --on-danger: #1A0F0E;
    --warn-bg: #3A2F14;
    --warn-fg: #F0CF88;
    --ok-bg: #16311E;
    --ok-fg: #7FD49C;
    --bad-bg: #3D1E1C;
    --info-bg: #1B2F45;
    --custom-fg: #F0CF88;
    --shadow: rgba(0, 0, 0, .45);
}
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
a { color: var(--cold); }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.boot { padding: 40px; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 20px; letter-spacing: -0.02em; color: var(--ink); text-decoration: none; }
.brand img { width: 30px; height: 30px; display: block; border-radius: 7px; }
:root[data-theme="dark"] .brand img { box-shadow: 0 0 0 1px var(--line); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand img { box-shadow: 0 0 0 1px var(--line); } }

/* Buttons and inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); padding: 8px 16px; border-radius: 99px; white-space: nowrap; min-height: 38px; }
.btn:hover { background: var(--hover); }
a.btn { text-decoration: none; color: inherit; }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); }
.btn.danger.primary { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 0; background: transparent; border-radius: 50%; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn.on { background: var(--select); color: var(--ink); }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], select {
  width: 100%; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); min-height: 42px;
}
.linkish { background: none; border: 0; padding: 0; color: var(--cold); justify-self: start; font-size: 14px; }

/* Sign-in */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 20px; border: 1px solid var(--line); }
.auth-card form { padding: 32px; display: grid; gap: 14px; }
.auth-card h1 { margin: 6px 0 0; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.auth-card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.auth-card .error { color: var(--danger); font-size: 14px; margin: 0; }
.auth-card .info { background: var(--sunk); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 0; }
.auth-foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 16px; }

/* Layout */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 16px 12px; gap: 14px; }
.side .brand { padding: 4px 10px 6px; }
.new-btn { align-self: flex-start; display: inline-flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 22px 14px 18px; font-weight: 500; box-shadow: 0 1px 2px var(--shadow); }
.new-btn:hover { background: var(--hover); }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 14px; padding: 9px 14px; border-radius: 99px; color: var(--ink); text-decoration: none; }
.nav a:hover { background: var(--hover); }
.nav a.active { background: var(--select); font-weight: 600; }
.side-storage { padding: 6px 14px; display: grid; gap: 6px; font-size: 13px; color: var(--muted); text-decoration: none; }
.side-storage:hover { color: var(--ink); }
.side-foot { margin-top: auto; display: grid; gap: 6px; padding: 0 6px; }
.main { min-width: 0; padding: 12px 24px 100px 8px; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; min-height: 52px; }
.searchbox { flex: 1; max-width: 720px; position: relative; }
.searchbox svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.searchbox input { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding-left: 48px; min-height: 48px; }
.searchbox input:focus { background: var(--surface); box-shadow: 0 1px 6px var(--shadow); outline: none; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--primary); color: var(--on-primary); border: 0; font-weight: 600; display: grid; place-items: center; flex: none; margin-left: auto; }
.content { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; min-height: calc(100vh - 80px); padding: 14px 18px 24px; }
.mobile-bar, .bottom-nav, .fab { display: none; }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; min-height: 48px; margin-bottom: 8px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-size: 21px; font-weight: 500; letter-spacing: -0.01em; min-width: 0; }
.crumbs a, .crumbs .here { padding: 4px 10px; border-radius: 99px; color: var(--muted); text-decoration: none; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumbs a:hover { background: var(--hover); color: var(--ink); }
.crumbs .here { color: var(--ink); }
.crumbs .sep { color: var(--muted); display: inline-flex; }
.tools { display: flex; align-items: center; gap: 4px; }
.tools select { width: auto; min-height: 36px; padding: 4px 30px 4px 12px; border-radius: 99px; font-size: 14px; }
.view-title { font-size: 21px; font-weight: 500; margin: 0; letter-spacing: -0.01em; }
.selbar { display: flex; align-items: center; gap: 4px; background: var(--select); border-radius: 99px; padding: 4px 8px; min-height: 48px; margin-bottom: 8px; position: sticky; top: 8px; z-index: 5; }
.selbar .count { font-weight: 500; margin: 0 10px 0 4px; }
.selbar .spacer { flex: 1; }

/* Sections */
.section-label { font-size: 14px; font-weight: 500; color: var(--muted); margin: 16px 4px 10px; }

/* Folder chips (grid view) */
.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.folder-chip { position: relative; display: flex; align-items: center; gap: 12px; padding: 0 12px 0 14px; height: 52px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); text-align: left; user-select: none; }
.folder-chip:hover { background: var(--hover); }
.folder-chip .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.folder-chip svg.i { color: var(--muted); }

/* File cards (grid view) */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.card { position: relative; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); padding: 0 0 10px; display: grid; gap: 0; user-select: none; overflow: hidden; }
.card:hover { background: var(--hover); }
.card .head { display: flex; align-items: center; gap: 10px; padding: 4px 2px 4px 12px; min-width: 0; min-height: 46px; }
.card .head .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 500; }
.card .pic { margin: 0 10px; height: 150px; border-radius: 8px; background: var(--sunk); display: grid; place-items: center; overflow: hidden; position: relative; }
.card .pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .pic .ext { font-size: 13px; font-weight: 600; color: var(--muted); border: 1.5px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.card .pic .play { position: absolute; width: 40px; height: 40px; border-radius: 50%; background: rgba(22, 35, 43, .65); color: #fff; display: grid; place-items: center; }
.card .pic .play svg { fill: #fff; stroke: none; width: 16px; height: 16px; margin-left: 2px; }
.card .pic .cold-veil { position: absolute; inset: 0; background: rgba(30, 45, 92, .45); display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 500; text-align: center; padding: 8px; }
.card .meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px 0; font-size: 12px; color: var(--muted); min-height: 24px; }
.card.selected, .folder-chip.selected { background: var(--select); box-shadow: inset 0 0 0 2px var(--focus); }
.check { position: absolute; top: 8px; left: 8px; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--muted); background: var(--surface); display: none; place-items: center; z-index: 2; padding: 0; }
.check svg { width: 14px; height: 14px; stroke: #fff; stroke-width: 3; opacity: 0; }
.selected .check { background: var(--focus); border-color: var(--focus); display: grid; }
.selected .check svg { opacity: 1; }
.picking .check, .card:hover .check, .folder-chip:hover .check, .row:hover .check { display: grid; }
.card .check { top: 54px; left: 18px; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); }
.folder-chip .check { position: static; flex: none; }
.folder-chip:not(.selected) .check { display: none; }
.picking .folder-chip .check, .folder-chip:hover .check { display: grid; }

/* List view */
.list { display: grid; }
.row { position: relative; display: grid; grid-template-columns: 34px minmax(0, 1fr) 170px 90px 110px 40px; gap: 10px; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--line); user-select: none; min-height: 52px; }
.row.head { font-size: 13px; color: var(--muted); min-height: 40px; font-weight: 500; }
.row:not(.head):hover { background: var(--sunk); }
.row.selected { background: var(--select); }
.row .check { position: static; }
.row .nmcell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .loc { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .loc-mobile { display: none; }
.mini { width: 34px; height: 34px; border-radius: 8px; background: var(--sunk); display: grid; place-items: center; overflow: hidden; flex: none; color: var(--muted); font-size: 10px; font-weight: 600; }
.mini img { width: 100%; height: 100%; object-fit: cover; }
.link-mark { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 0 7px; flex: none; }

/* Tier chip */
.tier { display: grid; gap: 1px; font-size: 13px; line-height: 1.3; min-width: 0; }
.tier .t { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.tier .t::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.tier .s { color: var(--muted); font-size: 12px; padding-left: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-smart { --c: var(--smart); } .c-archive { --c: var(--archive); } .c-cold { --c: var(--cold); } .c-deep { --c: var(--deep); } .c-held { --c: var(--held); }

.empty { padding: 64px 24px; text-align: center; color: var(--muted); display: grid; justify-items: center; gap: 6px; }
.empty svg { width: 44px; height: 44px; stroke-width: 1.4; margin-bottom: 6px; }
.empty strong { color: var(--ink); font-size: 17px; font-weight: 500; }
.drop-zone { position: relative; }
.drop-hint { position: absolute; inset: 0; background: rgba(47, 109, 168, .08); border: 2px dashed var(--cold); border-radius: var(--radius); display: none; place-items: center; font-weight: 600; color: var(--cold); pointer-events: none; z-index: 4; }
.drop-zone.dragging .drop-hint { display: grid; }
.skeleton { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 16px; }
.skeleton div { height: 200px; border-radius: 12px; background: var(--sunk); }

/* Menus, sheets and dialogs */
.menu { position: fixed; z-index: 40; background: var(--surface); border-radius: 12px; padding: 6px 0; min-width: 230px; box-shadow: 0 6px 30px var(--shadow); max-height: 80vh; overflow: auto; }
.menu button { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; border: 0; background: none; padding: 10px 18px; }
.menu button:hover { background: var(--hover); }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.menu .menu-title { padding: 8px 18px 10px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scrim { position: fixed; inset: 0; background: rgba(22, 35, 43, .35); z-index: 39; }
dialog { border: 0; border-radius: 20px; padding: 0; width: min(540px, calc(100vw - 24px)); color: var(--ink); background: var(--surface); box-shadow: 0 0 0 1px var(--line), 0 16px 48px var(--shadow); max-height: calc(100vh - 32px); }
dialog::backdrop { background: rgba(22, 35, 43, .45); }
.dlg { padding: 24px; display: grid; gap: 16px; }
.dlg h3 { margin: 0; font-size: 20px; font-weight: 500; }
.dlg .buttons { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.dlg p { margin: 0; }
.note { background: var(--sunk); border-radius: 10px; padding: 10px 14px; font-size: 14px; }
.note.warn { background: var(--warn-bg); color: var(--warn-fg); }
.choices { display: grid; gap: 8px; }
.choice { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: start; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.choice:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.choice.disabled { opacity: .5; cursor: not-allowed; }
.choice input { margin-top: 4px; }
.choice .title { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.choice .title::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--c, transparent); }
.choice .price { text-align: right; font-size: 14px; }
.choice .desc { grid-column: 2 / 4; font-size: 13px; color: var(--muted); }
.folder-pick { border: 1px solid var(--line); border-radius: 12px; max-height: 300px; overflow: auto; }
.folder-pick button { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--line); padding: 11px 14px; }
.folder-pick button:first-child { border-top: 0; }
.folder-pick button:hover { background: var(--hover); }
.copy-row { display: flex; gap: 8px; }
.steps { margin: 0; padding-left: 22px; display: grid; gap: 8px; }

/* Viewer */
.viewer { position: fixed; inset: 0; z-index: 60; background: #0D1418; color: #fff; display: grid; grid-template-rows: auto 1fr; }
.viewer header { display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; }
.viewer header .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.viewer .icon-btn { color: #DDE3E7; }
.viewer .icon-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.viewer .stage { position: relative; display: grid; place-items: center; min-height: 0; padding: 0 64px calc(16px + env(safe-area-inset-bottom)); }
.viewer .stage img, .viewer .stage video { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.viewer .stage iframe { width: min(1000px, 100%); height: 100%; border: 0; background: #fff; border-radius: 6px; }
.viewer .nav-btn { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .1); color: #fff; display: grid; place-items: center; }
.viewer .nav-btn:hover { background: rgba(255, 255, 255, .2); }
.viewer .nav-btn.prev { left: 10px; } .viewer .nav-btn.next { right: 10px; }
.viewer .card-msg { background: #1B262D; border-radius: 16px; padding: 28px; display: grid; gap: 12px; justify-items: center; text-align: center; max-width: 380px; }
.viewer .card-msg .muted { color: #A9B4BB; }

/* Meters */
.meter { height: 6px; background: var(--hover); border-radius: 99px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--ink); border-radius: 99px; }
.meter.over span { background: var(--danger); }

/* Storage, admin pages */
.page { display: grid; gap: 18px; max-width: 900px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; }
.panel h3 { margin: 0 0 12px; font-size: 16px; font-weight: 600; }
.cost-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.cost-head .big { font-size: 44px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; }
.thermo { display: flex; height: 36px; border-radius: 8px; overflow: hidden; background: var(--hover); gap: 2px; }
.thermo span { background: var(--c); min-width: 3px; }
.legend { display: grid; margin-top: 14px; }
.legend .lrow { display: grid; grid-template-columns: minmax(0, 1fr) 100px 80px 90px; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.legend .lrow:first-child { border-top: 0; color: var(--muted); font-size: 13px; }
.legend .lrow > :not(:first-child) { text-align: right; }
.stat-line { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; margin-bottom: 6px; flex-wrap: wrap; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 8px 10px; }
.table td { padding: 10px; border-top: 1px solid var(--line); vertical-align: top; }
.table td.r, .table th.r { text-align: right; }
.invite { display: flex; gap: 8px; max-width: 520px; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.badge { font-size: 11px; font-weight: 500; border-radius: 99px; padding: 1px 8px; background: var(--sunk); color: var(--muted); }
.badge.admin { background: var(--info-bg); color: var(--focus); }
.badge.hold { background: var(--bad-bg); color: var(--danger); }
.badge.custom { background: var(--warn-bg); color: var(--custom-fg); }
.badge.ok { background: var(--ok-bg); color: var(--ok-fg); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.form-grid input, .form-grid select { color: var(--ink); }
.audit { display: grid; font-size: 13px; }
.audit div { display: grid; grid-template-columns: 130px 1fr; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.audit div:first-child { border-top: 0; }
.kpis { display: flex; flex-wrap: wrap; gap: 28px; margin-bottom: 16px; }
.kpis .k { display: grid; }
.kpis .k b { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.kpis .k span { font-size: 13px; color: var(--muted); }
.checks { display: grid; gap: 8px; margin: 12px 0; }
.checks div { display: grid; grid-template-columns: 22px 1fr; gap: 8px; font-size: 14px; }
.checks .detail { grid-column: 2; font-size: 12px; color: var(--muted); word-break: break-word; }
details > summary::-webkit-details-marker { display: none; }
details > summary svg.i { width: 16px; height: 16px; transition: transform .15s; color: var(--muted); }
details[open] > summary svg.i { transform: rotate(90deg); }
.banner { display: flex; align-items: center; gap: 10px; background: var(--warn-bg); color: var(--warn-fg); border-radius: 12px; padding: 6px 6px 6px 14px; margin-bottom: 10px; font-size: 14px; }
.banner > span { flex: 1; }
.banner .icon-btn { color: var(--warn-fg); width: 32px; height: 32px; }
.theme-opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-opt { display: grid; gap: 8px; justify-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 12px 8px; background: var(--surface); }
.theme-opt.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.theme-opt .sw { width: 64px; height: 42px; border-radius: 8px; border: 1px solid var(--line); overflow: hidden; display: flex; }
.theme-opt .sw span { flex: 1; }
.held-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; text-align: center; }

/* Upload tray */
.tray { position: fixed; right: 20px; bottom: 20px; width: min(380px, calc(100vw - 24px)); background: var(--surface); border-radius: 14px; box-shadow: 0 8px 32px var(--shadow); z-index: 30; overflow: hidden; }
.tray header { display: flex; justify-content: space-between; align-items: center; padding: 6px 6px 6px 16px; background: var(--primary); color: var(--on-primary); font-size: 14px; font-weight: 500; }
.tray header .icon-btn { color: var(--on-primary); width: 34px; height: 34px; }
.tray header .icon-btn:hover { background: rgba(255, 255, 255, .15); }
.tray ul { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow: auto; }
.tray.collapsed ul { display: none; }
.tray li { padding: 10px 16px; border-top: 1px solid var(--line); font-size: 13px; display: grid; gap: 4px; }
.tray li .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray .meter { height: 4px; }
.tray li.failed .status { color: var(--danger); }
.tray li.ok .status { color: var(--ok-fg); }

#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 70; width: min(520px, calc(100vw - 24px)); pointer-events: none; }
.toast { background: var(--primary); color: var(--on-primary); padding: 12px 18px; border-radius: 10px; font-size: 14px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); }
.toast.error { background: var(--danger); color: var(--on-danger); }

/* Public share page */
.public { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.public .card-pub { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; width: min(440px, 100%); overflow: hidden; }
.public .card-pub img.prev { width: 100%; max-height: 300px; object-fit: cover; display: block; background: var(--sunk); }
.public .body { padding: 28px; display: grid; gap: 14px; }
.public .fname { font-size: 20px; font-weight: 600; word-break: break-word; }

/* Phones */
@media (max-width: 760px) {
  .shell { display: block; }
  .side { display: none; }
  .main { padding: 0 0 calc(84px + env(safe-area-inset-bottom)); }
  .topbar { display: none; }
  .mobile-bar { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; position: sticky; top: 0; z-index: 10; background: var(--bg); }
  .mobile-bar .brand { font-size: 18px; flex: 1; }
  .mobile-bar .brand img { width: 26px; height: 26px; }
  .mobile-bar .avatar { margin-left: 0; width: 34px; height: 34px; }
  .content { border-radius: 0; border-width: 0; padding: 10px 12px 24px; min-height: calc(100vh - 120px); }
  .crumbs { font-size: 18px; }
  .crumbs a, .crumbs .here { max-width: 150px; padding: 4px 6px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .folders { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .card .pic { height: 120px; margin: 0 8px; }
  .card .meta .num { display: none; }
  .card .check { top: 52px; left: 14px; }
  .row { grid-template-columns: 30px minmax(0, 1fr) 40px; }
  .row .col-tier, .row .col-size, .row .col-date { display: none; }
  .row .loc-mobile { display: block; font-size: 12px; color: var(--muted); }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-nav a { flex: 1; display: grid; justify-items: center; gap: 2px; padding: 4px 0; font-size: 11px; color: var(--muted); text-decoration: none; border-radius: 12px; }
  .bottom-nav a svg.i { width: 22px; height: 22px; }
  .bottom-nav a.active { color: var(--ink); font-weight: 600; }
  .bottom-nav a.active svg.i { background: var(--select); border-radius: 99px; width: 52px; padding: 2px 15px; height: 26px; }
  .fab { display: grid; place-items: center; position: fixed; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); width: 58px; height: 58px; border-radius: 18px; background: var(--primary); color: var(--on-primary); border: 0; z-index: 21; box-shadow: 0 6px 18px rgba(22, 35, 43, .3); }
  .fab svg.i { width: 26px; height: 26px; }
  .menu.sheet { left: 0 !important; right: 0; top: auto !important; bottom: 0; width: 100%; border-radius: 18px 18px 0 0; padding: 8px 0 calc(12px + env(safe-area-inset-bottom)); max-height: 75vh; }
  .menu.sheet button { padding: 14px 22px; }
  .tray { bottom: calc(84px + env(safe-area-inset-bottom)); right: 12px; }
  #toasts { bottom: calc(96px + env(safe-area-inset-bottom)); }
  .viewer .stage { padding: 0 0 calc(12px + env(safe-area-inset-bottom)); }
  .viewer .nav-btn { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .audit div { grid-template-columns: 1fr; gap: 0; }
  .legend .lrow { grid-template-columns: minmax(0, 1fr) 80px 70px; }
  .legend .lrow .col-files { display: none; }
  .page { padding: 4px 2px; }
  .panel { padding: 16px; }
  .selbar { top: 54px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
