:root {
  --bg: #0b0f16;
  --surface: #141a25;
  --surface-2: #1c2431;
  --line: #262f3e;
  --text: #eef2f8;
  --muted: #8b97ab;
  --accent: #5b8cff;
  --accent-soft: rgba(91, 140, 255, 0.16);
  --danger: #ff4d5e;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

body { display: flex; flex-direction: column; }

.screen { display: none; flex: 1; flex-direction: column; min-height: 0; }
.screen[data-active] { display: flex; }

.muted { color: var(--muted); }

.error {
  margin: 12px 20px 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255, 77, 94, 0.12);
  color: #ffb3ba;
  font-size: 14px;
  text-align: center;
}

/* ---------- sign in ---------- */

.gate {
  margin: auto;
  padding: 32px 28px calc(32px + var(--safe-bottom));
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.gate h1 { margin: 20px 0 6px; font-size: 28px; letter-spacing: -0.02em; }
.gate p { margin: 0 0 24px; font-size: 15px; }

.face { display: block; width: 128px; height: 128px; margin: 0 auto; }

input, textarea {
  font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 15px 16px; width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

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

.primary {
  margin-top: 12px; width: 100%; padding: 15px;
  border-radius: 14px; background: var(--accent); color: #fff; font-weight: 600;
}
.primary:disabled { opacity: .55; cursor: default; }

.link { color: var(--accent); font-size: 15px; padding: 6px; }
.gate-switch { margin-top: 18px; color: var(--muted); font-size: 14px; }

/* ---------- bars ---------- */

.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  border-bottom: 1px solid var(--line);
}
.who { font-weight: 600; font-size: 15px; }
.who-dinis { display: flex; align-items: center; gap: 10px; font-size: 18px; }
.who-dinis img { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); }
.bar-spacer { width: 52px; }

/* ---------- home ---------- */

.hero { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 28px 20px 0; }
.hero img { width: 140px; height: 140px; }
.hero h1 { margin: 0; font-size: 28px; letter-spacing: -0.02em; }

.choices {
  flex: 1; display: flex; flex-direction: column; gap: 16px;
  padding: 20px 20px calc(24px + var(--safe-bottom)); justify-content: center;
}

.choice {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 26px 24px; border-radius: 22px;
  background: var(--surface); border: 1px solid var(--line);
  text-align: left; transition: transform .12s ease, background .12s ease;
}
.choice:active { transform: scale(.985); background: var(--surface-2); }
.choice svg {
  width: 30px; height: 30px; margin-bottom: 12px;
  fill: none; stroke: var(--accent); stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.choice-voice { background: linear-gradient(160deg, #1a2540 0%, var(--surface) 60%); }
.choice-label { font-size: 21px; font-weight: 650; letter-spacing: -0.01em; }
.choice-sub { font-size: 14px; color: var(--muted); }

/* ---------- call ---------- */

.call {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  padding: calc(24px + var(--safe-top)) 24px 0; text-align: center;
}

.orb { position: relative; width: 200px; height: 200px; margin-bottom: 22px; }
.orb-core, .orb-ring { position: absolute; inset: 0; border-radius: 50%; }
.orb-core {
  inset: 28px; overflow: hidden;
  background: radial-gradient(circle at 35% 30%, #7ea6ff, var(--accent) 62%, #2f5ad0);
  box-shadow: 0 14px 50px rgba(91, 140, 255, .34);
}
.orb-ring { border: 2px solid var(--accent-soft); }

.orb[data-state="connecting"] .orb-ring { animation: ripple 1.7s ease-out infinite; }
.orb[data-state="listening"] .orb-ring { animation: ripple 2.6s ease-out infinite; }
.orb[data-state="listening"] .orb-core { animation: breathe 3.4s ease-in-out infinite; }
.orb[data-state="thinking"] .orb-ring { border-top-color: var(--accent); animation: spin 1.1s linear infinite; }
.orb[data-state="thinking"] .orb-core { opacity: .75; }
.orb[data-state="speaking"] .orb-ring { animation: ripple 1.2s ease-out infinite; }
.orb[data-state="speaking"] .orb-core { animation: talk .5s ease-in-out infinite alternate; }
.orb[data-state="ended"] .orb-core { filter: grayscale(1); opacity: .4; box-shadow: none; }
.orb[data-state="ended"] .orb-ring { animation: none; }

@keyframes ripple { 0% { transform: scale(.72); opacity: .85; } 100% { transform: scale(1.12); opacity: 0; } }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes talk { from { transform: scale(1); } to { transform: scale(1.07); } }

.orb-core img { display: block; width: 100%; height: 100%; }
.call-name { margin: 0; font-size: 28px; letter-spacing: -0.02em; }
.call-status { margin: 0; font-size: 21px; font-weight: 600; letter-spacing: -0.01em; }
.call-sub { margin: 0; font-size: 14px; }
.call-timer { margin: 10px 0 0; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 15px; }

/* Fixed height so the orb stays put as captions come and go. A long caption
   overflows at the top and is clipped there, keeping the newest words in view. */
.caption {
  display: flex; flex-direction: column; justify-content: flex-end;
  width: 100%; max-width: 30em; height: calc(1.4em * 4);
  margin: 14px 0 0; overflow: hidden;
  font-size: 17px; line-height: 1.4;
}
.caption[data-interim] { color: var(--muted); }

.call-actions {
  display: flex; gap: 26px; justify-content: center;
  padding: 30px 24px calc(40px + var(--safe-bottom));
}
.round {
  width: 66px; height: 66px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line);
  display: grid; place-items: center;
}
.round svg { width: 26px; height: 26px; fill: none; stroke: var(--text); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.round[aria-pressed="true"] { background: #fff; }
.round[aria-pressed="true"] svg { stroke: #0b0f16; }
.hangup { background: var(--danger); border-color: var(--danger); }
.hangup svg { fill: #fff; stroke: none; }
.round:active { transform: scale(.94); }

/* ---------- chat ---------- */

.thread {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 18px 16px; display: flex; flex-direction: column; gap: 10px;
}

.msg {
  max-width: 78%; padding: 11px 15px; border-radius: 20px;
  font-size: 15.5px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg.from-agent { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 7px; }
.msg.from-me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 7px; }
.msg.pending { opacity: .6; }

.typing { display: flex; gap: 4px; align-items: center; padding: 14px 16px; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  animation: blink 1.3s ease-in-out infinite;
}
.typing span:nth-child(2) { animation-delay: .18s; }
.typing span:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 100% { opacity: .3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }

.composer {
  display: flex; gap: 10px; align-items: flex-end;
  padding: 12px 14px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--line); background: var(--bg);
}
.composer textarea { flex: 1; resize: none; max-height: 140px; border-radius: 20px; padding: 12px 16px; }
.send {
  width: 46px; height: 46px; flex: none; border-radius: 50%;
  background: var(--accent); display: grid; place-items: center;
}
.send svg { width: 21px; height: 21px; fill: #fff; }
.send:disabled { opacity: .4; }

.choices, .call, .thread, .composer, .admin, .admin-foot {
  width: 100%; max-width: 560px; margin-inline: auto;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- access (admin) ---------- */

.bar-right { display: flex; align-items: center; gap: 4px; }

.notice {
  margin: 12px 20px 0; padding: 10px 14px; border-radius: 12px;
  background: rgba(91, 140, 255, .14); color: #c3d5ff;
  font-size: 14px; text-align: center;
}

.admin {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 14px 14px; display: flex; flex-direction: column; gap: 10px;
}

.person {
  flex: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  overflow: hidden;
}
.person[data-blocked] { border-color: rgba(255, 77, 94, .4); }

.person-head {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 14px 16px; text-align: left;
}
.person-head:active { background: var(--surface-2); }

.person-name { font-weight: 600; font-size: 16px; }
.person-sub { display: block; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.person-grow { flex: 1; min-width: 0; }

.tag {
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted);
}
.tag.on { background: rgba(91, 140, 255, .18); color: #a9c2ff; }
.tag.bad { background: rgba(255, 77, 94, .16); color: #ffb3ba; }
.tag.live { background: rgba(60, 210, 140, .16); color: #8ceeba; }

.chev { color: var(--muted); font-size: 13px; flex: none; }

.meters { display: flex; flex-direction: column; gap: 7px; padding: 0 16px 14px; }
.meter { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; }
.meter-label { font-size: 12.5px; color: var(--muted); }
.meter-value { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.meter-track {
  grid-column: 1 / -1; height: 4px; border-radius: 3px; background: var(--surface-2); overflow: hidden;
}
.meter-fill { height: 100%; border-radius: 3px; background: var(--accent); transition: width .25s ease; }
.meter-fill[data-level="warn"] { background: #f0b429; }
.meter-fill[data-level="full"] { background: var(--danger); }

.person-edit { border-top: 1px solid var(--line); padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 14px; }
.edit-main { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; color: var(--muted); }
.field input, .field textarea { padding: 11px 13px; border-radius: 11px; font-size: 15px; }
.field textarea { resize: vertical; }

.limits { display: flex; flex-direction: column; gap: 8px; }
.limit { display: grid; grid-template-columns: 1fr 96px 40px; gap: 8px; align-items: center; }
.limit label { font-size: 13.5px; }
.limit input { padding: 9px 11px; border-radius: 10px; font-size: 15px; text-align: right; }
.limit .inf { border: 1px solid var(--line); border-radius: 10px; padding: 9px 0; color: var(--muted); font-size: 15px; }
.limit .inf:active { background: var(--surface-2); }

.hint { font-size: 12.5px; color: var(--muted); margin: 0; }

.row-buttons { display: flex; flex-wrap: wrap; gap: 8px; }

.ghost {
  padding: 10px 14px; border-radius: 11px; font-size: 14px; font-weight: 550;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
}
.ghost:active { transform: scale(.98); }
.ghost.danger { color: #ffb3ba; border-color: rgba(255, 77, 94, .35); }
.ghost.go { background: var(--accent); border-color: var(--accent); color: #fff; }
.ghost:disabled { opacity: .5; }

.admin-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px calc(14px + var(--safe-bottom));
  border-top: 1px solid var(--line);
}
.admin-foot .muted { font-size: 12px; text-align: right; }

.allowance {
  margin: 0 20px calc(10px + var(--safe-bottom));
  font-size: 13px; text-align: center;
}

/* ---------- brand and legal links ---------- */

.gate-foot { margin-top: 36px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.brand img { width: 132px; height: auto; }
.brand span { font-size: 13px; color: var(--muted); }

.legal-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 14px; font-size: 13px; }
.legal-links a { color: var(--muted); text-decoration: none; padding: 4px; }
.home-legal { padding: 0 20px calc(12px + var(--safe-bottom)); }

/* ---------- about, privacy, terms ---------- */

.doc { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.doc-body {
  max-width: 680px; margin: 0 auto;
  padding: calc(18px + var(--safe-top)) 20px calc(40px + var(--safe-bottom));
}
.doc-back { display: inline-block; margin: 0 0 14px -6px; text-decoration: none; }
.doc .brand { align-items: flex-start; margin-bottom: 22px; }
.doc h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -0.02em; }
.doc h2 { margin: 30px 0 8px; font-size: 18px; letter-spacing: -0.01em; }
.doc p, .doc li, .doc dd { font-size: 15px; }
.doc p { margin: 0 0 12px; }
.doc ul { margin: 0 0 12px; padding-left: 20px; }
.doc li { margin-bottom: 6px; }
.doc a { color: var(--accent); }
.doc dl { margin: 0 0 12px; }
.doc dt { font-size: 12.5px; color: var(--muted); }
.doc dd { margin: 0 0 10px; }
.doc .legal-links { justify-content: flex-start; margin-top: 30px; }

@media (min-width: 900px) {
  .admin, .admin-foot { max-width: 1040px; }
  .admin {
    display: grid; align-content: start;
    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
    grid-auto-rows: min-content;
  }
  .person[data-open], .person[data-wide] { grid-column: 1 / -1; }

  .person[data-open] .person-edit,
  .person[data-wide] .person-edit {
    display: grid; gap: 14px 28px; align-items: start;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .person-edit > .row-buttons, .person-edit > .hint { grid-column: 1 / -1; }
  .person[data-wide] .person-edit { grid-template-columns: minmax(0, 560px); }
}

.admin-tools {
  display: flex; gap: 8px; align-items: center;
  padding: 12px 14px 0; width: 100%; max-width: 560px; margin-inline: auto;
}
.admin-tools input {
  flex: 1; min-width: 0; padding: 10px 13px; border-radius: 11px; font-size: 15px;
}
.admin-tools input::-webkit-search-cancel-button { filter: invert(.6); }
.admin-tools select {
  flex: none; font: inherit; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 11px; padding: 10px 12px;
}
.admin-empty { padding: 28px 16px; text-align: center; font-size: 14px; }

@media (min-width: 900px) {
  .admin-tools { max-width: 1040px; }
  .admin-empty { grid-column: 1 / -1; }
}
