:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #eef1f5; --border: #dde2e8;
  --text: #121820; --muted: #5b6673; --accent: #0b5cad; --accent-ink: #ffffff; --accent-soft: #e3eefb;
  --ok: #187a3d; --ok-soft: #e2f4e8; --warn: #9a5b00; --warn-soft: #fdf0d9; --bad: #b42318; --bad-soft: #fde7e5;
  --info: #5b3fb8; --info-soft: #eee9fb; --shadow: 0 1px 2px rgb(16 24 40 / .06), 0 2px 8px rgb(16 24 40 / .06);
  --radius: 12px; --tap: 44px; --top-h: 56px; --tab-h: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #0f1318; --surface: #171c23; --surface-2: #1f2630; --border: #2c3542;
    --text: #e8edf3; --muted: #98a4b3; --accent: #5aa2f0; --accent-ink: #06121f; --accent-soft: #15283d;
    --ok: #5cc98a; --ok-soft: #132a1d; --warn: #f0b14a; --warn-soft: #2e2412; --bad: #f2776b; --bad-soft: #351a18;
    --info: #b19cf5; --info-soft: #241d3d; --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 2px 10px rgb(0 0 0 / .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1318; --surface: #171c23; --surface-2: #1f2630; --border: #2c3542;
  --text: #e8edf3; --muted: #98a4b3; --accent: #5aa2f0; --accent-ink: #06121f; --accent-soft: #15283d;
  --ok: #5cc98a; --ok-soft: #132a1d; --warn: #f0b14a; --warn-soft: #2e2412; --bad: #f2776b; --bad-soft: #351a18;
  --info: #b19cf5; --info-soft: #241d3d; --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 2px 10px rgb(0 0 0 / .35);
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100dvh; }
a { color: var(--accent); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button, input, select { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 99; } .skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
/* top */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; min-height: calc(var(--top-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-size: 17px; white-space: nowrap; }
.logo-chip { display: flex; align-items: center; background: #fff; border-radius: 8px; padding: 3px 8px; border: 1px solid var(--border); } .logo-chip img { display: block; height: 28px; width: auto; }
.search { flex: 1 1 260px; max-width: 520px; display: flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 0 10px; min-height: 40px; }
.search input { flex: 1; border: 0; background: transparent; outline: none; min-width: 0; min-height: 38px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
.who { color: var(--muted); font-size: 13px; white-space: nowrap; display: flex; align-items: center; min-width: 0; max-width: 34ch; } .who .em { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; padding: 1px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); margin-left: 4px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); } .badge.bad { background: var(--bad-soft); color: var(--bad); }
.theme-pick { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 2px; }
.theme-pick button { display: grid; place-items: center; width: 34px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.theme-pick button svg { width: 17px; height: 17px; }
.theme-pick button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tabs { display: flex; gap: 4px; padding: 6px max(12px, env(safe-area-inset-left)); background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500; white-space: nowrap; }
.tabs a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
body:not(.is-mgr) .mgr, body:not(.is-adm) .adm, body:not(.has-manage) .shr { display: none !important; }
main { padding: 12px max(12px, env(safe-area-inset-right)) 120px max(12px, env(safe-area-inset-left)); max-width: 1280px; margin: 0 auto; outline: none; }
/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none; color: var(--text); }
.btn:hover { background: var(--surface-2); } .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); } .btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); } .btn.sm { min-height: 30px; padding: 0 10px; font-size: 13px; } .btn:disabled { opacity: .5; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 0; background: transparent; border-radius: 10px; color: inherit; cursor: pointer; } .icon-btn:hover { background: var(--surface-2); } .icon-btn.sm { width: 30px; height: 30px; }
/* toolbar + crumbs */
.bar-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 10px; }
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; font-size: 15px; flex: 1 1 auto; min-width: 0; }
.crumbs a { padding: 4px 8px; border-radius: 8px; text-decoration: none; color: var(--text); font-weight: 500; }
.crumbs a:hover, .crumbs a.drop-ok { background: var(--accent-soft); color: var(--accent); }
.crumbs .sep { color: var(--muted); }
.tools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.split { position: relative; }
.seg { display: flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; } .seg button { border: 0; background: var(--surface); width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; color: var(--muted); } .seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
/* floating selection bar: fixed, so selecting never shifts the list under the pointer */
.selbar { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 45; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 8px 30px rgb(0 0 0 / .22); border-radius: 12px; padding: 8px 12px; max-width: calc(100vw - 24px); }
body.has-uploads .selbar { left: 12px; transform: none; max-width: calc(100vw - 480px); }
/* list */
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; overflow: clip; box-shadow: var(--shadow); }  /* clip (not hidden): keeps the sticky header working */
.row { display: grid; grid-template-columns: 34px minmax(0, 1fr) 165px 170px 44px; align-items: center; gap: 8px; padding: 6px 10px; border-top: 1px solid var(--border); min-height: 48px; user-select: none; -webkit-user-select: none; }
.row.head { border-top: 0; min-height: 38px; color: var(--muted); font-size: 13px; font-weight: 600; background: var(--surface-2); }
/* column header stays visible while a long list scrolls (just under the sticky top bar; --sticky-top is set from its real height) */
.list:not(.grid) > .row.head { position: sticky; top: var(--sticky-top, var(--top-h)); z-index: 6; border-bottom: 1px solid var(--border); box-shadow: 0 1px 0 var(--border); }
.list:not(.grid) > .row.head + .row { border-top: 0; }
.row.head button { border: 0; background: none; color: inherit; font: inherit; cursor: pointer; padding: 0; text-align: left; }
.row:not(.head):hover { background: var(--surface-2); }
.row.sel { background: var(--accent-soft); } .row.drop-ok { outline: 2px dashed var(--accent); outline-offset: -3px; background: var(--accent-soft); }
.row .nm { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row .nm button { border: 0; background: none; padding: 0; cursor: pointer; text-align: left; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; min-height: 36px; }
.row .nm button:hover { color: var(--accent); text-decoration: underline; }
.row .sub { display: none; color: var(--muted); font-size: 12px; }
.row .num, .row .dt { color: var(--muted); font-size: 13px; white-space: nowrap; }
.row input[type=checkbox] { width: 18px; height: 18px; }
.ficon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.ficon.folder { background: #fdf0d0; color: #a86a00; } :root[data-theme="dark"] .ficon.folder { background: #3a2e12; color: #f0b14a; }
.ficon.pdf { background: var(--bad-soft); color: var(--bad); } .ficon.img { background: var(--ok-soft); color: var(--ok); } .ficon.exe { background: var(--info-soft); color: var(--info); }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text); margin-bottom: 4px; font-size: 16px; }
/* grid view */
.list.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 10px; background: transparent; border: 0; box-shadow: none; }
.list.grid .row.head { display: none; }
.list.grid .row { grid-template-columns: 1fr; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); padding: 12px; text-align: center; position: relative; min-height: 140px; }
.list.grid .row > input, .list.grid .row .num, .list.grid .row .dt { display: none; }
.list.grid .row .nm { flex-direction: column; } .list.grid .row .ficon { width: 64px; height: 64px; font-size: 14px; } .list.grid .row .ficon svg { width: 34px; height: 34px; }
.list.grid .row .nm button { white-space: normal; word-break: break-word; }
.list.grid .row .more { position: absolute; top: 4px; right: 4px; }
/* uploads panel */
.uploads { position: fixed; right: 12px; bottom: 12px; width: min(440px, calc(100vw - 24px)); max-height: 60vh; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 8px 30px rgb(0 0 0 / .2); z-index: 40; }
.uploads > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.up-actions { display: flex; gap: 4px; align-items: center; }
.uploads.min ul, .uploads.min .up-sum { display: none; }
.uploads ul { list-style: none; margin: 0; padding: 0; overflow: auto; }
.uploads li { padding: 8px 12px; border-top: 1px solid var(--border); font-size: 13px; }
.uploads li .l1 { display: flex; gap: 8px; align-items: center; } .uploads li .l1 b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.uploads li .l2 { color: var(--muted); font-size: 12px; margin-top: 2px; } .uploads li.err .l2 { color: var(--bad); } .uploads li.done .l2 { color: var(--ok); }
.up-sum { padding: 2px 12px 8px; color: var(--muted); font-size: 12px; }
.bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 5px; } .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.bar.total { margin: 8px 12px 4px; } li.done .bar i { background: var(--ok); } li.err .bar i { background: var(--bad); } li.paused .bar i { background: var(--warn); }
/* drop overlay */
.drop-hint { position: fixed; inset: 0; z-index: 60; background: rgb(11 92 173 / .14); display: grid; place-items: center; pointer-events: none; border: 4px dashed var(--accent); }
.drop-hint > div { background: var(--surface); padding: 20px 28px; border-radius: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.drop-hint svg { width: 40px; height: 40px; color: var(--accent); } .drop-hint span { color: var(--muted); }
/* menu + dialog + toast */
.menu { position: fixed; z-index: 70; min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 30px rgb(0 0 0 / .22); padding: 6px; }
.menu button { display: flex; width: 100%; align-items: center; gap: 10px; border: 0; background: none; padding: 9px 10px; border-radius: 8px; cursor: pointer; text-align: left; min-height: 38px; }
.menu button:hover, .menu button:focus { background: var(--surface-2); outline: none; } .menu button.danger { color: var(--bad); } .menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
dialog { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); padding: 0; width: min(560px, calc(100vw - 24px)); box-shadow: 0 20px 60px rgb(0 0 0 / .3); }
dialog.wide { width: min(1100px, calc(100vw - 24px)); height: calc(100dvh - 40px); }
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog form, dialog .dbody { padding: 18px; } dialog h2 { margin: 0 0 12px; font-size: 18px; }
dialog .acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
dialog input[type=text], dialog input[type=email], dialog select, .field { width: 100%; min-height: 40px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); padding: 6px 10px; }
dialog.wide .dbody { height: 100%; display: flex; flex-direction: column; } .preview-frame { flex: 1; width: 100%; border: 0; border-radius: 10px; background: var(--surface-2); min-height: 0; }
.preview-img { flex: 1; min-height: 0; display: grid; place-items: center; overflow: auto; } .preview-img img { max-width: 100%; max-height: 100%; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 14px; } .kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-all; }
.tree { max-height: 50vh; overflow: auto; border: 1px solid var(--border); border-radius: 10px; padding: 6px; }
.tree button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.tree button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); } .tree button:disabled { opacity: .4; cursor: not-allowed; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 80; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100vw - 24px); }
.toast.show { opacity: 1; } .toast.err { background: var(--bad); color: #fff; }
/* tables (trash/audit/settings) */
table.t { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; font-size: 13px; }
table.t th, table.t td { text-align: left; padding: 8px 10px; border-top: 1px solid var(--border); vertical-align: top; } table.t th { background: var(--surface-2); color: var(--muted); border-top: 0; }
table.t td.path { word-break: break-all; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; } .filters .field { width: auto; min-width: 160px; flex: 1 1 160px; }
h1.pg { font-size: 20px; margin: 6px 0 12px; }
.muted { color: var(--muted); } .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
/* phones / techs: card rows, big tap targets */
@media (max-width: 720px) {
  .who { display: none; } .search { order: 5; flex-basis: 100%; max-width: none; margin-bottom: 8px; }
  .row { grid-template-columns: minmax(0, 1fr) 44px; padding: 8px 10px; min-height: 60px; }
  .row > input, .row .num, .row .dt { display: none; }
  /* phones: compact sticky header with the sort buttons (Name · Size · Modified) */
  .list:not(.grid) > .row.head { display: flex; gap: 14px; min-height: 40px; padding: 6px 12px; }
  .row.head > span { display: none; } .row.head button { min-height: 32px; } .row.head [data-sort="name"] { flex: 1; }
  .row .sub { display: block; } .row .nm button { min-height: 44px; white-space: normal; }
  .ficon { width: 40px; height: 40px; }
  .kv { grid-template-columns: 1fr; } .kv dt { margin-top: 6px; }
  table.t .hide-sm { display: none; }
  .uploads { right: 6px; left: 6px; width: auto; bottom: 6px; }
  .menu.sheet { left: 6px !important; right: 6px; top: auto !important; bottom: 6px; }
  body.has-uploads .selbar { left: 6px; right: 6px; max-width: none; bottom: auto; top: calc(var(--top-h) + 100px); }
}

/* share dialog / shared links / audit extras */
fieldset.opts { border: 1px solid var(--border); border-radius: 10px; display: flex; gap: 14px; flex-wrap: wrap; padding: 8px 12px; margin: 10px 0; }
fieldset.opts legend { padding: 0 4px; color: var(--muted); font-size: 13px; }
label.chk { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; cursor: pointer; }
label.chk input { width: 18px; height: 18px; }
textarea.field { width: 100%; resize: vertical; }
.ua { font-size: 11px; word-break: break-word; } td.acts-cell { white-space: nowrap; }
/* public / share pages (filez.protekms.com) */
body.pub main { max-width: 1100px; margin: 0 auto; padding: 14px max(12px, env(safe-area-inset-left)) 40px; }
body.pub .row { grid-template-columns: minmax(0, 1fr) 165px 170px 44px; }
body.pub .gate { max-width: 440px; margin: 30px auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
body.pub .gate h1 { font-size: 20px; margin: 0 0 6px; } body.pub .gate .field { width: 100%; margin: 6px 0 10px; }
body.pub .gate input.code { font-size: 26px; letter-spacing: 8px; text-align: center; font-family: ui-monospace, monospace; }
body.pub .note { color: var(--muted); font-size: 13px; margin: 6px 0 12px; }
body.pub .filecard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; box-shadow: var(--shadow); }
body.pub .filecard .ficon { width: 52px; height: 52px; font-size: 13px; } body.pub .filecard .meta { flex: 1; min-width: 200px; } body.pub .filecard b { word-break: break-word; }
@media (max-width: 720px) { body.pub .row { grid-template-columns: minmax(0, 1fr) 44px; } }

/* per-folder permissions */
.ficon.folder.locked { position: relative; }
.ficon.folder.locked svg.lock { position: absolute; right: -3px; bottom: -3px; width: 15px; height: 15px; padding: 1px; border-radius: 4px; background: var(--surface); stroke: var(--text); fill: none; stroke-width: 2.2; }
.crumbs svg.lock, .btn svg.lock, h2 svg.lock { width: 14px; height: 14px; vertical-align: -2px; margin-right: 3px; fill: none; stroke: currentColor; stroke-width: 2.2; }
.perms .inh { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; margin: 8px 0; font-size: 14px; }
.perms .inh ul { margin: 4px 0 0; padding-left: 18px; } .perms select.field { max-width: 100%; }
.note.bad, .bg-banner { color: #fff; background: #b42318; }
.bg-banner { padding: 8px max(12px, env(safe-area-inset-left)); font-size: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.bg-banner .btn { background: #fff; color: #b42318; border-color: #fff; }
.note.bad { padding: 6px 10px; border-radius: 6px; }
