/* style.css — mobile-first UI. Big touch targets, camera as the focus. */

* { box-sizing: border-box; }

:root {
  --bg: #10141a;
  --panel: #1b222c;
  --accent: #2e7dff;
  --accent-active: #21b463;
  --text: #eef2f6;
  --muted: #8a97a6;
  --warn: #ffb020;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

header {
  padding: 10px 14px;
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}
header h1 { margin: 0; font-size: 1.1rem; text-align: center; }

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 10px 12px 40px;
}

/* The <video> is only a source for canvas processing; keep it out of layout. */
#video {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.canvas-wrap {
  width: 100%;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  line-height: 0;
}
#mainCanvas {
  width: 100%;
  height: auto;
  display: block;
  touch-action: manipulation;
}
#mainCanvas.dragging-corners { touch-action: none; cursor: grab; }
#mainCanvas.dragging-corners.is-dragging { cursor: grabbing; }

.instruction {
  margin: 10px 2px 4px;
  font-size: 0.95rem;
  color: var(--accent);
  min-height: 1.2em;
}
.tip-row {
  margin: 2px;
  font-size: 0.9rem;
  color: var(--muted);
}
.tip-row span { color: var(--text); font-variant-numeric: tabular-nums; }

.status {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0;
}
.status > div {
  background: var(--panel);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
}
.status .label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.status .value { font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.warning {
  margin: 4px 2px;
  min-height: 1.2em;
  color: var(--warn);
  font-weight: 600;
}

.settings {
  background: var(--panel);
  border-radius: 10px;
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 8px 0 10px;
}
.settings label { display: flex; flex-direction: column; gap: 5px; }
.settings label > span { color: var(--muted); font-size: 0.78rem; }
.settings select {
  width: 100%;
  padding: 10px 8px;
  color: var(--text);
  background: #111821;
  border: 1px solid #394656;
  border-radius: 7px;
  font: inherit;
}
.settings-hint {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}
.camera-device-setting { grid-column: 1 / 2; }
.settings-button {
  align-self: end;
  min-height: 43px;
  padding: 8px 10px;
  color: var(--text);
  background: #34445a;
  border: 1px solid #52647b;
  border-radius: 7px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.settings-button:disabled { opacity: 0.5; cursor: wait; }
.camera-device-hint { margin-top: -4px; }

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}
.controls button {
  padding: 16px 12px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  background: var(--accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
}
.controls button:active { filter: brightness(0.85); }
.controls button.active { background: var(--accent-active); }
.controls button:disabled { opacity: 0.45; cursor: not-allowed; }

.error {
  color: #ff6b6b;
  font-size: 0.9rem;
  margin: 6px 2px;
  min-height: 0;
}

.debug {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.debug.hidden { display: none; }
.dbg-item {
  background: var(--panel);
  border-radius: 8px;
  padding: 8px;
}
.dbg-item span { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 6px; }
.dbg-item canvas { width: 100%; height: auto; display: block; background: #000; border-radius: 4px; }

@media (min-width: 520px) {
  .debug { grid-template-columns: 1fr 1fr; }
}
