:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --text: #111111;
  --muted: #5c5c5c;
  --border: #2b2b2b;
  --dashed: #9a9a9a;
  --primary: #111111;
  --primary-text: #ffffff;
  --alert-bg: #fff4d6;
  --alert-border: #c98a00;
  --error: #b3261e;
  --ok: #1e7a3c;
  --radius: 14px;
  --gutter: 16px;
  --btn-height: 96px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f0f;
    --surface: #1a1a1a;
    --text: #f2f2f2;
    --muted: #a8a8a8;
    --border: #d8d8d8;
    --dashed: #6b6b6b;
    --primary: #f2f2f2;
    --primary-text: #111111;
    --alert-bg: #3a2c00;
    --alert-border: #e0a400;
    --error: #ff8a80;
    --ok: #7ad69a;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: max(16px, env(safe-area-inset-top)) var(--gutter) max(16px, env(safe-area-inset-bottom));
}

.meta {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border: 1px solid var(--muted);
  border-radius: 6px;
}

.headline {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.headline-xl { font-size: 40px; margin-top: 24px; }

.note, .sub {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.error {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--error);
}

/* Capture */
.viewfinder {
  position: relative;
  flex: 1;
  min-height: 240px;
  max-height: 56vh;
  border: 2px dashed var(--dashed);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: var(--surface);
}

.viewfinder video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.viewfinder-placeholder { color: var(--dashed); font-size: 18px; margin: 0; }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
}

/* Cards */
.card {
  border: 1.5px dashed var(--dashed);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--surface);
}

.card h3 { margin: 0 0 6px; font-size: 18px; }
.card ul { margin: 0; padding-left: 20px; line-height: 1.45; }

.card-alert {
  border: 2px solid var(--alert-border);
  background: var(--alert-bg);
  font-size: 18px;
}

.part-card { display: flex; gap: 14px; align-items: center; }
.part-name { margin: 0 0 4px; font-size: 22px; }
.thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--dashed);
  flex-shrink: 0;
}

/* Job mode */
.progress {
  height: 8px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--muted) 25%, transparent);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--primary);
  transition: width 0.2s ease;
}

.step-text {
  margin: 4px 0 0;
  font-size: clamp(28px, 8vw, 38px);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.spec {
  border: 2.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 20px;
}

.warning {
  margin: 0;
  font-size: 17px;
  color: var(--text);
}

.mic-hint {
  margin: 0;
  border: 1.5px dashed var(--dashed);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 18px;
}

.mic-hint.is-offline { border-style: solid; border-color: var(--alert-border); background: var(--alert-bg); }

/* Buttons */
.actions { margin-top: auto; padding-top: 12px; display: grid; gap: 10px; }
.actions-row { grid-template-columns: 1fr 1fr 1fr; }
.actions-stack { grid-template-columns: 1fr; }

.btn {
  min-height: var(--btn-height);
  border: 2.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.02em;
  padding: 8px;
  cursor: pointer;
  touch-action: manipulation;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn:focus-visible { outline: 3px solid var(--alert-border); outline-offset: 2px; }

.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-secondary { min-height: 64px; font-size: 18px; }

@media (max-width: 360px) {
  .btn { font-size: 18px; }
}
