:root {
  --bg: #f7f5ef;
  --card: #ffffff;
  --ink: #2b2b28;
  --muted: #7a766c;
  --line: #e7e2d6;
  --accent: #b5772a;
  --accent-dark: #96601f;
  --green: #3f7d4e;
  --red: #a33b3b;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  color: var(--ink);
  font-weight: 700;
  font-size: 18px;
  text-decoration: none;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 32px;
}

.site-footer {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  border-top: 1px solid var(--line);
}

h1 { font-size: 22px; margin: 8px 0 12px; }
h2 { font-size: 17px; margin: 24px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.search-wrap { margin: 4px 0 8px; }

.search-input {
  width: 100%;
  font-size: 17px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
}

.search-input:focus {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
}

.group-list { list-style: none; margin: 0; padding: 0; }

.group-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}

.group-list a:active { background: #f1ede1; }

.count {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.item-list { list-style: none; margin: 0; padding: 0; }

.item-list a {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 8px;
  color: var(--ink);
  text-decoration: none;
}

.item-list a:active { background: #f1ede1; }

.item-list a.removed { opacity: 0.55; }

.thumb {
  width: 72px;
  height: 72px;
  min-width: 72px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--line);
}

.thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  padding: 4px;
}

.item-meta { min-width: 0; }

.item-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.item-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 999px;
  padding: 2px 8px;
  margin-top: 4px;
}

.badge-stored { background: #e3efe4; color: var(--green); }
.badge-removed { background: #f3e0e0; color: var(--red); }

.back {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 600;
}

.detail-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.detail-card h1 { margin-top: 0; }

.detail-grid { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; margin: 12px 0; font-size: 15px; }
.detail-grid dt { color: var(--muted); }
.detail-grid dd { margin: 0; }

.photo-grid { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }

.photo-grid .thumb {
  width: 96px;
  height: 96px;
  min-width: 96px;
  cursor: zoom-in;
}

.notes { margin-top: 12px; font-size: 15px; }

.nfc {
  background: var(--card);
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 20px;
}

.nfc p { margin: 0 0 8px; font-size: 14px; }

.nfc-row { display: flex; gap: 8px; }

.nfc-row input {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--muted);
}

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn:active { background: var(--accent-dark); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 32px 16px;
  font-size: 15px;
}

.result-count { color: var(--muted); font-size: 14px; margin: 8px 0; }

.viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  touch-action: pan-y;
}

.viewer-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 22px;
  cursor: pointer;
}

.viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  font-size: 24px;
  cursor: pointer;
}

.viewer-prev { left: 8px; }
.viewer-next { right: 8px; }

.viewer-caption {
  position: absolute;
  bottom: 14px;
  left: 0;
  right: 0;
  text-align: center;
  color: #fff;
  font-size: 14px;
}

.loading { text-align: center; color: var(--muted); padding: 48px 16px; }
