:root {
  --bg: #0b0c10;
  --panel: #151821;
  --line: #2a3142;
  --text: #f4f6fb;
  --muted: #9aa3b5;
  --gold: #e8c36a;
  --gold-2: #c9a24a;
  --danger: #ff7a7a;
  --safe: env(safe-area-inset-bottom, 16px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

body {
  min-height: 100dvh;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 16px 16px calc(12px + var(--safe));
}

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

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
}

.brand-mark {
  width: 12px;
  height: 36px;
  border-radius: 99px;
  background: linear-gradient(180deg, var(--gold), var(--gold-2));
}

h1 {
  font-size: 20px;
  letter-spacing: 0.04em;
}

.brand p,
.field span,
.chip,
.ghost-btn,
.side-btn,
.status-pill {
  font-size: 13px;
  color: var(--muted);
}

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.viewfinder {
  position: relative;
  flex: 1;
  min-height: 420px;
  border-radius: 24px;
  overflow: hidden;
  background: #05060a;
  border: 1px solid var(--line);
}

#camera, #snapshot, #previewImage {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scan-frame {
  pointer-events: none;
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(232, 195, 106, 0.28);
  border-radius: 18px;
}

.watermark {
  position: absolute;
  left: 22px;
  bottom: 22px;
  min-width: 180px;
  max-width: 78%;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(8, 10, 16, 0.55);
  border: 1px solid rgba(232, 195, 106, 0.35);
  backdrop-filter: blur(10px);
  color: #fff7e6;
}

.watermark.tl { top: 22px; left: 22px; bottom: auto; right: auto; }
.watermark.tr { top: 22px; right: 22px; left: auto; bottom: auto; text-align: right; }
.watermark.bl { bottom: 22px; left: 22px; top: auto; right: auto; }
.watermark.br { bottom: 22px; right: 22px; left: auto; top: auto; text-align: right; }

.wm-time {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.1;
}

.wm-date,
.wm-location,
.wm-note {
  margin-top: 4px;
  font-size: 13px;
  color: #f3e6c4;
}

.wm-note:empty {
  display: none;
}

.status-pill {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  white-space: nowrap;
}

.controls {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 14px;
}

.quick-row,
.preview-actions,
.sheet-head,
.shutter-row,
.pos-grid {
  display: flex;
  gap: 8px;
}

.quick-row {
  flex-wrap: wrap;
}

.chip,
.ghost-btn,
.side-btn,
.primary-btn,
.pos-grid button {
  border: 1px solid var(--line);
  background: #10131b;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
}

.chip.active,
.pos-grid button.active {
  background: rgba(232, 195, 106, 0.16);
  border-color: var(--gold);
  color: var(--gold);
}

.input-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field.hidden {
  display: none;
}

input[type="text"],
input[type="datetime-local"] {
  width: 100%;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0d1017;
  color: var(--text);
  padding: 0 12px;
}

.shutter-row {
  margin-top: 16px;
  align-items: center;
  justify-content: space-between;
}

.side-btn {
  min-width: 72px;
}

.shutter {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: radial-gradient(circle at 50% 50%, #fff 0 54%, transparent 56%),
    conic-gradient(from 180deg, var(--gold), #fff3cc, var(--gold-2), var(--gold));
  cursor: pointer;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.sheet-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.sheet-panel {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(520px, 100%);
  background: #12151d;
  border-top: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(18px + var(--safe));
  display: grid;
  gap: 14px;
}

.pos-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 10, 0.86);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 30;
}

.preview-card {
  width: min(520px, 100%);
  display: grid;
  gap: 14px;
}

.preview-card img {
  width: 100%;
  height: auto;
  max-height: 72vh;
  object-fit: contain;
  border-radius: 18px;
  background: #000;
}

.preview-actions {
  justify-content: flex-end;
}

.primary-btn {
  text-decoration: none;
  background: var(--gold);
  color: #1a1408;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
}

[hidden] {
  display: none !important;
}

@media (max-width: 420px) {
  .viewfinder {
    min-height: 360px;
  }
  .wm-time {
    font-size: 24px;
  }
}
