:root {
  color-scheme: light;
  --ink: #0f172a;
  --muted-ink: #475569;
  --quiet-ink: #64748b;
  --paper: #f8fafc;
  --surface: #ffffff;
  --line: #d7dee7;
  --line-strong: #b7c4d3;
  --primary: #334155;
  --primary-hover: #1e293b;
  --accent: #047857;
  --accent-soft: #ecfdf5;
  --warning: #a16207;
  --warning-soft: #fffbeb;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --focus: #0ea5e9;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--paper); }
body { min-width: 320px; min-height: 100vh; margin: 0; overflow-x: hidden; background: var(--paper); color: var(--ink); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
button, a, label { touch-action: manipulation; }

.skip-link { position: absolute; left: 16px; top: 8px; z-index: 20; padding: 10px 14px; border-radius: 4px; background: var(--ink); color: #fff; transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }
.page-shell { width: min(100% - 32px, 640px); min-height: 100vh; margin: 0 auto; padding: calc(24px + env(safe-area-inset-top)) 0 calc(28px + env(safe-area-inset-bottom)); }
.page-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.brand-mark { display: grid; width: 44px; height: 44px; flex: 0 0 44px; place-items: center; border-radius: 8px; background: var(--primary); color: #fff; font-size: 22px; font-weight: 700; }
.eyebrow, .section-kicker { margin: 0; color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(24px, 7vw, 32px); line-height: 1.15; }
h2 { margin: 2px 0 0; font-size: 20px; line-height: 1.25; }
.intro { max-width: 52ch; margin-bottom: 24px; color: var(--muted-ink); }
.capture-panel, .result-panel { border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.capture-panel { padding: 20px; }
.section-heading, .result-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.format-note, .result-status { color: var(--quiet-ink); font-size: 12px; text-align: right; }
.upload-zone { display: flex; min-height: 72px; align-items: center; gap: 12px; margin-top: 20px; padding: 12px; border: 1px dashed var(--line-strong); border-radius: 6px; cursor: pointer; transition: border-color .2s ease, background-color .2s ease; }
.upload-zone:hover, .upload-zone:focus-within { border-color: var(--accent); background: #f8fffc; }
.upload-zone.is-disabled { cursor: not-allowed; opacity: .55; pointer-events: none; }
.upload-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-icon { display: grid; width: 44px; height: 44px; flex: 0 0 44px; place-items: center; border-radius: 4px; background: #f1f5f9; color: var(--primary); }
.upload-icon svg { width: 23px; height: 23px; }
.upload-copy { min-width: 0; flex: 1; }
.upload-copy strong, .upload-copy small { display: block; }
.upload-copy strong { font-size: 15px; }
.upload-copy small { margin-top: 2px; color: var(--quiet-ink); font-size: 12px; }
.upload-action { flex: 0 0 auto; color: var(--primary); font-size: 14px; font-weight: 700; }
.field-hint { min-height: 24px; margin: 8px 0 12px; color: var(--quiet-ink); font-size: 13px; }
.preview-frame { position: relative; display: grid; width: 100%; min-height: 220px; aspect-ratio: 16 / 10; max-height: 380px; place-items: center; overflow: hidden; border-radius: 4px; background: #eef2f6; touch-action: none; }
.preview-empty { display: grid; place-items: center; gap: 8px; color: var(--quiet-ink); font-size: 14px; }
.preview-crosshair { width: 38px; height: 26px; border: 1px solid var(--line-strong); border-radius: 3px; position: relative; }
.preview-crosshair::before, .preview-crosshair::after { content: ""; position: absolute; background: var(--line-strong); }
.preview-crosshair::before { width: 1px; height: 100%; left: 50%; top: 0; }
.preview-crosshair::after { height: 1px; width: 100%; top: 50%; left: 0; }
.preview-frame img { position: absolute; inset: 0; display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; margin: auto; object-fit: contain; }
.selection-box { position: absolute; z-index: 2; border: 3px solid #10b981; background: rgba(16,185,129,.12); box-shadow: 0 0 0 1px rgba(15,23,42,.45); pointer-events: none; }
.selection-box::before, .selection-box::after { content: ""; position: absolute; background: #fff; box-shadow: 0 0 0 1px rgba(15,23,42,.35); }
.selection-box::before { width: 16px; height: 2px; left: calc(50% - 8px); top: calc(50% - 1px); }
.selection-box::after { width: 2px; height: 16px; left: calc(50% - 1px); top: calc(50% - 8px); }
.selection-hint { margin: 10px 0 0; color: var(--accent); font-size: 13px; font-weight: 700; }

.primary-button, .secondary-button { min-height: 48px; border: 1px solid transparent; border-radius: 4px; cursor: pointer; font-weight: 700; transition: background-color .2s ease, border-color .2s ease, opacity .2s ease; }
.primary-button { display: flex; width: 100%; align-items: center; justify-content: center; gap: 10px; margin-top: 16px; background: var(--primary); color: #fff; }
.primary-button:hover:not(:disabled) { background: var(--primary-hover); }
.primary-button:disabled { cursor: not-allowed; opacity: .45; }
.secondary-button { padding: 8px 16px; border-color: var(--line-strong); background: #fff; color: var(--primary); }
.secondary-button:hover { border-color: var(--primary); background: #f8fafc; }
.button-spinner { display: none; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; }
.is-loading .button-spinner { display: block; animation: spin .8s linear infinite; }

.result-panel { min-height: 238px; margin-top: 20px; padding: 20px; outline: none; transition: border-color .2s ease, background-color .2s ease; }
.result-panel:focus-visible { box-shadow: 0 0 0 3px rgba(14,165,233,.25); }
.result-content { display: flex; min-height: 170px; flex-direction: column; justify-content: center; padding-top: 16px; }
.result-label { margin-bottom: 4px; color: var(--quiet-ink); font-size: 13px; font-weight: 700; }
.lot-value { max-width: 100%; margin: 0; overflow-wrap: anywhere; color: var(--ink); font-size: clamp(28px, 9vw, 40px); font-weight: 800; line-height: 1.15; }
.result-message { min-height: 24px; margin: 12px 0 0; color: var(--muted-ink); }
.result-panel.result-success { border: 2px solid var(--accent); background: var(--accent-soft); }
.result-success .lot-value { color: #065f46; }
.result-success .result-status { color: var(--accent); font-weight: 700; }
.result-panel.result-warning { border-color: #eab308; background: var(--warning-soft); }
.result-warning .result-status { color: var(--warning); font-weight: 700; }
.result-panel.result-error { border-color: #fca5a5; background: var(--danger-soft); }
.result-error .result-status, .result-error .result-message { color: var(--danger); font-weight: 600; }
.result-panel.result-loading { border-color: var(--line-strong); }
.result-loading .result-status { color: var(--primary); font-weight: 700; }
.result-actions { display: flex; min-height: 48px; align-items: center; gap: 12px; margin-top: 16px; }
.copy-feedback { color: var(--accent); font-size: 13px; }
.support-note { margin: 12px 0 0; color: var(--danger); font-size: 14px; }
.page-footer { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; color: var(--quiet-ink); font-size: 13px; }
.page-footer a { color: var(--primary); font-weight: 700; }
a:focus-visible, button:focus-visible, .upload-zone:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (min-width: 680px) { .page-shell { padding-top: calc(40px + env(safe-area-inset-top)); } .capture-panel, .result-panel { padding: 24px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }
