/* The phone (design-docs/0028, 0030): dark, quiet, large targets, readable at a glance. Tokens only. */
body.phone {
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
/* The page never scrolls or bounces (iOS rubber-banding read as "the UI scrolls"); a screen is exactly the viewport
   and only its own content scrolls, and only when it is taller than the phone. */
html:has(body.phone),
body.phone {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
.p-screen {
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 20px);
  max-width: 560px;
  margin: 0 auto;
}
.p-screen > * {
  flex-shrink: 0; /* the screen scrolls; its parts never squash */
}
body.phone .p-screen {
  background: radial-gradient(420px 260px at 50% -60px, var(--accent-glow-soft), transparent 70%), var(--background);
}
body.phone.driving .p-screen {
  background: var(--background);
}
.p-mono {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.02em;
  color: var(--muted-foreground);
}
.p-muted {
  color: var(--muted-foreground);
}
.p-grow {
  flex: 1;
  min-height: var(--space-4);
}
.p-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: var(--touch);
}
.p-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.p-brand.small {
  font-size: var(--text-md);
  color: var(--muted-foreground);
}
.p-brand.small .brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
}
.p-icon {
  width: var(--touch);
  height: var(--touch);
  flex: none;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted-foreground);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition:
    color var(--fast) var(--ease),
    border-color var(--fast) var(--ease);
}
.p-icon:hover {
  color: var(--foreground);
  border-color: var(--border-strong);
}
.p-icon.p-wide {
  width: auto;
  padding: 0 var(--space-4);
}
.p-icon-space {
  width: var(--touch);
}
.p-greet {
  margin-top: var(--space-4);
}
.p-title {
  margin: var(--space-3) 0 0;
  font-weight: 600;
  font-size: var(--text-2xl);
  line-height: 36px;
  letter-spacing: -0.03em;
}
.p-title span {
  color: var(--muted-foreground);
}
.p-lead {
  margin: 0 auto;
  max-width: 340px;
  text-align: center;
  color: var(--muted-foreground);
  font-size: var(--text-md);
}
.p-hint {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
  text-align: center;
}

/* --- status strip --- */
.p-strip {
  margin-top: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--card);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
}
.p-strip > div {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.p-strip > div + div {
  border-left: 1px solid var(--border);
}
.p-strip .hot {
  background: var(--warning-bg);
}
.p-strip .hot .p-label {
  color: var(--warning);
}
.p-strip b {
  font-weight: 600;
  font-size: 26px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.p-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  color: var(--muted-foreground);
}
.p-label .dot {
  width: 6px;
  height: 6px;
}

/* --- sections and cards --- */
.p-section {
  margin-top: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.p-section h2 {
  margin: 0;
  font-weight: 500;
  font-size: var(--text-sm);
  letter-spacing: 0;
  color: var(--muted-foreground);
}
.p-card {
  min-height: 56px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: var(--space-3) 14px;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--foreground);
  transition:
    border-color var(--fast) var(--ease),
    background var(--fast) var(--ease);
}
a.p-card:hover {
  border-color: var(--border-strong);
  background: var(--card-hover);
}
a.p-card > .ico:last-child {
  color: var(--faint-foreground);
}
.p-card.amber {
  border-color: var(--warning-border);
  background: var(--warning-bg);
}
.p-card.ready {
  border-color: var(--success-border);
}
.p-card .ok {
  color: var(--success);
  display: inline-flex;
}
.p-card .p-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: var(--text-base);
  line-height: 20px;
}
.p-card .p-text > span:first-child {
  font-weight: 500;
}
.p-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.p-entry-icon {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-soft);
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
}
.p-empty {
  font-size: var(--text-base);
  color: var(--muted-foreground);
  padding: var(--space-3) 0;
}

/* --- project switcher and the big button --- */
/* the talk button stays in reach while the screen scrolls above it */
.p-foot {
  position: sticky;
  z-index: 2;
  bottom: calc(-1 * (env(safe-area-inset-bottom) + 20px));
  margin: 0 -16px calc(-1 * (env(safe-area-inset-bottom) + 20px));
  padding: var(--space-6) 16px calc(env(safe-area-inset-bottom) + 20px);
  background: linear-gradient(transparent, var(--background) var(--space-6));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-3);
}
.p-switch-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.p-switch {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.p-switch-chip {
  flex: none;
  height: var(--touch);
  padding: 0 var(--space-4);
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted-foreground);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
}
.p-switch-chip.on {
  color: var(--accent-soft);
  border-color: var(--accent);
  background: var(--accent-bg);
  box-shadow: 0 0 16px var(--accent-glow-soft);
}
.p-primary {
  width: 100%;
  height: 60px;
  border-radius: var(--radius-xl);
  border: 0;
  background: var(--primary);
  color: var(--primary-foreground);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow:
    0 0 0 1px var(--primary),
    0 0 40px var(--accent-glow);
  transition: background var(--fast) var(--ease);
}
.p-primary:hover {
  background: var(--primary-hover);
}
.p-pill {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-full);
  padding: 6px 12px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}
.p-live {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted-foreground);
}
.p-live.on {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}
.p-about {
  margin-top: var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: var(--text-sm);
  color: var(--muted-foreground);
}
.p-chips {
  margin-top: var(--space-3);
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}

/* --- the orb --- */
.p-orb-wrap {
  height: 240px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.p-orb {
  position: relative;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: 1px solid var(--accent-glow-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}
.p-orb::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 70%, var(--accent) 85%, transparent 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 1px), var(--background) calc(100% - 1px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 1px), var(--background) calc(100% - 1px));
  opacity: 0;
  transition: opacity var(--normal) var(--ease);
}
.p-orb.live::before {
  opacity: 1;
  animation: spin 6s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.p-orb > div {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 1px solid var(--accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
}
.p-orb > div > div {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--accent-border), var(--accent-bg) 70%);
  border: 1px solid var(--accent);
  box-shadow:
    0 0 60px var(--accent-glow),
    inset 0 0 24px var(--accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.p-orb i {
  width: 4px;
  border-radius: 2px;
  background: var(--accent-soft);
  height: 10px;
  transition: height var(--normal);
}
.p-orb.live i {
  animation: p-wave 1.4s ease-in-out infinite;
}
.p-orb.live i:nth-child(2) {
  animation-delay: 0.15s;
}
.p-orb.live i:nth-child(3) {
  animation-delay: 0.3s;
}
.p-orb.live i:nth-child(4) {
  animation-delay: 0.45s;
  background: var(--foreground);
}
.p-orb.live i:nth-child(5) {
  animation-delay: 0.6s;
}
.p-orb.live i:nth-child(6) {
  animation-delay: 0.75s;
}
.p-orb.off {
  opacity: 0.4;
}
@keyframes p-wave {
  0%,
  100% {
    height: 10px;
  }
  50% {
    height: 34px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .p-orb.live i {
    animation: none;
    height: 22px;
  }
  .p-orb.live::before {
    animation: none;
  }
}

/* --- the talk --- */
.p-state {
  text-align: center;
  margin-top: -10px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted-foreground);
}
.p-captions {
  margin-top: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 72px;
}
.p-captions p {
  margin: 0;
  font-size: var(--text-base);
  line-height: 20px;
  color: var(--muted-foreground);
}
.p-captions p:last-child {
  font-size: var(--text-lg);
  line-height: 26px;
  letter-spacing: -0.01em;
  color: var(--foreground);
}
.p-captions b {
  font-weight: 500;
  color: var(--foreground-2);
  margin-right: 6px;
}
.p-captions b.her {
  color: var(--accent);
}
.p-talk-cards {
  margin-top: var(--space-4);
}
.p-controls {
  padding: var(--space-4) var(--space-4) 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.p-round,
.p-round-space {
  width: 60px;
  height: 60px;
}
.p-round {
  border-radius: 30px;
  border: 1px solid var(--border);
  background: var(--raised);
  color: var(--foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}
.p-end {
  width: 76px;
  height: 76px;
  border-radius: 38px;
  border: 0;
  background: var(--destructive);
  color: var(--destructive-foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  box-shadow: 0 0 32px var(--destructive-glow);
}
.p-end:hover,
.p-end-wide:hover {
  background: var(--destructive-hover);
}

/* --- driving: black, one status line, a giant End button --- */
.p-drive-pill {
  letter-spacing: 0.08em;
  color: var(--muted-foreground);
}
.p-drive {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
  text-align: center;
}
.p-drive .p-big {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  font-size: 34px;
  line-height: 40px;
  letter-spacing: -0.03em;
}
.p-drive .p-big .amber {
  color: var(--warning);
}
.p-drive p {
  margin: 0;
  font-size: 16px;
  line-height: 23px;
  color: var(--muted-foreground);
}
.p-drive-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.p-end-wide {
  width: 100%;
  height: 92px;
  border-radius: 20px;
  border: 0;
  background: var(--destructive);
  color: var(--destructive-foreground);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  cursor: pointer;
}
.p-center {
  align-self: center;
}
.p-login {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-4);
}
.p-input {
  height: 52px;
  border-radius: var(--radius-lg);
  font-family: var(--font-mono);
  font-size: var(--text-md);
}
.p-error {
  color: var(--danger);
  font-size: var(--text-base);
}

/* --- shared pages (agents, an agent, projects) inside a phone screen --- */
.p-screen .page {
  padding: var(--space-3) 0 var(--space-4);
  gap: var(--space-4);
  width: 100%;
}
.p-screen .back {
  display: none;
}
.p-screen .page-head {
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-3);
}
.p-screen .page-head h1 {
  font-size: var(--text-2xl);
  letter-spacing: -0.03em;
}
.p-screen .page-head > .row .btn {
  flex: 1;
}
.p-screen .btn,
.p-screen .input {
  min-height: var(--touch);
}
.p-screen .btn.sm {
  height: var(--touch);
}
.p-screen .input,
.p-screen .textarea {
  font-size: 16px; /* iOS zooms into smaller inputs */
}
.p-screen .agent-row {
  padding: 14px;
}
.p-screen .agent-row-main {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    'badge side'
    'body body';
  row-gap: var(--space-2);
}
.p-screen .agent-row-main > .badge {
  grid-area: badge;
}
.p-screen .agent-row-body {
  grid-area: body;
}
.p-screen .agent-row-side {
  grid-area: side;
}
.p-screen .agent-row-title {
  white-space: normal;
  font-size: var(--text-md);
}
.p-screen .question.compact {
  margin-left: 0;
}
.p-screen a.chip::before {
  content: '';
  position: absolute;
  inset: -9px -4px;
}
.p-screen .agent-grid {
  grid-template-columns: minmax(0, 1fr);
}
.p-screen .timeline {
  max-height: 46vh;
}
.p-screen .cards {
  grid-template-columns: minmax(0, 1fr);
}
.p-screen .agent-rows .agent-row {
  min-height: 56px;
}
.p-screen .composer-foot .mono {
  visibility: hidden; /* no keyboard shortcut on a phone */
}
