/* Console layout (DESIGN.md, design audit C-1 to C-14). Components come from ui.css. */
body.console {
  background: var(--bg);
}
.brand,
.topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text);
  font-weight: var(--weight-display);
  letter-spacing: -0.03em;
  text-decoration: none;
}
.brand {
  font-size: var(--text-title-3);
}
.brand:hover,
.topbar-brand:hover {
  text-decoration: none;
}
.brand img,
.topbar-brand img {
  border-radius: var(--radius-md);
}

/* Signed out ------------------------------------------------------------------------------- */
.auth {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.auth-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--gutter);
}
.auth-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.auth-main {
  flex: 1;
  display: grid;
  justify-items: center;
  align-content: start;
  padding: var(--space-4) var(--gutter) var(--space-16);
}
.auth-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-5);
  width: min(100%, 440px);
  padding: var(--space-6) var(--space-5);
  box-shadow: var(--shadow-1);
}
@media (min-width: 600px) {
  .auth-main {
    padding-top: var(--space-10);
  }
  .auth-card {
    padding: var(--space-8);
  }
}
.auth-tabs {
  display: flex;
  width: 100%;
}
.auth-tabs button {
  flex: 1;
  justify-content: center;
  min-height: 36px;
  font-size: var(--text-body-sm);
}
.auth-heading {
  display: grid;
  gap: var(--space-1);
}
.auth-heading h1 {
  font-size: var(--text-title-2);
  font-weight: var(--weight-title);
  line-height: 1.25;
  letter-spacing: -0.015em;
}
.auth-heading > p:last-child {
  color: var(--text-muted);
  font-size: var(--text-body-sm);
}
#auth-form,
#credentials,
#connect-form {
  display: grid;
  gap: var(--space-4);
}
#connect-form {
  margin-top: var(--space-3);
}
.auth-recover {
  justify-self: center;
  white-space: normal;
  text-align: center;
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-caption);
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.legacy-access > summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-md);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--text-body-sm);
  font-weight: var(--weight-strong);
  list-style: none;
  cursor: pointer;
}
.legacy-access > summary::-webkit-details-marker {
  display: none;
}
.legacy-access > summary:hover {
  background: var(--surface-hover);
}
.legacy-access[open] > summary .icon {
  rotate: 180deg;
}
.auth-cookies {
  text-align: center;
}

/* Shell ------------------------------------------------------------------------------------ */
.shell {
  display: grid;
  min-height: 100vh;
  background: var(--surface);
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  grid-template-rows: var(--topbar) 1fr;
  grid-template-areas:
    'topbar topbar'
    'sidebar main';
}
.app-topbar {
  grid-area: topbar;
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: var(--topbar);
  padding: 0 var(--space-3) 0 var(--space-4);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
}
.topbar-brand {
  font-size: var(--text-body);
}
#topbar-theme-slot {
  display: contents;
}
.topbar-end {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-left: auto;
}
.app-topbar .theme-menu > summary {
  width: var(--control-md);
  height: var(--control-md);
  border-color: transparent;
  background: transparent;
}
.app-topbar .theme-menu > summary:hover {
  background: var(--surface-hover);
}
.status-trigger {
  cursor: pointer;
  margin-right: var(--space-2);
}
.delivery-menu {
  width: 300px;
}
.delivery-menu .menu-meta span {
  display: block;
  margin-top: var(--space-1);
}
.account-button {
  display: grid;
  place-items: center;
  width: var(--control-md);
  height: var(--control-md);
  margin-left: var(--space-1);
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: none;
}
.account-button:hover .avatar {
  box-shadow: 0 0 0 3px var(--surface-hover);
}
.nav-toggle {
  display: none;
}
.console .theme-menu > summary {
  width: var(--control-md);
  height: var(--control-md);
  border-color: transparent;
  background: transparent;
}
.console .theme-menu > summary:hover {
  background: var(--surface-hover);
}
.section-description a {
  text-decoration: underline;
}

.sidebar {
  grid-area: sidebar;
  position: sticky;
  top: var(--topbar);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  height: calc(100vh - var(--topbar));
  padding: var(--space-4) var(--space-3);
  overflow-y: auto;
  background: var(--surface);
}
.sidebar-workspace {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-1) var(--space-2);
}
.sidebar-workspace .avatar {
  width: 32px;
  height: 32px;
}
.sidebar-workspace-text {
  display: grid;
  min-width: 0;
}
.sidebar-workspace-text strong,
.sidebar-workspace-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-workspace-text strong {
  font-size: var(--text-body-sm);
  font-weight: var(--weight-strong);
}
.sidebar-workspace-text small {
  color: var(--text-muted);
  font-size: var(--text-caption);
}
.nav-group {
  display: grid;
  gap: var(--space-0-5);
}
.nav-group-end {
  margin-top: auto;
}
.nav-group-label {
  padding: var(--space-1) var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-micro);
  font-weight: var(--weight-strong);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  height: 36px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  color: var(--text);
  font-size: var(--text-body-sm);
  font-weight: var(--weight-ui);
  text-align: left;
}
.nav-item .icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}
.nav-item:hover {
  background: var(--surface-hover);
}
.nav-item.active {
  background: var(--surface-selected);
  color: var(--accent);
  font-weight: var(--weight-strong);
}
.nav-item.active .icon {
  color: var(--accent);
}
.nav-item:disabled {
  cursor: progress;
}
.nav-count {
  margin-left: auto;
  color: var(--text-muted);
  font-size: var(--text-caption);
  font-variant-numeric: tabular-nums;
}
.nav-scrim {
  display: none;
}

.workarea {
  grid-area: main;
  min-width: 0;
  border-left: 1px solid var(--border);
  background: var(--bg);
  padding: var(--space-8) var(--gutter) var(--space-16);
}
.workarea:focus {
  outline: 0;
}
.workarea > .page-header,
.workarea > .view {
  max-width: var(--console-content);
  margin-left: auto;
  margin-right: auto;
}
.page-header {
  align-items: center;
}
.page-actions {
  flex-wrap: nowrap;
}
.view {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-5);
  align-content: start;
}
.list-footer {
  display: flex;
  justify-content: center;
}
.list-footer:has(> [hidden]:only-child) {
  display: none;
}
.list-footer > .btn {
  margin: var(--space-4);
}

/* Tablet: icon rail with tooltips. */
@media (max-width: 1023px) {
  .shell {
    grid-template-columns: var(--rail) minmax(0, 1fr);
  }
  .sidebar {
    align-items: center;
    padding: var(--space-3) var(--space-2);
  }
  .sidebar-workspace {
    padding: 0;
  }
  .nav-group {
    justify-items: center;
  }
  .nav-item {
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
  }
  .plan-meter {
    display: none;
  }
  .sidebar-workspace-text,
  .nav-label,
  .nav-count,
  .nav-group-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

/* Phone: the sidebar becomes a drawer. */
@media (max-width: 599px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'topbar'
      'main';
  }
  .nav-toggle {
    display: inline-flex;
  }
  .app-topbar {
    padding-left: var(--space-2);
  }
  .topbar-brand span {
    display: none;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: var(--z-dialog);
    width: min(300px, 86vw);
    height: 100vh;
    align-items: stretch;
    padding: var(--space-5) var(--space-3);
    box-shadow: var(--shadow-3);
    translate: -105% 0;
    visibility: hidden;
  }
  .shell.nav-open .sidebar {
    translate: 0 0;
    visibility: visible;
  }
  /* Only toggling animates; crossing a breakpoint while resizing does not. */
  .shell.drawer-moving .sidebar {
    transition:
      translate var(--duration-slow) var(--ease-out),
      visibility 0s linear var(--duration-slow);
  }
  .shell.drawer-moving.nav-open .sidebar {
    transition: translate var(--duration-slow) var(--ease-out);
  }
  .sidebar-workspace {
    padding: var(--space-1) var(--space-2);
  }
  .nav-group {
    justify-items: stretch;
  }
  .nav-item {
    justify-content: flex-start;
    width: 100%;
    height: 44px;
    padding: 0 var(--space-3);
  }
  .plan-meter {
    display: grid;
  }
  .sidebar-workspace-text,
  .nav-label,
  .nav-count,
  .nav-group-label {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
  }
  .sidebar-workspace-text {
    overflow: hidden;
  }
  .nav-scrim {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-dialog) - 1);
    display: block;
    background: var(--scrim);
  }
  .nav-scrim[hidden] {
    display: none;
  }
  .workarea {
    padding-top: var(--space-6);
    border-left: 0;
  }
  #updated-at {
    display: none;
  }
  .page-header {
    margin-bottom: var(--space-4);
  }
  .page-header h1 {
    font-size: var(--text-title-2);
  }
  .status-trigger {
    margin-right: 0;
  }
}

/* Messages --------------------------------------------------------------------------------- */
.summary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.summary-item {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-1);
  min-height: 36px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text-muted);
  font-size: var(--text-body-sm);
  line-height: 34px;
}
.summary-item strong {
  color: var(--text);
  font-weight: var(--weight-title);
}
.summary-item:hover {
  background: var(--surface-hover);
}
.summary-item[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--surface-selected);
}
.summary-attention.has-attention strong {
  color: var(--danger-text);
}
.activity > summary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--control-sm);
  padding: 0 var(--space-2);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: var(--text-body-sm);
  font-weight: var(--weight-strong);
  list-style: none;
  cursor: pointer;
}
.activity > summary::-webkit-details-marker {
  display: none;
}
.activity > summary:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.activity[open] > summary .chevron {
  rotate: 180deg;
}
.activity-panel {
  display: grid;
  gap: var(--space-4);
  margin-top: var(--space-2);
  padding: var(--space-5) var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
}
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--chart-outbound);
}
.legend-dot.received {
  margin-left: var(--space-2);
  background: var(--chart-received);
}
.activity-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--space-3);
  height: 140px;
}
.chart-day {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: var(--space-2);
  min-width: 0;
}
.chart-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  border-bottom: 1px solid var(--chart-grid);
}
.chart-bar {
  width: min(16px, 40%);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--chart-outbound);
}
.chart-bar.received {
  background: var(--chart-received);
}
.chart-day small {
  color: var(--text-muted);
  font-size: var(--text-micro);
  text-align: center;
}
.chart-value {
  font-size: var(--text-micro);
  color: var(--text-muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.mail-panel {
  overflow: visible;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.toolbar-search {
  flex: 1 1 240px;
  max-width: 440px;
}
.toolbar-search input {
  min-height: var(--control-sm);
  padding-top: var(--space-1);
  padding-bottom: var(--space-1);
}
.toolbar-count {
  margin-left: auto;
}
.filter-details {
  position: relative;
}
.filter-details > summary {
  list-style: none;
}
.filter-details > summary::-webkit-details-marker {
  display: none;
}
.filter-count:not(:empty) {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  background: var(--action);
  color: var(--on-action);
  font-size: var(--text-micro);
}
.filters {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 0;
  z-index: var(--z-dropdown);
  display: grid;
  gap: var(--space-4);
  width: min(320px, calc(100vw - 2 * var(--gutter)));
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-2);
}
.message-rows:empty {
  display: none;
}
.day-heading {
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-size: var(--text-micro);
  font-weight: var(--weight-strong);
}
.message-row {
  position: relative;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: center;
  min-height: 64px;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.message-row:last-child {
  border-bottom: 0;
}
.message-row:hover {
  background: var(--surface-hover);
}
.message-row:focus-within {
  background: var(--surface-hover);
}
.direction {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--surface-subtle);
  color: var(--text-muted);
}
.direction .icon {
  width: 16px;
  height: 16px;
}
.direction.inbound {
  background: var(--info-bg);
  color: var(--info-text);
}
.row-main {
  display: grid;
  gap: var(--space-0-5);
  min-width: 0;
}
.row-line {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  min-width: 0;
}
.row-who {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-body-sm);
  font-weight: var(--weight-strong);
}
.row-agent {
  flex: none;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: var(--text-caption);
}
.subject-link {
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font-size: var(--text-body-sm);
  font-weight: var(--weight-ui);
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.subject-link::after {
  content: '';
  position: absolute;
  inset: 0;
}
.subject-link:focus-visible {
  outline: 0;
}
.subject-link:focus-visible::after {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.row-snippet {
  color: var(--text-muted);
  font-weight: var(--weight-body);
}
.row-meta {
  display: grid;
  justify-items: end;
  gap: var(--space-1);
  color: var(--text-muted);
  font-size: var(--text-caption);
  white-space: nowrap;
}
.message-row.unread .row-who::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: var(--space-2);
  border-radius: var(--radius-full);
  background: var(--accent);
  vertical-align: 2px;
}
@media (max-width: 599px) {
  .filter-details {
    width: 100%;
  }
  .filters {
    position: static;
    width: 100%;
    margin-top: var(--space-3);
    padding: 0;
    border: 0;
    box-shadow: none;
  }
  .message-row {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: var(--space-3);
  }
  .message-row .direction {
    display: none;
  }
  .row-agent {
    display: none;
  }
  .toolbar-count {
    width: 100%;
    margin-left: 0;
  }
}

/* Agents ----------------------------------------------------------------------------------- */
.agents {
  grid-template-columns: 280px minmax(0, 1fr);
  align-items: start;
}
.agents-list {
  display: grid;
  gap: var(--space-2);
}
.agent-cards {
  display: grid;
  gap: var(--space-1);
}
.agent-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  background: none;
  color: var(--text);
  text-align: left;
}
.agent-card:hover {
  background: var(--surface-hover);
}
.agent-card.selected {
  border-color: var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.agent-card-text {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
}
.agent-card-text strong {
  font-size: var(--text-body-sm);
  font-weight: var(--weight-strong);
}
.agent-card-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: var(--text-caption);
}
.agent-card .badge {
  justify-self: start;
}
.agent-detail {
  overflow: hidden;
  min-width: 0;
}
.agent-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: var(--space-2) var(--space-4);
  align-items: center;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
}
.agent-head-text {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
  justify-items: start;
}
.agent-head h2 {
  font-size: var(--text-title-3);
  font-weight: var(--weight-strong);
  line-height: 1.35;
}
.agent-address {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  max-width: 100%;
  min-width: 0;
  color: var(--text-muted);
}
.agent-address .mono {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-reason {
  grid-column: 2 / -1;
  text-align: right;
}
.mobile-agent-label,
.mobile-agent-switcher {
  display: none;
}
@media (max-width: 1023px) {
  .agents {
    grid-template-columns: minmax(0, 1fr);
  }
  .agent-cards {
    display: none;
  }
  .mobile-agent-label,
  .mobile-agent-switcher {
    display: block;
  }
}
@media (max-width: 599px) {
  .agent-head {
    grid-template-columns: auto minmax(0, 1fr);
    padding: var(--space-4);
  }
  .agent-actions,
  .agent-reason {
    grid-column: 1 / -1;
    text-align: left;
  }
}

/* Tables (domains, keys) -------------------------------------------------------------------- */
.view-toolbar {
  display: flex;
  justify-content: flex-end;
}
.empty-state-card .empty-state {
  padding-block: var(--space-10);
}
.key-access {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  align-items: center;
}

/* Get started ------------------------------------------------------------------------------ */
.checklist {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}
.check-step {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.step-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid var(--border-control);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-size: var(--text-caption);
  font-weight: var(--weight-title);
}
.check-step.done .step-mark {
  border-color: var(--success-text);
  background: var(--success-bg);
  color: var(--success-text);
}
.check-step.done .step-mark .icon {
  width: 16px;
  height: 16px;
}
.check-step h3 {
  font-size: var(--text-body-sm);
  font-weight: var(--weight-strong);
}
.check-step.done h3 {
  color: var(--text-muted);
  text-decoration: line-through;
  text-decoration-color: var(--border-control);
}
.check-step p {
  margin-top: var(--space-0-5);
  color: var(--text-muted);
  font-size: var(--text-caption);
}
.start-done {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.start-done .empty-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: var(--radius-full);
  background: var(--success-bg);
  color: var(--success-text);
}
@media (max-width: 599px) {
  .check-step {
    grid-template-columns: 32px minmax(0, 1fr);
  }
  .check-step > .btn {
    grid-column: 2;
    justify-self: start;
  }
}

/* Connect an AI app ------------------------------------------------------------------------- */
.connect {
  gap: var(--space-10);
}
.connect .section + .section {
  margin-top: 0;
}
.step-number {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-right: var(--space-3);
  border-radius: var(--radius-full);
  background: var(--surface-selected);
  color: var(--accent);
  font-size: var(--text-caption);
  font-weight: var(--weight-title);
  vertical-align: 1px;
}
.client-choices {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}
.mcp-endpoint {
  max-width: 560px;
}
.client-steps {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
}
.steps {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
  margin: 0;
  padding-left: var(--space-5);
  font-size: var(--text-body-sm);
}
.steps li {
  padding-left: var(--space-1);
}
.steps li > .code-block {
  margin-top: var(--space-3);
}
.steps code,
.section-description code {
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  font-size: var(--text-code-inline);
}
.code-block pre code {
  padding: 0;
  background: none;
}
.connect-key > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  list-style: none;
  cursor: pointer;
}
.connect-key > summary::-webkit-details-marker {
  display: none;
}
.connect-key > summary > span {
  display: grid;
  gap: var(--space-1);
}
.connect-key[open] > summary .chevron {
  rotate: 180deg;
}
.connect-key-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
  align-items: start;
  margin-top: var(--space-5);
}
.connect-key-form .btn-row {
  grid-column: 1 / -1;
}
.secret-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
  margin-top: var(--space-5);
}
.secret-panel .code-block-header label {
  color: inherit;
  font-size: inherit;
}

/* Billing ---------------------------------------------------------------------------------- */
#billing-view {
  gap: var(--space-8);
}
#billing-view > .section + .section {
  margin-top: 0;
}
.plan-card {
  display: grid;
  gap: var(--space-5);
}
.plan-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}
.plan-card-title {
  display: grid;
  gap: var(--space-1);
}
.plan-card-title h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}
.plan-badges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
#billing-summary {
  font-size: var(--text-body-sm);
  font-variant-numeric: tabular-nums;
}
#billing-summary:empty,
#billing-usage:empty {
  display: none;
}
.meters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-5) var(--space-8);
}
.meter {
  display: grid;
  gap: var(--space-2);
}
.meter-head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--text-body-sm);
}
.meter-head span:last-child {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* Checkout: choices on the left, a summary that stays in view on the right (stacked on
   phones and tablets). Two sibling cards, never one inside the other. */
.checkout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: var(--space-5);
}
.checkout-main {
  display: grid;
  gap: var(--space-6);
}
.checkout-main .stepper {
  justify-self: start;
}
.plan-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: var(--space-3);
}
.plan-choice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: var(--space-1) var(--space-3);
  padding: var(--space-5);
}
.plan-choice:has(input:checked) {
  box-shadow: 0 0 0 1px var(--accent);
}
.plan-choice .plan-choice-name {
  font-size: var(--text-body);
}
.plan-choice .plan-choice-price {
  grid-column: 2;
  color: var(--text);
  font-size: var(--text-title-2);
  font-weight: var(--weight-title);
  line-height: 1.2;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
}
.plan-choice .plan-choice-price small {
  margin-left: var(--space-1);
  color: var(--text-muted);
  font-size: var(--text-caption);
  font-weight: var(--weight-ui);
  letter-spacing: 0;
}
.plan-choice .plan-choice-limits {
  grid-column: 2;
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
  color: var(--text);
  font-size: var(--text-body-sm);
}
.plan-choice .plan-choice-limits > span {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: inherit;
  font-size: inherit;
}
.plan-choice-limits .icon {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--success-text);
}
.checkout-summary {
  display: grid;
  gap: var(--space-5);
}
.summary-lines {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  font-size: var(--text-body-sm);
  font-variant-numeric: tabular-nums;
}
.summary-lines > div {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
}
.summary-lines dt {
  color: var(--text-muted);
}
.summary-lines dd {
  margin: 0;
}
.summary-total {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: var(--space-0-5) var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}
.summary-total-label {
  font-size: var(--text-body-sm);
  font-weight: var(--weight-strong);
}
#billing-total {
  font-size: var(--text-title-1);
  font-weight: var(--weight-title);
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-align: right;
}
#billing-total-note {
  grid-column: 1 / -1;
  text-align: right;
}
.acknowledgements {
  display: grid;
  gap: var(--space-3);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.secure-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: calc(-1 * var(--space-2));
  color: var(--text-muted);
  font-size: var(--text-caption);
}
.withdrawal-note {
  margin-top: calc(-1 * var(--space-3));
  text-align: center;
}
@media (min-width: 1024px) {
  .checkout {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 340px);
  }
  .checkout-summary {
    position: sticky;
    top: calc(var(--topbar) + var(--space-6));
  }
}
.billing-how {
  padding-top: var(--space-2);
}
.billing-facts {
  display: grid;
  gap: var(--space-3);
  max-width: var(--reading);
  margin: 0 0 var(--space-4);
  padding: 0;
  list-style: none;
  color: var(--text-muted);
  font-size: var(--text-body-sm);
}
.billing-facts strong {
  color: var(--text);
  font-weight: var(--weight-strong);
}
.documents-table td:first-child strong {
  display: block;
  font-weight: var(--weight-strong);
}
.documents-table td:first-child span {
  color: var(--text-muted);
  font-size: var(--text-caption);
}

/* Sidebar plan meter: the plan and the limit closest to running out, linked to Billing. */
.plan-meter {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    'plan action'
    'bar bar'
    'detail detail';
  gap: var(--space-2);
  width: 100%;
  margin-bottom: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  text-align: left;
}
.plan-meter:hover {
  background: var(--surface-hover);
}
.plan-meter-plan,
.plan-meter-action {
  font-size: var(--text-caption);
  font-weight: var(--weight-strong);
}
.plan-meter-plan {
  grid-area: plan;
}
.plan-meter-action {
  grid-area: action;
  color: var(--accent);
}
.plan-meter .progress {
  grid-area: bar;
  height: 6px;
}
.plan-meter-detail {
  grid-area: detail;
  color: var(--text-muted);
  font-size: var(--text-caption);
  font-variant-numeric: tabular-nums;
}
.plan-meter[data-tone='warning'] .plan-meter-detail {
  color: var(--warning-text);
}
.plan-meter[data-tone='danger'] .plan-meter-detail {
  color: var(--danger-text);
}

/* Upgrade prompt: what changes with the next plan, beside what the workspace has now. */
.plan-compare {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-body-sm);
  font-variant-numeric: tabular-nums;
}
.plan-compare th,
.plan-compare td {
  padding: var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.plan-compare tr > :first-child {
  padding-left: 0;
}
.plan-compare thead th {
  color: var(--text-muted);
  font-size: var(--text-micro);
  font-weight: var(--weight-strong);
}
.plan-compare tbody th {
  color: var(--text-muted);
  font-weight: var(--weight-ui);
}
/* The next plan's column is the point of the prompt, so it carries the selection tint. */
.plan-compare tr > :last-child {
  background: var(--surface-selected);
  font-weight: var(--weight-strong);
}
.plan-compare thead th:last-child {
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  color: var(--accent);
}
.plan-compare tbody tr:last-child > * {
  border-bottom: 0;
}
.plan-compare tbody tr:last-child > :last-child {
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.auth-intent {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--info-bg);
  color: var(--info-text);
  font-size: var(--text-caption);
  font-weight: var(--weight-strong);
}

/* Settings --------------------------------------------------------------------------------- */
.settings {
  gap: var(--space-10);
}
#user-settings {
  display: grid;
  gap: var(--space-10);
}
.settings-section {
  display: grid;
  grid-template-columns: minmax(200px, 280px) minmax(0, 1fr);
  gap: var(--space-8);
  align-items: start;
}
.settings-section form,
.settings-section .card > form {
  display: grid;
  gap: var(--space-4);
}
.settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}
.settings-divider {
  margin: var(--space-6) 0;
}
.danger-zone .card {
  border-color: var(--danger-border);
}
.legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-6);
  font-size: var(--text-body-sm);
}
.request-history {
  display: grid;
  gap: var(--space-3);
}
.request-history:not(:empty) {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}
.request-history article {
  display: grid;
  gap: var(--space-1);
  font-size: var(--text-body-sm);
}
.request-history article p {
  color: var(--text-muted);
}
@media (max-width: 1023px) {
  .settings-section {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-3);
  }
}

/* Events ----------------------------------------------------------------------------------- */
.event-list {
  overflow: hidden;
}
.event-list:empty {
  display: none;
}
.event-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: start;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.event-row:last-child {
  border-bottom: 0;
}
.event-row .direction {
  margin-top: 2px;
}
.event-text {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
  font-size: var(--text-body-sm);
}
.event-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}
.event-text .event-type {
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-micro);
}
.event-text details summary {
  color: var(--text-muted);
  font-size: var(--text-caption);
  cursor: pointer;
}
.event-text pre {
  margin: var(--space-2) 0 0;
  padding: var(--space-3);
  overflow-x: auto;
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  font-size: var(--text-micro);
}
.event-row time {
  color: var(--text-muted);
  font-size: var(--text-caption);
  white-space: nowrap;
}

/* Dialog details --------------------------------------------------------------------------- */
.dialog-body {
  display: grid;
  gap: var(--space-4);
  align-content: start;
}
.footer-spacer,
.compose-note {
  margin-right: auto;
}
.address-group > input {
  flex: 1 1 40%;
}
.address-group .at {
  padding: 0 var(--space-2);
}
.address-group > select {
  flex: 0 1 auto;
  border-left: 0;
}
.inline-button {
  min-height: auto;
  padding: 0;
  vertical-align: baseline;
}
@media (max-width: 599px) {
  .address-group {
    flex-wrap: wrap;
  }
  .address-group > input {
    flex: 1 1 60%;
  }
  .address-group > select.input-addon {
    flex: 1 1 100%;
    max-width: none;
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
  }
  .compose-note {
    display: none;
  }
}
.secret-field textarea {
  min-height: 0;
  resize: none;
  font-size: var(--text-code);
  word-break: break-all;
}
.secret-next {
  display: grid;
  gap: var(--space-2);
}
.domain-progress {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}
.domain-progress li {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-caption);
}
.domain-progress strong {
  font-size: var(--text-body-sm);
}
.dns-records {
  display: grid;
  gap: var(--space-3);
}
.dns-record {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.dns-record-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.dns-record-head h3 {
  font-size: var(--text-body-sm);
  font-weight: var(--weight-strong);
}
.dns-value {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: var(--space-3);
  align-items: center;
  font-size: var(--text-caption);
}
.dns-value > span {
  color: var(--text-muted);
}
@media (max-width: 599px) {
  .domain-progress {
    grid-template-columns: minmax(0, 1fr);
  }
  .dns-value {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-1);
  }
}

/* Compose */
.compose-body {
  gap: 0;
  padding-top: var(--space-2);
}
.compose-body > .callout {
  margin-bottom: var(--space-3);
}
.compose-row {
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: var(--space-2);
  border-bottom: 1px solid var(--border);
}
.compose-row > label {
  color: var(--text-muted);
  font-weight: var(--weight-ui);
}
.compose-row > input,
.compose-row > select {
  min-height: 44px;
  padding-left: 0;
  border: 0;
  border-radius: 0;
  background-color: transparent;
}
.compose-row > input:focus-visible,
.compose-row > select:focus-visible {
  outline: 0;
}
.compose-row:focus-within {
  border-bottom-color: var(--accent);
}
.compose-body textarea {
  min-height: 240px;
  margin-top: var(--space-3);
  padding: var(--space-3) 0;
  border: 0;
  border-radius: 0;
  font-size: var(--text-body);
  line-height: 1.6;
  resize: none;
}
.compose-body textarea:focus-visible {
  outline: 0;
}
.compose-body input[readonly] {
  background: transparent;
  color: var(--text-muted);
}

/* Reader: a side sheet that keeps the list in place behind it. */
dialog.reader {
  width: min(760px, 100vw);
  height: 100vh;
  max-height: 100vh;
  margin: 0 0 0 auto;
  border-width: 0 0 0 1px;
  border-radius: var(--radius-xl) 0 0 var(--radius-xl);
}
dialog.reader[open] {
  animation-name: reader-in;
}
@keyframes reader-in {
  from {
    translate: 24px 0;
    opacity: 0;
  }
}
.reader-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.reader-scroll {
  display: grid;
  gap: var(--space-6);
  align-content: start;
  padding: var(--space-6) var(--space-8) var(--space-12);
  overflow-y: auto;
}
.reader-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}
.reader-title h2 {
  font-size: var(--text-title-2);
  font-weight: var(--weight-title);
  line-height: 1.25;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}
.reader-title .badge {
  margin-top: var(--space-1);
}
.reader-meta {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-1) var(--space-4);
  margin-top: var(--space-4);
  font-size: var(--text-body-sm);
}
.reader-meta dt {
  color: var(--text-muted);
}
.reader-meta dd {
  min-width: 0;
  overflow-wrap: anywhere;
}
.reader-body {
  display: grid;
  gap: var(--space-4);
}
.reader-tabs {
  justify-self: start;
}
#message-body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
#message-html {
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.attachments:empty {
  display: none;
}
.reader-activity {
  display: grid;
  gap: var(--space-3);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}
.timeline {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}
.timeline li {
  position: relative;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: baseline;
  padding: var(--space-2) 0;
  font-size: var(--text-body-sm);
}
.timeline li::before {
  content: '';
  width: 9px;
  height: 9px;
  margin-left: 3px;
  border-radius: var(--radius-full);
  background: var(--border-control);
  translate: 0 1px;
}
.timeline li:last-child::before {
  background: var(--accent);
}
.timeline li:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 7px;
  top: 22px;
  bottom: -8px;
  width: 1px;
  background: var(--border);
}
.timeline time {
  color: var(--text-muted);
  font-size: var(--text-caption);
}
.technical-details summary {
  color: var(--text-muted);
  font-size: var(--text-caption);
  font-weight: var(--weight-strong);
  cursor: pointer;
}
.technical-details .description-list {
  margin-top: var(--space-2);
}
.technical-details dd {
  font-family: var(--font-mono);
  font-size: var(--text-caption);
}
@media (max-width: 599px) {
  dialog.reader {
    width: 100%;
    height: 100%;
    max-height: 100%;
    margin: 0;
    border: 0;
    border-radius: 0;
  }
  .reader-scroll {
    padding: var(--space-5) var(--space-4) var(--space-10);
  }
}

/* OAuth consent (design audit O-1) ---------------------------------------------------------- */
.consent-apps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  color: var(--text-muted);
}
.consent-apps img {
  border-radius: var(--radius-md);
}
.consent-loading,
.consent-form {
  display: grid;
  gap: var(--space-4);
}
.consent-form h2 {
  font-size: var(--text-title-3);
  font-weight: var(--weight-strong);
  line-height: 1.35;
}
/* App names come from the app and may be long or unspaced; they wrap rather than widen the card. */
.consent h1,
.consent h2,
.consent .choice strong {
  overflow-wrap: anywhere;
}
.consent-account {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  background: var(--surface-subtle);
}
.consent-account > div {
  display: grid;
  flex: 1 1 8rem;
  min-width: 0;
}
.consent-account .btn {
  margin-left: auto;
}
/* The verified return host, the one detail Cyberpigeon checks, reads at body size. */
.consent-destination {
  font-size: var(--text-body-sm);
  overflow-wrap: anywhere;
}
/* The form's grid gap already spaces fields; drop the stacked-field margins from ui.css. */
.consent-form > .field,
.consent-form > .btn {
  margin-top: 0;
}
/* The full address, so people with similar accounts can tell which one is granting access. */
.consent-account strong {
  overflow-wrap: anywhere;
  font-size: var(--text-body-sm);
}
.consent-permissions {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  border: 0;
}
.consent-permissions .check + .check {
  margin-top: 0;
}
.consent-permissions legend {
  margin-bottom: var(--space-2);
  padding: 0;
  font-size: var(--text-body-sm);
  font-weight: var(--weight-strong);
}
.consent-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}
.consent .callout-body p:empty {
  display: none;
}

/* Email wake-ups (Connect an AI app) -------------------------------------------------------- */
.wakeup-clients {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding-left: var(--space-5);
  font-size: var(--text-body-sm);
  color: var(--text-muted);
}
.wakeup-clients strong {
  color: var(--text);
  font-weight: var(--weight-strong);
}
.wakeup-list {
  display: grid;
  gap: var(--space-3);
}
.wakeup-list:empty {
  display: none;
}
.wakeup-item {
  display: grid;
  gap: var(--space-2);
}
.wakeup-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-width: 0;
}
.wakeup-head strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: var(--text-body-sm);
  font-weight: var(--weight-strong);
}
#wakeups-status {
  margin-bottom: var(--space-4);
}
