:root {
  --bg: #f7f5f0; --card: #fff; --ink: #222; --muted: #777; --line: #e2ddd3;
  --bar: #e9e4da; --fill: #3b7d4f; --done: #c49a2c; --on-ink: #fff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1a18; --card: #252320; --ink: #eee; --muted: #999; --line: #3a3732;
    --bar: #34312c; --fill: #5fae75; --done: #e0b84a; --on-ink: #111;
  }
  .icon { filter: invert(1); }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.4 system-ui, sans-serif; background: var(--bg); color: var(--ink); }
a { color: inherit; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

header { position: sticky; top: 0; z-index: 2; background: var(--bg); border-bottom: 1px solid var(--line); padding-top: 12px; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
h1 { margin: 0; font-size: 20px; }
h1 a { text-decoration: none; }
.actions { display: flex; gap: 8px; align-items: center; }
.badge { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; }
.status { font-size: 12px; color: var(--muted); min-height: 1.4em; margin: 4px 0 6px; }

button, input[type=search], input[type=password], select {
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--card); color: var(--ink); font: inherit;
}
button { cursor: pointer; }
button.primary { background: var(--fill); color: var(--on-ink); border-color: var(--fill); }

main { padding-top: 14px; padding-bottom: 40px; }
.controls { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; font-size: 14px; margin-bottom: 8px; }
.summary { color: var(--muted); font-size: 14px; margin: 6px 0 12px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }
.bar { height: 6px; background: var(--bar); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--fill); }
.done .bar span { background: var(--done); }
.icon { width: 24px; height: 24px; }
.meta { color: var(--muted); font-size: 12px; }

/* Overview */
.set {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 8px; text-decoration: none;
}
.set:hover { border-color: var(--muted); }
.set.done { border-color: var(--done); }
.set .name { font-weight: 600; }
.set .count { color: var(--muted); font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Set view */
.back { display: inline-block; font-size: 14px; color: var(--muted); margin-bottom: 10px; text-decoration: none; }
.back:hover { text-decoration: underline; }
.sethead { display: flex; gap: 12px; align-items: center; }
.sethead .icon { width: 36px; height: 36px; }
.sethead h2 { margin: 0; font-size: 22px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.card { background: var(--card); border: 2px solid var(--line); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; user-select: none; }
.card:hover { border-color: var(--muted); }
.card:focus-visible { outline: 2px solid var(--fill); outline-offset: 2px; }
.card.own { border-color: var(--fill); }
.card .img { aspect-ratio: 488 / 680; border-radius: 5px; overflow: hidden; background: var(--bar); }
.card .img img { width: 100%; height: 100%; display: block; object-fit: cover; filter: grayscale(1); opacity: .45; transition: filter .15s, opacity .15s; }
.card.own .img img { filter: none; opacity: 1; }
.card .noimg { padding: 8px; font-size: 12px; color: var(--muted); }
.cinfo { font-size: 12px; display: flex; gap: 4px; min-width: 0; }
.cinfo .num { color: var(--muted); flex: none; }
.cinfo .cname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); max-width: 420px; width: calc(100% - 32px); }
dialog::backdrop { background: rgb(0 0 0 / .4); }
dialog h2 { margin: 0 0 6px; font-size: 18px; }
dialog p { font-size: 14px; color: var(--muted); }
dialog input { width: 100%; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 14px 0 0; }

@media (max-width: 520px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
}
