:root {
  --bg: #f3f1ed;
  --ink: #1d1c1a;
  --muted: #6f6a62;
  --line: #dcd7ce;
  --card: #ffffff;
  --accent: #1d1c1a;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  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%;
}

a { color: inherit; }

/* ---------- top bar ---------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.bar .titles { flex: 1; min-width: 0; }
.bar .site { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.bar h1 { margin: 0; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .count { font-size: 13px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.btn {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }

/* ---------- viewer ---------- */

.pages { max-width: 900px; margin: 0 auto; padding: 12px 8px 40px; }

.page {
  position: relative;
  width: 100%;
  margin: 0 0 12px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .14);
  overflow: hidden;
}
.page canvas { display: block; width: 100%; height: 100%; }

.status { max-width: 520px; margin: 18vh auto 0; padding: 0 24px; text-align: center; color: var(--muted); }
.status .big { font-size: 18px; color: var(--ink); margin-bottom: 8px; }
.status .btn { margin-top: 16px; }

.progress { height: 3px; width: 180px; margin: 16px auto 0; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--ink); transition: width .15s; }

/* ---------- index + admin ---------- */

.wrap { max-width: 980px; margin: 0 auto; padding: 28px 18px 60px; }
.wrap > h1 { font-size: 26px; margin: 0 0 4px; }
.lead { color: var(--muted); margin: 0 0 22px; }

.list { list-style: none; margin: 0; padding: 0; }
.list a {
  display: block;
  padding: 16px 18px;
  margin-bottom: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-decoration: none;
  font-weight: 600;
}

.field { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.field input {
  flex: 1; min-width: 240px;
  padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  font: inherit; background: #fff;
}

.note { padding: 12px 14px; margin-bottom: 18px; border-radius: 10px; background: #fff6d6; border: 1px solid #ecd98a; font-size: 14px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.card { padding: 18px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; text-align: center; break-inside: avoid; }
.card h2 { margin: 0 0 10px; font-size: 17px; }
.card canvas { width: 100%; max-width: 240px; height: auto; image-rendering: pixelated; }
.card .url { margin: 8px 0 12px; font-size: 12px; color: var(--muted); word-break: break-all; }
.card .missing { color: #b3261e; font-size: 13px; margin-bottom: 8px; }
.card .actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .wrap { padding: 0; max-width: none; }
  .cards { grid-template-columns: repeat(2, 1fr); gap: 10mm; }
  .card { border: 1px solid #999; }
}
