:root {
  --bg-void: #0f1014;
  --bg-panel: #1a1b22;
  --bg-raised: #25262f;
  --line: #3c3e48;
  --line-strong: #4a4d58;
  --accent: #3b82f6;
  --accent-hover: #4b5bd6;
  --accent-soft: #60a5fa;
  --flare: #ef4444;
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --font-display: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', 'Meiryo', sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', 'Meiryo', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg-void);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app {
  max-width: 920px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 100vh;
}

/* ── ヘッダー ── */
.header {
  text-align: center;
  padding: 12px 0 4px;
}
.title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.title .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}
.subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 8px 0 0;
}

/* ── メイン ── */
.main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

/* ── パネル ── */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
}
.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.step-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-soft);
  background: rgba(59, 130, 246, 0.1);
  padding: 4px 8px;
  border-radius: 4px;
}
.panel-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
}

/* ── スキャンステージ ── */
.scan-stage {
  position: relative;
  background: #0a0a0c;
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 320px;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.scan-placeholder {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.scan-placeholder .glyph {
  font-size: 48px;
  color: var(--line-strong);
  line-height: 1;
}
.scan-placeholder .hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.scan-mount {
  width: 100%;
  height: 100%;
  display: none;
}
.scan-mount.active {
  display: block;
}
.scan-mount video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── コントロール ── */
.scan-controls {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.btn {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 18px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  user-select: none;
  min-width: 120px;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn-ghost {
  background: var(--bg-raised);
  color: var(--text-primary);
  border-color: var(--line);
}
.btn-ghost:hover {
  background: #3f4148;
  border-color: var(--line-strong);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── プログレス ── */
.scan-progress {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.progress-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}
.progress-value {
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}
.progress-bar {
  height: 6px;
  background: var(--bg-raised);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.2s ease;
  border-radius: 3px;
}
.progress-meta {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── 受信結果 ── */
.result-panel {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.2);
}
.result-image-wrap {
  background: #0a0a0c;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
}
.result-image-wrap img {
  max-width: 100%;
  max-height: 60vh;
  display: block;
  border-radius: 6px;
}
.result-meta {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.result-meta strong {
  color: var(--text-primary);
  font-weight: 600;
}
.result-actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── フッター ── */
.footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding-top: 12px;
}

/* ── エラー表示用 ── */
.scan-stage.error {
  border-color: var(--flare);
}
.error-message {
  color: var(--flare);
  font-size: 12px;
  text-align: center;
  padding: 16px;
}

/* ── レスポンシブ ── */
@media (max-width: 600px) {
  .app { padding: 16px 12px 32px; }
  .title { font-size: 20px; }
  .subtitle { font-size: 12px; }
  .panel { padding: 16px; }
  .scan-stage { min-height: 240px; }
  .btn { min-width: auto; flex: 1; padding: 12px 14px; }
}
