:root {
  color-scheme: dark;
  --bg: #101412;
  --ink: #f7fbf5;
  --muted: #b7c5ba;
  --line: rgba(255, 255, 255, 0.18);
  --panel: rgba(16, 20, 18, 0.74);
  --panel-strong: rgba(16, 20, 18, 0.9);
  --accent: #79e08f;
  --accent-strong: #41c466;
  --warning: #ffd166;
  --danger: #ff7b6e;
  --blue: #7dc8ff;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.42);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.app-shell {
  position: relative;
  width: 100vw;
  min-height: 100svh;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(16, 20, 18, 0.32), rgba(16, 20, 18, 0.84)),
    #17201a;
}

.camera {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.88;
  transform: scaleX(-1);
}

.analysis-canvas {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.touch-surface {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto minmax(160px, 1fr) auto auto;
  gap: 16px;
  padding: calc(16px + var(--safe-top)) calc(16px + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(16px + var(--safe-left));
  outline: 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;
}

.top-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 8vw, 4.5rem);
  line-height: 0.98;
  font-weight: 900;
  letter-spacing: 0;
}

.icon-button {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.icon-button span {
  font-size: 1.4rem;
  line-height: 1;
}

.focus-ring {
  align-self: center;
  justify-self: center;
  position: relative;
  width: min(64vw, 460px);
  aspect-ratio: 4 / 3;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.03);
}

.focus-corner {
  position: absolute;
  width: 42px;
  height: 42px;
  border-color: var(--accent);
}

.top-left {
  top: -2px;
  left: -2px;
  border-top: 4px solid;
  border-left: 4px solid;
}

.top-right {
  top: -2px;
  right: -2px;
  border-top: 4px solid;
  border-right: 4px solid;
}

.bottom-left {
  bottom: -2px;
  left: -2px;
  border-bottom: 4px solid;
  border-left: 4px solid;
}

.bottom-right {
  right: -2px;
  bottom: -2px;
  border-right: 4px solid;
  border-bottom: 4px solid;
}

.status-panel {
  width: min(100%, 680px);
  justify-self: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.mode-label {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.spoken-status {
  margin: 0;
  font-size: clamp(1.1rem, 4vw, 1.55rem);
  line-height: 1.28;
  font-weight: 800;
}

.confidence-label {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.35;
}

.controls {
  width: min(100%, 680px);
  justify-self: center;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.primary-action,
.secondary-action {
  min-height: 82px;
  padding: 14px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: clamp(1.1rem, 4.4vw, 1.45rem);
  line-height: 1.08;
  font-weight: 900;
  text-align: center;
}

.primary-action {
  background: var(--accent);
  color: #07100a;
}

.secondary-action {
  background: var(--panel-strong);
  color: var(--ink);
  border-color: var(--line);
}

.start-action,
.describe-action {
  min-height: 108px;
  grid-column: 1 / -1;
  font-size: clamp(1.35rem, 6vw, 2rem);
}

.gesture-help {
  width: min(100%, 680px);
  justify-self: center;
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
  text-align: center;
}

.is-located .focus-corner {
  border-color: var(--accent-strong);
}

.is-warning .focus-corner {
  border-color: var(--warning);
}

.is-danger .focus-corner {
  border-color: var(--danger);
}

button:focus-visible,
.touch-surface:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

@media (max-width: 540px) {
  .touch-surface {
    gap: 14px;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .primary-action,
  .secondary-action {
    min-height: 76px;
  }

  .start-action,
  .describe-action {
    min-height: 112px;
  }

  .gesture-help {
    text-align: left;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .focus-ring {
    transition: border-color 180ms ease, background-color 180ms ease;
  }

  .focus-corner {
    transition: border-color 180ms ease;
  }
}
