:root {
  --bg: #f6f5f1; --panel: #fff; --ink: #1d2327; --muted: #66707a; --line: #e2e0da;
  --accent: #1f5f8b; --accent-ink: #fff; --chip: #eef3f7; --warn: #8a5a00;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #15181b; --panel: #1e2226; --ink: #e8eaec; --muted: #9aa3ab; --line: #2f353a;
          --accent: #6fb1e0; --accent-ink: #0e1a22; --chip: #23303a; --warn: #e0b060; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
       padding: 18px 24px 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
h1 { margin: 0; font-size: 20px; letter-spacing: .2px; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.tabs button { border: 1px solid var(--line); background: transparent; color: var(--ink); padding: 7px 14px; font: inherit; cursor: pointer; }
.tabs button:first-child { border-radius: 8px 0 0 8px; }
.tabs button:last-child { border-radius: 0 8px 8px 0; border-left: 0; }
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 24px; position: sticky; top: 0; z-index: 2;
           background: var(--bg); border-bottom: 1px solid var(--line); }
.filters input[type=search] { flex: 1 1 320px; min-width: 220px; }
input[type=search], select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); }
.check { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 14px; white-space: nowrap; }
main { padding: 12px 24px 48px; }
.count { color: var(--muted); font-size: 13px; margin: 4px 0 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer;
        box-shadow: var(--shadow); text-align: left; padding: 0; font: inherit; color: inherit; display: flex; flex-direction: column; }
.card:hover, .card:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
.thumb { aspect-ratio: 4 / 3; background: var(--chip); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px;
         position: relative; overflow: hidden; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.meta { padding: 9px 11px 11px; }
.meta .t { font-weight: 600; }
.meta .s { color: var(--muted); font-size: 13px; margin-top: 2px; }
.num { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 500; }
.more { display: block; margin: 22px auto 0; font: inherit; padding: 9px 22px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; }
.hidden { display: none !important; }
table.files { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.files th, .files td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; vertical-align: middle; }
.files th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.files td.r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.files img { width: 64px; height: 48px; object-fit: cover; border-radius: 4px; background: var(--chip); display: block; }
a { color: var(--accent); }
a.btn, button.link { display: inline-block; padding: 5px 10px; border: 1px solid var(--line); border-radius: 7px; text-decoration: none; color: var(--ink); background: transparent; font: inherit; font-size: 13px; cursor: pointer; }
a.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
dialog { border: 0; padding: 0; border-radius: 14px; width: min(1200px, 96vw); max-height: 94vh; background: var(--panel); color: var(--ink); }
dialog::backdrop { background: rgba(10, 14, 18, .6); }
.d-wrap { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); max-height: 94vh; position: relative; }
.d-img { background: #0d0f11; display: flex; align-items: center; justify-content: center; min-height: 320px; }
.d-img img { max-width: 100%; max-height: 94vh; display: block; }
.d-info { padding: 22px 22px 26px; overflow: auto; max-height: 94vh; }
.d-info h2 { margin: 0 0 4px; font-size: 20px; }
.d-info dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 14px 0; font-size: 14px; }
.d-info dt { color: var(--muted); }
.d-info dd { margin: 0; }
.d-info h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 18px 0 8px; font-weight: 600; }
.flist { list-style: none; margin: 0; padding: 0; }
.flist li { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; font-size: 14px; }
.flist li.on { border-color: var(--accent); }
.flist .fn { word-break: break-all; font-weight: 500; }
.flist .fs { color: var(--muted); font-size: 12px; margin: 2px 0 6px; }
.flist .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--chip); color: var(--muted); margin-left: 4px; vertical-align: 1px; }
.tag.warn { color: var(--warn); }
.close { position: absolute; top: 8px; right: 10px; z-index: 1; width: 34px; height: 34px; border-radius: 50%; border: 0; font-size: 22px; line-height: 1;
         background: rgba(0,0,0,.55); color: #fff; cursor: pointer; }
.note { color: var(--muted); font-size: 13px; }
.signout { margin-left: 12px; font-size: 13px; color: var(--muted); }
body.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
             padding: 28px 28px 24px; width: min(360px, 92vw); display: flex; flex-direction: column; gap: 8px; }
.login-box h1 { font-size: 19px; }
.login-box .sub { margin: 0 0 10px; }
.login-box label { font-size: 13px; color: var(--muted); }
.login-box input { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }
.login-box button { margin-top: 8px; font: inherit; padding: 10px; border: 0; border-radius: 8px; background: var(--accent); color: var(--accent-ink); cursor: pointer; }
.err { color: #c0392b; margin: 2px 0 0; font-size: 14px; }
@media (max-width: 800px) {
  .d-wrap { grid-template-columns: 1fr; }
  .d-img img { max-height: 50vh; }
  .top, .filters, main { padding-left: 14px; padding-right: 14px; }
}
