:root {
  --bg: #f4f4f2; --panel: #ffffff; --ink: #171717; --muted: #6f6f6c; --line: #d9d9d6; --soft: #ebebe9;
  --accent: #171717; --danger: #9a2f2f; --ok: #2f6b3a;
  font-family: -apple-system, "Helvetica Neue", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; }
a { color: inherit; }
h1 { font-size: 20px; font-weight: 500; letter-spacing: .01em; margin: 0 0 8px; }
h2 { font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 28px 0 10px; }
h2 .muted { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 8px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: ui-monospace, Menlo, monospace; }
code { background: var(--soft); padding: 1px 5px; border-radius: 3px; font-size: 12px; }
main { max-width: 1120px; margin: 0 auto; padding: 24px 20px 60px; }
body.wide main { max-width: 1600px; }

/* header */
.top { display: flex; align-items: center; gap: 28px; padding: 0 20px; height: 52px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { text-decoration: none; letter-spacing: .18em; font-weight: 600; font-size: 13px; }
.brand span { font-weight: 400; letter-spacing: .04em; color: var(--muted); }
.top nav { display: flex; gap: 20px; }
.top nav a { text-decoration: none; padding: 16px 0; border-bottom: 2px solid transparent; }
.top nav a[aria-current] { border-color: var(--ink); }
.logout { margin-left: auto; } .logout button { background: none; border: 0; color: var(--muted); cursor: pointer; }
.flash { max-width: 1120px; margin: 16px auto -8px; padding: 10px 14px; background: #e8efe9; color: var(--ok); border-radius: 4px; }
body.wide .flash { max-width: 1600px; }

/* forms */
input[type=text], input[type=search], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); font: inherit; color: inherit;
}
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
label > input, label > select, label > textarea { margin-top: 4px; font-size: 14px; color: var(--ink); }
label.check { display: flex; align-items: center; gap: 6px; }
label.check input { width: auto; margin: 0; }
button, .button { display: inline-block; padding: 8px 14px; border: 1px solid var(--ink); border-radius: 4px; background: var(--panel); color: var(--ink); font: inherit; cursor: pointer; text-decoration: none; }
button.primary, .button.primary { background: var(--ink); color: #fff; }
button:disabled { opacity: .4; cursor: default; }
.button.small { padding: 4px 10px; font-size: 12px; margin-top: 6px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.editform { max-width: 520px; }
.error { color: var(--danger); }
.danger button { border-color: var(--danger); color: var(--danger); margin-top: 32px; }

/* login */
.login { max-width: 340px; margin: 12vh auto 0; text-align: center; }
.login h1 { letter-spacing: .2em; font-weight: 600; }
.login h1 span { font-weight: 400; letter-spacing: .04em; color: var(--muted); }
.login form { text-align: left; margin-top: 24px; }
.login button { width: 100%; background: var(--ink); color: #fff; }

/* library */
.library { display: grid; grid-template-columns: 240px 1fr; gap: 28px; }
.filters { position: sticky; top: 72px; align-self: start; }
.filterform > * { margin-bottom: 10px; }
.filterform button { width: 100%; }
.selectionbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.selectionbar .count { margin-right: auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 16px; }
.grid.small { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.card { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.card.withheld { opacity: .55; }
.card .thumb { display: block; aspect-ratio: 1; background: var(--soft); }
.card .thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.nothumb { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); text-transform: uppercase; font-size: 12px; letter-spacing: .1em; }
.nothumb.big { aspect-ratio: 1; }
.card .meta { padding: 8px 10px 10px; font-size: 12px; }
.card .line1 { display: flex; align-items: center; gap: 6px; }
.card .line3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); display: inline-block; }
.pick { position: absolute; top: 8px; left: 8px; z-index: 2; margin: 0; }
.pick input { position: absolute; opacity: 0; width: 22px; height: 22px; margin: 0; cursor: pointer; }
.pick span { display: block; width: 22px; height: 22px; border-radius: 4px; border: 1px solid var(--line); background: rgba(255,255,255,.9); }
.pick input:checked + span { background: var(--ink); border-color: var(--ink); box-shadow: inset 0 0 0 3px #fff; }
.card:has(.pick input:checked) { outline: 2px solid var(--ink); }
.empty { padding: 60px 0; text-align: center; color: var(--muted); }
.withremove { position: relative; } .withremove form { position: absolute; top: 8px; right: 8px; }
.withremove form button { padding: 2px 8px; font-size: 11px; background: rgba(255,255,255,.9); }

/* asset */
.asset { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 32px; }
.asset .preview { background: var(--soft); border: 1px solid var(--line); border-radius: 4px; min-height: 320px; display: flex; align-items: center; justify-content: center; align-self: start; position: sticky; top: 72px; }
.asset .preview img { max-width: 100%; max-height: calc(100vh - 110px); display: block; }
.asset h1 { word-break: break-all; }
.crumbs { font-size: 12px; color: var(--muted); margin: 0 0 6px; }
.facts { display: grid; grid-template-columns: 60px 1fr; gap: 4px 10px; font-size: 13px; margin: 12px 0; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; }
.actions { margin: 14px 0 6px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.versions ul, .incollections ul { list-style: none; padding: 0; margin: 0; }
.versions li { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.versions li.this { background: var(--soft); margin: 0 -8px; padding: 8px; border-radius: 4px; }
.versions li img { width: 56px; height: 56px; object-fit: contain; background: var(--soft); border: 1px solid var(--line); display: block; }
.versions li form button { padding: 3px 8px; font-size: 12px; }
.incollections li { padding: 4px 0; }

/* upload */
.upload { max-width: 860px; }
.batchnote { max-width: 420px; }
.drop { border: 1.5px dashed var(--line); border-radius: 6px; padding: 44px 20px; text-align: center; background: var(--panel); }
.drop.over { border-color: var(--ink); background: var(--soft); }
.drop p { margin: 4px 0; }
.link { display: inline; color: var(--ink); text-decoration: underline; cursor: pointer; font-size: 14px; }
.link input { display: none; }
.uploadbar { display: flex; align-items: center; gap: 12px; margin: 16px 0; }
.uploadbar span { margin-right: auto; }
.queue { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--panel); }
.queue th, .queue td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.queue th { font-weight: 500; color: var(--muted); font-size: 12px; }
.queue td.name { max-width: 320px; word-break: break-all; }
.queue .bar { height: 3px; background: var(--soft); margin-top: 5px; }
.queue .bar i { display: block; height: 100%; background: var(--ink); width: 0; transition: width .2s; }
.queue tr.done td { color: var(--muted); }
.queue tr.error td.status { color: var(--danger); }
.queue .slot-unknown { color: var(--danger); }

/* collections */
.list { width: 100%; border-collapse: collapse; background: var(--panel); font-size: 13px; }
.list th, .list td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.list th { font-weight: 500; color: var(--muted); font-size: 12px; }
.tag { font-size: 11px; border: 1px solid var(--line); border-radius: 3px; padding: 0 5px; color: var(--muted); }
.linkbox { display: flex; gap: 8px; margin: 12px 0 24px; max-width: 720px; }
.linkbox input { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.linkbox a { padding: 8px 12px; }

/* share page */
.share { max-width: 1400px; margin: 0 auto; }
.share header { padding: 20px 0 28px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.share .brand { letter-spacing: .24em; font-weight: 600; font-size: 12px; margin: 0 0 14px; }
.share h1 { font-size: 24px; }
.share .note { max-width: 720px; white-space: pre-line; }
.share footer { margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--line); }
.share-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

@media (max-width: 800px) {
  .library { grid-template-columns: 1fr; }
  .filters { position: static; }
  .asset { grid-template-columns: 1fr; }
  .asset .preview { position: static; }
  .row { grid-template-columns: 1fr; }
  .top { gap: 14px; } .top nav { gap: 12px; }
}

/* settings */
.settings { max-width: 860px; }
.tokenbox { background: var(--panel); border: 1px solid var(--ink); border-radius: 4px; padding: 14px 16px; margin: 12px 0; }
.tokenbox p { margin: 0 0 8px; }
.tokenbox .linkbox { margin: 0; }
.settings .list td:first-child { white-space: nowrap; }
