:root {
  color-scheme: light;
  --bg: #f3f2ed;
  --surface: #ffffff;
  --surface-2: #eceee9;
  --ink: #172019;
  --muted: #667067;
  --line: #d8ddd7;
  --accent: #315a3b;
  --accent-strong: #21462c;
  --danger: #9b302f;
  --success: #2d6c3d;
  --radius: 18px;
  --shadow: 0 8px 24px rgba(20, 34, 23, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif; }
body { padding-bottom: env(safe-area-inset-bottom); }
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.app-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: calc(14px + env(safe-area-inset-top)) 18px 12px; background: rgba(243,242,237,.94); backdrop-filter: blur(12px); border-bottom: 1px solid rgba(216,221,215,.8); }
.eyebrow { margin: 0 0 2px; color: var(--muted); font-size: 12px; letter-spacing: .08em; }
h1 { margin: 0; font-size: 22px; }
h2 { margin: 0 0 14px; font-size: 19px; }
.app-main { width: min(680px, 100%); margin: 0 auto; padding: 18px 14px 36px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.mode-card { margin-top: 10px; }
.mode-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.mode-button { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; min-height: 68px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); text-align: left; }
.mode-button:active { transform: translateY(1px); }
.mode-title { font-size: 17px; font-weight: 700; }
.mode-note { color: var(--muted); font-size: 13px; }
.status-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.badge { display: inline-flex; align-items: center; min-height: 30px; padding: 5px 10px; border-radius: 999px; background: #dfe9e1; color: var(--accent-strong); font-weight: 700; font-size: 13px; }
.text-button { border: 0; background: transparent; color: var(--accent); padding: 8px; text-decoration: underline; text-underline-offset: 3px; }
.progress-card { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-bottom: 12px; padding: 12px; box-shadow: none; }
.progress-item { display: flex; gap: 9px; align-items: center; min-width: 0; }
.progress-item > div { min-width: 0; }
.progress-item strong, .result-placeholder { display: block; }
.result-placeholder { margin-top: 3px; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-item.done .result-placeholder { color: var(--success); font-weight: 700; }
.step-number { flex: 0 0 28px; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); font-weight: 700; }
.progress-item.active .step-number { background: var(--accent); color: #fff; }
.progress-item.done .step-number { background: var(--success); color: #fff; }
.progress-line { width: 20px; height: 2px; background: var(--line); }
.scanner-shell { position: relative; overflow: hidden; aspect-ratio: 3 / 4; max-height: 62vh; background: #111; border-radius: 22px; box-shadow: var(--shadow); }
#preview { width: 100%; height: 100%; object-fit: cover; background: #111; }
.scan-mask { pointer-events: none; position: absolute; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at center, transparent 0 34%, rgba(0,0,0,.28) 65%); }
.scan-frame { width: min(68vw, 300px); aspect-ratio: 1; border: 3px solid rgba(255,255,255,.95); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.07), inset 0 0 0 1px rgba(0,0,0,.12); }
.camera-placeholder { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; background: #202520; color: #fff; text-align: center; }
.scan-message { display: grid; gap: 4px; padding: 14px 4px 8px; text-align: center; }
.scan-message strong { font-size: 17px; }
.scan-message span { color: var(--muted); font-size: 13px; }
.camera-controls { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 8px; }
.primary-button, .secondary-button, .icon-button { min-height: 46px; border-radius: 12px; font-weight: 700; }
.primary-button { border: 1px solid var(--accent); background: var(--accent); color: #fff; padding: 10px 14px; }
.primary-button:active { background: var(--accent-strong); }
.secondary-button { border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 10px 14px; }
.icon-button { border: 1px solid var(--line); background: var(--surface); color: var(--ink); min-height: 38px; padding: 7px 11px; }
.select, input { width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 9px 11px; color: var(--ink); }
.manual-card { margin-top: 14px; box-shadow: none; }
.manual-card summary { font-weight: 700; cursor: pointer; }
.manual-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 12px; }
.help-text { color: var(--muted); font-size: 12px; line-height: 1.6; }
.result-card { margin-top: 18px; text-align: center; }
.success-mark { width: 56px; height: 56px; display: grid; place-items: center; margin: 0 auto 10px; border-radius: 50%; background: #dceadf; color: var(--success); font-size: 30px; font-weight: 800; }
.result-list { margin: 18px 0; text-align: left; }
.result-list > div { display: grid; grid-template-columns: 92px 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.result-list > div:last-child { border-bottom: 1px solid var(--line); }
.result-list dt { color: var(--muted); }
.result-list dd { margin: 0; font-weight: 700; word-break: break-all; }
.button-stack { display: grid; gap: 9px; }
.error-card { margin-top: 14px; border-color: #e5bdbc; color: var(--danger); }
.settings-dialog { width: min(620px, calc(100% - 24px)); border: 0; border-radius: 18px; padding: 0; box-shadow: 0 20px 60px rgba(0,0,0,.28); }
.settings-dialog::backdrop { background: rgba(0,0,0,.4); }
.settings-dialog form { padding: 18px; }
.settings-dialog label { display: block; margin: 12px 0 7px; font-weight: 700; }
.dialog-actions { display: grid; gap: 8px; margin-top: 16px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 100; transform: translateX(-50%); width: min(90vw, 520px); padding: 12px 14px; border-radius: 12px; background: #182219; color: #fff; text-align: center; box-shadow: 0 12px 34px rgba(0,0,0,.25); }
@media (min-width: 560px) {
  .mode-grid { grid-template-columns: repeat(3, 1fr); }
  .mode-button { display: grid; align-content: center; min-height: 104px; }
  .camera-controls { grid-template-columns: 1fr 1fr auto; }
  .scanner-shell { aspect-ratio: 4 / 3; }
  .dialog-actions { grid-template-columns: 1fr auto auto; align-items: center; }
}
