:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #1a6fb5;
  --accent-press: #155a94;
  --danger: #c0392b;
  --ok: #1e7a45;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --bar-h: 72px;
  --gap: 12px;
  --label-w: 6.8em;
}
* { box-sizing: border-box; }
html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
body {
  min-height: 100%;
  min-height: 100dvh;
}
.wrap {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding:
    calc(12px + var(--safe-top))
    calc(12px + var(--safe-right))
    calc(var(--bar-h) + var(--safe-bottom) + 12px)
    calc(12px + var(--safe-left));
}
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 12px 4px;
  margin-bottom: var(--gap);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}
.field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin-bottom: 12px;
}
.field label {
  flex: none;
  margin: 0;
  text-align: left;
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.3;
}
.field label .req {
  color: var(--danger);
  margin-left: 2px;
}
.field .control {
  flex: 1;
  min-width: 0;
  width: 100%;
}
input, select, textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 16px;
  background: #fff;
  color: var(--text);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, #9ca3af 50%), linear-gradient(135deg, #9ca3af 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 36px;
  color: var(--text);
  opacity: 1;
}
select option {
  color: #111827;
  background: #fff;
}
.editable-combo {
  display: block;
  width: 100%;
}
.editable-combo .combo-select,
.editable-combo .combo-text {
  display: block;
  width: 100%;
}
.combo-edit-toggle {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 8px 0 2px;
  padding: 0;
  border: none;
  background: none;
  color: #1a6fb5;
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  line-height: 1.4;
  -webkit-appearance: none;
  appearance: none;
}
.combo-edit-toggle:active {
  color: #155a94;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26, 111, 181, 0.14);
}
input:disabled, select:disabled {
  background: #f3f4f6;
  color: var(--muted);
}
.hint {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--muted);
}
.banner {
  display: none;
  position: sticky;
  top: calc(8px + var(--safe-top));
  z-index: 20;
  margin-bottom: 12px;
  padding: 11px 12px;
  border-radius: 12px;
  font-size: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}
.banner.show { display: block; }
.banner.err {
  background: #fdecea;
  color: var(--danger);
}
.banner.ok {
  background: #e8f7ee;
  color: var(--ok);
}
.submit-mask {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(40, 44, 52, 0.42);
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.submit-mask.show {
  display: flex;
}
.submit-mask-text {
  max-width: 280px;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
body.submitting {
  overflow: hidden;
}
.bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid var(--line);
  padding: 10px calc(12px + var(--safe-right)) calc(10px + var(--safe-bottom)) calc(12px + var(--safe-left));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.bar-inner {
  max-width: 560px;
  margin: 0 auto;
}
.btn {
  width: 100%;
  min-height: 48px;
  border: none;
  border-radius: 14px;
  padding: 13px 16px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}
.btn:active { background: var(--accent-press); }
.btn.secondary {
  background: #fff;
  color: var(--accent);
  border: 1px solid var(--accent);
  margin-top: 10px;
}
.btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}
a.link-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
}
.success-wrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-bottom: calc(24px + var(--safe-bottom));
}
.success-wrap .card {
  padding: 18px 14px 16px;
  margin-bottom: 0;
}
.success-wrap .btn {
  margin-top: 10px;
}
.code-box {
  text-align: center;
  padding: 22px 14px;
  background: #eef6fc;
  border-radius: 14px;
  margin-bottom: 14px;
}
.code-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
  font-weight: 600;
}
.code-value {
  font-size: clamp(18px, 5.2vw, 24px);
  font-weight: 800;
  letter-spacing: 0.08em;
  word-break: break-all;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.35;
  user-select: all;
  -webkit-user-select: all;
}
.code-input {
  width: 100%;
  min-height: auto;
  border: none;
  background: transparent;
  text-align: center;
  padding: 0;
  box-shadow: none;
  border-radius: 0;
  caret-color: transparent;
}
.code-input:focus {
  border: none;
  box-shadow: none;
}
.photo-field {
  align-items: stretch;
}
.photo-control {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.photo-box {
  width: 132px;
  height: 176px;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}
.photo-box.is-cert {
  width: 176px;
  height: 132px;
}
.photo-box:active {
  background: #eef2f7;
}
.photo-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}
.photo-box.is-cert img {
  object-fit: contain;
  background: #f8fafc;
}
.photo-box.has-photo img { display: block; }
.photo-box .placeholder {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 8px;
  line-height: 1.4;
}
.photo-box.has-photo .placeholder { display: none; }
.photo-actions {
  display: flex;
  flex-direction: row;
  gap: 8px;
  width: 132px;
}
.photo-control.is-cert .photo-actions {
  width: 176px;
}
.photo-actions .mini {
  flex: 1;
  min-height: 40px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.photo-actions .mini:active {
  background: #f3f4f6;
}
.photo-actions .mini.danger {
  color: var(--danger);
  border-color: #f0c2bd;
}
#photoInput { display: none; }
.checkbox-text {
  display: flex;
  align-items: center;
  gap: 10px;
}
.checkbox-text .field-check {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--accent);
}
.checkbox-text input[type="text"] {
  flex: 1;
  min-width: 0;
}

@media (min-width: 420px) {
  .field {
    flex-direction: row;
    align-items: center;
    gap: 10px;
  }
  .field:has(.editable-combo) {
    align-items: flex-start;
  }
  .field:has(.editable-combo) > label {
    padding-top: 12px;
  }
  .field label {
    flex: 0 0 var(--label-w);
    text-align: right;
    font-size: 15px;
    color: var(--text);
    font-weight: 500;
  }
  .photo-field {
    align-items: flex-start;
  }
  .photo-field > label {
    padding-top: 8px;
  }
  .photo-control {
    align-items: flex-start;
  }
}

@media (min-width: 520px) {
  .wrap {
    padding-left: 16px;
    padding-right: 16px;
  }
  .card {
    padding: 16px 16px 6px;
  }
}
