/* DowniTo – vzhľad v štýle moderných cloudových úložísk. Svetlý aj tmavý režim podľa systému. */

:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #f0f4f9;
  --surface-3: #e9eef6;
  --hover: rgba(31, 41, 55, .06);
  --press: rgba(31, 41, 55, .1);
  --line: #e3e7ee;
  --line-strong: #c9d0da;
  --text: #1f2328;
  --text-2: #444b55;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-ink: #ffffff;
  --primary-soft: #dbe7fe;
  --primary-soft-ink: #1e3a8a;
  --selected: #c9defc;
  --selected-ink: #0b2a5b;
  --danger: #c62828;
  --danger-soft: #fde4e4;
  --ok: #18794e;
  --ok-soft: #d7f5e5;
  --warn-soft: #fff4d6;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow: 0 4px 8px -2px rgba(16, 24, 40, .1), 0 2px 4px -2px rgba(16, 24, 40, .06);
  --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, .25), 0 8px 16px -8px rgba(16, 24, 40, .12);
  --input-bg: #ffffff;
  --thumb-bg: #e9eef6;
  --c-folder: #64748b;
  --c-image: #e5484d;
  --c-video: #d6409f;
  --c-audio: #8e4ec6;
  --c-archive: #b4690e;
  --c-doc: #2563eb;
  --c-file: #6b7280;
  --radius: 14px;
  --radius-sm: 10px;
  --side-w: 260px;
  --top-h: 64px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318;
    --surface: #1b1e24;
    --surface-2: #23272f;
    --surface-3: #2b3039;
    --hover: rgba(255, 255, 255, .06);
    --press: rgba(255, 255, 255, .1);
    --line: #2d323b;
    --line-strong: #414855;
    --text: #e6e8ec;
    --text-2: #c3c8d1;
    --muted: #9099a6;
    --primary: #6ea2ff;
    --primary-hover: #8db5ff;
    --primary-ink: #0a1d3f;
    --primary-soft: #1d3461;
    --primary-soft-ink: #cfe0ff;
    --selected: #1f3d6b;
    --selected-ink: #dbe8ff;
    --danger: #ff8a85;
    --danger-soft: #4a1d1d;
    --ok: #5fd39a;
    --ok-soft: #173d2b;
    --warn-soft: #3d3216;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 4px 12px rgba(0, 0, 0, .45);
    --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, .7);
    --input-bg: #15181d;
    --thumb-bg: #262b33;
    --c-folder: #9aa6b8;
    --c-image: #ff7a7f;
    --c-video: #f07cc4;
    --c-audio: #b993f0;
    --c-archive: #e8a54b;
    --c-doc: #7aa7ff;
    --c-file: #9099a6;
  }
}

/* ------------------------------------------------------------------ Základ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--text); letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 14px; }
p { margin: 0 0 12px; }
code { font: 12.5px/1.4 ui-monospace, 'Cascadia Code', Consolas, monospace; color: var(--text-2); background: var(--surface-2); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.ic { width: 20px; height: 20px; flex: none; fill: currentColor; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ------------------------------------------------------------------ Kostra aplikácie */
.app {
  display: grid;
  grid-template: "top top" var(--top-h) "side main" minmax(0, 1fr) / var(--side-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px 0 12px;
}
.brand { display: flex; align-items: center; gap: 10px; width: calc(var(--side-w) - 24px); padding-left: 8px; color: var(--text); flex: none; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; flex: none; filter: drop-shadow(0 2px 4px rgba(37, 99, 235, .25)); }
.brand-mark.lg { width: 48px; height: 48px; }
.brand-name { font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.nav-toggle { display: none; }

.search {
  flex: 1;
  min-width: 0;
  max-width: 720px;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 16px;
  background: var(--surface-3);
  border-radius: 999px;
  color: var(--muted);
  transition: background .15s, box-shadow .15s;
  cursor: text;
}
.search:focus-within { background: var(--surface); box-shadow: var(--shadow); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; font-size: 15px; color: var(--text); outline: none; }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search kbd { font: 500 11px/1 var(--font); padding: 3px 6px; border: 1px solid var(--line-strong); border-radius: 5px; color: var(--muted); }
.search:focus-within kbd { display: none; }
.search-spacer { flex: 1; }
.top-right { position: relative; margin-left: auto; display: flex; align-items: center; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #6366f1, #06b6d4); color: #fff;
  font: 600 14px/1 var(--font); letter-spacing: .02em;
  box-shadow: 0 0 0 3px var(--bg);
}
.avatar:hover { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--line-strong); }
.avatar-lg { width: 64px; height: 64px; font-size: 24px; cursor: default; }

/* Bočný panel */
.sidebar {
  grid-area: side;
  display: flex;
  flex-direction: column;
  padding: 4px 12px 12px;
  overflow-y: auto;
  min-height: 0;
}
.side-gap { height: 8px; }
.new-wrap { position: relative; margin: 4px 0 16px; }
.btn-new {
  display: inline-flex; align-items: center; gap: 12px;
  height: 56px; padding: 0 24px 0 18px;
  background: var(--surface); color: var(--text);
  border: 0; border-radius: 16px; cursor: pointer;
  font: 500 15px/1 var(--font);
  box-shadow: var(--shadow);
  transition: box-shadow .15s, background .15s;
}
.btn-new:hover { box-shadow: var(--shadow-lg); background: var(--surface-2); }
.btn-new .ic { width: 24px; height: 24px; color: var(--primary); }

.side-nav { display: flex; flex-direction: column; gap: 1px; }
.side-nav a {
  display: flex; align-items: center; gap: 14px;
  height: 36px; padding: 0 16px; border-radius: 999px;
  color: var(--text-2); font-weight: 500;
}
.side-nav a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-nav a:hover { background: var(--hover); text-decoration: none; }
.side-nav a.is-active { background: var(--selected); color: var(--selected-ink); font-weight: 600; }
.side-nav a .ic { width: 20px; height: 20px; color: var(--muted); }
.side-nav a.is-active .ic { color: var(--selected-ink); }
.side-label { margin: 18px 16px 6px; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* Zoznam priečinkov v bočnom paneli – zbalený náhľad, ktorý sa stráca do stratena */
.side-toggle {
  display: flex; align-items: center; gap: 8px; width: calc(100% - 16px); margin: 14px 8px 4px; padding: 6px 8px;
  border: 0; border-radius: 8px; background: none; font-family: var(--font); text-align: left; cursor: pointer;
}
.side-toggle:hover { background: var(--hover); color: var(--text); }
.side-toggle .ic { width: 18px; height: 18px; margin-left: auto; transition: transform .2s; }
.side-toggle[aria-expanded=true] .ic { transform: rotate(180deg); }
.side-count { padding: 1px 7px; border-radius: 99px; background: var(--surface-3); font-size: 11px; letter-spacing: 0; color: var(--text-2); }
.side-folders { display: flex; flex-direction: column; gap: 1px; }
.side-folders.is-collapsible {
  max-height: 168px; overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 45%, transparent 100%);
          mask-image: linear-gradient(to bottom, #000 45%, transparent 100%);
  transition: max-height .25s ease;
}
.side-folders.is-collapsible.is-open {
  max-height: min(55vh, 440px); overflow-y: auto; overscroll-behavior: contain;
  -webkit-mask-image: none; mask-image: none;
  padding: 4px 0; border-radius: 12px; background: var(--surface-2);
}
.side-folders a { flex: none; }
.side-folders::-webkit-scrollbar { width: 6px; }
.side-folders::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; }
.side-folders { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.side-filter {
  position: sticky; top: -4px; z-index: 1; display: flex; align-items: center; gap: 8px;
  margin: 0 6px 4px; padding: 0 10px; height: 34px; border-radius: 9px; background: var(--surface); color: var(--muted);
  border: 1px solid var(--line);
}
.side-folders:not(.is-open) .side-filter { display: none; }
.side-filter .ic { width: 16px; height: 16px; }
.side-filter input { flex: 1; min-width: 0; border: 0; background: none; font: 400 13px/1 var(--font); color: var(--text); outline: none; }
.side-more {
  align-self: flex-start; margin: 2px 0 0 52px; padding: 4px 8px; border: 0; border-radius: 6px; background: none;
  font: 500 12.5px/1.2 var(--font); color: var(--primary); cursor: pointer;
}
.side-more:hover { background: var(--primary-soft); }

.storage { margin: 20px 8px 0; padding: 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.storage-label { display: flex; align-items: center; gap: 8px; font-weight: 500; margin-bottom: 10px; }
.storage-label .ic { color: var(--muted); }
.meter { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; margin-bottom: 6px; }
.meter > i { display: block; height: 100%; border-radius: 99px; background: var(--primary); }
.meter.is-full > i { background: var(--danger); }
.side-foot { margin-top: auto; padding: 18px 16px 4px; font-size: 12px; color: var(--muted); }

.scrim { display: none; }

/* Hlavný obsah */
.main {
  grid-area: main;
  position: relative;
  min-height: 0;
  overflow-y: auto;
  margin: 0 16px 16px 0;
  padding: 20px 28px 40px;
  background: var(--surface);
  border-radius: 20px;
}

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; min-height: 44px; }
.page-title { font-size: 24px; font-weight: 600; margin: 0; line-height: 1.25; }
.page-sub { margin: 4px 0 0; }
.back-link { margin: -4px 0 16px; }

/* ------------------------------------------------------------------ Tlačidlá a formuláre */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 18px;
  font: 500 14px/1 var(--font); color: var(--text); white-space: nowrap; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { background: var(--surface-3); }
.btn .ic { width: 18px; height: 18px; }
.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn-primary:hover { background: var(--primary-hover); box-shadow: var(--shadow-sm); }
.btn-danger { color: var(--danger); border-color: var(--line-strong); }
.btn-danger:hover { background: var(--danger-soft); border-color: transparent; }
.btn-danger-fill { background: var(--danger) !important; color: #fff !important; }
.btn-text { background: transparent; border-color: transparent; color: var(--primary); }
.btn-text:hover { background: var(--primary-soft); }
.btn-sm { height: 32px; padding: 0 14px; font-size: 13px; }
.btn-lg { height: 46px; font-size: 15px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: none; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.icon-btn:active { background: var(--press); }

.chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 14px;
  font: 500 13.5px/1 var(--font); color: var(--text-2); white-space: nowrap; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 9px;
}
.chip:hover { background: var(--surface-2); }
.chip .ic { width: 18px; height: 18px; }
.chip-primary { background: var(--primary-soft); color: var(--primary-soft-ink); border-color: transparent; }
.chip-primary:hover { background: var(--selected); }
.chip-danger { color: var(--danger); }
.chip-danger:hover { background: var(--danger-soft); border-color: transparent; }

.form { display: grid; gap: 16px; }
.form label, .field { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.form label.check { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 400; color: var(--text); cursor: pointer; }
.form label.indent { padding-left: 28px; }
.sub-mark { color: var(--muted); margin: 0 6px 0 4px; }
.form-sub { margin: 18px 0 0; font-size: 15px; font-weight: 600; }
.check-row { display: flex; flex-wrap: wrap; gap: 6px 18px; }
input[type=text], input[type=password], input[type=email], input[type=number], select {
  width: 100%; height: 42px; padding: 0 14px;
  font: 400 14px/1 var(--font); color: var(--text);
  background: var(--input-bg); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  outline: none; transition: border-color .12s, box-shadow .12s;
}
input[type=text]:focus, input[type=password]:focus, input[type=email]:focus, input[type=number]:focus, select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}
select { cursor: pointer; padding-right: 32px; }
.select-sm { height: 36px; width: auto; border-radius: 9px; font-size: 13.5px; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; margin: 0; accent-color: var(--primary); cursor: pointer; }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; }
.input-row > .muted { align-self: center; white-space: nowrap; }

.flash { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13.5px; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.flash .ic { width: 18px; height: 18px; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; padding: 2px 9px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge .ic { width: 14px; height: 14px; }
.badge-ok, .badge-up { background: var(--ok-soft); color: var(--ok); }
.badge-danger, .badge-del { background: var(--danger-soft); color: var(--danger); }

/* ------------------------------------------------------------------ Karty a tabuľky (administrácia) */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 20px; }
.card.narrow { max-width: 480px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.danger-zone { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }

.table-wrap { overflow-x: auto; margin: 0 -8px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th { text-align: left; font-weight: 500; font-size: 12.5px; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.is-off td { opacity: .5; }
table.perms th:not(:first-child), table.perms td:not(:first-child) { text-align: center; width: 84px; }
table.perms td:first-child { min-width: 170px; }
table.log .detail { word-break: break-word; max-width: 440px; color: var(--text-2); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters select { width: auto; }
.pager { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 18px; }
.pager a, .pager strong { min-width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; padding: 0 8px; }
.pager a:hover { background: var(--hover); text-decoration: none; }
.pager strong { background: var(--selected); color: var(--selected-ink); }

/* ------------------------------------------------------------------ Domov */
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-top: 8px; }
.folder-card {
  display: flex; gap: 14px; padding: 18px; color: var(--text);
  background: var(--surface-2); border: 1px solid transparent; border-radius: var(--radius);
  transition: background .15s, box-shadow .15s, transform .15s;
}
.folder-card:hover { text-decoration: none; background: var(--surface); border-color: var(--line); box-shadow: var(--shadow); transform: translateY(-1px); }
.folder-card-ic { width: 44px; height: 44px; flex: none; display: flex; align-items: center; justify-content: center; border-radius: 12px; background: var(--primary-soft); color: var(--primary); }
.folder-card-ic .ic { width: 24px; height: 24px; }
.folder-card-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.folder-name { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-desc { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-meta { color: var(--text-2); font-size: 12.5px; margin-top: 6px; }
.folder-users { display: flex; align-items: flex-start; gap: 6px; color: var(--text-2); font-size: 12.5px; line-height: 1.4; margin-top: 4px; }
.folder-users .ic { width: 16px; height: 16px; margin-top: 1px; color: var(--muted); }
.folder-users > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-meta.one-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

/* ------------------------------------------------------------------ Prehliadanie priečinka */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-size: 22px; font-weight: 500; min-width: 0; }
.crumbs a { color: var(--text-2); padding: 4px 10px; border-radius: 10px; }
.crumbs a:hover { background: var(--hover); text-decoration: none; color: var(--text); }
.crumbs a:last-child { color: var(--text); font-weight: 600; }
.crumbs a:first-child { margin-left: -10px; }
.crumb-sep { width: 20px; height: 20px; color: var(--muted); }
.head-tools { display: flex; gap: 10px; align-items: center; }
.folder-desc-line { margin: -4px 0 12px; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; }
.seg button { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 34px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button:hover { background: var(--hover); }
.seg button[aria-pressed=true] { background: var(--selected); color: var(--selected-ink); }
.seg .ic { width: 18px; height: 18px; }

/* Lišta akcií – mení sa na lištu výberu */
.actionbar { position: sticky; top: 0; z-index: 5; margin: 0 -12px 8px; padding: 8px 12px; background: var(--surface); }
.ab-default, .ab-select { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 42px; }
.ab-info { margin-left: auto; color: var(--muted); font-size: 13px; }
.ab-select { display: none; padding: 3px 8px 3px 4px; background: var(--surface-3); border-radius: 999px; }
.has-selection .ab-default { display: none; }
.has-selection .ab-select { display: flex; }
.ab-select .icon-btn { width: 36px; height: 36px; }
.sel-info { font-weight: 500; }
.ab-spacer { flex: 1; }
.ab-select .chip { background: transparent; border-color: transparent; }
.ab-select .chip:hover { background: var(--hover); }

/* Položky – spoločné */
.files { --cols: 40px 44px minmax(0, 1fr) 150px 100px 48px; }
.item { position: relative; cursor: default; user-select: none; -webkit-user-select: none; }
.item .name { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .name:hover { text-decoration: none; }
.item a.name:hover { text-decoration: underline; }
.i-check { display: flex; align-items: center; justify-content: center; }
.i-check input { opacity: 0; transition: opacity .1s; }
.item:hover .i-check input, .files.selecting .i-check input, .i-check input:checked, .files-head .i-check input { opacity: 1; }
@media (hover: none) { .i-check input { opacity: 1; } }
.i-thumb { position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--c-file); }
.i-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.i-thumb.js-open { cursor: pointer; }
/* Náhľad videa: ▶ v strede, aby sa nepletlo s fotkou */
.kind-video .i-thumb:has(img)::after {
  content: ''; position: absolute; z-index: 2; left: 50%; top: 50%; width: 36%; max-width: 46px; aspect-ratio: 1;
  transform: translate(-50%, -50%); border-radius: 50%; pointer-events: none;
  background: rgba(0, 0, 0, .55) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='M8 5.5v13l10.5-6.5z'/%3E%3C/svg%3E") 58% 50% / 52% no-repeat;
}
.i-date, .i-size { color: var(--muted); font-size: 13px; white-space: nowrap; }
.i-act { display: flex; justify-content: flex-end; }
.i-act .icon-btn { width: 36px; height: 36px; opacity: 0; }
.item:hover .i-act .icon-btn, .i-act .icon-btn:focus-visible { opacity: 1; }
@media (hover: none) { .i-act .icon-btn { opacity: 1; } }
.name-ic { width: 20px; height: 20px; flex: none; }

.kind-dir     { --kc: var(--c-folder); }
.kind-image   { --kc: var(--c-image); }
.kind-video   { --kc: var(--c-video); }
.kind-audio   { --kc: var(--c-audio); }
.kind-archive { --kc: var(--c-archive); }
.kind-doc     { --kc: var(--c-doc); }
.kind-file    { --kc: var(--c-file); }
.item .kind-ic, .item .name-ic { color: var(--kc); }

.play-badge { position: absolute; z-index: 2; display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; pointer-events: none; }
.play-badge .ic { width: 22px; height: 22px; }

/* Zoznam */
.view-list .files-head, .view-list .item {
  display: grid; grid-template-columns: var(--cols); align-items: center; column-gap: 4px;
}
.view-list .files-head { height: 40px; border-bottom: 1px solid var(--line); position: sticky; top: 58px; z-index: 4; background: var(--surface); }
.view-list .item { height: 52px; border-bottom: 1px solid var(--line); border-radius: 0; }
.view-list .item:hover { background: var(--surface-2); }
.view-list .item.is-selected { background: var(--selected); border-bottom-color: transparent; }
.view-list .item.is-selected .name, .view-list .item.is-selected .i-date, .view-list .item.is-selected .i-size { color: var(--selected-ink); }
.view-list .i-thumb { width: 36px; height: 36px; border-radius: 8px; }
.view-list .item:not(.kind-image) .i-thumb { background: transparent; }
.view-list .kind-image .i-thumb { background: var(--thumb-bg); }
.view-list .i-thumb .kind-ic { width: 24px; height: 24px; }
.view-list .play-badge { display: none; }
.view-list .name-ic { display: none; }
.view-list .i-name { display: flex; align-items: center; min-width: 0; padding-right: 8px; }
.view-list .i-size { text-align: right; padding-right: 8px; }
.sort-h { display: flex; align-items: center; gap: 4px; height: 30px; padding: 0 8px; margin-left: -8px; border: 0; border-radius: 8px; background: none; font: 500 12.5px/1 var(--font); color: var(--muted); cursor: pointer; justify-self: start; }
.sort-h.i-size { justify-self: end; margin: 0; }
.sort-h:hover { background: var(--hover); color: var(--text); }
.sort-h.is-sorted { color: var(--text); }
.sort-h.is-sorted::after { content: '↑'; font-size: 13px; }
.sort-h.is-sorted[data-dir=desc]::after { content: '↓'; }

/* Mriežka */
.view-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; align-items: start; }
.view-grid .files-head { display: none; }
.view-grid .item.first-file { grid-column-start: 1; }
.view-grid .item {
  display: flex; flex-direction: column;
  padding: 0 8px 8px; border-radius: var(--radius);
  background: var(--surface-2); transition: background .12s, box-shadow .12s;
}
.view-grid .item:hover { background: var(--surface-3); }
.view-grid .item.is-selected { background: var(--selected); }
.view-grid .i-name { order: 1; display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 4px 0 6px; min-width: 0; }
.view-grid .item.is-selected .name { color: var(--selected-ink); }
.view-grid .i-thumb { order: 2; aspect-ratio: 4 / 3; border-radius: 10px; background: var(--surface); }
.view-grid .i-thumb .kind-ic { width: 56px; height: 56px; opacity: .9; }
.view-grid .i-date, .view-grid .i-size { display: none; }
.view-grid .i-act { position: absolute; top: 5px; right: 4px; }
.view-grid .item:hover .i-name { padding-right: 40px; }
.view-grid .i-check { position: absolute; top: 14px; left: 14px; z-index: 3; }
.view-grid .item:hover .name-ic, .view-grid.selecting .name-ic, .view-grid .item.is-selected .name-ic { visibility: hidden; }
.view-grid .item.is-dir { padding-bottom: 0; }
.view-grid .item.is-dir .i-thumb { display: none; }
.view-grid .item.is-dir .i-name { height: 52px; }
.view-grid .item.is-dir .i-check { top: 17px; }

/* Prázdny stav */
.empty { text-align: center; padding: 64px 20px; max-width: 520px; margin: 0 auto; }
.empty-sm { padding: 40px 20px; }
.empty-ic { width: 88px; height: 88px; margin: 0 auto 18px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--primary-soft); color: var(--primary); }
.empty-ic .ic { width: 42px; height: 42px; }
.empty h2 { font-size: 18px; margin-bottom: 6px; }

/* Pretiahnutie súborov */
.dropover {
  position: fixed; z-index: 30; inset: var(--top-h) 16px 16px var(--side-w);
  display: none; align-items: center; justify-content: center;
  border: 2px dashed var(--primary); border-radius: 20px;
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  backdrop-filter: blur(2px); pointer-events: none;
}
.dropover.is-on { display: flex; }
.dropover-box { display: flex; align-items: center; gap: 16px; padding: 18px 26px; border-radius: 16px; background: var(--primary); color: var(--primary-ink); font-size: 16px; font-weight: 600; box-shadow: var(--shadow-lg); }
.dropover-box span { font-weight: 400; font-size: 13.5px; opacity: .9; }
.dropover-box .ic { width: 36px; height: 36px; }

/* ------------------------------------------------------------------ Panel nahrávania */
.upl {
  position: fixed; z-index: 40; right: 24px; bottom: 0; width: 380px; max-width: calc(100vw - 24px);
  background: var(--surface); border-radius: 14px 14px 0 0; box-shadow: var(--shadow-lg); overflow: hidden;
  border: 1px solid var(--line); border-bottom: 0;
}
.upl-head { display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 18px; background: var(--surface-2); }
.upl-title { flex: 1; font-weight: 600; font-size: 14.5px; }
.upl-head .icon-btn { width: 36px; height: 36px; }
.upl.is-min .upl-toggle .ic { transform: rotate(180deg); }
.upl-eta { font-size: 12.5px; color: var(--muted); white-space: nowrap; display: none; }
.upl.is-min .upl-eta { display: inline; }
.upl-bar { height: 3px; background: var(--line); }
.upl-bar i { display: block; height: 100%; width: 0; background: var(--primary); transition: width .3s; }
.upl-sub { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 8px; padding: 8px 18px; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--line); }
.upl-list { max-height: 300px; overflow-y: auto; }
.upl.is-min .upl-list, .upl.is-min .upl-sub { display: none; }
.up-item { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 4px 12px; padding: 10px 18px; font-size: 13.5px; }
.up-item + .up-item { border-top: 1px solid var(--line); }
.up-item > .ic { width: 20px; height: 20px; color: var(--muted); }
.up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-status { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.up-bar { grid-column: 2 / -1; height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.up-bar > i { display: block; height: 100%; width: 0; border-radius: 4px; background: var(--primary); transition: width .2s; }
.up-item.is-done .up-bar { display: none; }
.up-item.is-done .up-status { color: var(--ok); }
.up-item.is-done > .ic { color: var(--ok); }
.up-item.is-error .up-bar > i { background: var(--danger); width: 100% !important; }
.up-item.is-error .up-status { color: var(--danger); white-space: normal; grid-column: 2 / -1; }

/* ------------------------------------------------------------------ Prehliadač fotiek a videí */
.lightbox { position: fixed; inset: 0; z-index: 60; display: none; flex-direction: column; background: rgba(8, 10, 14, .96); color: #fff; }
.lightbox.is-open { display: flex; animation: fade .15s ease; }
.lb-top { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 20px; }
.lb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.lb-count { color: rgba(255, 255, 255, .6); font-size: 13px; margin-right: 8px; }
.lightbox .icon-btn { color: #fff; }
.lightbox .icon-btn:hover { background: rgba(255, 255, 255, .12); }
.lightbox .btn { background: rgba(255, 255, 255, .1); border-color: transparent; color: #fff; }
.lightbox .btn:hover { background: rgba(255, 255, 255, .2); }
.lightbox .btn-primary { background: #fff; color: #111; }
.lightbox .btn-primary:hover { background: #e6e6e6; }
.lb-sel.is-on { background: #6ea2ff !important; color: #0a1d3f !important; }
.lb-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; position: relative; padding: 0 72px 20px; }
.lb-stage img, .lb-stage video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
.lb-stage audio { width: min(600px, 100%); }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 52px; height: 52px; border: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; color: #fff; background: rgba(255, 255, 255, .1); }
.lb-nav:hover { background: rgba(255, 255, 255, .22); }
.lb-nav .ic { width: 30px; height: 30px; }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }

/* ------------------------------------------------------------------ Menu, dialóg, notifikácie */
.menu {
  position: absolute; z-index: 50; min-width: 240px; padding: 6px 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg);
  animation: pop .12s ease;
}
.menu form { margin: 0; }
.menu-item {
  display: flex; align-items: center; gap: 14px; width: 100%; height: 40px; padding: 0 18px;
  border: 0; background: none; font: 400 14px/1 var(--font); color: var(--text); text-align: left; cursor: pointer;
}
.menu-item:hover { background: var(--hover); text-decoration: none; }
.menu-item .ic { color: var(--muted); }
.new-menu { top: 0; left: 0; }
.user-menu { top: 46px; right: 0; width: 300px; }
.user-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 18px 16px 16px; border-bottom: 1px solid var(--line); margin-bottom: 6px; text-align: center; }
.user-card .avatar { margin-bottom: 8px; box-shadow: none; }
.user-card strong { font-size: 15px; }

.dialog {
  width: min(420px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 20px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgba(10, 14, 22, .45); }
.dialog[open] { animation: pop .15s ease; }
.dialog form { padding: 24px; display: grid; gap: 12px; }
.dlg-title { margin: 0; font-size: 19px; font-weight: 600; }
.dlg-msg { margin: 0; color: var(--text-2); white-space: pre-line; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.dialog-wide { width: min(560px, calc(100vw - 32px)); }
.del-list { display: grid; gap: 6px; max-height: 320px; overflow-y: auto; margin: 2px 0; }
.del-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; }
.del-item:hover { background: var(--surface-2); }
.del-item.is-checked { border-color: var(--danger); background: var(--danger-soft); }
.del-item input { margin-top: 2px; }
.del-ic { color: var(--c-folder); }
.del-body { display: grid; gap: 2px; min-width: 0; }
.del-warn { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--danger); }
.del-warn .ic { width: 15px; height: 15px; }

.toasts { position: fixed; z-index: 70; left: 24px; bottom: 24px; display: grid; gap: 8px; max-width: calc(100vw - 48px); }
.toast {
  display: flex; align-items: center; gap: 12px; min-width: 280px; max-width: 480px; padding: 13px 18px;
  background: #1f2328; color: #f3f4f6; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 14px;
  animation: slide-up .2s ease; transition: opacity .3s, transform .3s; cursor: pointer;
}
.toast .ic { width: 20px; height: 20px; color: #6ee7a8; }
.toast-error .ic { color: #ff8a85; }
.toast.is-hiding { opacity: 0; transform: translateY(8px); }
@media (prefers-color-scheme: dark) { .toast { background: #e6e8ec; color: #111318; } .toast .ic { color: #18794e; } .toast-error .ic { color: #c62828; } }

@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(-4px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes slide-up { from { opacity: 0; transform: translateY(12px); } }

/* ------------------------------------------------------------------ Prihlásenie a inštalácia */
.bare-main { min-height: 100vh; min-height: 100dvh; }
.auth { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card {
  width: 100%; max-width: 420px; display: grid; gap: 16px;
  padding: 40px 36px 36px; background: var(--surface); border-radius: 24px; box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
}
.auth-brand { display: flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 600; letter-spacing: -.02em; margin-bottom: 4px; }
.auth-card h1 { margin: 6px 0 0; font-size: 26px; font-weight: 600; }
.auth-card > p { margin: -8px 0 4px; }
.auth-card .btn { margin-top: 6px; }
.auth-foot { margin-top: 20px; color: var(--muted); font-size: 12.5px; }
.lang-item:hover { background: none; }
.lang-switch { display: inline-flex; gap: 8px; align-items: center; }
.lang-switch a, .lang-switch strong { padding: 2px 6px; border-radius: 6px; }
.lang-switch a { color: var(--muted); }
.lang-switch a:hover { background: var(--hover); color: inherit; text-decoration: none; }
.lang-switch .lang-on { background: var(--hover); }
.auth-lang { margin-top: 10px; font-size: 13px; }
.is-bare { background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--primary) 14%, transparent), transparent), radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, #06b6d4 14%, transparent), transparent), var(--bg); }

.install { max-width: 1100px; margin: 0 auto; padding: 40px 24px; }
.install-title { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }

/* ------------------------------------------------------------------ Mobil a tablet */
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .files { --cols: 40px 44px minmax(0, 1fr) 100px 48px; }
  .view-list .i-date { display: none; }
}

@media (max-width: 860px) {
  :root { --side-w: 280px; }
  .app { grid-template: "top" var(--top-h) "main" minmax(0, 1fr) / minmax(0, 1fr); }
  .nav-toggle { display: inline-flex; }
  .brand { width: auto; padding-left: 0; }
  .sidebar {
    position: fixed; z-index: 45; top: 0; bottom: 0; left: 0; width: var(--side-w);
    padding-top: 16px; background: var(--bg); box-shadow: var(--shadow-lg);
    transform: translateX(-105%); transition: transform .2s ease;
  }
  .nav-open .sidebar { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 44; background: rgba(10, 14, 22, .4); }
  .main { margin: 0 8px 8px; padding: 16px 16px 32px; border-radius: 16px; }
  .dropover { inset: var(--top-h) 8px 8px 8px; }
  .search kbd { display: none; }
}

@media (max-width: 600px) {
  .topbar { gap: 6px; padding: 0 8px 0 4px; }
  .brand-name { display: none; }
  .search { height: 42px; padding: 0 12px; }
  .search input { font-size: 16px; text-overflow: ellipsis; }
  .top-right { flex: none; }
  .main { margin: 0; border-radius: 0; padding: 14px 14px 32px; }
  .crumbs { font-size: 19px; }
  .page-title { font-size: 21px; }
  .files { --cols: 34px 40px minmax(0, 1fr) 76px 40px; }
  .view-list .i-size { font-size: 12px; padding-right: 0; }
  .view-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .view-grid .item { padding: 0 6px 6px; }
  .ab-default { flex-wrap: nowrap; gap: 6px; }
  .ab-default .chip { width: 38px; height: 38px; padding: 0; justify-content: center; flex: none; }
  .ab-default .chip .ic { width: 20px; height: 20px; }
  .ext-badge { flex: none; }
  .chip-txt { display: none; }
  .ab-select { flex-wrap: wrap; gap: 8px 6px; padding: 10px 12px 12px 6px; border-radius: 14px; }
  .ab-select .icon-btn { width: 34px; height: 34px; }
  .sel-info { flex: 1 1 calc(100% - 44px); min-width: 0; font-size: 13.5px; line-height: 1.35; }
  .ab-select .ab-spacer { display: none; }
  .ab-select .chip { flex: 1; justify-content: center; height: 38px; margin-left: 6px; background: var(--surface); border-color: var(--line-strong); }
  .ab-select .chip + .chip { margin-left: 0; }
  .ab-select .chip-danger { border-color: transparent; background: var(--danger-soft); }
  .ab-info { min-width: 0; margin-left: auto; padding-left: 6px; font-size: 12px; line-height: 1.3; text-align: right; }
  .lb-stage { padding: 0 0 12px; }
  .lb-nav { background: rgba(0, 0, 0, .45); }
  .lb-sel span, .lb-dl span { display: none; }
  .upl { right: 0; width: 100%; max-width: 100%; }
  /* Aktivita: riadky v jednom riadku, dlhé sa posúvajú do strany (namiesto lámania po písmenách). */
  table.log td { white-space: nowrap; padding: 9px 8px; }
  table.log .detail { max-width: none; word-break: normal; }
  .filters select { flex: 1 1 100%; min-width: 0; }
  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { min-width: 0; }
  .auth-card { padding: 32px 22px 26px; }
}

/* Živé hľadanie v zozname (admin → Používatelia) */
.list-search { margin: 4px 0 14px; }
.list-search-box {
  display: flex; align-items: center; gap: 10px; max-width: 420px; height: 44px; padding: 0 14px;
  background: var(--surface-3); border: 1px solid transparent; border-radius: 999px; color: var(--muted);
  cursor: text; transition: background .15s, border-color .15s, box-shadow .15s;
}
.list-search-box:hover { background: var(--hover); }
.list-search-box:focus-within { background: var(--surface); border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.list-search-box .ic { width: 20px; height: 20px; flex: none; }
.list-search-box input {
  flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; outline: none;
  font: 400 15px/1 var(--font); color: var(--text);
}
.list-search-box input::placeholder { color: var(--muted); }
.list-search-box input::-webkit-search-cancel-button { cursor: pointer; }
.list-search-spin {
  width: 16px; height: 16px; flex: none; border-radius: 50%; border: 2px solid var(--line-strong);
  border-top-color: var(--primary); opacity: 0; transition: opacity .15s;
}
.list-search.is-loading .list-search-spin { opacity: 1; animation: list-spin .7s linear infinite; }
@keyframes list-spin { to { transform: rotate(360deg); } }
.list-search-count { margin: -6px 0 10px 16px; }
#users-list { transition: opacity .15s; }
.list-search.is-loading + #users-list { opacity: .55; }
@media (max-width: 640px) { .list-search-box { max-width: none; } }
