:root {
  --bg: #f6f5f2; --panel: #ffffff; --ink: #1f2328; --muted: #6b6f76; --line: #e4e2dc;
  --accent: #c2603a; --accent-ink: #fff; --sel: #2f6fdb; --hover: #efede8; --tile: 180px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151618; --panel: #1d1f22; --ink: #e8e6e1; --muted: #9a9ea6; --line: #2d3035; --accent: #e07a52; --hover: #26292d; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.grow { flex: 1; }
.app { display: flex; height: 100vh; }

.side { width: 240px; flex: none; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; overflow-y: auto; }
.brand { font-size: 18px; font-weight: 700; padding: 18px 16px 10px; }
nav { padding: 4px 8px; flex: 1; }
.nav { display: flex; width: 100%; align-items: center; gap: 6px; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.nav:hover { background: var(--hover); }
.nav.active { background: var(--accent); color: var(--accent-ink); }
.nav .cnt { margin-left: auto; font-size: 12px; opacity: .75; }
.nav.sub { padding-left: 22px; font-size: 13px; }
.navhead { display: flex; align-items: center; justify-content: space-between; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 4px; }
.mini { border: 1px solid var(--line); background: none; border-radius: 6px; width: 22px; height: 22px; line-height: 1; cursor: pointer; }
.foot { font-size: 12px; color: var(--muted); padding: 12px 16px; border-top: 1px solid var(--line); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.top { display: flex; gap: 10px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.top input[type=search] { flex: 1; min-width: 200px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.filters input, .filters select, .row input, .lbPanel input, .lbPanel textarea, dialog input, dialog select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.btn { display: inline-flex; align-items: center; gap: 4px; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: #c62828; border-color: #e0a0a0; }
.iconbtn { border: 0; background: none; font-size: 18px; cursor: pointer; padding: 6px 8px; border-radius: 8px; color: inherit; text-decoration: none; }
.iconbtn:hover { background: rgba(127,127,127,.2); }
.menu { display: none; }

.titlebar { display: flex; align-items: baseline; gap: 10px; padding: 14px 16px 6px; }
.titlebar h1 { font-size: 20px; margin: 0; }
.sub { color: var(--muted); }
.selbar { display: flex; gap: 8px; align-items: center; padding: 8px 16px; background: var(--sel); color: #fff; flex-wrap: wrap; }
.selbar .btn { background: rgba(255,255,255,.15); border-color: transparent; color: #fff; }
.selbar .btn.danger { background: #c62828; }

#gridWrap { flex: 1; overflow-y: auto; padding: 0 16px 40px; }
.mhead { font-weight: 600; margin: 18px 0 8px; display: flex; align-items: center; gap: 8px; }
.mhead .muted { font-weight: 400; font-size: 12px; }
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tile), 1fr)); gap: 4px; }
.tile { position: relative; aspect-ratio: 1; background: var(--hover); overflow: hidden; border-radius: 4px; cursor: pointer; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .15s; }
.tile:hover img { transform: scale(1.03); }
.tile .badge { position: absolute; bottom: 4px; left: 6px; color: #fff; font-size: 12px; text-shadow: 0 1px 3px #000; }
.tile .fav { position: absolute; top: 4px; right: 6px; font-size: 14px; text-shadow: 0 1px 3px #000; }
.tile .noimg { width: 100%; height: 100%; display: grid; place-items: center; font-size: 12px; color: var(--muted); text-align: center; padding: 6px; }
.tile .chk { position: absolute; top: 6px; left: 6px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; background: rgba(0,0,0,.25); display: none; }
.selecting .tile .chk { display: block; }
.tile.sel { outline: 3px solid var(--sel); outline-offset: -3px; }
.tile.sel .chk { background: var(--sel); }
.tile.sel .chk::after { content: "✓"; color: #fff; font-size: 13px; position: absolute; inset: 0; display: grid; place-items: center; }
.tile.sel img { transform: scale(.9); }
.empty { text-align: center; padding: 80px 20px; }
.empty .big { font-size: 56px; }

.albums { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-top: 10px; }

.tools { padding: 8px 16px 40px; overflow-y: auto; display: grid; gap: 14px; max-width: 820px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.card h2 { font-size: 16px; margin: 0 0 6px; }
.row { display: flex; gap: 8px; margin-top: 8px; }
.row input { flex: 1; }
.row.end { justify-content: flex-end; margin-top: 16px; }
.progress { height: 8px; border-radius: 99px; background: var(--hover); overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
pre { white-space: pre-wrap; font-size: 12px; max-height: 200px; overflow: auto; }

.drop { position: fixed; inset: 0; background: rgba(194,96,58,.85); color: #fff; display: grid; place-items: center; font-size: 26px; font-weight: 600; z-index: 50; pointer-events: none; }
.drop > div { border: 3px dashed #fff; border-radius: 20px; padding: 60px 80px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 60; max-width: 90vw; }
.uploadbox { position: fixed; right: 20px; bottom: 20px; width: 300px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; z-index: 55; box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.uploadbox .progress { margin-top: 8px; }

.lb { position: fixed; inset: 0; background: #0b0b0c; color: #eee; z-index: 40; display: flex; flex-direction: column; }
.lbTop { display: flex; align-items: center; gap: 4px; padding: 8px 12px; z-index: 2; }
.lbStage { flex: 1; display: grid; place-items: center; min-height: 0; padding: 0 60px 20px; }
.lbStage img, .lbStage video { max-width: 100%; max-height: calc(100vh - 80px); object-fit: contain; }
.lbNav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.08); color: #fff; border: 0; font-size: 40px; width: 48px; height: 80px; border-radius: 10px; cursor: pointer; z-index: 2; }
.lbNav:hover { background: rgba(255,255,255,.2); }
.prev { left: 8px; } .next { right: 8px; }
.lbPanel { position: absolute; right: 0; top: 52px; bottom: 0; width: 300px; background: #1a1b1e; padding: 16px; display: flex; flex-direction: column; gap: 12px; z-index: 3; }
.lbPanel label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.lbPanel input, .lbPanel textarea { background: #0f1012; color: #eee; border-color: #333; }
.lbPanel .muted { font-size: 12px; word-break: break-all; color: #999; }

dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink); min-width: 320px; }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog h3 { margin: 0 0 10px; }
dialog input, dialog select { width: 100%; }

.filtbtn { display: none; }
.dev { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.dev:first-child { border-top: 0; }
.devIcon { font-size: 26px; }
.devMain { flex: 1; min-width: 0; font-size: 13px; }
.devMain .muted { font-size: 12px; }
.devAct { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tag { background: var(--accent); color: var(--accent-ink); border-radius: 99px; padding: 1px 8px; font-size: 11px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--hover); border-radius: 99px; padding: 2px 4px 2px 10px; margin: 2px; color: var(--ink); }
#lanInfo p { margin: 8px 0; }
code { font-size: 12px; background: var(--hover); padding: 1px 4px; border-radius: 4px; }
@media (max-width: 760px) {
  .top { padding: 8px 10px; gap: 6px; padding-top: max(8px, env(safe-area-inset-top)); }
  .top input[type=search] { min-width: 0; }
  .filtbtn { display: inline-block; }
  .filters { display: none; }
  .filters.show { display: flex; }
  .upbtn span { display: none; }
  .titlebar { padding: 10px 10px 4px; flex-wrap: wrap; }
  #gridWrap { padding: 0 6px 40px; }
  .mgrid { gap: 2px; }
  .tile { border-radius: 0; }
  .tools { padding: 8px 10px 40px; }
  .row { flex-wrap: wrap; }
  .row input { min-width: 140px; }
  .selbar { padding: 6px 8px; gap: 6px; font-size: 13px; }
  .selbar .btn { padding: 6px 8px; }
  .lbTop { padding-top: max(8px, env(safe-area-inset-top)); }
  .lbTop .iconbtn { padding: 6px; font-size: 17px; }
  #lbDate { font-size: 12px; }
  .lbNav { display: none; }
  .uploadbox { left: 10px; right: 10px; width: auto; }
  dialog { min-width: 0; width: calc(100vw - 32px); }

  .side { position: fixed; z-index: 30; height: 100%; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .menu { display: inline-block; }
  .filters { width: 100%; }
  .lbStage { padding: 0 0 20px; }
  .lbPanel { width: 100%; }
}
