:root {
  --bg: #f4f6f9;
  --card: #fff;
  --text: #1b2430;
  --muted: #6b7684;
  --line: #e1e6ee;
  --brand: #ed1c24;
  --ink: #231f20;
  --accent: #ed1c24;
  --danger: #c0392b;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11161d; --card: #1a212b; --text: #e7ecf2; --muted: #93a0b0; --line: #2a3441; --brand: #ff3b42; --ink: #e7ecf2; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
.muted { color: var(--muted); }
.small { font-size: 13px; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: #fff; border-bottom: 3px solid #ed1c24;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand .logo { height: 34px; width: auto; display: block; }
.brand .sub { color: #231f20; font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  border-left: 1px solid #d5d9df; padding-left: 12px; white-space: nowrap; }
@media (max-width: 420px) { .brand .logo { height: 28px; } .brand .sub { display: none; } }
.top-right { display: flex; align-items: center; gap: 10px; }
.top .muted { color: #6b7684; }
.top .btn { background: #fff; color: #231f20; border-color: #d5d9df; }
@media (max-width: 600px) { #userEmail { display: none; } }

.tabs {
  position: sticky; top: 57px; z-index: 4;
  display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px;
  background: var(--card); border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; border: 1px solid var(--line); background: transparent; color: var(--text);
  padding: 7px 14px; border-radius: 999px; font: inherit; cursor: pointer; white-space: nowrap;
}
.tab .n { color: var(--muted); font-size: 12px; margin-left: 4px; }
.tab[aria-selected="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.tab[aria-selected="true"] .n { color: #ffffffbb; }

main { max-width: 900px; margin: 0 auto; padding: 14px 16px 40px; }
.toolbar { display: flex; gap: 8px; margin-bottom: 10px; }
.toolbar input { flex: 1; min-width: 0; }
input, select {
  font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
.toolbar select { width: auto; max-width: 45%; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; padding: 8px 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--text); text-decoration: none;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.admin { margin-bottom: 14px; }
.admin h2 { margin: 0 0 12px; font-size: 16px; }
.admin form { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.admin label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; }
.admin label .muted { font-weight: 400; }
.admin button, .admin #uploadStatus { grid-column: 1 / -1; }
.admin label.btn { display: inline-flex; font-weight: 600; }
.admin .sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.admin code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }
#folderStatus { margin-top: 8px; white-space: pre-line; }
@media (max-width: 600px) { .admin form { grid-template-columns: 1fr; } }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; cursor: pointer;
}
.item:hover { border-color: var(--brand); }
.ficon {
  flex: none; width: 38px; height: 46px; border-radius: 6px;
  display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; background: #c0392b;
}
.ficon.img { background: #2e86ab; }
.item .meta { flex: 1; min-width: 0; }
.item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .p { color: var(--muted); font-size: 13px; }
.item .actions { display: flex; gap: 4px; flex: none; }
.item .actions .btn { padding: 6px 10px; }
.group-h { margin: 16px 2px 2px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.empty { text-align: center; padding: 50px 10px; color: var(--muted); }

.viewer { position: fixed; inset: 0; z-index: 20; background: #2b2f36; display: flex; flex-direction: column; }
.viewer-bar {
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 10px 8px; background: var(--card); border-bottom: 1px solid var(--line);
}
.viewer-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.viewer-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-body { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 12px; -webkit-overflow-scrolling: touch; }
.viewer-body canvas, .viewer-body img { max-width: none; background: #fff; box-shadow: 0 2px 10px #0006; }
.viewer-body img { max-width: 100%; }
.viewer-body .loading { color: #ccc; margin-top: 40px; }
@media (max-width: 600px) { #vPage { display: none; } }

.credit { text-align: center; color: var(--muted); font-size: 12px; letter-spacing: .03em;
  padding: 8px 16px calc(24px + env(safe-area-inset-bottom)); }
.credit strong { color: var(--text); font-weight: 600; }
