:root {
  --bg: oklch(0.18 0.018 75);
  --ink: oklch(0.95 0.02 85);
  --muted: oklch(0.7 0.022 80);
  --line: oklch(0.3 0.016 75);
  --primary: oklch(0.74 0.12 75);
  --accent: oklch(0.62 0.14 145);
  --danger: oklch(0.68 0.14 30);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.875rem;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: none;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ── Toolbar ── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  padding: calc(0.4rem + var(--safe-top)) calc(0.6rem + var(--safe-right)) 0.4rem
    calc(0.6rem + var(--safe-left));
  background: oklch(0.15 0.016 75);
  border-bottom: 1px solid var(--line);
}

.btn {
  appearance: none;
  flex: 0 0 auto;
  height: 2rem;
  padding: 0 0.75rem;
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: oklch(0.18 0.02 75);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
}

.btn:active:not(:disabled) { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

.btn-accent { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { color: var(--ink); }

.status {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding-left: 0.25rem;
  color: var(--muted);
  font-size: 0.6875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status.is-error { color: var(--danger); }

/* ── Stage: camera always renders, answer overlays it ── */
.stage {
  flex: 1;
  position: relative;
  min-height: 0;
  background: #000;
}

.panel-camera {
  position: absolute;
  inset: 0;
}

.preview {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

/* Answer panel overlays camera; hidden until .is-visible added */
.panel-answer {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
  padding: 1.25rem calc(1rem + var(--safe-right)) calc(1.25rem + var(--safe-bottom))
    calc(1rem + var(--safe-left));
  background: var(--bg);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  z-index: 1;
}

.panel-answer.is-visible {
  display: block;
}

.answer {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1.65rem;
  line-height: 1.4;
  color: var(--ink);
  white-space: pre-wrap;
  transition: font-size 0.15s ease;
}

.answer .placeholder {
  color: var(--muted);
  font-style: italic;
  font-size: 1.1rem;
}
