:root {
  color-scheme: light dark;
  --bg: #F2F3F7;
  --surface: #FFFFFF;
  --fill: #E7E9EF;
  --fill-strong: #D9DCE5;
  --ink: #15171C;
  --ink-2: #5B606D;
  --ink-3: #8C919D;
  --sep: rgba(60, 66, 85, 0.15);
  --tint: #2A57D4;
  --tint-press: #1F47B5;
  --on-tint: #FFFFFF;
  --signal: #EE9B00;
  --signal-soft: #FFF4DB;
  --signal-line: rgba(238, 155, 0, 0.45);
  --signal-ink: #6B4300;
  --danger: #D7261B;
  --danger-soft: #FDECEA;
  --danger-solid: #D7261B;
  --ok: #178A4B;
  --old-bg: #FDF0EF;
  --new-bg: #ECF7F0;
  --bubble: var(--tint);
  --on-bubble: #FFFFFF;
  --bar: rgba(242, 243, 247, 0.82);
  --shadow-card: 0 1px 2px rgba(20, 24, 40, 0.06), 0 6px 20px rgba(20, 24, 40, 0.06);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --font-display: -apple-system-headline, -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --gutter: 16px;
  --radius-group: 14px;
  --radius-card: 18px;
  --radius-btn: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --kb: 0px;
  --dock-h: 72px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #17181C;
    --fill: #24262C;
    --fill-strong: #31343B;
    --ink: #F2F3F6;
    --ink-2: #A2A7B3;
    --ink-3: #6D727E;
    --sep: rgba(235, 238, 255, 0.12);
    --tint: #7F9CFF;
    --tint-press: #9DB3FF;
    --on-tint: #0A1640;
    --signal: #FFB224;
    --signal-soft: rgba(255, 178, 36, 0.12);
    --signal-line: rgba(255, 178, 36, 0.38);
    --signal-ink: #FFD27E;
    --danger: #FF6359;
    --danger-soft: rgba(255, 99, 89, 0.14);
    --danger-solid: #D3322A;
    --ok: #4CD487;
    --old-bg: rgba(255, 99, 89, 0.1);
    --new-bg: rgba(76, 212, 135, 0.1);
    --bubble: #2F5BE0;
    --on-bubble: #FFFFFF;
    --bar: rgba(0, 0, 0, 0.78);
    --shadow-card: none;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-padding-top: 80px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

@media (pointer: fine) {
  html {
    overscroll-behavior: none;
  }
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

a {
  color: var(--tint);
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--tint);
  outline-offset: 2px;
  border-radius: 6px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -60px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
}

.skip-link:focus {
  top: calc(var(--safe-top) + 8px);
}

.view {
  max-width: 680px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

.navbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(var(--safe-top) + 6px) var(--gutter) 8px;
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid transparent;
  transition: border-color 0.2s;
}

.navbar-session {
  border-bottom-color: var(--sep);
  min-height: calc(var(--safe-top) + 52px);
}

.navbar-home {
  padding-top: calc(var(--safe-top) + 14px);
  padding-bottom: 10px;
}

.home-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font: 700 32px/1.1 var(--font-display);
  letter-spacing: 0.01em;
}

.conn-label {
  flex: 1;
  font-size: 13px;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-right: -10px;
  margin-left: auto;
  border-radius: 22px;
  color: var(--tint);
}

.icon-btn:active {
  background: var(--fill);
}

.led {
  position: relative;
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ink-3);
  box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, 0.08);
  transition: background-color 0.3s;
}

.led[data-conn="online"] {
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent);
}

.led[data-conn="connecting"],
.led[data-conn="reconnecting"] {
  background: var(--signal);
  animation: led-blink 1.1s steps(2, jump-none) infinite;
}

.led[data-conn="offline"] {
  background: var(--danger);
}

.led-small {
  width: 8px;
  height: 8px;
  margin-left: 4px;
}

.navbar-spacer {
  width: 8px;
}

@keyframes led-blink {
  50% {
    opacity: 0.25;
  }
}

.home-main {
  padding: 4px var(--gutter) calc(var(--safe-bottom) + 40px);
}

.banner {
  display: grid;
  gap: 2px;
  margin: 4px 0 16px;
  padding: 12px 14px;
  border-radius: var(--radius-group);
  font-size: 15px;
  line-height: 1.35;
}

.banner-warn {
  background: var(--danger-soft);
  color: var(--ink);
}

.banner-warn strong {
  color: var(--danger);
  font-weight: 600;
}

.banner-warn span {
  color: var(--ink-2);
}

.zone-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 4px 10px;
  font: 600 20px/1.2 var(--font-display);
}

.count-pill:empty {
  display: none;
}

.count-pill {
  min-width: 24px;
  padding: 1px 8px;
  border-radius: 12px;
  background: var(--signal);
  color: #2A1A00;
  font: 700 14px/22px var(--font);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.approvals-zone {
  margin-bottom: 26px;
}

.approval-list {
  display: grid;
  gap: 12px;
}

.approval {
  position: relative;
  padding: 14px 16px 12px;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-card), inset 0 0 0 1px var(--signal-line);
  animation: card-in 0.35s var(--ease-out) both;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
}

.ap-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ap-signal {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 0 4px var(--signal-soft);
}

.ap-title {
  flex: 1;
  min-width: 0;
  font-weight: 650;
  font-size: 17px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ap-time {
  flex: none;
  font-size: 13px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.ap-session {
  display: inline-block;
  margin: 2px 0 0 18px;
  padding: 2px 0;
  font-size: 14px;
  color: var(--ink-2);
  text-decoration: none;
}

.ap-session::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 6px;
  border-top: 1.6px solid currentColor;
  border-right: 1.6px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  opacity: 0.7;
}

.ap-note {
  margin: 8px 0 0;
  font-size: 15px;
  line-height: 1.35;
  color: var(--ink-2);
}

.ap-detail {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--fill);
  font: 14px/1.45 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 9.5em;
  overflow: auto;
}

.link-btn {
  min-height: 36px;
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--tint);
  font-size: 15px;
}

.ap-expand {
  margin-top: 2px;
}

.ap-raw {
  display: grid;
  gap: 8px;
  margin-bottom: 4px;
}

.raw-path {
  font: 13px/1.4 var(--mono);
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.raw-label {
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.raw-pre {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--fill);
  font: 13px/1.45 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 22em;
  overflow: auto;
}

.is-old .raw-pre {
  background: var(--old-bg);
}

.is-new .raw-pre {
  background: var(--new-bg);
}

.is-old .raw-label {
  color: var(--danger);
}

.is-new .raw-label {
  color: var(--ok);
}

.raw-note {
  margin: 0;
  font-size: 14px;
  color: var(--ink-2);
}

.ap-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 46px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-btn);
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.12s, background-color 0.15s, opacity 0.15s;
  -webkit-user-select: none;
  user-select: none;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-allow {
  flex: 1.4;
  background: var(--tint);
  color: var(--on-tint);
}

.btn-allow:active:not(:disabled) {
  background: var(--tint-press);
}

.btn-quiet {
  background: var(--fill);
  color: var(--ink);
}

.btn-deny {
  background: var(--danger-soft);
  color: var(--danger);
  -webkit-touch-callout: none;
}

.btn-deny-solid {
  background: var(--danger-solid);
  color: #FFFFFF;
}

.ap-comment-toggle {
  display: block;
  margin: 4px auto -4px;
  color: var(--ink-2);
  font-size: 14px;
}

.ap-comment {
  margin-top: 12px;
}

.ap-comment textarea,
.q-own-input {
  display: block;
  width: 100%;
  min-height: 64px;
  padding: 10px 12px;
  border: 1px solid var(--sep);
  border-radius: 12px;
  background: var(--bg);
  font-size: 16px;
  resize: vertical;
}

.ap-questions {
  margin-top: 6px;
}

.q {
  margin: 0;
  padding: 10px 0 4px;
  border: 0;
  min-width: 0;
}

.q + .q {
  margin-top: 10px;
  padding-top: 14px;
  box-shadow: inset 0 0.5px 0 var(--sep);
}

.q legend {
  display: grid;
  gap: 2px;
  padding: 0;
  margin-bottom: 10px;
}

.q-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--signal-ink);
}

.q-text {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
}

.q-hint {
  font-size: 13px;
  color: var(--ink-3);
}

.q-options {
  display: grid;
  gap: 6px;
}

.q-opt {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 11px 12px;
  border: 0;
  border-radius: 12px;
  background: var(--fill);
  text-align: left;
  transition: background-color 0.15s, box-shadow 0.15s;
}

.q-opt[aria-pressed="true"] {
  background: color-mix(in srgb, var(--tint) 13%, var(--surface));
  box-shadow: inset 0 0 0 1.5px var(--tint);
}

.q-opt-mark {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 50%;
  border: 1.8px solid var(--ink-3);
  transition: border-color 0.15s, background-color 0.15s;
}

[data-multi="1"] .q-opt-mark {
  border-radius: 6px;
}

.q-opt[aria-pressed="true"] .q-opt-mark {
  border-color: var(--tint);
  background: var(--tint) center / 12px no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 6.3 4.8 9 10 3' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.q-opt-text {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.q-opt-label {
  font-size: 16px;
  font-weight: 500;
}

.q-opt-desc {
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.3;
}

.q-own .q-opt-label {
  color: var(--ink-2);
}

.group {
  margin-bottom: 22px;
}

.group-heading {
  margin: 0;
}

.group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 4px 4px 6px;
  border: 0;
  background: none;
  text-align: left;
}

.group-name {
  flex: 1;
  min-width: 0;
  font: 600 20px/1.2 var(--font-display);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-count {
  font-size: 15px;
  font-weight: 400;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.group-unread {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tint);
}

.chev {
  color: var(--ink-3);
  transition: transform 0.25s var(--ease-out);
}

.is-collapsed .chev {
  transform: rotate(-90deg);
}

.group-body {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.28s var(--ease-out), opacity 0.2s;
}

.is-collapsed .group-body {
  grid-template-rows: 0fr;
  opacity: 0;
}

.rows {
  min-height: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
  list-style: none;
  border-radius: var(--radius-group);
  background: var(--surface);
}

.row-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
  padding-left: calc(var(--depth, 0) * 18px);
  content-visibility: auto;
  contain-intrinsic-size: auto 66px;
}

.node + .node > .row-wrap::before,
.sub > .node:first-child > .row-wrap::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: calc(var(--depth, 0) * 18px + 22px);
  border-top: 0.5px solid var(--sep);
}

.row-wrap > .row {
  flex: 1;
  min-width: 0;
}

.row-wrap:has(.disclose) .row-body {
  padding-right: 2px;
}

.disclose {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex: none;
  min-width: 60px;
  padding: 0 14px 0 8px;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  transition: background-color 0.12s;
}

.disclose:active {
  background: var(--fill);
}

.disclose .chev {
  transform: rotate(-90deg);
}

.disclose[aria-expanded="true"] .chev {
  transform: none;
}

.kid-mark {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.kid-waiting {
  width: 10px;
  height: 10px;
  background: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-soft);
}

.kid-running {
  background: var(--ok);
  animation: pulse 1.4s ease-in-out infinite;
}

.kid-error {
  background: var(--danger);
}

.sub {
  margin: 0;
  padding: 0;
  list-style: none;
  background: color-mix(in srgb, var(--fill) 38%, var(--surface));
}

.is-child > .row-wrap .row-title {
  font-size: 16px;
  font-weight: 400;
}

.is-child > .row-wrap .is-unread .row-title {
  font-weight: 600;
}

.is-child > .row-wrap .row-body {
  padding-top: 9px;
  padding-bottom: 9px;
}

.row {
  display: flex;
  align-items: stretch;
  color: inherit;
  text-decoration: none;
  transition: background-color 0.12s;
}

.row:active {
  background: var(--fill);
}

.row-lead {
  display: flex;
  justify-content: center;
  flex: none;
  width: 22px;
  padding-top: 18px;
}

.unread-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: transparent;
}

.is-unread .unread-dot {
  background: var(--tint);
}

.row-body {
  display: grid;
  gap: 2px;
  flex: 1;
  min-width: 0;
  padding: 11px 14px 11px 0;
}

.row-top,
.row-bottom {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.row-title {
  flex: 1;
  min-width: 0;
  font-size: 17px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.is-unread .row-title {
  font-weight: 650;
}

.row-time {
  flex: none;
  font-size: 14px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.is-unread .row-time {
  color: var(--tint);
}

.row-summary {
  font-size: 15px;
  line-height: 1.3;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-project {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-status {
  display: flex;
  align-items: center;
  flex: none;
  min-height: 20px;
}

.badge {
  display: inline-block;
  min-width: 22px;
  padding: 0 7px;
  border-radius: 11px;
  font: 700 13px/20px var(--font);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.badge-signal {
  background: var(--signal);
  color: #2A1A00;
}

.badge-error {
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 600;
}

.run-dot {
  position: relative;
  width: 8px;
  height: 8px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--ok);
}

.run-dot::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 1.5px solid var(--ok);
  opacity: 0;
  animation: run-ring 1.8s var(--ease-out) infinite;
}

@keyframes run-ring {
  0% {
    transform: scale(0.4);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.2);
    opacity: 0;
  }
}

.empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 48px 24px;
  text-align: center;
  color: var(--ink-2);
  font-size: 15px;
}

.empty p {
  margin: 0;
  max-width: 32ch;
}

.empty-title {
  color: var(--ink);
  font-size: 17px;
  font-weight: 600;
}

.empty .btn {
  flex: none;
  margin-top: 10px;
  padding: 0 22px;
}

.skeleton {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border-radius: var(--radius-group);
  margin-top: 40px;
}

.skeleton i {
  display: block;
  height: 66px;
  background: var(--surface);
  animation: pulse 1.4s ease-in-out infinite;
}

.skeleton-chat {
  gap: 14px;
  margin: 24px var(--gutter);
  border-radius: 0;
}

.skeleton-chat i {
  height: 54px;
  border-radius: 16px;
}

.skeleton-chat i:nth-child(2) {
  width: 70%;
  margin-left: auto;
}

@keyframes pulse {
  50% {
    opacity: 0.55;
  }
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
  min-width: 44px;
  min-height: 44px;
  margin-left: -8px;
  padding: 0 8px;
  color: var(--tint);
  font-size: 17px;
  text-decoration: none;
}

.back-btn:active {
  opacity: 0.5;
}

.session-head {
  flex: 1;
  min-width: 0;
  text-align: center;
  margin-right: 20px;
}

.session-parent {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  min-height: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--tint);
  text-decoration: none;
}

.session-parent .parent-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-status {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  margin: 1px 0 0;
  font-size: 12px;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
}

.session-status:empty {
  display: none;
}

.status-mark {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-3);
}

[data-status="running"] .status-mark {
  background: var(--ok);
  animation: pulse 1.4s ease-in-out infinite;
}

[data-status="waiting"] .status-mark {
  background: var(--signal);
}

[data-status="error"] .status-mark {
  background: var(--danger);
}

[data-status="error"] {
  color: var(--danger);
}

.status-project {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink-3);
}

.status-project::before {
  content: "/";
  margin: 0 5px 0 2px;
  opacity: 0.6;
}

.transcript {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px var(--gutter) calc(var(--dock-h) + var(--kb) + 16px);
  overflow-wrap: anywhere;
}

.day-sep {
  margin: 8px 0 0;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
}

.msg-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  margin-left: 14%;
}

.bubble {
  max-width: 100%;
  padding: 9px 14px;
  border-radius: 20px 20px 6px 20px;
  background: var(--bubble);
  color: var(--on-bubble);
  font-size: 16px;
  line-height: 1.38;
}

.from-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding-right: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}

.from-label::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--signal);
}

.msg-time {
  padding-right: 6px;
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.is-pending .bubble {
  opacity: 0.75;
}

.is-pending[data-status="delivered"] .bubble {
  opacity: 1;
}

.is-pending[data-status="failed"] .bubble {
  opacity: 1;
  background: var(--danger-soft);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--danger);
}

.delivery {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 6px;
  font-size: 12px;
  color: var(--ink-3);
}

[data-status="failed"] .delivery {
  color: var(--danger);
}

.delivery {
  flex-wrap: wrap;
  justify-content: flex-end;
  text-align: right;
}

.delivery .link-btn {
  flex: none;
  white-space: nowrap;
  min-height: 28px;
  font-size: 13px;
}

.msg-assistant {
  font-size: 16px;
  line-height: 1.5;
}

.md > :first-child {
  margin-top: 0;
}

.md > :last-child {
  margin-bottom: 0;
}

.md p,
.md ul,
.md ol,
.md blockquote,
.md .code-block,
.md .md-table {
  margin: 0 0 0.7em;
}

.md ul,
.md ol {
  padding-left: 1.3em;
}

.md li + li {
  margin-top: 0.2em;
}

.md li.d1 {
  margin-left: 1.1em;
}

.md li.d2,
.md li.d3 {
  margin-left: 2.2em;
}

.md li::marker {
  color: var(--ink-3);
}

.md .md-h {
  font-weight: 650;
  margin-top: 1em;
}

.md .md-h1 {
  font-size: 1.15em;
}

.md strong {
  font-weight: 650;
}

.md code {
  padding: 0.1em 0.35em;
  border-radius: 5px;
  background: var(--fill);
  font: 0.86em/1.3 var(--mono);
}

.md a {
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.md blockquote {
  padding-left: 12px;
  border-left: 3px solid var(--fill-strong);
  color: var(--ink-2);
}

.md hr {
  border: 0;
  border-top: 0.5px solid var(--sep);
  margin: 1em 0;
}

.code-block {
  position: relative;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: inset 0 0 0 0.5px var(--sep);
}

.code-block pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  font: 13px/1.5 var(--mono);
  -webkit-overflow-scrolling: touch;
}

.code-block pre code {
  padding: 0;
  background: none;
  font: inherit;
}

.code-lang {
  display: block;
  padding: 8px 14px 0;
  font-size: 12px;
  color: var(--ink-3);
}

.md-table {
  overflow-x: auto;
  border-radius: 10px;
  box-shadow: inset 0 0 0 0.5px var(--sep);
}

.md table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}

.md th,
.md td {
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
  border-bottom: 0.5px solid var(--sep);
}

.md th {
  font-weight: 600;
  background: var(--fill);
}

.md tr:last-child td {
  border-bottom: 0;
}

.tool-run {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0 0 0 10px;
  list-style: none;
  border-left: 2px solid var(--fill-strong);
}

.tool-line {
  display: flex;
  gap: 8px;
  min-width: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-3);
}

.tool-name {
  flex: none;
  font-weight: 600;
  color: var(--ink-2);
}

.tool-detail {
  min-width: 0;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recap {
  padding: 10px 14px 12px;
  border-radius: 14px;
  background: var(--fill);
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.45;
}

.recap-label {
  margin: 0 0 2px;
  font-size: 12px;
  font-weight: 650;
  color: var(--ink-3);
}

.recap .md code {
  background: var(--fill-strong);
}

.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  max-width: 680px;
  margin: 0 auto;
  padding: 8px calc(var(--gutter) + var(--safe-right)) calc(var(--safe-bottom) + 8px) calc(var(--gutter) + var(--safe-left));
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--sep);
  transform: translateY(calc(-1 * var(--kb)));
}

.kb-open .dock {
  padding-bottom: 8px;
}

.dock-approvals {
  max-height: 52vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0 calc(-1 * var(--gutter));
  padding: 4px var(--gutter);
}

.dock-approvals:not(:empty) {
  margin-bottom: 8px;
}

.kb-open .dock-approvals {
  max-height: 30vh;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.composer textarea {
  flex: 1;
  min-height: 40px;
  max-height: 168px;
  padding: 8px 14px;
  border: 0.5px solid var(--sep);
  border-radius: 20px;
  background: var(--surface);
  font-size: 17px;
  line-height: 1.35;
  resize: none;
  overflow-y: auto;
}

.composer textarea::placeholder {
  color: var(--ink-3);
}

.composer textarea:focus-visible {
  outline: none;
  border-color: var(--tint);
}

.send-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--tint);
  color: var(--on-tint);
  transition: transform 0.12s, opacity 0.15s;
}

.send-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.send-btn:active:not(:disabled) {
  transform: scale(0.9);
}

.settings {
  padding: 8px var(--gutter) calc(var(--safe-bottom) + 40px);
}

.list-title {
  margin: 22px 16px 7px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
}

.list {
  overflow: hidden;
  border-radius: var(--radius-group);
  background: var(--surface);
}

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 10px 16px;
  border: 0;
  background: none;
  text-align: left;
  transition: opacity 0.2s;
}

.list-row + .list-row {
  box-shadow: inset 0 0.5px 0 var(--sep);
}

.list-row.is-dim {
  opacity: 0.45;
}

.list-text {
  display: grid;
  gap: 1px;
  flex: 1;
  min-width: 0;
}

.list-main {
  flex: 1;
  font-size: 17px;
}

.list-note {
  font-size: 13px;
  color: var(--ink-3);
}

.list-value {
  color: var(--ink-2);
}

.list-action {
  color: var(--tint);
  font-size: 17px;
}

.list-action:active:not(:disabled) {
  background: var(--fill);
}

.list-action:disabled {
  color: var(--ink-3);
  cursor: default;
}

.list-foot {
  margin: 8px 16px 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink-2);
}

.push-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ink-3);
}

.push-dot[data-on="true"] {
  background: var(--ok);
}

.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 51px;
  height: 31px;
  margin: 0;
  border-radius: 16px;
  background: var(--fill-strong);
  cursor: pointer;
  transition: background-color 0.2s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
  transition: transform 0.22s var(--ease-out);
}

.switch:checked {
  background: var(--ok);
}

.switch:checked::after {
  transform: translateX(20px);
}

.switch:focus-visible {
  outline-offset: 3px;
  border-radius: 16px;
}

.stepper {
  display: flex;
  align-items: center;
  flex: none;
  border-radius: 10px;
  background: var(--fill);
}

.stepper button {
  width: 44px;
  height: 36px;
  border: 0;
  background: none;
  font-size: 22px;
  line-height: 1;
  color: var(--ink);
}

.stepper button:active {
  opacity: 0.4;
}

.stepper output {
  min-width: 56px;
  text-align: center;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 24px);
  z-index: 50;
  max-width: min(420px, calc(100vw - 32px));
  padding: 11px 18px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--bg);
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: opacity 0.22s, transform 0.22s var(--ease-out);
  pointer-events: none;
}

.toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast[data-tone="error"] {
  background: var(--danger-solid);
  color: #FFFFFF;
}

[data-view="session"] .toast {
  bottom: calc(var(--dock-h) + var(--kb) + 12px);
}

html[data-view="session"] {
  scroll-padding-bottom: calc(var(--dock-h) + var(--kb) + 12px);
}

.zone-title,
.q-text,
.empty-title {
  text-wrap: balance;
}

.msg-user.is-long .bubble {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 8;
  overflow: hidden;
}

.bubble-more {
  min-height: 28px;
  padding: 2px 6px 0 0;
  font-size: 13px;
}

@media (hover: hover) {
  .btn:hover:not(:disabled),
  .send-btn:hover:not(:disabled) {
    filter: brightness(0.94);
  }

  .link-btn:hover,
  .ap-session:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
  }

  .disclose:hover {
    background: color-mix(in srgb, var(--fill) 60%, transparent);
  }

  .row:hover {
    background: color-mix(in srgb, var(--fill) 60%, var(--surface));
  }

  .q-opt:hover:not([aria-pressed="true"]) {
    background: var(--fill-strong);
  }
}

@media (min-width: 720px) {
  .home-main,
  .settings {
    padding-top: 12px;
  }
}

.pair {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 420px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 12vh) var(--gutter) calc(var(--safe-bottom) + 32px);
  text-align: center;
}

.pair-mark {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin-bottom: 22px;
  border-radius: 18px;
  background: linear-gradient(180deg, #2442A8, #142466);
}

.pair-mark span {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 6px solid #F2F3F7;
}

.pair-mark span::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: #FFB224;
}

.pair-title {
  margin: 0 0 8px;
  font: 700 28px/1.15 var(--font-display);
  text-wrap: balance;
}

.pair-lead {
  margin: 0 0 28px;
  max-width: 30ch;
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink-2);
  text-wrap: pretty;
}

.pair-lead code {
  padding: 0.1em 0.35em;
  border-radius: 5px;
  background: var(--fill);
  font: 0.9em/1.3 var(--mono);
  color: var(--ink);
}

.pair-form {
  width: 100%;
}

.pair-field {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 0 16px;
  text-align: left;
}

.pair-field + .pair-field {
  box-shadow: inset 0 0.5px 0 var(--sep);
}

.pair-label {
  flex: none;
  width: 104px;
  font-size: 17px;
}

.pair-field input {
  flex: 1;
  min-width: 0;
  height: 54px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 17px;
  outline: none;
}

.pair-field:focus-within {
  box-shadow: inset 0 0 0 2px var(--tint);
  border-radius: var(--radius-group);
}

.pair-field + .pair-field:focus-within {
  box-shadow: inset 0 0 0 2px var(--tint);
}

.pair-field input.pair-code {
  font: 600 22px/1 var(--mono);
  letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
}

.pair-code::placeholder {
  color: var(--ink-3);
  opacity: 0.5;
  font-weight: 400;
}

.pair-code[aria-invalid="true"] {
  color: var(--danger);
}

.pair-error {
  min-height: 1.4em;
  margin: 10px 4px 14px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--danger);
  text-wrap: pretty;
}

.pair-submit {
  width: 100%;
  min-height: 52px;
  font-size: 17px;
}

.pair-back {
  margin-top: 18px;
  font-size: 15px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
