:root {
  --text: #182131;
  --muted: #5f6b80;
  --accent: #6168e9;
  --accent-soft: rgba(97, 104, 233, .12);
  --card: rgba(255, 255, 255, .92);
  --card-border: rgba(116, 135, 181, .18);
  --field: #f5f7fc;
  --field-border: #dde3f0;
  --bg: #f4f7ff;
  --glow-a: rgba(137, 163, 255, .32);
  --glow-b: rgba(154, 221, 255, .38);
  --success: #1f8a58;
  --success-soft: rgba(31, 138, 88, .1);
  --danger: #c43d3d;
  --danger-soft: rgba(196, 61, 61, .1);
  --pending: #b7791f;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #e9edf6;
    --muted: #9aa5ba;
    --accent: #8d92ff;
    --accent-soft: rgba(141, 146, 255, .16);
    --card: rgba(28, 31, 42, .92);
    --card-border: rgba(255, 255, 255, .08);
    --field: #232735;
    --field-border: #343a4d;
    --bg: #12141c;
    --glow-a: rgba(97, 104, 233, .22);
    --glow-b: rgba(64, 140, 190, .18);
    --success: #5fd49a;
    --success-soft: rgba(95, 212, 154, .12);
    --danger: #ff8080;
    --danger-soft: rgba(255, 128, 128, .12);
    --pending: #f0b35a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 15%, var(--glow-a), transparent 35%),
    radial-gradient(circle at 90% 85%, var(--glow-b), transparent 38%),
    var(--bg);
}

.page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.loading { color: var(--muted); }

.card {
  width: min(100%, 520px);
  padding: 38px;
  border: 1px solid var(--card-border);
  border-radius: 28px;
  background: var(--card);
  box-shadow: 0 24px 70px rgba(53, 71, 117, .16);
  backdrop-filter: blur(18px);
}

.card.compose { width: min(100%, 760px); padding: 28px 32px 32px; }

.brand {
  width: 54px;
  height: 54px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 17px;
  color: white;
  font: 700 28px/1 Georgia, serif;
  background: linear-gradient(145deg, #8d92ff, #6168e9);
  box-shadow: 0 12px 24px rgba(98, 105, 233, .3);
}

.brand.small { width: 40px; height: 40px; border-radius: 12px; font-size: 21px; box-shadow: none; }

.eyebrow {
  margin: 25px 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .16em;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 7vw, 36px);
  letter-spacing: -.03em;
}

.intro { margin: 12px 0 0; color: var(--muted); line-height: 1.6; }

.qr-box {
  position: relative;
  width: 240px;
  height: 240px;
  margin: 28px auto 24px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 0 0 1px var(--field-border);
  overflow: hidden;
}

.qr-box img { width: 224px; height: 224px; image-rendering: pixelated; }
.qr-box img.expired { opacity: .12; filter: blur(2px); }
.qr-placeholder { color: #5f6b80; font-size: 14px; }

.qr-refresh {
  position: absolute;
  inset: auto 20px 50% 20px;
  transform: translateY(50%);
  padding: 12px 14px;
  border: 0;
  border-radius: 12px;
  color: white;
  font: inherit;
  font-weight: 600;
  background: var(--accent);
  cursor: pointer;
}

.facts {
  margin: 0;
  padding: 18px 20px 18px 38px;
  border-radius: 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
  background: var(--accent-soft);
}

.compose-header { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.compose-title { flex: 1; min-width: 0; display: grid; gap: 2px; }
.compose-title strong { font-size: 19px; }

.status { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status[data-state="ok"]::before { content: "● "; color: var(--success); }
.status[data-state="pending"]::before { content: "● "; color: var(--pending); }

.ghost {
  flex: none;
  padding: 8px 12px;
  border: 1px solid var(--field-border);
  border-radius: 10px;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  background: transparent;
  cursor: pointer;
}

.ghost:hover { color: var(--text); }

.row { display: flex; gap: 12px; }

input, textarea {
  width: 100%;
  border: 1px solid var(--field-border);
  border-radius: 14px;
  color: var(--text);
  font: inherit;
  background: var(--field);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input { padding: 13px 15px; font-size: 17px; }
input#title { font-weight: 600; }
input[type="date"] { width: 180px; flex: none; font-size: 15px; }
textarea {
  display: block;
  margin-top: 12px;
  min-height: 280px;
  padding: 15px;
  font-size: 17px;
  line-height: 1.75;
  resize: none;
}

input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.hint { color: var(--muted); font-size: 13px; }

button[type="submit"] {
  min-width: 140px;
  padding: 13px 22px;
  border: 0;
  border-radius: 14px;
  color: white;
  font: inherit;
  font-weight: 650;
  background: linear-gradient(145deg, #8d92ff, #6168e9);
  box-shadow: 0 10px 22px rgba(98, 105, 233, .28);
  cursor: pointer;
}

button:disabled { opacity: .6; cursor: progress; }
button:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }

.result { margin-top: 16px; padding: 13px 16px; border-radius: 14px; font-size: 14px; line-height: 1.6; }
.result[data-kind="success"] { color: var(--success); background: var(--success-soft); }
.result[data-kind="error"] { color: var(--danger); background: var(--danger-soft); }

.open-app {
  display: block;
  margin-top: 26px;
  padding: 14px;
  border-radius: 14px;
  color: white;
  font-weight: 650;
  text-align: center;
  text-decoration: none;
  background: linear-gradient(145deg, #8d92ff, #6168e9);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 560px) {
  .card, .card.compose { padding: 26px 20px; border-radius: 22px; }
  .row { flex-direction: column; }
  input[type="date"] { width: 100%; }
  .hint { display: none; }
  button[type="submit"] { width: 100%; }
}

/* 照片 */
.photo-section { margin-top: 12px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.thumb, .add-photo {
  position: relative;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: white;
  font-size: 16px;
  line-height: 1;
  background: rgba(0, 0, 0, .55);
  cursor: pointer;
}
.thumb.processing::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--field);
  animation: pulse 1s ease-in-out infinite alternate;
}
@keyframes pulse { from { opacity: .9; } to { opacity: .5; } }
.add-photo {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  border: 1.5px dashed var(--field-border);
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  background: var(--field);
  cursor: pointer;
}
.add-photo span { font-size: 26px; line-height: 1; }
.add-photo:hover { color: var(--accent); border-color: var(--accent); }
.photo-hint { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.photo-hint[data-kind="error"] { color: var(--danger); }
.compose.dragging { outline: 3px dashed var(--accent); outline-offset: -10px; }
