:root {
  color-scheme: light;
  --ink: #17233b;
  --muted: #68758a;
  --subtle: #8b97aa;
  --paper: #f7fbff;
  --card: rgba(255, 255, 255, 0.96);
  --panel: #eef7fb;
  --line: rgba(42, 72, 107, 0.14);
  --brand: #1769aa;
  --brand-strong: #0b4f8a;
  --clinical: #0e9f9a;
  --clinical-soft: #dff6f4;
  --navy: #102a43;
  --danger: #b42318;
  --success: #087f5b;
  --shadow: 0 18px 48px rgba(31, 71, 112, 0.14);
  --radius: 22px;
  font-family: "Noto Sans SC", "Noto Sans TC", "Source Han Sans SC", "Source Han Sans TC", "HarmonyOS Sans", "MiSans", "Aptos", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--ink);
  background:
    linear-gradient(rgba(23, 105, 170, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 105, 170, 0.045) 1px, transparent 1px),
    radial-gradient(circle at 15% 0%, rgba(14, 159, 154, 0.16), transparent 30%),
    radial-gradient(circle at 95% 12%, rgba(23, 105, 170, 0.18), transparent 32%),
    linear-gradient(180deg, #f8fcff 0%, #eef7fb 52%, #f7fbff 100%);
  background-size: 22px 22px, 22px 22px, auto, auto, auto;
  background-attachment: fixed;
}

button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; }

.app-shell {
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(28px, env(safe-area-inset-bottom));
}

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

.brand-mark { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo-dot {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: transparent;
  background: linear-gradient(145deg, #1f7fbd, #0e9f9a);
  box-shadow: 0 12px 28px rgba(23, 105, 170, 0.22);
}
.logo-dot::before, .logo-dot::after {
  content: "";
  position: absolute;
  border-radius: 2px;
  background: #fff;
}
.logo-dot::before { width: 20px; height: 5px; }
.logo-dot::after { width: 5px; height: 20px; }
.brand-title { font-size: 16px; font-weight: 820; letter-spacing: -0.01em; }
.brand-subtitle { color: var(--muted); font-size: 12px; margin-top: 2px; }

.lang-row { display: flex; gap: 6px; padding: 4px; border-radius: 999px; background: rgba(255, 255, 255, 0.82); border: 1px solid var(--line); }
.lang-row button {
  min-width: 39px;
  padding: 8px 9px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}
.lang-row button.active { background: var(--brand); color: white; box-shadow: 0 6px 16px rgba(23, 105, 170, 0.2); }

.card {
  position: relative;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.88);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  backdrop-filter: blur(16px);
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(90deg, var(--brand), var(--clinical));
}

.hero { padding: 22px; min-height: calc(100dvh - 34px); display: flex; flex-direction: column; justify-content: center; }
.kicker {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 7px;
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 7px 10px;
  border-radius: 999px;
  background: #e8f3fb;
  border: 1px solid rgba(23, 105, 170, 0.12);
}
.kicker::before { content: ""; width: 7px; height: 7px; border-radius: 99px; background: var(--clinical); }

h1, h2, h3 { margin: 0; color: var(--navy); letter-spacing: -0.025em; }
h1 { margin-top: 14px; font-size: clamp(31px, 9.6vw, 45px); line-height: 1.03; }
h2 { font-size: 27px; line-height: 1.08; }
h3 { font-size: 17px; }
p { color: var(--muted); line-height: 1.62; }

.stage-pills { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin: 12px 0 18px; }
.stage-pills span { height: 6px; border-radius: 999px; background: #d9e7f2; }
.stage-pills span.active { background: linear-gradient(90deg, var(--brand), var(--clinical)); }

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 18px 0 2px;
  padding: 5px;
  border-radius: 16px;
  background: #eef5fb;
  border: 1px solid var(--line);
}
.auth-tabs button {
  min-height: 44px;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}
.auth-tabs button.active { background: #fff; color: var(--brand-strong); box-shadow: 0 8px 20px rgba(31, 71, 112, 0.1); }

.form-grid { display: grid; gap: 14px; margin-top: 18px; }
.field { display: grid; gap: 7px; }
.field label, .field-label { color: var(--navy); font-size: 13px; font-weight: 820; }
.field small, .helper-text { color: var(--subtle); font-size: 12px; line-height: 1.45; }
.input, select, textarea {
  width: 100%;
  min-height: 52px;
  padding: 14px 15px;
  border-radius: 14px;
  color: var(--ink);
  background: #fbfdff;
  border: 1px solid #cfdeeb;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}
textarea { min-height: 104px; resize: vertical; }
.input:focus, select:focus, textarea:focus {
  border-color: rgba(23, 105, 170, 0.62);
  box-shadow: 0 0 0 4px rgba(23, 105, 170, 0.12);
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice-grid.three { grid-template-columns: repeat(3, 1fr); }
.choice {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid #cfdeeb;
  background: #fbfdff;
  color: var(--muted);
  text-align: center;
  font-weight: 780;
}
.choice input { position: absolute; inset: 0; opacity: 0; }
.choice:has(input:checked) { background: var(--clinical-soft); color: #06615e; border-color: rgba(14, 159, 154, 0.36); }

.primary, .secondary, .ghost, .danger {
  width: 100%;
  min-height: 54px;
  border-radius: 14px;
  padding: 14px 16px;
  font-weight: 850;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.primary { color: white; background: linear-gradient(135deg, var(--brand), var(--brand-strong)); box-shadow: 0 14px 26px rgba(23, 105, 170, 0.22); }
.secondary { color: #075d5a; background: var(--clinical-soft); border: 1px solid rgba(14, 159, 154, 0.18); }
.ghost { color: var(--brand-strong); background: #f7fbff; border: 1px solid #cfdeeb; }
.danger { color: white; background: var(--danger); }
.primary[disabled], .secondary[disabled], .ghost[disabled] { opacity: 0.55; }

.actions { display: grid; gap: 10px; margin-top: 18px; }
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.notice {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 14px;
  color: #075d5a;
  background: var(--clinical-soft);
  border: 1px solid rgba(14, 159, 154, 0.22);
}
.notice.error { color: #842029; background: #fff1f0; border-color: rgba(180, 35, 24, 0.22); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 42, 67, 0.42);
  backdrop-filter: blur(8px);
}

.review-modal {
  width: min(100%, 560px);
  display: grid;
  gap: 12px;
  padding: 20px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid rgba(255,255,255,0.86);
  box-shadow: 0 24px 70px rgba(16, 42, 67, 0.28);
}

.review-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  background: var(--brand);
}
.review-modal.success .review-icon { background: var(--success); }
.review-modal.error .review-icon { background: var(--danger); }
.review-modal h3 { font-size: 21px; }
.review-modal p { margin: 0; color: var(--navy); font-weight: 820; }
.review-details {
  white-space: pre-line;
  line-height: 1.55;
  color: var(--muted);
  background: #f7fbff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}
.review-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 2px; }
.review-actions .primary:only-child { grid-column: 1 / -1; }
.review-spinner {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.48);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.summary-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0; }
.summary-strip div, .duration-list div {
  border-radius: 14px;
  background: #f7fbff;
  border: 1px solid var(--line);
  padding: 12px;
}
.summary-strip b { display: block; font-size: 18px; color: var(--brand-strong); }
.summary-strip span { color: var(--muted); font-size: 12px; }

.capture-card { overflow: hidden; padding: 0; }
.capture-card::before { height: 5px; }
.capture-head { padding: 20px 18px 12px; }
.progress-ring { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.step-count {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(145deg, var(--brand), var(--clinical));
  font-size: 20px;
  font-weight: 900;
}
.step-meter { flex: 1; height: 8px; border-radius: 999px; background: #dcebf5; overflow: hidden; }
.step-meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--clinical)); }

.guide-frame {
  margin: 0 18px 16px;
  min-height: 260px;
  border-radius: 18px;
  overflow: hidden;
  background: #0f2537;
  position: relative;
  border: 1px solid rgba(16, 42, 67, 0.16);
}
.guide-frame img { width: 100%; height: 100%; min-height: 260px; object-fit: contain; display: block; }
.preview-badge {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 8px 11px;
  border-radius: 999px;
  color: white;
  background: rgba(16, 42, 67, 0.78);
  font-size: 12px;
  font-weight: 820;
}

.tips { display: grid; gap: 8px; margin: 14px 18px 0; padding: 0 0 16px; }
.tip { display: flex; gap: 8px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.tip::before { content: ""; width: 7px; height: 7px; flex: 0 0 7px; margin-top: 7px; border-radius: 999px; background: var(--clinical); }
.live-panel {
  margin: 0 18px 14px;
  padding: 12px;
  border-radius: 16px;
  background: #f7fbff;
  border: 1px solid var(--line);
}
.live-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.live-toolbar button {
  width: auto;
  min-height: 42px;
  padding: 10px 13px;
  border-radius: 12px;
  white-space: nowrap;
}
.live-status {
  flex: 1 1 170px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
  line-height: 1.35;
}
.live-status.good { color: var(--success); }
.live-status.error { color: var(--danger); }
.live-view {
  position: relative;
  margin-top: 12px;
  aspect-ratio: 9 / 16;
  max-height: min(72dvh, 620px);
  overflow: hidden;
  border-radius: 14px;
  background: #0f2537;
}
.live-view video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}
.live-guide-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0.46;
  filter: drop-shadow(0 0 8px rgba(0, 0, 0, 0.42));
  mix-blend-mode: screen;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
.live-guide-overlay.hidden {
  opacity: 0;
}
.live-reticle {
  position: absolute;
  inset: 13%;
  border: 2px solid rgba(255, 255, 255, 0.76);
  border-radius: 18px;
  box-shadow: 0 0 0 999px rgba(6, 24, 36, 0.14);
  pointer-events: none;
}
.live-reticle i,
.live-reticle b {
  position: absolute;
  display: block;
  background: rgba(255, 255, 255, 0.72);
}
.live-reticle i {
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
}
.live-reticle b {
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
}
.camera-picker {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}
.camera-picker span {
  color: var(--navy);
  font-size: 13px;
  font-weight: 820;
}
.live-capture { margin-top: 10px; }
.photo-input { display: none; }
.capture-actions { padding: 0 18px 18px; display: grid; gap: 10px; }

.upload-status { display: grid; gap: 12px; }
.loader { height: 10px; border-radius: 999px; background: #dcebf5; overflow: hidden; }
.loader i { display: block; height: 100%; width: var(--pct, 0%); background: linear-gradient(90deg, var(--brand), var(--clinical)); transition: width 0.25s ease; }

.check-list { display: grid; gap: 10px; margin-top: 14px; }
.check-list label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border-radius: 14px;
  background: #f7fbff;
  border: 1px solid var(--line);
}
.check-list input { margin-top: 4px; }

.duration-list { display: grid; gap: 8px; margin-top: 14px; }
.duration-list div { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); }
.duration-list b { color: var(--brand-strong); }

details.api-box { margin-top: 16px; color: var(--muted); }
details.api-box summary { font-weight: 820; color: var(--brand-strong); }
.footer-note { text-align: center; font-size: 12px; color: var(--muted); margin-top: 16px; }
.hidden { display: none !important; }

@media (prefers-reduced-motion: no-preference) {
  .card { animation: clinical-rise 260ms ease both; }
  @keyframes clinical-rise { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
}
