:root {
  color-scheme: light;
  --bg: #f5f5f0;
  --text: #20201e;
  --muted: #62625b;
  --line: #c7c7be;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
.screen {
  display: flex; flex-direction: column;
  height: 100dvh; max-width: 600px; margin: 0 auto;
}
button, input { font: inherit; color: inherit; border-radius: 0; }
button {
  min-height: 48px; padding: 10px 14px;
  border: 1px solid var(--text); background: transparent;
  cursor: pointer; touch-action: manipulation;
}
button:active { background: var(--text); color: var(--bg); }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
input[type=text], input[type=file] {
  width: 100%; min-width: 0; min-height: 48px; padding: 10px;
  font-size: 16px; background: transparent; border: 1px solid var(--line);
}
input::placeholder { color: var(--muted); opacity: 1; }
h1 { font-size: 24px; font-weight: 600; margin: 0 0 28px; }
.section-label { margin: 0 0 8px; }
.sub, .consent, .status, .hint { color: var(--muted); font-size: 13px; }
.sub, .consent { margin: 0; }
#onboarding {
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  gap: 28px; overflow-y: auto;
}
#enroll { display: flex; flex-direction: column; gap: 20px; }
.field { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
#submit { background: var(--text); color: var(--bg); }
.error { color: #a02020; font-size: 14px; }
.camera {
  position: relative; width: 100%; aspect-ratio: 3 / 4;
  max-height: 38dvh; background: #20201e; overflow: hidden;
}
.camera video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.camera .oval {
  position: absolute; inset: 8% 18%; border: 2px dashed #fff;
  border-radius: 50%; pointer-events: none;
}
.framing {
  position: absolute; bottom: 0; left: 0; right: 0; margin: 0;
  padding: 6px; background: #20201ecc; color: #fff; text-align: center; font-size: 12px;
}
#preview { width: 100%; max-height: 38dvh; object-fit: contain; background: #20201e; }
#chat { position: relative; }
.bar {
  display: flex; align-items: center; gap: 12px; position: relative;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid var(--line);
}
.who { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.who strong { font-weight: 600; }
.who span { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
#menu-button { font-size: 13px; border-color: var(--line); }
#menu { position: absolute; right: 16px; top: 100%; z-index: 2; background: var(--bg); }
#messages {
  flex: 1; min-height: 0; overflow-y: auto; padding: 24px 16px;
  display: flex; flex-direction: column; gap: 24px;
}
.msg { width: 100%; overflow-wrap: anywhere; }
.sender { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.sender::after { content: " >"; }
.frank .sender { color: var(--text); font-weight: 600; }
.message-body { display: block; white-space: pre-wrap; }
.thinking { color: var(--muted); font-size: 12px; }
.startover {
  border: 0; color: var(--muted); font-size: 12px; text-decoration: underline;
  min-height: 44px; padding: 8px 16px;
}
#composer { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
#composer input { flex: 1; }
#composer button { flex-shrink: 0; font-size: 14px; }
.voice { padding: 0 16px max(16px, env(safe-area-inset-bottom)); }
#mic { width: 100%; touch-action: none; user-select: none; -webkit-user-select: none; }
#mic.listening { background: var(--text); color: var(--bg); }
#mic.pending { border-style: dashed; }
.hint { margin: 6px 0 0; text-align: center; font-size: 12px; min-height: 18px; }
@media (min-width: 640px) {
  .screen { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
