/* AI colleagues: one calm, warm system in light and dark. */

:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #f0ede6;
  --surface-3: #e8e4db;
  --ink: #1d1c1a;
  --ink-2: #57544e;
  --ink-3: #8a867e;
  --line: #e3dfd6;
  --line-strong: #d3cec3;
  --accent: #1f5f5b;
  --accent-hover: #184c49;
  --accent-ink: #ffffff;
  --accent-soft: #e2eeec;
  --accent-soft-ink: #164744;
  --danger: #c0412e;
  --danger-hover: #a53625;
  --ok: #2f7d4f;
  --warn: #a8701a;
  --warn-soft: #f7ecd8;
  --shadow: 0 1px 2px rgb(28 25 20 / 6%), 0 8px 24px -12px rgb(28 25 20 / 18%);
  --shadow-lift: 0 2px 4px rgb(28 25 20 / 6%), 0 18px 40px -18px rgb(28 25 20 / 28%);
  --radius: 16px;
  --radius-sm: 10px;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "New York", ui-serif, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --avatar-l: 88%;
  --avatar-c: 0.07;
  --avatar-ink-l: 34%;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111213;
    --surface: #1a1b1d;
    --surface-2: #222326;
    --surface-3: #2b2c30;
    --ink: #edebe7;
    --ink-2: #b4b0a9;
    --ink-3: #85817a;
    --line: #2c2d31;
    --line-strong: #3a3b40;
    --accent: #62b5ab;
    --accent-hover: #7cc6bd;
    --accent-ink: #0b1f1d;
    --accent-soft: #1b3431;
    --accent-soft-ink: #a9ddd6;
    --danger: #e0664f;
    --danger-hover: #ea7f6b;
    --ok: #5cbf86;
    --warn: #e3a94b;
    --warn-soft: #33291a;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px -12px rgb(0 0 0 / 60%);
    --shadow-lift: 0 2px 4px rgb(0 0 0 / 30%), 0 18px 40px -18px rgb(0 0 0 / 70%);
    --avatar-l: 36%;
    --avatar-c: 0.06;
    --avatar-ink-l: 88%;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
h1, h2, p { margin: 0; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 32px 24px 48px; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1120px; margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; gap: 20px;
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-mark {
  display: inline-block; width: 28px; height: 28px; border-radius: 9px; background: var(--accent); position: relative; flex: none;
}
.brand-mark::before, .brand-mark::after {
  content: ""; position: absolute; top: 10px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent-ink);
}
.brand-mark::before { left: 8px; }
.brand-mark::after { right: 8px; }
.brand-mark.large { width: 52px; height: 52px; border-radius: 16px; }
.brand-mark.large::before, .brand-mark.large::after { top: 18px; width: 9px; height: 9px; }
.brand-mark.large::before { left: 14px; }
.brand-mark.large::after { right: 14px; }
.brand-name { font-weight: 650; letter-spacing: -0.01em; }
.brand-tag {
  font-size: 12px; color: var(--ink-3); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px;
}

.switch {
  margin-left: auto; display: flex; gap: 2px; padding: 3px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
}
.switch button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 9px; cursor: pointer;
  color: var(--ink-2); font-size: 14px; display: flex; gap: 6px; align-items: baseline; white-space: nowrap;
}
.switch button small { color: var(--ink-3); font-size: 12px; }
.switch button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.switch button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.me { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 14px; }
.icon-btn {
  width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px;
  border: 1px solid transparent; background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--line); color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 11px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 560; font-size: 14px; transition: background .15s, border-color .15s, transform .08s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn.wide { width: 100%; height: 44px; }
.btn.round { width: 56px; height: 56px; padding: 0; border-radius: 50%; }
.btn.round svg { width: 22px; height: 22px; }
.btn.icon-only { width: 40px; height: 40px; padding: 0; border-radius: 12px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn.toggled { background: var(--ink); border-color: var(--ink); color: var(--bg); }

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

.view-login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px; padding: 36px 32px 28px; box-shadow: var(--shadow-lift); text-align: center;
}
.login-card h1 { font-family: var(--serif); font-weight: 600; font-size: 30px; letter-spacing: -0.01em; margin-top: 18px; }
.login-card .lede { color: var(--ink-2); margin: 8px auto 24px; max-width: 36ch; }
.login-card form { text-align: left; display: grid; gap: 8px; }
#password-field:not([hidden]) { display: grid; gap: 8px; }
.login-card label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.login-card input {
  height: 44px; border-radius: 11px; border: 1px solid var(--line-strong); background: var(--bg);
  padding: 0 14px; font: inherit; color: var(--ink); margin-bottom: 8px;
}
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.fineprint { font-size: 12.5px; color: var(--ink-3); margin-top: 16px; }

/* ---------- cast ---------- */

.client-hero {
  display: grid; grid-template-columns: 1fr minmax(300px, 400px); gap: 24px; align-items: end;
  padding-bottom: 28px; border-bottom: 1px solid var(--line); margin-bottom: 28px;
}
.eyebrow { font-size: 12.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 600; }
.client-name { font-family: var(--serif); font-size: clamp(30px, 5vw, 44px); font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; margin-top: 6px; }

.sponsor-card {
  display: flex; gap: 14px; align-items: center; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.sponsor-card .who { min-width: 0; }
.sponsor-card .name { font-weight: 620; }
.sponsor-card .role { color: var(--ink-2); font-size: 13.5px; }
.sponsor-card .badge { margin-top: 6px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}
.badge.human::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }

.notice {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; margin-bottom: 24px;
  border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--ink); font-size: 14px;
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
}
.notice code { font-family: var(--mono); font-size: 12.5px; background: color-mix(in srgb, var(--surface) 70%, transparent); padding: 1px 6px; border-radius: 6px; }

.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.section-head h2 { font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.section-head p { color: var(--ink-3); font-size: 14px; }

.cast-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.card {
  display: flex; flex-direction: column; gap: 14px; padding: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 1px 0 rgb(0 0 0 / 2%); transition: box-shadow .2s, transform .2s, border-color .2s;
  animation: rise .4s cubic-bezier(.2,.7,.2,1) both;
}
.card:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); border-color: var(--line-strong); }
.card-head { display: flex; gap: 12px; align-items: center; }
.card-head .name { font-weight: 640; font-size: 16px; letter-spacing: -0.005em; }
.card-head .role { color: var(--ink-2); font-size: 13.5px; }
.card .remit { color: var(--ink-2); font-size: 14px; flex: 1; }
.card .avail { display: flex; align-items: center; gap: 6px; color: var(--ink-3); font-size: 13px; }
.card .avail svg { width: 14px; height: 14px; }
.card-actions { display: flex; gap: 8px; }
.card-actions .btn { flex: 1; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.avatar {
  --h: 180;
  width: 44px; height: 44px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: oklch(var(--avatar-l) var(--avatar-c) var(--h));
  color: oklch(var(--avatar-ink-l) calc(var(--avatar-c) * 1.6) var(--h));
  font-weight: 650; font-size: 15px; letter-spacing: .02em; user-select: none;
}
.avatar.xl { width: 128px; height: 128px; font-size: 40px; font-family: var(--serif); font-weight: 600; }

.status-line {
  margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 8px 24px; color: var(--ink-3); font-size: 13px;
}
.status-line span { display: inline-flex; align-items: center; gap: 6px; }
.status-line .led { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.status-line .led.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }

/* ---------- conversation ---------- */

.back {
  border: 0; background: none; color: var(--ink-2); cursor: pointer; padding: 6px 0; margin-bottom: 16px;
  font-size: 14px; display: inline-flex; gap: 6px;
}
.back:hover { color: var(--ink); }

.call {
  display: grid; grid-template-columns: 340px 1fr; min-height: min(680px, calc(100vh - 170px));
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px; overflow: hidden;
  box-shadow: var(--shadow-lift);
}
.stage {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 40px 24px; gap: 6px; border-right: 1px solid var(--line);
  background:
    radial-gradient(120% 70% at 50% 0%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
    var(--surface-2);
}
.orb { --level: 0; position: relative; width: 200px; height: 200px; display: grid; place-items: center; margin-bottom: 18px; }
.orb .avatar { position: relative; z-index: 2; box-shadow: 0 10px 30px -10px rgb(0 0 0 / 35%); }
.orb .ring {
  position: absolute; inset: 36px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent) 40%, transparent);
  opacity: 0; transition: opacity .3s, border-color .3s;
}
.orb .r1 { transform: scale(calc(1.08 + var(--level) * 0.28)); }
.orb .r2 { transform: scale(calc(1.18 + var(--level) * 0.55)); border-width: 1px; }
.orb[data-mode="speaking"] .ring { opacity: 1; }
.orb[data-mode="listening"] .ring { opacity: .55; border-color: color-mix(in srgb, var(--ink-3) 45%, transparent); }
.orb[data-mode="connecting"] .r1 { opacity: 1; animation: pulse 1.4s ease-in-out infinite; }
.orb[data-mode="thinking"] .r1 { opacity: 1; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1.05); opacity: .2; } 50% { transform: scale(1.25); opacity: .9; } }

.call-name { font-family: var(--serif); font-size: 26px; font-weight: 600; letter-spacing: -0.01em; }
.call-role { color: var(--ink-2); font-size: 14px; }
.call-status { display: inline-flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 14px; font-weight: 560; color: var(--ink-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.dot.live { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 20%, transparent); }
.dot.busy { background: var(--warn); animation: blink 1s infinite; }
.dot.off { background: var(--ink-3); }
@keyframes blink { 50% { opacity: .35; } }
.call-timer { font-family: var(--mono); font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.call-controls { display: flex; gap: 14px; margin-top: 22px; align-items: center; }
.call-controls .caption { display: block; font-size: 11.5px; color: var(--ink-3); margin-top: 6px; }
.call-controls .ctl { display: flex; flex-direction: column; align-items: center; }

.thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.thread-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 16px 22px; border-bottom: 1px solid var(--line); font-weight: 620;
}
.thread-note { font-weight: 400; font-size: 12.5px; color: var(--ink-3); }
.transcript {
  list-style: none; margin: 0; padding: 22px; display: flex; flex-direction: column; gap: 14px;
  overflow-y: auto; flex: 1; min-height: 260px; max-height: calc(100vh - 290px);
}
.transcript .empty { margin: auto; color: var(--ink-3); text-align: center; max-width: 36ch; font-size: 14px; }
.msg { display: flex; flex-direction: column; max-width: min(78%, 62ch); animation: rise .25s ease both; }
.msg .who { font-size: 12px; color: var(--ink-3); margin: 0 4px 4px; }
.msg .bubble { padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.agent { align-self: flex-start; }
.msg.agent .bubble { background: var(--surface-2); border-top-left-radius: 6px; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.user .bubble { background: var(--accent-soft); color: var(--accent-soft-ink); border-top-right-radius: 6px; }
.msg.system { align-self: center; max-width: 100%; }
.msg.system .bubble { background: transparent; color: var(--ink-3); font-size: 13px; padding: 4px 8px; }
.msg.streaming .bubble::after {
  content: ""; display: inline-block; width: 7px; height: 1em; margin-left: 2px; vertical-align: -2px;
  background: currentColor; opacity: .5; animation: blink .9s steps(2) infinite;
}
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: bounce 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

.composer { display: flex; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--line); align-items: flex-end; }
.composer textarea {
  flex: 1; resize: none; min-height: 40px; max-height: 160px; padding: 9px 14px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--bg); color: var(--ink); font: inherit; line-height: 1.45;
}
.composer textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }

/* ---------- toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px;
  box-shadow: var(--shadow-lift); max-width: min(560px, calc(100vw - 32px));
  animation: rise .25s ease both;
}

/* ---------- small screens ---------- */

@media (max-width: 860px) {
  .brand-tag { display: none; }
  .client-hero { grid-template-columns: 1fr; align-items: start; }
  .call { grid-template-columns: 1fr; }
  .stage { border-right: 0; border-bottom: 1px solid var(--line); padding: 28px 16px; }
  .orb { width: 150px; height: 150px; margin-bottom: 8px; }
  .avatar.xl { width: 96px; height: 96px; font-size: 30px; }
  .transcript { max-height: none; }
}
@media (max-width: 640px) {
  .wrap { padding: 20px 16px 36px; }
  .topbar-inner { padding: 10px 16px; gap: 10px; flex-wrap: wrap; }
  .switch { order: 3; margin-left: 0; width: 100%; }
  .switch button { flex: 1; justify-content: center; }
  .switch button small { display: none; }
  .me { margin-left: auto; }
  .cast-grid { grid-template-columns: 1fr; }
  .msg { max-width: 88%; }
}

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