:root {
  --paper: #f3e9d8;
  --panel: #fbf5e8;
  --ink: #2a2118;
  --fog: #8c7d68;
  --line: #e7dabf;

  --terracotta: #c1673d;
  --terracotta-press: #a8542e;
  --ochre: #d3a24a;
  --forest: #5c7a52;
  --clay-pulse: #b5623f;

  --font-display: "Fraunces", Georgia, serif;
  --font-rounded: "Fredoka", "Baloo 2", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  overflow: hidden;
}

body {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 10px 10px 0;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

.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;
}

/* ---------- Camera — dominates the screen, full field of view ---------- */
.camera {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  border-radius: 24px;
  background: var(--panel); /* letterbox fill so nothing is ever cropped out */
  box-shadow: 0 10px 30px rgba(42,33,24,0.12);
}

#video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain; /* show the whole feed — never crop out obstacles */
  opacity: 0;
  transition: opacity 0.3s ease;
}
#video.ready { opacity: 1; }
#video.mirror { transform: scaleX(-1); }

.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  padding-top: max(14px, env(safe-area-inset-top));
}

.wordmark {
  font-family: var(--font-rounded);
  font-weight: 600;
  font-size: 1.5rem;
  color: var(--ink);
  background: rgba(251,245,232,0.88);
  padding: 7px 14px;
  border-radius: 14px;
}

.status-pill {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(251,245,232,0.88);
  backdrop-filter: blur(6px);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.78rem;
  color: var(--fog);
}

.topbar .icon-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  background: rgba(251,245,232,0.88);
  font-size: 1.05rem;
  color: var(--ink);
}
.topbar .icon-btn:hover { background: var(--panel); }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--fog);
  transition: background 0.3s ease;
}
.status-dot.live { background: var(--clay-pulse); box-shadow: 0 0 0 3px rgba(181,98,63,0.2); }
.status-dot.error { background: var(--clay-pulse); }

/* ---------- Soft woven accent ---------- */
.weave {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
}
.weave span { width: 16px; height: 4px; border-radius: 999px; background: var(--terracotta); }
.weave span:nth-child(2) { background: var(--ochre); width: 11px; }
.weave span:nth-child(3) { background: var(--forest); width: 19px; }
.weave span:nth-child(4) { background: var(--ochre); width: 11px; }
.weave span:nth-child(5) { background: var(--terracotta); width: 16px; }

/* ---------- Control panel: big button, description beside it ---------- */
.control-panel {
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  background: var(--panel);
  border-radius: 24px;
  margin: 0 0 10px;
  padding: 14px 16px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  max-height: 34vh;
  box-shadow: 0 6px 22px rgba(42,33,24,0.08);
}

.desc-wrap {
  flex: 1 1 auto;
  min-width: 0;
  max-height: 96px;
  overflow-y: auto;
}

.desc-text {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--ink);
  margin: 0;
  text-align: left;
}

.desc-text span.active {
  background: var(--ochre);
  color: var(--ink);
  border-radius: 4px;
  padding: 1px 2px;
  transition: background 0.1s ease;
}

/* ---------- Beacon: big, the clear single action ---------- */
.beacon {
  position: relative;
  flex-shrink: 0;
  width: 96px;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.beacon-ring {
  position: absolute;
  inset: -3px;
  border-radius: 30px;
  border: 2px solid rgba(181,98,63,0);
  transition: border-color 0.25s ease;
}

.beacon-core {
  width: 100%;
  height: 100%;
  border-radius: 26px;
  background: var(--terracotta);
  color: var(--panel);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(193,103,61,0.38);
  transition: transform 0.06s ease, background 0.1s ease;
}

.beacon.pressed .beacon-core,
.beacon:active .beacon-core { transform: scale(0.92); background: var(--terracotta-press); }

.beacon-icon-spinner { display: none; }
.beacon.busy .beacon-icon-eye { display: none; }
.beacon.busy .beacon-icon-spinner {
  display: block;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.beacon.busy .beacon-ring,
.beacon.speaking .beacon-ring {
  border-color: var(--clay-pulse);
  animation: pulse 1.2s ease-out infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(181,98,63,0.3); }
  100% { box-shadow: 0 0 0 18px rgba(181,98,63,0); }
}

@media (prefers-reduced-motion: reduce) {
  .beacon.busy .beacon-ring, .beacon.speaking .beacon-ring { animation: none; }
  .beacon.busy .beacon-icon-spinner { animation: none; }
}

/* ---------- Settings drawer ---------- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(42,33,24,0.32);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 31;
  background: var(--panel);
  border-radius: 26px 26px 0 0;
  padding: 24px 22px max(24px, env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.3s ease;
  box-shadow: 0 -10px 30px rgba(42,33,24,0.15);
}
.drawer.open { transform: translateY(0); }

.drawer h2 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--ink);
}

.drawer-copy {
  color: var(--fog);
  font-size: 0.88rem;
  line-height: 1.5;
  margin: 0 0 18px;
}

.drawer label {
  display: block;
  font-size: 0.8rem;
  color: var(--fog);
  margin-bottom: 6px;
}

.drawer-row { margin-bottom: 16px; }
.drawer-row input[type="range"] { width: 100%; accent-color: var(--terracotta); }

.drawer-secondary {
  width: 100%;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 600;
  padding: 12px;
  border-radius: 14px;
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.drawer-save {
  width: 100%;
  background: var(--terracotta);
  color: var(--panel);
  font-weight: 600;
  padding: 13px;
  border-radius: 16px;
  font-size: 0.95rem;
}

.beacon:focus-visible,
.icon-btn:focus-visible,
.status-pill:focus-visible,
.drawer-secondary:focus-visible,
.drawer input:focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 2px;
}
