:root {
  --bg: #fafaf9; --panel: #ffffff; --ink: #1c1917; --muted: #78716c; --line: #e7e5e4;
  --hover: #f5f5f4; --sel: #fef3c7; --accent: #d97706; --accent-ink: #ffffff; --danger: #b91c1c;
  --radius: 10px; --shadow: 0 10px 30px rgba(28, 25, 23, .12);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0c0a09; --panel: #1c1917; --ink: #f5f5f4; --muted: #a8a29e; --line: #292524;
    --hover: #231f1d; --sel: #3b2a10; --accent: #f59e0b; --accent-ink: #1c1917; --danger: #f87171; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; }
.hidden { display: none !important; }
svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; margin: .4rem 0 0; font-size: .9rem; }

.btn { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line); background: var(--panel);
  color: var(--ink); border-radius: 8px; padding: .5rem .85rem; font: inherit; font-weight: 500; cursor: pointer;
  text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: .3rem .6rem; font-size: .88rem; }
.btn.wide { width: 100%; justify-content: center; padding: .7rem; }
.btn[disabled] { opacity: .5; cursor: default; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 2rem 1.6rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .8rem; }
.login-card h1 { margin: .2rem 0 0; font-size: 1.5rem; }
.login-card p { margin: 0 0 .4rem; }
.login-mark { border-radius: 10px; }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; color: var(--muted); }
input[type=text], input:not([type]), input[type=password] { font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem; }
.divider { display: flex; align-items: center; gap: .6rem; color: var(--muted); font-size: .82rem; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: .8rem; padding: .6rem 1rem;
  background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .5rem; color: inherit; text-decoration: none; font-weight: 650; }
.brand img { border-radius: 7px; }
.crumbs { flex: 1; display: flex; align-items: center; gap: .15rem; overflow-x: auto; white-space: nowrap; min-width: 0; }
.crumbs a { color: var(--muted); text-decoration: none; padding: .25rem .4rem; border-radius: 6px; }
.crumbs a:hover { background: var(--hover); color: var(--ink); }
.crumbs a:last-child { color: var(--ink); font-weight: 600; }
.crumbs .sep { color: var(--line); }
.user-btn { margin-left: auto; }
.menu { position: absolute; right: 1rem; top: 3.2rem; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); padding: .3rem; display: flex; flex-direction: column; min-width: 160px; }
.menu button { text-align: left; background: none; border: 0; padding: .55rem .7rem; border-radius: 7px; font: inherit; color: inherit; cursor: pointer; }
.menu button:hover { background: var(--hover); }

.nudge { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between;
  margin: .8rem 1rem 0; padding: .7rem .9rem; border-radius: var(--radius); background: var(--sel); font-size: .92rem; }
.nudge-actions { display: flex; gap: .4rem; }

.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; padding: .8rem 1rem; }
.tb-main, .tb-sel { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.tb-sel span { color: var(--muted); margin-right: .3rem; font-size: .9rem; }

/* list */
.list-wrap { position: relative; margin: 0 1rem 6rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list { width: 100%; border-collapse: collapse; table-layout: fixed; }
.list th { text-align: left; font-weight: 500; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  padding: .6rem .7rem; border-bottom: 1px solid var(--line); }
.list td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list tr:last-child td { border-bottom: 0; }
.list tbody tr { cursor: pointer; }
.list tbody tr:hover { background: var(--hover); }
.list tbody tr.selected { background: var(--sel); }
.c-check { width: 2.6rem; }
.c-size { width: 7rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.c-date { width: 11rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.list td.c-size, .list td.c-date { font-size: .9rem; }
.name { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ficon { width: 22px; height: 22px; color: var(--muted); }
.ficon.dir { color: var(--accent); }
input[type=checkbox] { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }
.empty { text-align: center; color: var(--muted); padding: 3rem 1rem; margin: 0; }
.drop-hint { display: none; position: absolute; inset: 0; place-items: center; background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 2px dashed var(--accent); border-radius: var(--radius); font-weight: 600; color: var(--accent); }
.dragging .drop-hint { display: grid; }

/* uploads */
.uploads { position: fixed; right: 1rem; bottom: 1rem; width: min(360px, calc(100% - 2rem)); background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 10; max-height: 50vh; display: flex; flex-direction: column; }
.uploads header { display: flex; justify-content: space-between; align-items: center; padding: .55rem .8rem; border-bottom: 1px solid var(--line); }
.uploads ul { list-style: none; margin: 0; padding: .3rem 0; overflow: auto; }
.uploads li { padding: .45rem .8rem; font-size: .88rem; }
.up-row { display: flex; justify-content: space-between; gap: .5rem; }
.up-row span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 4px; background: var(--line); border-radius: 2px; margin-top: .35rem; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.up-err { color: var(--danger); }
.up-done .bar i { background: #16a34a; }

/* dialog */
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--ink); padding: 1.3rem; width: min(440px, calc(100% - 2rem)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(12, 10, 9, .45); }
dialog h2 { margin: 0 0 .8rem; font-size: 1.15rem; }
dialog menu { display: flex; justify-content: flex-end; gap: .5rem; padding: 0; margin: 1rem 0 0; }
dialog input:not([type=checkbox]) { width: 100%; }
.picker { border: 1px solid var(--line); border-radius: 8px; max-height: 260px; overflow: auto; margin-top: .5rem; }
.picker button { display: flex; width: 100%; gap: .5rem; align-items: center; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line);
  padding: .5rem .7rem; font: inherit; color: inherit; cursor: pointer; }
.picker button:hover { background: var(--hover); }
.picker-path { font-size: .9rem; color: var(--muted); display: flex; gap: .4rem; align-items: center; }
.pk-list { list-style: none; padding: 0; margin: 0 0 .8rem; }
.pk-list li { display: flex; justify-content: space-between; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--line); gap: .5rem; }
.pk-list small { color: var(--muted); display: block; }

/* preview */
.preview { position: fixed; inset: 0; z-index: 20; background: rgba(12, 10, 9, .92); display: flex; flex-direction: column; color: #fafaf9; }
.preview header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem 1rem; }
.preview header span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview .btn { color: #fafaf9; background: transparent; border-color: #44403c; }
.pv-body { flex: 1; display: grid; place-items: center; padding: 0 1rem 1rem; min-height: 0; }
.pv-body img, .pv-body video { max-width: 100%; max-height: calc(100vh - 5rem); border-radius: 6px; }
.pv-body iframe { width: 100%; height: 100%; border: 0; background: #fff; border-radius: 6px; }

.toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: .65rem 1rem; border-radius: 10px; z-index: 30; max-width: calc(100% - 2rem); box-shadow: var(--shadow); font-size: .92rem; }

@media (max-width: 640px) {
  .c-date, .list td.c-date { display: none; }
  .c-size { width: 5.5rem; }
  .brand .site-name { display: none; }
  .list-wrap { margin: 0 .5rem 6rem; }
  .toolbar { padding: .7rem .5rem; }
}
