:root {
  --bg: #f5eee8;
  --card: #fff;
  --ink: #2b2420;
  --muted: #8a7f78;
  --accent: #c2607a;
  --accent-ink: #fff;
  --line: #e8ded6;
  --danger: #b4362f;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  padding-bottom: 96px;
}
h1, h2 { margin: 0; font-weight: 700; }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  border: 0; border-radius: 999px; padding: 10px 18px;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
button.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
button.link { background: none; color: var(--muted); padding: 6px 8px; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; background: #fff;
}
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 0; }
label > input, label > select, label > textarea { margin-top: 4px; font-size: 16px; color: var(--ink); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 6px; padding-top: max(14px, env(safe-area-inset-top));
}
.top h1 { font-size: 22px; }
.count { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 4px; }

.toolbar { padding: 6px 16px 10px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 6px 12px; border-radius: 999px; font-size: 13px;
  background: #fff; border: 1px solid var(--line); color: var(--ink);
}
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }

main { padding: 0 16px; }
.grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.card {
  position: relative; background: var(--card); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.05);
  aspect-ratio: 3 / 4;
}
.card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .badge {
  position: absolute; top: 8px; left: 8px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 14px;
  padding: 3px 9px; border-radius: 999px; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.card .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 10px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,.6)); color: #fff; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.empty { text-align: center; color: var(--muted); margin-top: 60px; }

.fab {
  position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom));
  width: 60px; height: 60px; border-radius: 50%; font-size: 32px; line-height: 1;
  box-shadow: 0 6px 18px rgba(194,96,122,.45); z-index: 10; padding: 0;
}

dialog {
  border: 0; border-radius: 18px; padding: 18px; width: min(92vw, 440px);
  max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(43,36,32,.5); }
dialog img { width: 100%; max-height: 50vh; object-fit: contain; border-radius: 12px; background: #f1ece8; margin-top: 10px; }
dialog .row { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }
.num { color: var(--accent); }
.view-head { display: flex; justify-content: space-between; align-items: center; }

.login-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login { background: #fff; padding: 28px; border-radius: 18px; width: min(92vw, 360px); text-align: center; }
.login input { margin: 14px 0; font-size: 18px; text-align: center; }
.login button { width: 100%; padding: 12px; }
.err { color: var(--danger); margin: 10px 0 0; }

a.link { color: var(--muted); text-decoration: none; padding: 6px 8px; }
a.plain { color: inherit; text-decoration: none; }
.top nav.row { gap: 2px; align-items: center; }
main.narrow { max-width: 720px; margin: 0 auto; }
.panel { background: #fff; border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.panel h2 { font-size: 17px; }
.row.end { justify-content: flex-end; margin-top: 14px; }
table.users { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
table.users th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 6px 6px; }
table.users td { padding: 10px 6px; border-top: 1px solid var(--line); vertical-align: middle; word-break: break-all; }
.role { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--line); }
.role.admin { background: var(--accent); color: #fff; }
.small-btn { padding: 6px 12px; font-size: 13px; }
dialog .row .row { margin-top: 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 20;
}
