:root {
  --bg: #f6f1ea;
  --surface: #ffffff;
  --surface-2: #efe8df;
  --text: #1f1b18;
  --text-2: #675e57;
  --border: #d6cdc4;
  --accent: #a8622e;        /* Boo's warm iris */
  --accent-text: #ffffff;
  --live: #c0392b;
  --ok: #2e8b57;
  --warn: #c98a1b;
  --shadow: 0 10px 30px rgba(60, 40, 20, 0.18);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14110f;
    --surface: #211d1a;
    --surface-2: #2b2622;
    --text: #efe9e3;
    --text-2: #a59c94;
    --border: #3b3531;
    --accent: #c47a3e;
    --accent-text: #1a120c;
    --live: #e0574a;
    --ok: #4fb07a;
    --warn: #e0a83a;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
.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;
}

.app {
  min-height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right))
           env(safe-area-inset-bottom) max(16px, env(safe-area-inset-left));
}

/* --- top bar --------------------------------------------------------------- */
.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0 4px;
}
.status {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status span:last-child { overflow: hidden; text-overflow: ellipsis; }
.dot {
  flex: none;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--border);
}
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.live { background: var(--live); animation: pulse 1s ease-in-out infinite; }
.dot.speaking { background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

.icon-btn {
  flex: none;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.icon-btn:focus-visible, .btn:focus-visible, .talk:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* --- eyes ------------------------------------------------------------------- */
.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.eyes {
  --eye: min(40vw, 34vh, 300px);
  display: flex;
  justify-content: center;
  gap: min(4vw, 28px);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.eye {
  width: calc(var(--eye) * 1.08);
  height: calc(var(--eye) * 1.08);
  border-radius: 50%;
  background: #000;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}
.eye canvas {
  width: var(--eye);
  height: var(--eye);
  border-radius: 50%;
  display: block;
}
@media (orientation: landscape) and (max-height: 520px) {
  .eyes { --eye: min(30vw, 48vh, 300px); }
}

.notice {
  text-align: center;
  max-width: 420px;
}
.notice p { margin: 0 0 10px; color: var(--text-2); }

.transcript {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 15px;
}
.transcript p {
  margin: 0;
  padding: 8px 12px;
  border-radius: 14px;
  max-width: 85%;
  overflow-wrap: anywhere;
}
.transcript .me { align-self: flex-end; background: var(--surface-2); }
.transcript .boo { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); }

/* --- talk button --------------------------------------------------------------- */
.dock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 0 18px;
}
.talk {
  width: 112px; height: 112px;
  border-radius: 50%;
  border: 0;
  display: grid; place-items: center;
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: var(--shadow);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform 0.12s ease, background-color 0.2s ease;
}
.talk:active { transform: scale(0.96); }
.talk[aria-pressed="true"] {
  background: var(--live);
  color: #fff;
  transform: scale(1.06);
  box-shadow: 0 0 0 10px color-mix(in srgb, var(--live) 25%, transparent), var(--shadow);
}
.talk:disabled { opacity: 0.45; cursor: default; }
.hint {
  margin: 0;
  font-size: 13px;
  color: var(--text-2);
  text-align: center;
  min-height: 1.45em;
}

/* --- buttons and settings ---------------------------------------------------------- */
.btn {
  font: inherit;
  font-size: 15px;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.ghost { background: transparent; }

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
}
.sheet {
  width: 100%;
  max-width: 520px;
  max-height: 100%;
  overflow-y: auto;
  background: var(--surface);
  color: var(--text);
  border-radius: 20px 20px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
}
@media (min-width: 600px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 20px; padding: 24px; }
}
.sheet h2 { margin: 0 0 4px; font-size: 20px; }
.sheet .lead { margin: 0 0 16px; color: var(--text-2); font-size: 14px; }
.field { display: block; margin: 0 0 14px; }
.field span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field input {
  width: 100%;
  font: inherit;
  font-size: 16px;   /* below 16px iOS zooms into the field */
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.field small, .check small { display: block; margin-top: 4px; color: var(--text-2); font-size: 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 14px; font-size: 14px; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); }
.error { color: var(--live); font-size: 14px; margin: 0 0 12px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.grow { flex: 1; }

@media (prefers-reduced-motion: reduce) {
  .dot.live, .dot.speaking { animation: none; }
  .talk { transition: none; }
}
