:root {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  color: #1c1c1e;
  background: #f2f2f7;
  font-synthesis: none;
  --bg: #f2f2f7;
  --card: #ffffff;
  --line: rgba(60, 60, 67, 0.12);
  --muted: #8e8e93;
  --blue: #007aff;
  --green: #34c759;
  --red: #ff3b30;
  --fill: rgba(120, 120, 128, 0.12);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
button, input, select, textarea { font: inherit; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; border: 0; color: inherit; background: none; }
button:disabled { opacity: .34; cursor: not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--blue) 45%, white); outline-offset: 2px;
}
a { color: var(--blue); }
button, input, select { min-height: 44px; }
h1, h2, h3, p { margin-top: 0; }
[hidden], section[hidden] { display: none !important; }
.muted { color: var(--muted); font-size: 15px; line-height: 1.4; }
.eyebrow { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.text-button { color: var(--blue); font-size: 17px; min-height: 44px; padding: 0; }
.primary {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 50px; padding: 0 18px; border-radius: 12px;
  background: var(--blue); color: #fff; font-size: 17px; font-weight: 600;
}
.pill {
  min-height: 32px; padding: 0 14px; border-radius: 999px;
  background: var(--fill); color: #1c1c1e; font-size: 15px;
}
.pill.selected, .pill[aria-pressed=true] { background: #1c1c1e; color: #fff; }

.login {
  width: min(400px, 100%); margin: 0 auto; padding: 88px 28px 48px;
}
.brand-mark {
  margin: 0 0 28px; font-size: 21px; font-weight: 700; letter-spacing: -0.4px;
}
.login h1 { font-size: 34px; font-weight: 700; letter-spacing: -0.6px; margin: 0 0 8px; }
.login form { margin-top: 28px; }
.login label, dialog label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.login input, dialog select, dialog input, .setting-block select {
  width: 100%; border: 0; background: var(--card); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 14px; box-shadow: 0 0 0 1px var(--line);
}
.login .primary { width: 100%; }
.login [role=alert] { font-size: 15px; color: var(--red); margin-top: 12px; }

.shell { min-height: 100dvh; }
.app-frame { min-height: 100dvh; display: flex; flex-direction: column; }
.app-bar {
  position: sticky; top: 0; z-index: 8;
  display: flex; align-items: center; gap: 8px;
  min-height: 52px; padding: 8px 16px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
}
#menu-open, #page-back {
  width: 44px; min-width: 44px; color: var(--blue); font-size: 28px; line-height: 1;
}
#page-title { flex: 1; margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.2px; }
.app-bar-trail { display: flex; align-items: center; gap: 10px; }
#chat-status {
  margin: 0; font-size: 13px; color: var(--muted); max-width: 42vw;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#open-settings, #header-call { color: var(--blue); font-size: 17px; padding: 0 4px; }

main {
  width: min(720px, 100%); margin: 0 auto; padding: 8px 20px 40px;
  flex: 1; min-width: 0; display: flex; flex-direction: column;
}
.large-title { font-size: 34px; font-weight: 700; letter-spacing: -0.7px; margin: 4px 0 6px; }
.page-kicker { margin: 0; font-size: 13px; color: var(--muted); text-transform: capitalize; }
.page-sub { margin: 0 0 22px; color: var(--muted); font-size: 15px; }

#app-menu {
  position: fixed; inset: 0 auto 0 0; width: min(320px, 86vw);
  background: #f2f2f7; z-index: 30; padding: 28px 18px 24px;
  transform: translateX(-105%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
  box-shadow: none; display: flex; flex-direction: column; gap: 18px;
  visibility: hidden; pointer-events: none;
}
.shell.menu-open #app-menu {
  transform: translateX(0); box-shadow: 16px 0 40px rgba(0,0,0,.12);
  visibility: visible; pointer-events: auto;
}
#menu-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.2); z-index: 25;
}
.menu-brand { margin: 8px 12px 0; font-size: 21px; font-weight: 700; letter-spacing: -0.4px; }
#app-menu nav { display: grid; background: var(--card); border-radius: 14px; overflow: hidden; }
#app-menu nav button {
  text-align: left; padding: 0 16px; height: 48px; font-size: 17px;
  border-bottom: 0.5px solid var(--line); background: var(--card);
}
#app-menu nav button:last-child { border-bottom: 0; }
#app-menu nav button.selected { color: var(--blue); font-weight: 600; }
#missed-badge { font-style: normal; font-size: 13px; color: var(--red); margin-left: 6px; }
.mode-banner { background: var(--card); border-radius: 14px; padding: 12px 14px; font-size: 13px; }
.mode-banner p { margin: 6px 0 0; color: var(--muted); }
.mode-banner select { width: 100%; margin-top: 8px; }
.menu-status { margin: auto 12px 0; font-size: 13px; color: var(--muted); }
.availability-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-right: 6px; }

#home-note:empty, #sessions-status:empty { display: none; }
.section-label { margin: 28px 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
#phone-sessions { display: grid; gap: 12px; margin-bottom: 8px; }
#home-list { display: grid; gap: 12px; }
.agent-card {
  display: grid; grid-template-columns: 52px 1fr; gap: 12px 14px;
  background: var(--card); border-radius: 16px; padding: 16px;
}
.avatar, .caller-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center; font-size: 22px; font-weight: 600; color: #1c1c1e;
}
.agent-card h3 { margin: 2px 0 2px; font-size: 17px; font-weight: 600; }
.agent-card p { margin: 0; font-size: 13px; color: var(--muted); }
.agent-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.agent-actions button {
  min-height: 44px; border-radius: 12px; background: var(--fill);
  font-size: 17px; font-weight: 600; color: var(--blue);
}
.agent-actions .call { color: var(--green); }

.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--fill); border-radius: 12px; padding: 0 12px; margin: 0 0 16px;
}
.search span { color: var(--muted); font-size: 17px; }
.search input { flex: 1; border: 0; background: none; min-height: 40px; outline: none; width: 100%; }

.grouped { background: var(--card); border-radius: 14px; overflow: hidden; }
.grouped button {
  display: block; width: 100%; text-align: left; padding: 0 16px;
  height: 52px; font-size: 17px; color: var(--blue);
  border-bottom: 0.5px solid var(--line); background: var(--card);
}
.grouped button:last-child { border-bottom: 0; }

.contact-list { background: var(--card); border-radius: 14px; overflow: hidden; }
.contact {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  border-bottom: 0.5px solid var(--line); background: var(--card);
}
.contact:last-child { border-bottom: 0; }
.contact .avatar { width: 40px; height: 40px; font-size: 17px; }
.contact h3 { margin: 0; font-size: 17px; font-weight: 600; }
.contact .role, .contact .presence { margin: 0; font-size: 13px; color: var(--muted); }
.contact .arrow { margin-left: auto; color: var(--green); font-size: 15px; font-weight: 600; padding: 0 4px; }
.presence i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #c7c7cc; margin-right: 4px; }
.presence.online i { background: var(--green); }

.filters { display: flex; gap: 8px; margin-bottom: 14px; }
.history-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-bottom: 0.5px solid var(--line);
}
.history-row .avatar { width: 40px; height: 40px; font-size: 17px; }
.history-row h3 { margin: 0 0 2px; font-size: 17px; }
.history-row p { margin: 0; font-size: 13px; color: var(--muted); }
.history-row .missed { color: var(--red); }
.history-row time { margin-left: auto; color: var(--muted); font-size: 13px; }
.history-row button { color: var(--green); font-size: 17px; font-weight: 600; }

.empty { padding: 36px 16px; text-align: center; color: var(--muted); font-size: 15px; }
.notice {
  display: flex; gap: 12px; align-items: center;
  background: var(--card); border-radius: 14px; padding: 14px 16px; margin-bottom: 16px;
}
.notice p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.notice button { margin-left: auto; color: var(--blue); font-weight: 600; }
.settings-card {
  background: var(--card); border-radius: 14px; padding: 16px; margin: 0 0 12px;
}
.settings-card h3 { margin: 0 0 8px; font-size: 17px; }
.settings-card p { margin: 0 0 10px; font-size: 15px; color: var(--muted); }

#inbox-view .rail-project { margin: 0 0 18px; }
.rail-project-btn {
  display: block; width: 100%; text-align: left; min-height: 28px;
  font-size: 13px; color: var(--muted); font-weight: 600; padding: 0 4px 8px;
}
.rail-project ul { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: 14px; overflow: hidden; }
.rail-project li button {
  width: 100%; display: flex; gap: 12px; align-items: center;
  padding: 12px 14px; text-align: left; border-bottom: 0.5px solid var(--line);
}
.rail-project li:last-child button { border-bottom: 0; }
.rail-project li button.selected { background: #eaf2ff; }
.rail-project li i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.rail-project li span { display: grid; gap: 1px; min-width: 0; }
.rail-project li b { font-size: 17px; font-weight: 600; }
.rail-project li small, .rail-project li em { font-size: 13px; color: var(--muted); font-style: normal; }

#chat-view {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  margin: 0 -20px; padding: 0;
}
.chat-heading { padding: 0 20px 10px; }
.chat-heading h2 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }
.chat-heading p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
#transcript-list {
  flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 8px;
  padding: 8px 20px 12px; min-height: 180px;
}
.bubble {
  max-width: min(520px, 86%); padding: 10px 14px; border-radius: 18px;
  background: var(--card); font-size: 17px; line-height: 1.35;
}
.bubble.me { align-self: flex-end; background: #007aff; color: #fff; }
.bubble.me small { color: rgba(255,255,255,.78); }
.bubble p { margin: 0; }
.bubble small { display: block; margin-top: 6px; font-size: 12px; color: var(--muted); }
.task-card, .approval-card, .file-card, .media-card {
  background: var(--card); border-radius: 16px; padding: 14px 16px;
}
.task-card h3, .approval-card h3, .file-card h3 { margin: 0 0 6px; font-size: 17px; }
.approval-card label { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.approval-card textarea, .queue-edit textarea, #transcript-edit {
  width: 100%; min-height: 72px; border: 0; border-radius: 12px;
  padding: 10px; background: var(--fill);
}
#queue-bar { display: grid; gap: 8px; padding: 0 20px 8px; }
.queue-item {
  display: grid; grid-template-columns: 1fr auto; gap: 8px;
  background: var(--card); border-radius: 14px; padding: 12px 14px; position: relative;
}
.queue-item span, .queue-status { display: block; font-size: 13px; color: var(--muted); }
.queue-paused { background: #f3e8ff; border-radius: 12px; padding: 10px 12px; font-size: 13px; }
.queue-menu {
  position: absolute; right: 12px; top: 44px; z-index: 6;
  background: var(--card); border-radius: 12px; padding: 6px;
  min-width: 240px; box-shadow: 0 12px 40px rgba(0,0,0,.16);
}
.queue-menu button { display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 8px; }
.composer {
  position: sticky; bottom: 0; padding: 8px 16px 16px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(16px);
}
.composer-target { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
.composer-hint { margin: 0 0 8px; font-size: 13px; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer-row textarea {
  flex: 1; border: 0; border-radius: 20px; padding: 10px 14px;
  background: var(--card); resize: none; min-height: 40px; max-height: 140px;
  box-shadow: 0 0 0 1px var(--line);
}
.plus-wrap { position: relative; }
#plus-menu, #record-start, #stop-turn, #resume-queue {
  width: 40px; min-width: 40px; height: 40px; min-height: 40px;
  border-radius: 50%; background: var(--fill); font-size: 20px;
}
#resume-queue { width: auto; padding: 0 12px; border-radius: 20px; font-size: 15px; color: var(--blue); }
#composer-send { min-width: 40px; width: 40px; height: 40px; min-height: 40px; padding: 0; border-radius: 50%; }
#plus-popover {
  position: absolute; left: 0; bottom: 48px; z-index: 7;
  background: var(--card); border-radius: 14px; padding: 6px;
  min-width: 200px; box-shadow: 0 12px 40px rgba(0,0,0,.16);
}
#plus-popover button { display: block; width: 100%; text-align: left; padding: 10px 12px; }
#recorder { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 8px; }
#recorder button { background: var(--fill); border-radius: 12px; padding: 0 12px; color: var(--blue); }
.file-chip { display: inline-block; margin: 4px 6px 0 0; padding: 6px 10px; border-radius: 999px; background: var(--fill); font-size: 13px; }
.media-card { margin-bottom: 8px; }
.media-card .media-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.media-card .media-actions button { color: var(--blue); font-weight: 600; }

#context-panel {
  position: fixed; inset: 0 0 0 auto; width: min(380px, 100%);
  background: var(--bg); z-index: 22; padding: 20px 18px 32px;
  overflow: auto; box-shadow: -12px 0 40px rgba(0,0,0,.12);
  display: none;
}
#context-panel.open { display: block; }
#context-panel header { display: flex; justify-content: space-between; align-items: center; }
#context-panel h2 { margin: 0; font-size: 22px; }
.sheet-tabs { display: flex; gap: 6px; margin: 14px 0 18px; }
.sheet-tabs button {
  min-height: 32px; padding: 0 12px; border-radius: 999px;
  background: var(--fill); font-size: 15px;
}
.sheet-tabs button.selected { background: #1c1c1e; color: #fff; }
.setting-block { background: var(--card); border-radius: 14px; padding: 14px; margin-bottom: 10px; }
.setting-block.disabled { opacity: .55; }
.apply { font-size: 13px; color: var(--blue); font-weight: 600; margin: 0 0 6px; }
.diff { font-size: 13px; color: var(--muted); }
.activity-log { padding-left: 18px; font-size: 13px; color: var(--muted); }

#call-strip { margin: 0 20px 8px; border-radius: 14px; padding: 12px 14px; background: #1c1c1e; color: #fff; }
.call-strip-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.call-strip-actions button { background: #ffffff22; color: #fff; border-radius: 10px; padding: 0 12px; }

dialog {
  border: 0; border-radius: 18px; background: var(--bg); padding: 28px 22px;
  width: min(400px, calc(100% - 32px)); color: #1c1c1e;
}
dialog::backdrop { background: rgba(0,0,0,.32); }
dialog h2 { font-size: 28px; margin: 0 0 12px; }
dialog .primary { width: 100%; }
dialog .close { position: absolute; right: 10px; top: 8px; font-size: 24px; width: 40px; color: var(--muted); }
.wide-dialog { width: min(640px, calc(100% - 24px)); max-height: 90dvh; overflow: auto; }
.picker-list { list-style: none; padding: 0; display: grid; gap: 8px; }
.picker-list button {
  width: 100%; text-align: left; background: var(--card); border-radius: 14px; padding: 12px; display: grid; gap: 4px;
}
.caps { font-size: 12px; color: var(--muted); }
.folder-tree ul { list-style: none; margin: 0; padding: 0 0 0 12px; }
.folder-row { display: flex; gap: 6px; align-items: center; }
.folder-tree li.selected > .folder-row button { font-weight: 650; color: var(--blue); }
.lock-reason, .folder-path { font-size: 12px; color: var(--muted); margin: 0 0 8px 28px; }
.folder-crumb, .folder-favs { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.folder-crumb button, .folder-favs button { background: var(--fill); border-radius: 999px; padding: 0 12px; min-height: 32px; font-size: 13px; }
.folder-actions { display: grid; gap: 8px; margin-top: 16px; }
.folder-spacer { width: 28px; display: inline-block; }

.call-dialog {
  background: #111; color: #f5f5f7; text-align: center;
  width: min(400px, 100%); padding: 40px 24px 28px; border-radius: 24px;
}
.call-dialog .eyebrow { color: #8e8e93; }
.caller-avatar { margin: 28px auto 16px; background: #d8edac; }
.call-dialog h2 { color: #fff; font-size: 32px; }
.call-dialog #call-reason { color: #aeaeb2; font-size: 15px; white-space: pre-wrap; }
.call-dialog #call-status { color: #8e8e93; font-size: 15px; }
.wave { display: flex; gap: 5px; height: 38px; align-items: center; justify-content: center; margin: 20px 0 8px; }
.wave i { display: block; width: 4px; height: 7px; border-radius: 8px; background: #d1d1d6; }
.wave.active i { animation: pulse .9s ease-in-out infinite alternate; }
.wave i:nth-child(3n) { animation-delay: -.4s; }
.wave i:nth-child(2n) { animation-delay: -.7s; }
@keyframes pulse { to { height: 30px; opacity: .6; } }
#call-timer { font-size: 13px; letter-spacing: 1px; color: #8e8e93; font-variant-numeric: tabular-nums; }
.call-actions { display: flex; justify-content: space-around; margin: 28px 0 12px; }
.round { border-radius: 50%; height: 64px; width: 64px; font-size: 28px; }
.answer { background: var(--green); color: #fff; }
.danger { background: var(--red); color: #fff; }
.neutral { background: #2c2c2e; color: #fff; }
.neutral[aria-pressed=true] { background: #f2f2f7; color: #1c1c1e; }
.call-actions > div { display: grid; gap: 8px; justify-items: center; }
.call-actions span { font-size: 12px; color: #8e8e93; }
.call-hint { font-size: 13px; color: #8e8e93; }
.call-dialog details { font-size: 13px; text-align: left; color: #d1d1d6; }
.call-dialog summary { cursor: pointer; text-align: center; padding: 12px; }
#transcript { max-height: 140px; overflow: auto; }
#transcript p { margin: 8px 0; }
.self { color: #fff; }

#toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 14px;
  background: rgba(28,28,30,.92); color: #fff; font-size: 15px; z-index: 100;
}
#sessions-error:empty { display: none; }

@media (max-width: 650px) {
  main { padding: 4px 16px 28px; }
  #chat-view { margin: 0 -16px; }
  #chat-status { max-width: 28vw; }
  .queue-menu { position: static; box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
