:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #1b1f24; --muted: #667085; --line: #e4e7ec;
  --accent: #2563eb; --accent-soft: #e8efff; --danger: #d92d20; --row-hover: #f2f4f7; --ok: #12b76a;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --panel: #171a21; --text: #e6e8ec; --muted: #98a2b3; --line: #262b35;
    --accent: #5b8cff; --accent-soft: #1c2640; --danger: #f97066; --row-hover: #1d212a; --ok: #32d583;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 12px; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--danger); }
button:disabled { opacity: .45; cursor: default; }
input[type=text], input[type=password], input[type=search] {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 10px; outline: none; }
input:focus { border-color: var(--accent); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: 100%; max-width: 340px; display: grid; gap: 12px; }
.login h1 { margin: 0 0 4px; font-size: 20px; }
.login .err { color: var(--danger); min-height: 1.4em; font-size: 13px; }

/* app */
header { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); }
.bar { max-width: 1100px; margin: 0 auto; padding: 12px 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.brand { font-weight: 650; margin-right: 8px; display: flex; gap: 8px; align-items: center; }
.spacer { flex: 1; }
.crumbs { max-width: 1100px; margin: 0 auto; padding: 0 16px 10px; display: flex; flex-wrap: wrap; gap: 2px; align-items: center; color: var(--muted); }
.crumbs a { color: var(--text); text-decoration: none; padding: 2px 6px; border-radius: 6px; }
.crumbs a:hover { background: var(--row-hover); }
.crumbs .abs { margin-left: auto; font-family: ui-monospace, monospace; font-size: 12px; }
main { max-width: 1100px; margin: 0 auto; padding: 12px 16px 80px; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.tools input[type=search] { flex: 1; min-width: 160px; }
.list { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.row { display: grid; grid-template-columns: 28px 1fr 90px 150px 112px; gap: 8px; align-items: center; padding: 7px 12px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row.head { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.row.head span[data-sort] { cursor: pointer; user-select: none; }
.row:not(.head):hover { background: var(--row-hover); }
.row.sel { background: var(--accent-soft); }
.name { display: flex; gap: 8px; align-items: center; min-width: 0; }
.name a { color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name a:hover { text-decoration: underline; }
.icon { width: 18px; text-align: center; flex: none; }
.muted { color: var(--muted); }
.size, .date { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.size { text-align: right; }
.acts { display: flex; gap: 2px; justify-content: flex-end; opacity: 0; }
.row:hover .acts, .row.sel .acts { opacity: 1; }
.acts button { border: 0; background: transparent; padding: 4px 6px; border-radius: 6px; }
.acts button:hover { background: var(--line); }
.empty { padding: 40px; text-align: center; color: var(--muted); }
@media (max-width: 680px) {
  .row { grid-template-columns: 28px 1fr 70px 70px; }
  .row .date { display: none; }
  .acts { opacity: 1; }
  .crumbs .abs { display: none; }
}

/* drop overlay */
.drop { position: fixed; inset: 0; z-index: 20; background: color-mix(in srgb, var(--accent) 18%, transparent);
  border: 3px dashed var(--accent); display: none; place-items: center; font-size: 22px; font-weight: 600; pointer-events: none; }
body.dragging .drop { display: grid; }

/* uploads panel */
.uploads { position: fixed; right: 16px; bottom: 16px; width: min(380px, calc(100vw - 32px)); max-height: 50vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.18); z-index: 15; display: none; }
.uploads.show { display: block; }
.uploads .uh { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 600; position: sticky; top: 0; background: var(--panel); }
.up { padding: 8px 12px; border-top: 1px solid var(--line); font-size: 13px; }
.up:first-of-type { border-top: 0; }
.up .t { display: flex; justify-content: space-between; gap: 8px; }
.up .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-o { height: 4px; background: var(--line); border-radius: 4px; margin-top: 5px; overflow: hidden; }
.bar-i { height: 100%; background: var(--accent); width: 0; transition: width .15s; }
.up.done .bar-i { background: var(--ok); }
.up.fail .bar-i { background: var(--danger); }
.up.fail .s { color: var(--danger); }

/* preview */
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 0; background: var(--panel); color: var(--text); width: min(1000px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
dialog::backdrop { background: rgba(0,0,0,.55); }
.ph { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.ph .t { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb { padding: 12px; overflow: auto; max-height: calc(100vh - 120px); display: grid; place-items: center; }
.pb img, .pb video { max-width: 100%; max-height: calc(100vh - 150px); }
.pb iframe { width: 100%; height: calc(100vh - 160px); border: 0; background: #fff; }
.pb pre { margin: 0; width: 100%; white-space: pre-wrap; word-break: break-word; font: 12.5px/1.5 ui-monospace, monospace; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 8px 14px; border-radius: 8px; z-index: 30; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
