:root {
  --bg: #0b0f14; --panel: #11161d; --panel2: #161c25; --line: #232b36;
  --text: #e8edf3; --muted: #9aa7b6; --accent: #00bceb; --accent-ink: #00212b;
  --ok: #34d399; --warn: #fbbf24; --bad: #f87171; --radius: 14px; --side: 264px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: radial-gradient(900px 420px at 85% -10%, rgba(0,188,235,.10), transparent 60%), var(--bg);
       color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.ic { width: 20px; height: 20px; flex: none; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login form { width: min(380px, 100%); padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.err { margin: 0; min-height: 1.3em; color: var(--bad); font-size: 13px; }
.hint { margin: 0; color: var(--muted); font-size: 13px; }

/* Layout */
.app { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 8px; padding: 16px 12px;
           background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; }
.main { min-width: 0; display: flex; flex-direction: column; }
.content { width: 100%; max-width: 1240px; margin: 0 auto; padding: 28px; outline: none; }

/* Sidebar */
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 14px; }
.brand svg { width: 36px; height: 36px; flex: none; }
.brand-text { font-weight: 650; letter-spacing: .01em; line-height: 1.15; }
.brand-text small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
nav { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.nav-title { margin: 0 12px 6px; font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.nav-item { position: relative; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px; color: var(--muted); }
.nav-item:hover { background: var(--panel2); color: var(--text); }
.nav-item[aria-current="page"] { background: rgba(0,188,235,.12); color: var(--text); }
.nav-item[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-item[aria-current="page"] .ic { color: var(--accent); }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill, .tag { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); }
.tag { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.side-foot { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel2); font-size: 13px; color: var(--muted); }
.side-foot strong { color: var(--text); }
.meter { height: 6px; border-radius: 99px; background: #1f2732; overflow: hidden; margin-top: 8px; }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #5eead4); border-radius: inherit; }

/* Topbar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 14px 28px;
          background: rgba(11,15,20,.82); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 20px; font-weight: 650; white-space: nowrap; flex: 1; min-width: 0; }
.search { position: relative; flex: 1; max-width: 420px; }
.search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { width: 100%; height: 44px; padding: 0 14px 0 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); }
.search input::placeholder { color: var(--muted); }
.icon-btn.menu-btn { display: none; }

/* Buttons and fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border: 0; border-radius: 12px;
       background: var(--accent); color: var(--accent-ink); font-weight: 650; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: default; filter: none; }
.btn.ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--line); font-weight: 550; }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; vertical-align: middle; border-radius: 10px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover:not(:disabled) { background: var(--panel2); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.del:hover:not(:disabled) { color: var(--bad); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field input, .field select { height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
select option { background: var(--panel); }

/* Cards and stats */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { padding: 18px 20px; }
.stat p { margin: 0; color: var(--muted); font-size: 13px; }
.stat strong { display: block; margin-top: 4px; font-size: 28px; font-weight: 650; letter-spacing: -.01em; }
.stat small { color: var(--muted); }

.drop { display: flex; align-items: center; gap: 16px; padding: 20px; margin-bottom: 20px; border: 1.5px dashed #34414f; border-radius: var(--radius); background: rgba(17,22,29,.6); flex-wrap: wrap; }
.drop.over { border-color: var(--accent); background: rgba(0,188,235,.08); }
.drop .ic-wrap { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 12px; background: rgba(0,188,235,.12); color: var(--accent); }
.drop .txt { flex: 1; min-width: 220px; }
.drop .txt strong { display: block; }
.drop .txt span { color: var(--muted); font-size: 13px; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.chip { height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; }
.chip[aria-pressed="true"] { background: rgba(0,188,235,.14); border-color: rgba(0,188,235,.5); color: var(--text); }
.count { margin-left: auto; color: var(--muted); font-size: 13px; }

/* Table */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 16px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,.02); }
.ord { width: 48px; color: var(--muted); font-variant-numeric: tabular-nums; }
.vid { display: flex; align-items: center; gap: 14px; min-width: 220px; }
.thumb { width: 96px; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; flex: none; position: relative;
         background: linear-gradient(135deg, #0b2a36, #101826); display: grid; place-items: center; color: #4b6272; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.vtxt { min-width: 0; }
.vtxt strong { display: block; font-weight: 600; overflow-wrap: anywhere; }
.meta-m { display: none; color: var(--muted); font-size: 13px; }
.m-status { display: none; }
.chip-s { padding: 2px 10px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); font-size: 13px; white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; white-space: nowrap; }
.status i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.status.checking i { background: var(--warn); }
.status.error i { background: var(--bad); }
.upl { min-width: 130px; font-size: 13px; color: var(--muted); }
.errtext { color: var(--bad); font-size: 13px; white-space: normal; }
.actions { white-space: nowrap; text-align: right; }

/* Folders, empty states */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.fcard { padding: 20px; display: flex; flex-direction: column; gap: 6px; }
.fcard .ic-wrap { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: rgba(0,188,235,.12); color: var(--accent); margin-bottom: 8px; }
.fcard strong { font-size: 17px; overflow-wrap: anywhere; }
.fcard > span { color: var(--muted); font-size: 13px; }
.fcard .row { display: flex; gap: 4px; margin: 8px 0 0 -8px; }
.fcard.new { border-style: dashed; background: transparent; color: var(--muted); align-items: center; justify-content: center; min-height: 150px; cursor: pointer; font: inherit; }
.fcard.new:hover { color: var(--text); border-color: var(--accent); }
.empty { display: grid; place-items: center; text-align: center; gap: 8px; padding: 72px 24px; color: var(--muted); }
.empty .ic-wrap { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 16px; background: var(--panel2); color: var(--accent); }
.empty h2 { margin: 8px 0 0; color: var(--text); font-size: 20px; }
.empty p { margin: 0; max-width: 44ch; }

/* Dialogs */
dialog.sheet { position: fixed; inset: 0 0 0 auto; margin: 0; height: 100%; max-height: 100%; width: min(440px, 100%); padding: 0;
               border: 0; border-left: 1px solid var(--line); background: var(--panel); color: var(--text); }
dialog.sheet.small { inset: 0; margin: auto; height: auto; max-height: calc(100% - 32px); border: 1px solid var(--line); border-radius: var(--radius); width: min(420px, calc(100% - 32px)); }
dialog.sheet::backdrop { background: rgba(3,6,9,.6); backdrop-filter: blur(3px); }
.sheet form { display: flex; flex-direction: column; height: 100%; }
.sheet header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.sheet h2 { margin: 0; font-size: 18px; }
.sheet .body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.sheet footer { display: flex; gap: 12px; justify-content: flex-end; padding: 16px 20px; border-top: 1px solid var(--line); }
.preview { aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; position: relative; background: linear-gradient(135deg, #0b2a36, #101826); display: grid; place-items: center; color: #4b6272; }
.preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.scrim { display: none; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; display: flex; align-items: center; gap: 16px;
         padding: 12px 16px; border-radius: 12px; background: #1c2430; border: 1px solid #2f3b4a; box-shadow: 0 10px 30px rgba(0,0,0,.45); max-width: calc(100vw - 32px); }

/* Tablet and below: fewer columns, details move under the title */
@media (max-width: 1099px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .c-folder, .c-dur, .c-size, th.c-folder, th.c-dur, th.c-size { display: none; }
  .meta-m { display: block; }
}
/* Tablet: icon rail */
@media (min-width: 768px) and (max-width: 1099px) {
  .app { grid-template-columns: 72px minmax(0, 1fr); }
  .brand { justify-content: center; padding-inline: 0; }
  .brand-text, .nav-label, .nav-title, .pill, .tag, .side-foot { display: none; }
  .nav-group + .nav-group { border-top: 1px solid var(--line); padding-top: 14px; }
  .nav-item { justify-content: center; padding: 0; }
}
/* Phone: off-canvas drawer, card-style rows */
@media (max-width: 767px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 284px; z-index: 60; transform: translateX(-100%); }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.6); }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(3,6,9,.6); }
  .icon-btn.menu-btn { display: inline-grid; width: 44px; height: 44px; }
  .topbar { padding: 10px 16px; gap: 10px; flex-wrap: wrap; }
  .topbar h1 { font-size: 18px; }
  .search { order: 5; flex-basis: 100%; max-width: none; }
  .content { padding: 16px; }
  .btn { padding: 0 14px; }
  .btn .btn-label { display: none; }
  .icon-btn { width: 44px; height: 44px; }
  .c-folder, .c-dur, .c-size, .ord, th.c-folder, th.c-dur, th.c-size, th.ord, .mv { display: none; }
  .meta-m { display: block; }
  .c-status, th.c-status { display: none; }
  .m-status { display: block; margin-top: 4px; }
  .chip { min-height: 44px; }
  .thumb { width: 64px; }
  .vid { gap: 10px; min-width: 0; }
  td, th { padding: 10px 8px; }
  .count { width: 100%; margin-left: 0; }
}
@media (prefers-reduced-motion: no-preference) {
  .sidebar { transition: transform .22s ease; }
  .nav-item, .btn, .icon-btn, .chip { transition: background-color .15s, color .15s, filter .15s; }
}
