:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eff1f5;
  --hover: #f1f3f8;
  --text: #1a1e27;
  --muted: #667085;
  --border: #e2e5eb;
  --accent: #4f6bff;
  --accent-fg: #ffffff;
  --accent-soft: #e6ebff;
  --danger: #d92d20;
  --ok: #12a150;
  --shadow: 0 10px 34px rgba(16, 24, 40, .16);
  --radius: 10px;
  --sidebar-w: 264px;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0e1015;
  --surface: #171a21;
  --surface-2: #1f232c;
  --hover: #1c2029;
  --text: #e8eaf0;
  --muted: #98a1b3;
  --border: #292e39;
  --accent: #7088ff;
  --accent-fg: #0b0e18;
  --accent-soft: #212a52;
  --danger: #ff6b5e;
  --ok: #3ddc84;
  --shadow: 0 10px 34px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
svg.ico { width: 1em; height: 1em; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }

/* ---------- buttons / inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  height: 36px; padding: 0 14px; border-radius: 8px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.block { width: 100%; height: 42px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn .ico { font-size: 16px; }
.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 8px;
  background: transparent; border: 0; cursor: pointer; color: var(--muted); font-size: 18px; flex: none;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font-weight: 600; }
.link:hover { text-decoration: underline; }

.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=search], select {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 8px; background: var(--surface);
  border: 1px solid var(--border); outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.note { font-size: 12.5px; color: var(--muted); margin: 0 0 14px; }
.error { color: var(--danger); font-size: 13px; margin: 0 0 12px; }

/* ---------- auth ---------- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.auth-sub { text-align: center; color: var(--muted); margin: 6px 0 20px; }
.tabs { display: flex; background: var(--surface-2); border-radius: 9px; padding: 3px; margin-bottom: 18px; }
.tab { flex: 1; height: 32px; border: 0; background: none; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 600; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.brand img { width: 30px; height: 30px; }
.brand-lg { justify-content: center; font-size: 22px; }
.brand-lg img { width: 40px; height: 40px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); height: 100dvh; }
.sidebar {
  display: flex; flex-direction: column; padding: 18px 14px 14px; background: var(--surface);
  border-right: 1px solid var(--border); min-height: 0;
}
.sidebar .brand { padding: 4px 8px 18px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.nav a .ico { font-size: 18px; }
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.storage { padding: 14px 10px 4px; border-top: 1px solid var(--border); }
.storage-head { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 8px; }
.meter { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .3s; }
.meter i.warn { background: #f79009; }
.meter i.full { background: var(--danger); }
.storage-text { margin-top: 7px; font-size: 12.5px; color: var(--muted); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 10px 18px; min-height: 56px; border-bottom: 1px solid var(--border); }
.search { width: 260px; position: relative; display: block; flex: none; }
.search > span { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); display: flex; }
.search input { padding-left: 36px; height: 34px; background: transparent; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.main { position: relative; }
/* floats over the bottom of the list, so selecting never shifts the layout */
.selbar { position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 30; max-width: calc(100% - 24px); display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); overflow-x: auto; }
.selbar .spacer { width: 4px; }
.selbar .btn { background: var(--surface-2); white-space: nowrap; }
.selbar .sel-count { white-space: nowrap; }
.seg { display: inline-flex; border-radius: 8px; overflow: hidden; }
.seg button { width: 34px; height: 34px; border: 0; background: none; cursor: pointer; color: var(--muted); display: grid; place-items: center; font-size: 17px; border-radius: 8px; }
.seg button:hover { background: var(--hover); color: var(--text); }
.seg button.active { color: var(--text); }
.sel-count { font-weight: 600; margin-right: 6px; }
.crumbs { flex: 1; min-width: 0; display: flex; align-items: center; flex-wrap: nowrap; overflow: hidden; gap: 2px; font-size: 15px; }
.crumb { padding: 4px 8px; border-radius: 6px; cursor: pointer; border: 0; background: none; color: var(--muted); font-weight: 500; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: none; }
.crumb:hover, .crumb.drop { background: var(--hover); color: var(--text); }
.crumb.cur { color: var(--text); font-weight: 600; cursor: default; flex: 0 1 auto; min-width: 0; }
.crumbs .sep { color: var(--muted); font-size: 11px; flex: none; display: flex; }
.content { flex: 1; overflow: auto; padding: 4px 18px 90px; position: relative; outline: none; }
.banner { background: var(--accent-soft); color: var(--text); border-radius: 8px; padding: 10px 14px; margin: 8px 0 12px; font-size: 13px; }

/* ---------- list view ---------- */
.list { background: none; border: 0; }
.row { position: relative; display: grid; grid-template-columns: 0 minmax(0, 1fr) 110px 190px 34px; align-items: center; gap: 10px; padding: 0 10px; min-height: 44px; border-radius: 8px; cursor: default; user-select: none; }
.row.head { min-height: 34px; font-size: 12.5px; color: var(--muted); border-radius: 0; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 2; background: var(--bg); margin-bottom: 4px; }
.row.head button, .sortbar button { background: none; border: 0; cursor: pointer; text-align: left; padding: 0; font: inherit; font-weight: 500; color: var(--muted); display: inline-flex; gap: 4px; align-items: center; }
.row.head button:hover, .sortbar button:hover, .row.head button.on, .sortbar button.on { color: var(--text); }
.sortbar { display: flex; gap: 16px; padding: 4px 10px 10px; font-size: 12.5px; }
.sortbar.m-only { display: none; }
.row:not(.head):hover { background: var(--hover); }
.row.sel { background: var(--accent-soft) !important; }
/* consecutive selected rows read as one block: only the outer corners of the group stay rounded */
.row.sel + .row.sel { border-top-left-radius: 0; border-top-right-radius: 0; }
.row.sel:has(+ .row.sel) { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.row.drop, .card.drop { outline: 2px solid var(--accent); outline-offset: -2px; }
.row .name { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row .name b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srow .name b { display: block; }
.fb { display: contents; }
.row .sub { display: none; font-size: 12px; color: var(--muted); }
.row .col { color: var(--muted); font-size: 13px; white-space: nowrap; }
.thumb { width: 30px; height: 30px; border-radius: 6px; background: transparent; display: grid; place-items: center; overflow: hidden; flex: none; color: var(--muted); position: relative; }
.thumb:has(img) { background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .ico { font-size: 22px; }
.kind-folder .thumb, .kind-folder .tile { color: var(--accent); }
.thumb .play { position: absolute; inset: auto 1px 1px auto; width: 12px; height: 12px; border-radius: 99px; background: rgba(0,0,0,.6); color: #fff; display: grid; place-items: center; font-size: 7px; }
.chk { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; margin: 0; }
.row .chk { opacity: 0; pointer-events: none; width: 0; min-width: 0; }
.row .more { width: 28px; height: 28px; opacity: 0; }
.row:hover .more, .row.sel .more { opacity: 1; }

/* ---------- grid view ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.card { position: relative; background: transparent; border: 1px solid transparent; border-radius: 12px; padding: 6px; cursor: default; user-select: none; }
.card:hover { background: var(--hover); }
.card.sel { background: var(--accent-soft); border-color: var(--accent); }
.card .tile { aspect-ratio: 4 / 3; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); overflow: hidden; position: relative; }
.card .tile img { width: 100%; height: 100%; object-fit: cover; }
.card .tile .ico { font-size: 44px; }
.card .tile .play { position: absolute; right: 8px; bottom: 8px; width: 26px; height: 26px; border-radius: 99px; background: rgba(0,0,0,.6); color: #fff; display: grid; place-items: center; font-size: 11px; }
.card .cap { padding: 8px 4px 2px; min-width: 0; }
.card .cap b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .cap small { color: var(--muted); font-size: 12px; }
.card .chk { position: absolute; left: 14px; top: 14px; z-index: 1; opacity: 0; background: var(--surface); }
.card:hover .chk, .card.sel .chk { opacity: 1; }
.card .more { position: absolute; right: 12px; top: 12px; z-index: 1; background: var(--surface); opacity: 0; border-radius: 99px; width: 28px; height: 28px; }
.card:hover .more { opacity: 1; }

.card .tile .play .ico, .thumb .play .ico { font-size: inherit; }
.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty .ico { font-size: 44px; margin-bottom: 8px; opacity: .6; }
.empty h3 { margin: 6px 0; color: var(--text); font-weight: 600; }

/* shared links table */
.srow { display: grid; grid-template-columns: minmax(0,1fr) 120px 120px 90px auto; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.srow:last-child { border-bottom: 0; }
.srow .name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.srow .name b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srow .acts { display: flex; gap: 6px; }

/* ---------- context menu ---------- */
.ctx { position: fixed; z-index: 90; min-width: 210px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 5px; }
.ctx button { display: flex; width: 100%; align-items: center; gap: 11px; padding: 8px 11px; border: 0; background: none; border-radius: 6px; cursor: pointer; text-align: left; }
.ctx button:hover:not(:disabled) { background: var(--hover); }
.ctx button:disabled { opacity: .45; cursor: default; }
.ctx button.danger { color: var(--danger); }
.ctx .ico { font-size: 16px; color: var(--muted); }
.ctx button.danger .ico { color: var(--danger); }
.ctx hr { border: 0; border-top: 1px solid var(--border); margin: 5px 4px; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; z-index: 80; background: rgba(8, 10, 16, .55); display: grid; place-items: center; padding: 16px; }
.modal { width: 100%; max-width: 440px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: var(--surface); border-radius: 14px; border: 1px solid var(--border); box-shadow: var(--shadow); }
.modal.wide { max-width: 560px; }
.modal h2 { margin: 0; font-size: 17px; padding: 18px 20px 4px; }
.modal .body { padding: 12px 20px; overflow: auto; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; }
.modal p { margin: 0 0 10px; }
.keybox { font-family: ui-monospace, Consolas, monospace; background: var(--surface-2); border-radius: 8px; padding: 12px; word-break: break-all; font-size: 13px; line-height: 1.7; user-select: all; }
.picker { border: 1px solid var(--border); border-radius: 8px; max-height: 280px; overflow: auto; }
.picker button { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; padding: 8px 10px; cursor: pointer; text-align: left; }
.picker button:hover { background: var(--hover); }
.picker button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.picker button:disabled { opacity: .4; cursor: default; }
.plan { display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.plan.cur { border-color: var(--accent); background: var(--accent-soft); }
.inline { display: flex; gap: 8px; align-items: center; }
.inline > * { flex: 1; }
.inline > .btn { flex: none; }
.share-link { display: flex; gap: 8px; margin: 10px 0; }
.share-link input { flex: 1; font-size: 12.5px; }
.checkrow { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; }
.checkrow input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ---------- preview ---------- */
.pv { position: fixed; inset: 0; z-index: 85; background: rgba(6, 8, 12, .92); display: flex; flex-direction: column; color: #f2f4f8; }
.pv-top { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.pv-top .title { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv .icon-btn { color: #cfd5e2; }
.pv .icon-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
.pv-body { flex: 1; min-height: 0; display: grid; place-items: center; padding: 0 12px 16px; position: relative; }
.pv-body img, .pv-body video { max-width: 100%; max-height: 100%; border-radius: 6px; background: #000; }
.pv-body iframe { width: min(1000px, 100%); height: 100%; border: 0; background: #fff; border-radius: 6px; }
.pv-body pre { width: min(1000px, 100%); max-height: 100%; overflow: auto; margin: 0; padding: 18px; background: var(--surface); color: var(--text); border-radius: 8px; font: 13px/1.55 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.pv-body audio { width: min(520px, 100%); }
.pv-prog { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 220px; text-align: center; color: #cfd5e2; }
.pv-prog .bar { height: 4px; background: rgba(255,255,255,.18); border-radius: 9px; margin-top: 10px; overflow: hidden; }
.pv-prog .bar i { display: block; height: 100%; width: 0; background: #fff; }
.pv-nav { position: absolute; top: 50%; transform: translateY(-50%); }
.pv-nav.prev { left: 6px; } .pv-nav.next { right: 6px; }

/* ---------- uploads panel / toasts / dropzone ---------- */
.uploads { position: fixed; right: 16px; bottom: 16px; z-index: 70; width: 330px; max-width: calc(100vw - 32px); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.uploads .uh { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; font-weight: 600; background: var(--surface-2); }
.uploads .ul { max-height: 240px; overflow: auto; }
.tr { padding: 9px 14px; border-top: 1px solid var(--border); }
.tr .tn { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.tr .tn span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr .tn span:last-child { color: var(--muted); flex: none; }
.tr .bar { height: 4px; background: var(--surface-2); border-radius: 9px; margin-top: 6px; overflow: hidden; }
.tr .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.tr.done .bar i { background: var(--ok); }
.tr.err .bar i { background: var(--danger); }
.tr.err .tn span:last-child { color: var(--danger); }

.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 9px; box-shadow: var(--shadow); display: flex; gap: 14px; align-items: center; max-width: min(92vw, 520px); }
.toast.error { background: var(--danger); color: #fff; }
.toast button { background: none; border: 0; color: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; padding: 0; }
.dropzone { position: fixed; inset: 0; z-index: 75; background: color-mix(in srgb, var(--accent) 18%, transparent); display: grid; place-items: center; pointer-events: none; border: 3px dashed var(--accent); font-size: 22px; font-weight: 700; color: var(--accent); }

/* ---------- public share page ---------- */
.share-page { display: flex; flex-direction: column; min-height: 100dvh; }
.share-top { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; }
.share-main { flex: 1; display: grid; place-items: center; padding: 16px; }
.share-card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; text-align: center; box-shadow: var(--shadow); }
.share-thumb { width: 120px; height: 120px; margin: 0 auto 16px; border-radius: 16px; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; color: var(--muted); font-size: 48px; }
.share-thumb img { width: 100%; height: 100%; object-fit: cover; }
.share-card h1 { font-size: 18px; margin: 0 0 4px; word-break: break-word; }
.share-card .btns { display: flex; gap: 8px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.share-card form { text-align: left; margin-top: 14px; }
.lock { font-size: 40px; color: var(--muted); }

.only-mobile { display: none; }
/* fixed => out of the .app grid flow on desktop; only visible while the mobile drawer is open */
.scrim { position: fixed; inset: 0; z-index: 55; background: rgba(8,10,16,.5); opacity: 0; pointer-events: none; transition: opacity .2s; }

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .only-mobile { display: inline-grid; }
  .hide-mobile { display: none !important; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(290px, 86vw); z-index: 60;
    transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .topbar { flex-wrap: wrap; padding: 8px 10px 4px; row-gap: 6px; }
  .search { order: 5; flex: 1 1 100%; max-width: none; }
  .selbar { bottom: 12px; padding: 6px 8px 6px 12px; }
  .content { padding: 0 10px 90px; }
  .row { grid-template-columns: 28px minmax(0, 1fr) 34px; }
  .row .chk { opacity: 1; pointer-events: auto; width: 18px; }
  .row .more { opacity: 1; }
  .row .col { display: none; }
  .row .sub { display: block; }
  .row.head { display: none; }
  .sortbar.m-only { display: flex; }
  .srow { grid-template-columns: minmax(0,1fr) auto; }
  .srow .c2, .srow .c3, .srow .c4 { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .top-actions .lbl, .selbar .lbl { display: none; }
  .uploads { right: 8px; bottom: 8px; }
}
@media (hover: none) {
  .card .chk, .card .more, .row .more { opacity: 1; }
  .row .chk { opacity: 1; pointer-events: auto; width: 18px; }
}
@media (hover: none) and (min-width: 821px) {
  .row { grid-template-columns: 28px minmax(0, 1fr) 110px 190px 34px; } /* tablets: show the checkbox column */
}

