:root {
  color-scheme: light;
  --ink: #162019;
  --muted: #718078;
  --line: #dfe5e1;
  --surface: #ffffff;
  --accent: #186a45;
  --accent-soft: #e4f2e9;
  --page: #f4f6f4;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -20%, rgba(66, 139, 99, .14), transparent 40%),
    var(--page);
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.shell {
  width: min(100%, 480px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 22px max(24px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
}

.code-view { width: 100%; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .16em;
}

h1, h2, p { margin-top: 0; }
.topbar h1 { margin: 0; font-size: 24px; letter-spacing: -.04em; }

.badge {
  padding: 7px 10px;
  border: 1px solid #cfe1d6;
  border-radius: 999px;
  color: var(--accent);
  background: rgba(255, 255, 255, .72);
  font-size: 12px;
  font-weight: 700;
}

.qr-card {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 11%;
  overflow: hidden;
  border: 1px solid rgba(21, 44, 31, .08);
  border-radius: 30px;
  background: var(--surface);
  box-shadow: 0 20px 60px rgba(26, 55, 38, .10), 0 2px 8px rgba(26, 55, 38, .04);
}

#qrCanvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  image-rendering: pixelated;
}

.scan-corners {
  position: absolute;
  inset: 18px;
  pointer-events: none;
  background:
    linear-gradient(var(--accent), var(--accent)) left top / 24px 2px no-repeat,
    linear-gradient(var(--accent), var(--accent)) left top / 2px 24px no-repeat,
    linear-gradient(var(--accent), var(--accent)) right top / 24px 2px no-repeat,
    linear-gradient(var(--accent), var(--accent)) right top / 2px 24px no-repeat,
    linear-gradient(var(--accent), var(--accent)) left bottom / 24px 2px no-repeat,
    linear-gradient(var(--accent), var(--accent)) left bottom / 2px 24px no-repeat,
    linear-gradient(var(--accent), var(--accent)) right bottom / 24px 2px no-repeat,
    linear-gradient(var(--accent), var(--accent)) right bottom / 2px 24px no-repeat;
}

.status-panel {
  margin-top: 16px;
  padding: 17px 18px 15px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, .78);
  backdrop-filter: blur(14px);
}

.status-line, .meta-line {
  display: flex;
  align-items: center;
}

.status-line { font-size: 14px; }
.status-line strong { margin-left: auto; font-variant-numeric: tabular-nums; }

.live-dot {
  width: 8px;
  height: 8px;
  margin-right: 9px;
  border-radius: 50%;
  background: #20a464;
  box-shadow: 0 0 0 5px rgba(32, 164, 100, .11);
}

.divider { height: 1px; margin: 13px 0 12px; background: var(--line); }
.meta-line { justify-content: space-between; color: var(--muted); font-size: 12px; }
.meta-line time { color: #4f5e55; font-variant-numeric: tabular-nums; }
.expiry-row strong { color: var(--accent); font-size: 12px; font-variant-numeric: tabular-nums; }

.hint {
  margin: 14px 18px 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

.share-button, .primary-button {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 16px;
  color: white;
  background: var(--accent);
  font-weight: 750;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease;
}

.share-button { display: flex; align-items: center; justify-content: center; gap: 10px; }
.share-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.share-button:active, .primary-button:active { transform: scale(.985); background: #11593a; }

.state-view {
  width: 100%;
  padding: 48px 28px;
  text-align: center;
}

.state-view h1 { margin-bottom: 10px; font-size: 24px; }
.state-view p { margin: 0; color: var(--muted); line-height: 1.7; }
.brand-mark, .state-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 22px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 32px;
  font-weight: 700;
}
.state-icon svg { width: 30px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.state-icon.muted { color: #707a74; background: #e8ece9; }
.qr-error { color: #a53d3d; font-size: 14px; }

.share-dialog {
  width: min(calc(100% - 24px), 460px);
  margin: auto auto 10px;
  padding: 0;
  border: 0;
  border-radius: 26px;
  background: transparent;
}
.share-dialog::backdrop { background: rgba(8, 18, 12, .46); backdrop-filter: blur(4px); }
.dialog-card { padding: 10px 22px max(22px, env(safe-area-inset-bottom)); border-radius: 26px; background: var(--surface); }
.dialog-handle { width: 38px; height: 4px; margin: 0 auto 20px; border-radius: 99px; background: #d6ddd8; }
.dialog-title-row { display: flex; align-items: flex-start; justify-content: space-between; }
.dialog-title-row h2 { margin-bottom: 22px; font-size: 21px; }
.icon-button { width: 36px; height: 36px; border: 0; border-radius: 50%; color: #657168; background: #f0f3f1; font-size: 23px; cursor: pointer; }

.duration-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: #48564d;
  font-size: 14px;
}
.input-wrap { display: flex; align-items: baseline; gap: 6px; }
.input-wrap input { width: 76px; padding: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 21px; font-weight: 800; text-align: right; }
.input-wrap b { color: var(--muted); font-size: 12px; }
.expiry-preview { min-height: 20px; margin: 12px 4px 18px; color: var(--muted); font-size: 12px; }
.share-link-field {
  display: block;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 12px;
}
.share-link-field span { display: block; margin: 0 3px 7px; }
.share-link-field input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  color: #425149;
  background: #f6f8f6;
  font-size: 12px;
}
.share-link-field input:focus { border-color: #83ad94; box-shadow: 0 0 0 3px rgba(24, 106, 69, .08); }
.primary-button:disabled { cursor: wait; opacity: .55; }
.dialog-note { margin: 11px 0 0; color: #8a958e; font-size: 11px; text-align: center; }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  z-index: 20;
  max-width: calc(100% - 40px);
  padding: 11px 16px;
  border-radius: 999px;
  color: white;
  background: rgba(20, 30, 24, .92);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
[hidden] { display: none !important; }

@media (min-width: 600px) {
  .shell { padding-top: 44px; padding-bottom: 44px; }
  .share-dialog { margin: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
