:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --hover: #e8ebf1;
  --border: #dfe2e8;
  --text: #1b1e24;
  --muted: #646b78;
  --accent: #4f6ef7;
  --accent-soft: #e3e9ff;
  --accent-text: #ffffff;
  --danger: #d63c3c;
  --ok: #1f9d55;
  --shadow: 0 8px 28px rgba(20, 24, 40, .14);
  --radius: 12px;
  --ic-model: #8b5cf6;
  --ic-audio: #e2557c;
  --ic-image: #1f9d8a;
  --ic-video: #e07b22;
  --ic-code: #3b82f6;
  --ic-place: #ca8a04;
  --ic-archive: #6b7280;
  --ic-folder: #8a93a6;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318;
    --surface: #181b22;
    --surface-2: #20242d;
    --hover: #262b35;
    --border: #2c313c;
    --text: #e8e9ed;
    --muted: #9aa0ab;
    --accent: #6f8bff;
    --accent-soft: #263055;
    --accent-text: #0d1020;
    --danger: #ff6b6b;
    --ok: #4ade80;
    --shadow: 0 10px 34px rgba(0, 0, 0, .5);
    --ic-folder: #9aa3b5;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; width: 20px; height: 20px; flex: none; }
a { color: var(--accent); }

.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface); padding: 8px 14px; border-radius: 999px; cursor: pointer; text-decoration: none; color: var(--text); font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.on { background: var(--accent-soft); color: var(--accent); }
.icon-btn.danger:hover { color: var(--danger); }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { max-width: 400px; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 40px 28px; }
.login-card h1 { font-size: 22px; margin: 16px 0 8px; }
.login-card p { color: var(--muted); margin: 0 0 24px; }
.discord { background: #5865f2 !important; border-color: #5865f2 !important; color: #fff !important; padding: 11px 20px; }
.discord svg { fill: currentColor; stroke: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; inset: 8px 7px 6px; background: #fff; clip-path: polygon(0 0, 100% 0, 50% 100%); }
.brand-mark.big { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto; }
.brand-mark.big::after { inset: 16px 14px 12px; }

.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); grid-template-rows: 60px 1fr; height: 100vh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; padding: 0 16px; background: var(--bg); }
.brand { display: flex; align-items: center; gap: 10px; width: 216px; font-size: 16px; white-space: nowrap; }
.brand b { font-weight: 700; }
.menu-btn { display: none; }
.search { flex: 1; min-width: 0; max-width: 720px; display: flex; align-items: center; gap: 10px; background: var(--surface-2); border-radius: 999px; padding: 0 16px; height: 44px; color: var(--muted); }
.search:focus-within { background: var(--surface); box-shadow: var(--shadow); }
.search input { flex: 1; border: 0; background: transparent; outline: none; color: var(--text); min-width: 0; }
.user { margin-left: auto; flex: none; display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; cursor: pointer; }
.user:hover { background: var(--hover); }
.user img { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); }

.sidebar { padding: 8px 12px 16px; overflow-y: auto; display: flex; flex-direction: column; }
.new-wrap { padding: 4px 4px 14px; }
.new-btn { padding: 12px 22px 12px 16px; border-radius: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.15); font-size: 15px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 14px; border-radius: 999px; color: var(--text); text-decoration: none; border: 0; background: transparent; cursor: pointer; text-align: left; overflow: hidden; }
.nav-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item.drop-target { outline: 2px solid var(--accent); }
.nav-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 16px 14px 6px; }
.nav-empty { color: var(--muted); font-size: 13px; padding: 4px 14px; }
.storage { margin-top: auto; padding: 16px 14px 0; color: var(--muted); font-size: 12px; }
.side-legal { padding: 6px 14px 0; font-size: 12px; color: var(--muted); }
.side-legal a { color: var(--muted); }
.legal-links { font-size: 12px; margin: 18px 0 0 !important; }
.credit-line { margin-top: 6px !important; }
.legal-links a { color: var(--muted); }
.terms-box { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); cursor: pointer; color: var(--text); }
.terms-box input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.terms-list { margin: 0 0 14px; padding-left: 20px; color: var(--muted); }
.terms-list li { margin: 4px 0; }
.scrim { display: none; }

.main { background: var(--surface); border-radius: 16px 0 0 0; display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.toolbar { display: flex; align-items: center; gap: 8px; padding: 12px 16px 8px 20px; min-height: 60px; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; font-size: 20px; min-width: 0; flex: 1; }
.crumb { border: 0; background: transparent; padding: 4px 10px; border-radius: 999px; cursor: pointer; color: var(--muted); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb:last-child { color: var(--text); }
.crumb:hover { background: var(--hover); }
.crumb.drop-target { outline: 2px solid var(--accent); }
.crumb-sep { color: var(--muted); }
.crumb-sep svg { width: 16px; height: 16px; }
.tools { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.seg { display: flex; border: 1px solid var(--border); border-radius: 999px; padding: 2px; }
.seg .icon-btn { width: 34px; height: 30px; border-radius: 999px; }
.selection-tools { display: flex; align-items: center; gap: 2px; background: var(--surface-2); border-radius: 999px; padding: 2px 4px 2px 14px; }
.selection-tools span { margin-right: 6px; font-weight: 500; white-space: nowrap; }

.content { flex: 1; overflow-y: auto; padding: 4px 20px 80px; outline: none; }
.section-title { font-size: 14px; font-weight: 600; margin: 14px 0 10px; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.folder-tile { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius); cursor: default; user-select: none; border: 2px solid transparent; min-width: 0; }
.folder-tile svg { color: var(--ic-folder); }
.folder-tile .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.file-tile { background: var(--surface-2); border-radius: var(--radius); padding: 8px; user-select: none; border: 2px solid transparent; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.file-tile .tname { display: flex; align-items: center; gap: 8px; padding: 2px 4px; font-weight: 500; min-width: 0; }
.file-tile .tname span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-tile .tname svg { width: 18px; height: 18px; }
.thumb { aspect-ratio: 4 / 3; background: var(--surface); border-radius: 8px; display: grid; place-items: center; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb svg { width: 56px; height: 56px; stroke-width: 1.4; }
.thumb .ext { font-size: 11px; font-weight: 700; letter-spacing: .05em; color: var(--muted); margin-top: -18px; }
.thumb-inner { display: grid; justify-items: center; gap: 22px; }
.item.selected { background: var(--accent-soft); border-color: var(--accent); }
.item.drop-target { border-color: var(--accent); border-style: dashed; }
.item.dragging { opacity: .5; }

.list { width: 100%; border-collapse: collapse; table-layout: fixed; }
.list th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: 8px 10px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); cursor: pointer; user-select: none; z-index: 1; }
.list th.sorted { color: var(--text); }
.list td { padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; user-select: none; }
.list tr.item { border: 0; }
.list tr.item:hover td { background: var(--hover); }
.list tr.item.selected td { background: var(--accent-soft); }
.list tr.item.drop-target td { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.list .namecell { display: flex; align-items: center; gap: 12px; overflow: hidden; }
.list .namecell span { overflow: hidden; text-overflow: ellipsis; }
.list .muted { color: var(--muted); }
.list th.c-owner { width: 160px; } .list th.c-date { width: 150px; } .list th.c-size { width: 100px; } .list th.c-lib { width: 140px; } .list th.c-more { width: 56px; }

.empty { text-align: center; padding: 72px 16px; color: var(--muted); }
.empty > svg { width: 64px; height: 64px; stroke-width: 1.2; margin-bottom: 8px; }
.empty h3 { color: var(--text); margin: 6px 0; font-size: 18px; }
.empty .btn { margin-top: 14px; }

.drop-hint { position: absolute; inset: 0; border-radius: 16px 0 0 0; background: color-mix(in srgb, var(--accent) 10%, transparent); border: 2px dashed var(--accent); display: none; place-items: center; pointer-events: none; z-index: 5; }
.drop-hint.show { display: grid; }
.drop-hint div { background: var(--accent); color: var(--accent-text); padding: 12px 20px; border-radius: 999px; display: flex; gap: 10px; align-items: center; font-weight: 600; }

.menu { position: fixed; z-index: 50; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 6px 0; min-width: 220px; }
.menu button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 16px; border: 0; background: transparent; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--hover); }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.menu svg { color: var(--muted); }
.menu button.danger svg { color: var(--danger); }

.modal-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); width: min(460px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 22px; }
.modal.wide { width: min(720px, 100%); }
.modal h2 { margin: 0 0 14px; font-size: 19px; font-weight: 600; }
.modal p { color: var(--muted); margin: 0 0 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 600; }
.field small { color: var(--muted); }
.field input, .field textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); background: var(--bg); border-radius: 10px; outline: none; }
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.lib-rows { display: grid; gap: 8px; margin-bottom: 16px; }
.lib-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; }
.lib-row .info { flex: 1; min-width: 0; }
.lib-row .info b { display: block; }
.lib-row .info small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker { border: 1px solid var(--border); border-radius: 12px; max-height: 320px; overflow: auto; }
.picker-head { display: flex; align-items: center; gap: 6px; padding: 8px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.picker-head b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-row { display: flex; align-items: center; gap: 10px; padding: 9px 14px; cursor: pointer; }
.picker-row:hover { background: var(--hover); }
.picker-row svg { color: var(--ic-folder); }
.picker-row .chev { margin-left: auto; color: var(--muted); }
.picker-empty { padding: 18px; color: var(--muted); text-align: center; }

.preview { position: fixed; inset: 0; z-index: 45; background: rgba(8,10,14,.97); display: flex; flex-direction: column; color: #e8e9ed; }
.preview-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; }
.preview-head .icon-btn { color: #c9cdd6; }
.preview-head .icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.preview-head .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.preview-body { flex: 1; min-height: 0; display: grid; place-items: center; padding: 8px 16px 24px; }
.preview-body img, .preview-body video { max-width: 100%; max-height: 100%; border-radius: 6px; }
.preview-body audio { width: min(560px, 100%); }
.preview-body pre { width: min(1000px, 100%); height: 100%; overflow: auto; margin: 0; background: #14171d; border-radius: 10px; padding: 16px; font: 13px/1.5 ui-monospace, "Cascadia Code", Consolas, monospace; color: #d7dae0; white-space: pre; tab-size: 4; }
.preview-card { text-align: center; background: #1b1f27; padding: 32px; border-radius: 16px; }
.preview-card svg { width: 72px; height: 72px; stroke-width: 1.2; }
.preview-card p { color: #9aa0ab; }
.preview-meta { color: #9aa0ab; font-size: 13px; }

.uploads { position: fixed; right: 20px; bottom: 0; width: min(380px, calc(100vw - 32px)); background: var(--surface); border-radius: 14px 14px 0 0; box-shadow: var(--shadow); z-index: 30; border: 1px solid var(--border); border-bottom: 0; }
.uploads-head { display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 16px; background: var(--surface-2); border-radius: 14px 14px 0 0; font-weight: 600; }
.uploads-head span { flex: 1; }
.uploads.collapsed .uploads-list { display: none; }
.uploads.collapsed #uploadsToggle svg { transform: rotate(180deg); }
.uploads-list { max-height: 300px; overflow-y: auto; }
.up-row { display: grid; grid-template-columns: 20px 1fr auto; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.up-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-row small { color: var(--muted); display: block; }
.up-row small.err { color: var(--danger); white-space: normal; }
.bar { height: 4px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 5px; }
.bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.up-row .done { color: var(--ok); }

.toasts { position: fixed; left: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 60; }
.toast { background: #2a2f3a; color: #fff; padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow); max-width: min(420px, calc(100vw - 40px)); animation: pop .18s ease-out; }
.toast.err { background: #8f2525; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-grid; }
  .brand { width: auto; }
  .brand span { display: none; }
  .topbar { gap: 8px; }
  .user span { display: none; }
  .user { padding: 4px; }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: 272px; background: var(--surface); z-index: 35; transform: translateX(-100%); transition: transform .2s; padding-top: 16px; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 34; }
  .main { border-radius: 0; }
  .toolbar { padding: 10px 16px 6px; }
  .content { padding: 4px 16px 80px; }
  .crumbs { font-size: 17px; flex-basis: 100%; }
  .tools { margin-left: 0; width: 100%; justify-content: flex-end; }
  #zipBtn span { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .list .c-owner, .list .c-lib { display: none; }
  .list th.c-date { width: 100px; } .list th.c-size { width: 76px; }
}
@media (max-width: 520px) {
  .list .c-date { display: none; }
}

.avatar { border-radius: 50%; object-fit: cover; background: var(--surface-2); flex: none; display: inline-grid; place-items: center; }
.avatar.xs { width: 20px; height: 20px; font-size: 10px; }
.avatar.sm { width: 26px; height: 26px; font-size: 12px; }
.avatar.md { width: 40px; height: 40px; font-size: 16px; }
.avatar-letter { background: var(--accent); color: var(--accent-text); font-weight: 700; }
.thumb { position: relative; }
.uploader-badge { position: absolute; right: 6px; bottom: 6px; border-radius: 50%; padding: 2px; background: var(--surface); box-shadow: 0 1px 4px rgba(0,0,0,.25); display: grid; }
.ownercell { display: flex; align-items: center; gap: 8px; overflow: hidden; }
.ownercell span { overflow: hidden; text-overflow: ellipsis; }
.preview-meta { display: flex; align-items: center; gap: 6px; }
.members-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 6px 0 4px; }
.members-search { max-width: 460px; flex: 1 1 260px; }
.seg-text { padding: 3px; gap: 2px; }
.chip { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; cursor: pointer; color: var(--muted); font-weight: 500; }
.chip.on { background: var(--accent-soft); color: var(--accent); }
.members-note { color: var(--muted); font-size: 13px; margin: 8px 0 14px; }
.members-list { display: grid; gap: 8px; }
.member-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; }
.member-row.is-banned { opacity: .75; }
.member-info { flex: 1; min-width: 0; }
.member-name { display: flex; align-items: center; gap: 8px; }
.member-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-id { font: 12px ui-monospace, Menlo, Consolas, monospace; color: var(--muted); user-select: all; }
.member-meta { font-size: 12px; color: var(--muted); }
.member-action .muted { color: var(--muted); font-size: 13px; }
.danger-pill { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.muted-pill { background: var(--surface-2); color: var(--muted); }
.btn.danger-outline { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn.danger-outline:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.empty.small { padding: 40px 16px; }
@media (max-width: 600px) {
  .member-row { flex-wrap: wrap; }
  .member-action { width: 100%; display: flex; justify-content: flex-end; }
}
