:root {
  --ink: #14110e;
  --paper: #efe6d4;
  --print: #f7f1e4;
  --amber: #e39a3c;
  --amber-dim: #c47a22;
  --rust: #9a3b2a;
  --mute: #8a7d6b;
  --line: rgba(227, 154, 60, 0.28);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: "Noto Sans SC", "Songti SC", sans-serif;
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
}

.grain,
.safelight,
.sprockets {
  pointer-events: none;
  position: fixed;
}

.grain {
  inset: 0;
  z-index: 0;
  opacity: 0.09;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

.safelight {
  z-index: 0;
  width: 42vw;
  height: 42vw;
  top: -12vw;
  right: -10vw;
  background: radial-gradient(circle, rgba(227, 154, 60, 0.22), transparent 68%);
  filter: blur(8px);
}

.sprockets {
  z-index: 0;
  top: 0;
  bottom: 0;
  width: 22px;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0 18px,
      #2a241c 18px 34px
    );
  opacity: 0.55;
}

.sprockets-left { left: 8px; }
.sprockets-right { right: 8px; }

.shell {
  position: relative;
  z-index: 1;
  width: min(1200px, calc(100% - 64px));
  margin: 0 auto;
  padding: 48px 0 80px;
}

.site-footer {
  margin-top: 56px;
  text-align: center;
}

.site-footer a {
  color: var(--mute);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--amber);
}

.account-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
  color: var(--mute);
  font-size: 13px;
}

.account-bar a {
  color: var(--amber);
  text-decoration: none;
}

.account-bar .anchor-clear {
  margin-top: 0;
}

.admin-default {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px 16px;
  align-items: end;
}

.admin-default .btn {
  min-height: 44px;
}

.admin-default .anchor-hint {
  grid-column: 1 / -1;
}

.admin-table-wrap {
  margin-top: 28px;
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.admin-table th {
  color: var(--mute);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.admin-table .mono {
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

.admin-table .mute { color: var(--mute); font-size: 12px; }

.admin-table input[type="number"] {
  width: 88px;
  min-height: 36px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: #1b1308;
  color: var(--paper);
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

.admin-table .btn {
  min-height: 36px;
  padding: 0 14px;
  font-size: 13px;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(12, 10, 8, 0.78);
}

.auth-gate[hidden] { display: none; }

.auth-card {
  width: min(420px, calc(100% - 40px));
  padding: 28px 24px 22px;
  background: var(--print);
  color: #231c14;
  box-shadow: var(--shadow);
}

.auth-card h2 {
  margin: 8px 0 8px;
  font-family: "Noto Serif SC", serif;
  font-size: 32px;
}

.auth-lead {
  margin: 0 0 18px;
  color: #6f6253;
  font-size: 14px;
  line-height: 1.6;
}

.auth-card .anchor-field {
  margin-bottom: 14px;
  color: #6f6253;
}

.auth-card input {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid rgba(35, 28, 20, 0.18);
  background: #fffaf1;
  color: #231c14;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 16px;
  letter-spacing: 0.08em;
}

.auth-card .btn {
  width: 100%;
  margin-top: 8px;
  border: 0;
}

.auth-card .anchor-clear {
  display: block;
  width: 100%;
  margin-top: 14px;
  text-align: center;
}

.auth-error {
  margin: 0 0 10px;
  color: var(--rust);
  font-size: 13px;
}

.tea-card {
  text-align: center;
}

.pay-qr {
  display: block;
  width: min(240px, 70%);
  margin: 8px auto 12px;
  background: #fff;
}

.mast h1 {
  margin: 8px 0 16px;
  font-family: "Noto Serif SC", "Fraunces", serif;
  font-size: clamp(42px, 10vw, 72px);
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
}

.kicker {
  margin: 0;
  color: var(--amber);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.28em;
}

.lede {
  margin: 0;
  max-width: 36em;
  color: #d8ccb6;
  font-size: 16px;
  line-height: 1.75;
}

.lede strong { color: var(--amber); font-weight: 700; }

.scan-guide {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 32px;
  align-items: start;
  margin-top: 32px;
  padding: 22px 22px 20px;
  border: 1px solid var(--line);
  background: rgba(255, 248, 232, 0.03);
}

.scan-guide h2 {
  margin: 6px 0 14px;
  font-family: "Noto Serif SC", serif;
  font-size: 22px;
}

.faq-list {
  margin: 0;
  display: grid;
  gap: 16px;
}

.faq-list dt {
  color: var(--paper);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.55;
}

.faq-list dd {
  margin: 6px 0 0;
  color: #b6a892;
  font-size: 13px;
  line-height: 1.7;
}

.scan-how {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.scan-guide-copy {
  margin: 0 0 16px;
  color: #d8ccb6;
  font-size: 14px;
  line-height: 1.7;
}

.scan-guide-copy strong { color: var(--amber); }

.scan-shots {
  display: flex;
  gap: 12px;
}

.scan-shots figure {
  width: 148px;
  margin: 0;
  background: #0e0c0a;
  border: 1px solid var(--line);
}

.scan-shots img {
  display: block;
  width: 148px;
  height: auto;
  object-fit: contain;
  background: #0e0c0a;
}

.scan-shots figcaption {
  padding: 8px 8px 10px;
  color: #cbbca6;
  font-size: 11px;
  line-height: 1.4;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 36px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 22px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  user-select: none;
}

.btn-primary {
  background: var(--amber);
  color: #1b1308;
  box-shadow: 0 0 0 1px rgba(255, 210, 140, 0.35) inset;
}

.btn-ghost {
  background: transparent;
  color: var(--paper);
  border: 1px solid var(--line);
}

.btn:active { transform: translateY(1px); }

.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none;
}

.hint {
  margin: 18px 0 0;
  color: var(--mute);
  font-size: 13px;
  line-height: 1.7;
}

.hint code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px;
  color: #d7b07a;
}

.empty {
  margin-top: 40px;
}

.empty-frame {
  border: 1px dashed var(--line);
  padding: 42px 24px;
  text-align: center;
  background: rgba(255, 248, 232, 0.03);
}

.empty-date {
  display: block;
  margin-bottom: 14px;
  color: var(--amber);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 22px;
  letter-spacing: 0.12em;
}

.empty-frame p {
  margin: 0;
  color: var(--mute);
}

.results {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-top: 36px;
}

.card {
  position: relative;
  overflow: hidden;
  background: #0e0c0a;
  animation: rise 420ms ease both;
}

.card-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(12, 8, 4, 0.72);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.card-remove:hover {
  background: #9a3b2a;
}

.load-progress {
  margin-top: 28px;
}

.load-progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: #d8ccb6;
  font-size: 14px;
}

#progress-ratio {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  color: var(--amber);
}

.progress-track {
  height: 8px;
  overflow: hidden;
  background: rgba(255, 248, 232, 0.08);
  border: 1px solid var(--line);
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--stamp-color, var(--amber));
  transition: width 220ms ease;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.photo-wrap {
  position: relative;
  background: #0e0c0a;
  aspect-ratio: 1;
}

.photo-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-row {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 28px;
  align-items: start;
  margin-top: 36px;
}

.hero-side .actions { margin-top: 8px; }

.anchor-panel {
  margin-top: 28px;
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 248, 232, 0.03);
}

.anchor-field {
  display: grid;
  gap: 8px;
  color: var(--mute);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.anchor-field input[type="date"] {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #1b1308;
  color: var(--paper);
  color-scheme: dark;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 15px;
}

.anchor-hint {
  margin: 10px 0 0;
  color: #8a7d6b;
  font-size: 12px;
  line-height: 1.6;
  font-weight: 400;
  letter-spacing: 0;
}

.format-switch {
  display: flex;
  margin-top: 14px;
  border: 1px solid var(--line);
}

.fmt {
  flex: 1;
  min-height: 40px;
  border: 0;
  background: transparent;
  color: var(--paper);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.fmt.is-on {
  background: var(--stamp-color, var(--amber));
  color: #1b1308;
}

.anchor-clear {
  margin-top: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--amber);
  cursor: pointer;
  font-size: 13px;
}

.style-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: end;
  margin-top: 18px;
}

.style-row input[type="range"] {
  width: 100%;
  accent-color: var(--stamp-color, #ffb24a);
}

.style-row input[type="color"] {
  width: 48px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}

.swatches {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.swatch {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
}

.qr-ticket {
  padding: 18px 16px 16px;
  background: var(--print);
  color: #231c14;
  box-shadow: var(--shadow);
}

.qr-kicker,
.qr-url {
  margin: 0;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.qr-kicker {
  color: var(--amber-dim);
  font-size: 11px;
}

.qr-ticket h2 {
  margin: 12px 0 6px;
  font-family: "Noto Serif SC", serif;
  font-size: 22px;
}

.qr-copy {
  margin: 0 0 10px;
  color: #6f6253;
  font-size: 13px;
  line-height: 1.6;
}

.qr-frame {
  display: grid;
  place-items: center;
  margin: 12px 0 4px;
  padding: 10px;
  background: #ffffff;
}

.qr-img {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.qr-wait,
.qr-url {
  color: #8a7a64;
  font-size: 10px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  letter-spacing: 0;
  text-transform: none;
}

.qr-status {
  margin: 10px 0 0;
  color: var(--amber-dim);
  font-size: 13px;
  font-weight: 700;
}

.qr-status.is-live { color: #3f6b16; }

.scan-page {
  min-height: 100dvh;
}

.pick-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.pick-overlay.is-idle {
  pointer-events: none;
  height: 0;
}

.scan-shell {
  position: relative;
  z-index: 1;
  padding: 72px 28px 40px;
  text-align: center;
}

.scan-shell h1 {
  margin: 8px 0 16px;
  font-family: "Noto Serif SC", serif;
  font-size: 42px;
}

.scan-lead {
  margin: 0 auto;
  max-width: 18em;
  color: #d8ccb6;
  line-height: 1.7;
}

.scan-pulse {
  margin: 28px auto 0;
  width: fit-content;
  padding: 8px 14px;
  border: 1px solid var(--line);
  color: var(--amber);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: 0.18em;
  animation: pulse 1.4s ease-in-out infinite;
}

.scan-pulse.is-done {
  animation: none;
  color: #d7f0a3;
  border-color: rgba(215, 240, 163, 0.35);
}

@keyframes pulse {
  50% { opacity: 0.45; }
}

.scan-results {
  position: relative;
  z-index: 1;
  width: min(720px, calc(100% - 48px));
  margin: 12px auto 24px;
}

.scan-again {
  position: relative;
  z-index: 1;
  display: flex;
  width: min(280px, calc(100% - 48px));
  margin: 28px auto 0;
  border: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 30;
  transform: translateX(-50%);
  padding: 12px 18px;
  background: var(--amber);
  color: #1b1308;
  font-weight: 700;
  box-shadow: var(--shadow);
}

@media (max-width: 1100px) {
  .results { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .hero-row {
    grid-template-columns: 1fr;
  }

  .qr-ticket {
    max-width: 280px;
  }

  .results { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .shell { width: min(1200px, calc(100% - 52px)); padding-top: 36px; }
  .sprockets { width: 14px; }
  .scan-guide {
    grid-template-columns: 1fr;
  }
  .scan-how { order: -1; }
  .scan-shots { justify-content: flex-start; }
}
