:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --panel: #12161b;
  --line: #222a33;
  --text: #e9e7e3;
  --dim: #8e98a3;
  --accent: #8cc8ff;
  --accent-soft: rgba(140, 200, 255, 0.12);
  --rob: #1b2633;
  --danger: #ff8f8f;
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.5 var(--font); }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Chat */
body.chat-page { display: flex; flex-direction: column; height: 100dvh; }
.bar {
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid var(--line); background: var(--bg);
}
.who { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.name { font-size: 18px; font-weight: 600; letter-spacing: 0.3px; }
.pill {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 5px 12px; font-size: 14px; color: var(--dim); cursor: pointer;
}
.pill[data-v="business"] { color: var(--text); }
.pill[data-v="personal"] { color: var(--accent); border-color: rgba(140, 200, 255, 0.35); }
.icon-btn { background: none; border: 0; color: var(--dim); padding: 6px; cursor: pointer; border-radius: 10px; }
.icon-btn:focus-visible, .pill:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.chat { flex: 1; overflow-y: auto; padding: 16px 16px 8px; -webkit-overflow-scrolling: touch; }
#messages { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.earlier {
  display: block; margin: 0 auto 12px; background: none; border: 1px solid var(--line);
  color: var(--dim); border-radius: 999px; padding: 4px 14px; font-size: 13px; cursor: pointer;
}
.day { align-self: center; color: var(--dim); font-size: 12px; margin: 10px 0 2px; letter-spacing: 0.4px; }
.msg { max-width: 86%; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.rob { align-self: flex-end; background: var(--rob); padding: 9px 14px; border-radius: var(--radius) var(--radius) 6px var(--radius); }
.msg.maya { align-self: flex-start; padding: 2px 2px; }
.msg.maya.push::before { content: "messaged you"; display: block; color: var(--accent); font-size: 12px; margin-bottom: 2px; }
.msg .time { display: block; color: var(--dim); font-size: 11px; margin-top: 3px; }
.msg.rob .time { text-align: right; }
.msg.error { color: var(--danger); }
.typing { display: inline-flex; gap: 5px; padding: 8px 2px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .typing span { animation: none; opacity: 0.6; } }

.composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--bg);
  max-width: 760px; width: 100%; margin: 0 auto;
}
#input {
  flex: 1; resize: none; max-height: 160px; min-height: 44px;
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 22px;
  padding: 10px 16px; font: inherit; line-height: 1.4; outline: none;
}
#input:focus { border-color: rgba(140, 200, 255, 0.45); }
#send {
  width: 44px; height: 44px; flex: none; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); color: #07131f; display: grid; place-items: center;
}
#send:disabled { opacity: 0.45; cursor: default; }

/* Settings sheet */
.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet-card {
  width: 100%; max-width: 520px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 20px 20px 0 0; padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 90dvh; overflow-y: auto;
}
@media (min-width: 640px) { .sheet { align-items: center; } .sheet-card { border-radius: 20px; } }
.sheet-card h2 { margin: 0 0 8px; font-size: 18px; }
.field-label { display: block; color: var(--dim); font-size: 13px; margin: 16px 0 6px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg button { background: none; border: 0; border-radius: 9px; padding: 8px 0; color: var(--dim); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--text); }
.hint { color: var(--dim); font-size: 13px; margin: 6px 0 0; }
.row { display: flex; align-items: center; gap: 10px; color: var(--dim); }
input[type="time"], input[type="number"], .gate input {
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; font: inherit; color-scheme: dark;
}
input[type="number"] { width: 90px; }
.sheet-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 22px; }
.link { background: none; border: 0; color: var(--dim); text-decoration: underline; cursor: pointer; padding: 6px 0; }
.primary { background: var(--accent); color: #07131f; border: 0; border-radius: 12px; padding: 10px 20px; font-weight: 600; cursor: pointer; }

/* Sign-in and setup */
body.gate-page { display: grid; place-items: center; min-height: 100dvh; padding: 16px; }
.gate { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.gate h1 { margin: 6px 0 4px; font-size: 24px; font-weight: 600; letter-spacing: 0.3px; }
.gate input { width: 100%; padding: 12px 14px; }
.gate .primary { padding: 12px; }
.mark { width: 64px; height: 64px; margin: 0 auto; display: block; }
.error { color: var(--danger); min-height: 1.5em; margin: 0; font-size: 14px; }
