:root {
  color-scheme: dark light;
  --bg: #000;
  --surface: #121214;
  --surface-2: #1c1c1f;
  --line: #2a2a2e;
  --text: #f2f2f4;
  --muted: #8e8e93;
  --accent: #0a84ff;
  --accent-text: #fff;
  --ok: #30d158;
  --warn: #ffd60a;
  --danger: #ff453a;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 999px;
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 22px;
  --fs-2xl: 28px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f2f2f7;
    --surface: #fff;
    --surface-2: #f2f2f7;
    --line: #d1d1d6;
    --text: #000;
    --muted: #6c6c70;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-md);
  line-height: 1.45;
  padding: env(safe-area-inset-top) var(--s4) calc(76px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}

body.no-tabs {
  padding-bottom: calc(var(--s6) + env(safe-area-inset-bottom));
}

main {
  max-width: 640px;
  margin: 0 auto;
}

h1, h2, h3, p {
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: var(--fs-sm);
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: var(--r-sm);
}

/* Focus ring */
button:focus-visible,
a:focus-visible,
select:focus-visible,
textarea:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Icons */
.icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* Top bar */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  margin: 0 calc(-1 * var(--s4)) var(--s4);
  padding: 0 var(--s4);
}

.top-bar-inner {
  max-width: 640px;
  min-height: 52px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: var(--s1);
  min-width: 0;
  flex: 1;
}

.top-back-btn {
  background: transparent;
  color: var(--accent);
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  margin-left: -10px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.top-bar-titles {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.top-title {
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-bar.is-subview .top-title {
  font-size: var(--fs-lg);
}

.top-subtitle {
  font-size: var(--fs-xs);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex: none;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: var(--s2);
}

/* Connection status dot + label in top bar */
.conn {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-size: var(--fs-sm);
  color: var(--muted);
  font-weight: 500;
}

.conn::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}

.conn.connecting::before {
  background: var(--warn);
  animation: pulse-warn 1.4s infinite;
}

.conn.on {
  font-size: 0;
  gap: 0;
}

.conn.on::before {
  background: var(--ok);
}

@keyframes pulse-warn {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* Dots */
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}

.dot.on {
  background: var(--ok);
}

.dot.warn {
  background: var(--warn);
}

/* Typography helpers */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  margin: var(--s5) 0 var(--s2);
}

.section-header:first-child {
  margin-top: var(--s2);
}

.section-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.sub-group-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: var(--s5) 0 var(--s2);
}

#recent-section:first-child .sub-group-title:first-child {
  margin-top: var(--s2);
}

.meta {
  font-size: var(--fs-sm);
  color: var(--muted);
}

/* Buttons: three kinds only (primary, secondary, text), all >= 44px tall */
button,
.btn-primary,
.btn-secondary,
.btn-text {
  font: inherit;
  font-size: var(--fs-md);
  font-weight: 600;
  border: 0;
  border-radius: var(--r-md);
  padding: 0 var(--s4);
  min-height: 44px;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  text-decoration: none;
  transition: opacity 0.15s, background-color 0.15s, color 0.15s;
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn-secondary,
.btn-deny,
.btn-sched-action,
.btn-load-more,
.btn-notif {
  background: var(--surface-2);
  color: var(--text);
}

.btn-text,
.btn-link {
  background: transparent;
  color: var(--accent);
  padding: 0 var(--s2);
  border-radius: var(--r-sm);
}

.btn-danger,
.btn-stop {
  background: var(--surface-2);
  color: var(--danger);
}

.btn-danger.confirm {
  background: var(--danger);
  color: var(--accent-text);
}

.btn-text-danger,
.btn-stop-all,
.btn-sched-delete {
  background: transparent;
  color: var(--danger);
  padding: 0 var(--s2);
  font-size: var(--fs-sm);
}

.btn-text-danger.confirm,
.btn-sched-delete.confirm {
  background: var(--danger);
  color: var(--accent-text);
  padding: 0 var(--s3);
  border-radius: var(--r-md);
}

.btn-sm {
  font-size: var(--fs-sm);
  padding: 0 var(--s3);
}

.btn-block,
.btn-load-more {
  width: 100%;
}

/* Pills: one shape (--r-pill, --fs-xs, 600, uppercase) */
.pill {
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex: none;
  line-height: 1.3;
}

.pill-running,
.pill-scheduled {
  background: rgba(10, 132, 255, 0.16);
  color: var(--accent);
}

.pill-done,
.pill-reply {
  background: var(--surface-2);
  color: var(--muted);
}

.pill-failed,
.pill-stopped {
  background: rgba(255, 69, 58, 0.16);
  color: var(--danger);
}

.pill-waiting {
  background: rgba(255, 214, 10, 0.18);
  color: var(--warn);
}

@media (prefers-color-scheme: light) {
  .pill-waiting {
    background: rgba(255, 214, 10, 0.28);
    color: #8a6100;
  }
}

/* Bottom tab bar */
.tab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: var(--s1) var(--s4) calc(var(--s1) + env(safe-area-inset-bottom));
}

.tab-bar-inner {
  max-width: 640px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s2);
}

.tab-btn {
  background: transparent;
  color: var(--muted);
  border-radius: var(--r-sm);
  min-height: 48px;
  padding: var(--s1) var(--s2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: var(--fs-xs);
  font-weight: 600;
  position: relative;
}

.tab-btn[aria-current="page"] {
  color: var(--accent);
}

.tab-icon-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tab-badge {
  position: absolute;
  top: -4px;
  right: -10px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--r-pill);
  background: var(--danger);
  color: var(--accent-text);
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Toast (status) */
.status {
  position: fixed;
  left: var(--s4);
  right: var(--s4);
  bottom: calc(68px + env(safe-area-inset-bottom));
  max-width: 640px;
  margin: 0 auto;
  z-index: 30;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s3) var(--s4);
  font-size: var(--fs-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
}

body.no-tabs .status {
  bottom: calc(128px + env(safe-area-inset-bottom));
}

.status.err {
  border-color: var(--danger);
  border-left-width: 4px;
  color: var(--danger);
}

.status-text {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.status-close {
  background: transparent;
  color: var(--danger);
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  margin: -8px -8px -8px 0;
  border-radius: var(--r-sm);
  flex: none;
}

/* Skeleton loading rows */
.skeleton-list {
  display: grid;
  gap: var(--s2);
  margin: var(--s3) 0;
}

.skeleton-row {
  height: 60px;
  border-radius: var(--r-md);
  background: var(--surface);
  position: relative;
  overflow: hidden;
  padding: var(--s3) var(--s4);
  display: grid;
  gap: var(--s2);
  align-content: center;
}

.skeleton-bar {
  height: 12px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  width: 70%;
  animation: pulse-warn 1.5s infinite;
}

.skeleton-bar.short {
  width: 40%;
  height: 10px;
}

/* Lists & cards */
.task-cards,
.task-list,
.nodes,
.log-list,
.card-list {
  display: grid;
  gap: var(--s2);
}

.task-row {
  width: 100%;
  text-align: left;
  background: var(--surface);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: var(--s3) var(--s4);
  min-height: 60px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s3);
  cursor: pointer;
  font-weight: 400;
}

.task-row:hover {
  border-color: var(--line);
}

.task-row-main {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: var(--s1);
}

.task-row-prompt {
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

.task-row-meta {
  font-size: var(--fs-sm);
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* Floating "+ New task" button */
.fab {
  position: fixed;
  right: max(var(--s4), calc((100vw - 640px) / 2 + var(--s4)));
  bottom: calc(72px + env(safe-area-inset-bottom));
  z-index: 22;
  background: var(--accent);
  color: var(--accent-text);
  border-radius: var(--r-pill);
  padding: 0 var(--s4);
  min-height: 48px;
  font-size: var(--fs-md);
  font-weight: 600;
}

/* Empty states */
.empty-state {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--s5) var(--s4);
  margin-top: var(--s4);
  display: grid;
  gap: var(--s3);
  justify-items: start;
}

.empty {
  color: var(--muted);
  font-size: var(--fs-md);
  line-height: 1.5;
}

/* Needs-you / Approvals */
.approval-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--warn);
  border-radius: var(--r-lg);
  padding: var(--s4);
  display: grid;
  gap: var(--s2);
  cursor: pointer;
}

.approval-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  flex-wrap: wrap;
}

.approval-meta {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-width: 0;
  flex-wrap: wrap;
}

.name {
  font-size: var(--fs-md);
  font-weight: 600;
}

.approval-summary {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: var(--fs-sm);
  line-height: 1.4;
  max-height: 4.2em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  word-break: break-all;
  color: var(--text);
}

.approval-details {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: var(--fs-xs);
  line-height: 1.4;
  background: var(--surface-2);
  padding: var(--s3);
  border-radius: var(--r-sm);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 240px;
  overflow-y: auto;
}

.approval-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s2);
  margin-top: var(--s1);
}

.approval-actions button {
  width: 100%;
}

/* Machines tab & Machine page */
.machine-row {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: var(--s3) var(--s4);
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  text-align: left;
  font-weight: 400;
}

.machine-row:hover {
  border-color: var(--line);
}

.machine-row-left {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-width: 0;
  flex: 1;
}

.machine-row-info {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.machine-row-right {
  display: flex;
  align-items: center;
  gap: var(--s2);
  color: var(--muted);
  flex: none;
}

.machine-header-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--s4);
  display: grid;
  gap: var(--s2);
  margin-bottom: var(--s4);
}

.machine-status-row {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-wrap: wrap;
}

.info-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--s4);
  display: grid;
  gap: var(--s2);
  margin-bottom: var(--s4);
}

.agents,
.project-list,
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
}

.agent,
.project-chip {
  font-size: var(--fs-sm);
  padding: var(--s1) var(--s3);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text);
}

/* Grouped iOS-settings style list */
.grouped-list {
  background: var(--surface);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: var(--s4);
  display: grid;
}

.group-row {
  width: 100%;
  background: transparent;
  color: var(--text);
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: var(--s3) var(--s4);
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  text-align: left;
  font-size: var(--fs-md);
  font-weight: 500;
}

.group-row:last-child {
  border-bottom: 0;
}

.group-row:hover:not(:disabled) {
  background: var(--surface-2);
}

.group-row-right {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 400;
}

.quiet-row {
  background: var(--surface);
  border-radius: var(--r-lg);
  color: var(--muted);
}

/* Forms & New Task */
.form-section {
  margin-bottom: var(--s4);
  display: grid;
  gap: var(--s2);
}

.form-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-plain-line {
  font-size: var(--fs-md);
  color: var(--text);
  font-weight: 500;
  padding: var(--s1) 0;
}

.form-select,
.form-textarea,
.form-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--r-md);
  padding: var(--s3) var(--s4);
  font: inherit;
  font-size: var(--fs-md);
  min-height: 44px;
}

.form-textarea {
  resize: vertical;
  line-height: 1.45;
}

.prompt-textarea {
  resize: none;
}

.form-select:focus,
.form-textarea:focus,
.form-input:focus {
  outline: none;
  border-color: var(--accent);
}

.form-row {
  display: flex;
  gap: var(--s2);
  align-items: center;
  flex-wrap: wrap;
}

.form-row-col {
  flex: 1;
  min-width: 100px;
  display: grid;
  gap: var(--s1);
}

.hint {
  font-size: var(--fs-sm);
  color: var(--muted);
  line-height: 1.4;
  background: var(--surface);
  padding: var(--s3);
  border-radius: var(--r-sm);
}

/* Interactive chips (Machine, Project, Agent) */
.chip-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 0 var(--s4);
  min-height: 44px;
  font-size: var(--fs-sm);
  font-weight: 600;
}

.chip-btn.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

/* Mode cards side by side */
.mode-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s2);
}

.mode-card {
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s3);
  min-height: 76px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: var(--s1);
  text-align: left;
}

.mode-card.active {
  border-color: var(--accent);
  background: rgba(10, 132, 255, 0.1);
}

.mode-card-title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text);
}

.mode-card-desc {
  font-size: var(--fs-xs);
  font-weight: 400;
  color: var(--muted);
  line-height: 1.35;
}

/* Segmented control (Now | Schedule) */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s1);
  background: var(--surface);
  padding: var(--s1);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
}

.seg-btn {
  background: transparent;
  color: var(--muted);
  border-radius: var(--r-sm);
  min-height: 44px;
  font-size: var(--fs-sm);
  font-weight: 600;
}

.seg-btn.active {
  background: var(--surface-2);
  color: var(--text);
}

.schedule-fields {
  display: grid;
  gap: var(--s3);
  margin-top: var(--s2);
  padding: var(--s4);
  background: var(--surface);
  border-radius: var(--r-lg);
}

.schedule-fields .form-select,
.schedule-fields .form-input,
.schedule-fields .hint {
  background: var(--surface-2);
}

/* Sticky bottom action bar */
.sticky-bottom-bar {
  position: sticky;
  bottom: env(safe-area-inset-bottom);
  background: var(--bg);
  padding: var(--s3) 0;
  border-top: 1px solid var(--line);
  margin-top: var(--s4);
  z-index: 15;
}

.sticky-bottom-bar button {
  width: 100%;
}

.run-why {
  margin-top: var(--s2);
  font-size: var(--fs-sm);
  color: var(--muted);
  text-align: center;
}

.no-project-card {
  border: 1px solid var(--line);
  border-left: 3px solid var(--warn);
}

.no-project-hint {
  display: grid;
  gap: var(--s1);
}

.no-project-lead {
  font-size: var(--fs-md);
  color: var(--text);
  line-height: 1.45;
}

.no-project-line {
  font-size: var(--fs-sm);
  color: var(--muted);
  line-height: 1.45;
}

.no-project-actions {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-wrap: wrap;
  margin-top: var(--s1);
}

/* Task view (conversation) */
.thread {
  display: grid;
  gap: var(--s4);
  padding-bottom: calc(148px + env(safe-area-inset-bottom));
}

/* Working indicator */
.working-line {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-size: var(--fs-sm);
  color: var(--muted);
  padding: var(--s1) 0;
}

.working-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.working-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-warn 1.2s infinite ease-in-out;
}

.working-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.working-dot:nth-child(3) {
  animation-delay: 0.4s;
}

.earlier-turns {
  display: grid;
  gap: var(--s4);
}

.earlier-turn {
  display: grid;
  gap: var(--s3);
  padding-bottom: var(--s4);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.earlier-turn.loading {
  cursor: default;
  opacity: 0.7;
}

.earlier-loading {
  font-size: var(--fs-sm);
  color: var(--muted);
}

.turn-prompt-wrap {
  display: flex;
  justify-content: flex-end;
}

.task-prompt,
.earlier-prompt {
  background: var(--accent);
  color: var(--accent-text);
  border-radius: var(--r-lg) var(--r-lg) var(--s1) var(--r-lg);
  padding: var(--s3) var(--s4);
  max-width: 85%;
  font-size: var(--fs-md);
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.task-output {
  display: grid;
  gap: var(--s3);
}

/* Collapsible steps */
.steps-box {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: var(--s1) var(--s3);
}

.steps-toggle {
  width: 100%;
  background: transparent;
  color: var(--muted);
  min-height: 44px;
  padding: 0;
  justify-content: flex-start;
  font-size: var(--fs-sm);
  font-weight: 600;
}

.steps-toggle .icon {
  width: 16px;
  height: 16px;
  transition: transform 0.15s;
}

.steps-toggle[aria-expanded="true"] .icon {
  transform: rotate(90deg);
}

.step-live {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: var(--fs-xs);
  color: var(--muted);
  padding: 0 0 var(--s2) var(--s5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.steps-list {
  display: grid;
  gap: var(--s1);
  padding: 0 0 var(--s2) var(--s5);
  border-top: 1px solid var(--line);
  padding-top: var(--s2);
}

.out-tool,
.out-raw {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: var(--fs-xs);
  color: var(--muted);
  word-break: break-all;
}

.out-info {
  font-size: var(--fs-xs);
  color: var(--muted);
}

.out-error {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: var(--fs-sm);
  color: var(--danger);
  background: rgba(255, 69, 58, 0.1);
  padding: var(--s2) var(--s3);
  border-radius: var(--r-sm);
  word-break: break-all;
}

.out-denied {
  font-size: var(--fs-sm);
  color: var(--warn);
  word-break: break-word;
}

.out-ask {
  font-size: var(--fs-sm);
  color: var(--accent);
  font-weight: 500;
  word-break: break-word;
}

/* Full-width answer text, no border box */
.out-text,
.out-result,
.turn-answer,
.earlier-answer {
  font-size: var(--fs-md);
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.turn-footer,
.out-cost {
  font-size: var(--fs-xs);
  color: var(--muted);
}

.task-summary {
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--text);
}

.out-truncated {
  font-size: var(--fs-xs);
  color: var(--muted);
  padding-bottom: var(--s2);
  border-bottom: 1px solid var(--line);
}

/* Markdown blocks */
.md-line {
  margin: 0 0 var(--s2);
}

.md-line:last-child {
  margin-bottom: 0;
}

.md-h {
  font-weight: 700;
  font-size: var(--fs-lg);
  margin: var(--s3) 0 var(--s2);
}

.md-h:first-child {
  margin-top: 0;
}

.md-li {
  display: flex;
  gap: var(--s2);
  margin: 0 0 var(--s1);
}

.md-li .md-line {
  margin: 0;
  min-width: 0;
}

.md-l1 {
  padding-left: var(--s4);
}

.md-l2 {
  padding-left: var(--s6);
}

.md-mark {
  flex: none;
  color: var(--muted);
  min-width: 12px;
}

.md-code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: var(--fs-sm);
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: var(--r-sm);
  word-break: break-all;
}

.md-pre {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: var(--fs-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: var(--s3);
  border-radius: var(--r-sm);
  overflow-x: auto;
  white-space: pre;
  margin: 0 0 var(--s2);
}

.md-hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: var(--s3) 0;
}

/* Sticky reply composer */
.reply-box {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: var(--s2) var(--s4) calc(var(--s2) + env(safe-area-inset-bottom));
  z-index: 25;
}

.reply-box-inner {
  max-width: 640px;
  margin: 0 auto;
  display: grid;
  gap: var(--s2);
}

.reply-composer-row {
  display: flex;
  align-items: flex-end;
  gap: var(--s2);
}

.reply-textarea {
  flex: 1;
  min-height: 44px;
  background: var(--surface-2);
  padding: 10px var(--s3);
  line-height: 1.4;
  resize: none;
}

.reply-top-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--s2);
}

.reply-segmented {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  background: var(--surface-2);
  padding: 2px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
}

.reply-seg-btn {
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  min-height: 44px;
  padding: 0 var(--s3);
  font-size: var(--fs-xs);
  font-weight: 600;
}

.reply-seg-btn.active {
  background: var(--surface);
  color: var(--text);
}

.reply-error {
  font-size: var(--fs-sm);
  color: var(--danger);
}

.btn-continued {
  background: var(--surface);
  color: var(--accent);
  width: 100%;
  justify-content: space-between;
  padding: 0 var(--s4);
  margin-top: var(--s3);
}

/* Rules, Schedules, Log cards */
.rules-row,
.schedule-card,
.log-card,
.settings-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--s4);
  display: grid;
  gap: var(--s2);
}

.rules-label,
.schedule-name {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--text);
}

.rules-choices {
  display: flex;
  gap: var(--s2);
  flex-wrap: wrap;
}

.btn-choice {
  background: var(--surface-2);
  color: var(--muted);
  border-radius: var(--r-pill);
  padding: 0 var(--s4);
  min-height: 44px;
  font-size: var(--fs-sm);
  font-weight: 600;
}

.btn-choice.active {
  background: var(--accent);
  color: var(--accent-text);
}

.rules-explain,
.schedule-meta,
.schedule-last,
.log-time {
  font-size: var(--fs-sm);
  color: var(--muted);
}

.schedule-when {
  font-size: var(--fs-md);
  font-weight: 500;
}

.schedule-next {
  font-size: var(--fs-sm);
  color: var(--ok);
}

.schedule-next.paused {
  color: var(--warn);
}

.schedule-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  flex-wrap: wrap;
  padding-top: var(--s2);
  border-top: 1px solid var(--line);
  margin-top: var(--s1);
}

.schedule-actions-left {
  display: flex;
  gap: var(--s2);
  flex-wrap: wrap;
}

.btn-new-schedule {
  width: 100%;
  margin-bottom: var(--s3);
}

.banner-held {
  background: rgba(255, 214, 10, 0.14);
  border: 1px solid var(--warn);
  border-radius: var(--r-lg);
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  flex-wrap: wrap;
}

.banner-held-text {
  font-size: var(--fs-sm);
  color: var(--text);
  font-weight: 500;
  flex: 1;
  min-width: 180px;
}

.btn-resume-all {
  background: var(--warn);
  color: #000;
}

.log-card.clickable {
  cursor: pointer;
  border: 1px solid transparent;
}

.log-card.clickable:hover {
  border-color: var(--line);
}

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
}

.log-chip {
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  text-transform: uppercase;
  background: var(--surface-2);
  color: var(--muted);
}

.log-text {
  font-size: var(--fs-md);
  word-break: break-word;
}

/* Settings */
.notif-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--s4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  flex-wrap: wrap;
}

.notif-status {
  font-size: var(--fs-md);
  font-weight: 600;
}

.notif-msg {
  font-size: var(--fs-sm);
  color: var(--muted);
  margin-top: 2px;
}

.about-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  font-size: var(--fs-md);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .working-dot {
    animation: none !important;
  }
}

/* Welcome: a phone with no machine yet */
.welcome-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--s5) var(--s4);
  margin-top: var(--s4);
  display: grid;
  gap: var(--s4);
  justify-items: start;
}

.welcome-title {
  font-size: var(--fs-xl);
  font-weight: 700;
}

.welcome-lead,
.welcome-note {
  color: var(--muted);
  font-size: var(--fs-md);
  line-height: 1.5;
}

.welcome-note {
  font-size: var(--fs-sm);
}

.welcome-steps {
  display: grid;
  gap: var(--s3);
  padding-left: var(--s5);
  margin: 0;
}

.welcome-steps li {
  font-size: var(--fs-md);
  line-height: 1.5;
}

.welcome-step-title {
  display: block;
  font-weight: 600;
}

.welcome-step-note {
  display: block;
  color: var(--muted);
  font-size: var(--fs-sm);
  margin-top: var(--s1);
}

/* Search bar on Tasks tab */
.search-bar {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: var(--s3);
}

.search-input {
  padding-right: 44px;
}

.search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.search-clear {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  color: var(--muted);
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: var(--r-sm);
  font-size: var(--fs-lg);
  font-weight: 500;
}

/* Today daily summary card */
.today-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s3);
  display: grid;
  gap: var(--s1);
}

.today-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  flex-wrap: wrap;
}

.today-title {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.today-spend {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--muted);
}

.today-counts {
  display: flex;
  align-items: center;
  gap: var(--s1);
  flex-wrap: wrap;
  margin-left: calc(-1 * var(--s2));
}

.today-filter-btn {
  background: transparent;
  color: var(--text);
  min-height: 44px;
  padding: 0 var(--s2);
  border-radius: var(--r-sm);
  font-size: var(--fs-md);
  font-weight: 600;
}

.today-filter-btn.active {
  color: var(--accent);
}

.today-sep {
  color: var(--muted);
  font-size: var(--fs-md);
}

/* Answer copy button */
.answer-wrap {
  display: grid;
  gap: var(--s1);
  justify-items: start;
}

.btn-copy {
  font-size: var(--fs-xs);
  color: var(--muted);
  padding: 0 var(--s2);
  margin-left: calc(-1 * var(--s2));
  min-height: 44px;
}

.btn-copy:hover {
  color: var(--accent);
}

/* Rules segmented control */
.rules-segmented {
  display: grid;
  gap: var(--s1);
  background: var(--surface-2);
  padding: var(--s1);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
}

.rules-segmented.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.rules-segmented.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.rules-seg-btn {
  background: transparent;
  color: var(--muted);
  border-radius: var(--r-sm);
  min-height: 44px;
  padding: 0 var(--s2);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.rules-seg-btn.active {
  background: var(--accent);
  color: var(--accent-text);
}

.rules-explain {
  padding: 0 var(--s2) var(--s2);
  margin-top: calc(-1 * var(--s1));
}

/* Machine spending editor */
.static-row {
  cursor: default;
}

.static-row:hover {
  background: transparent !important;
}

.cap-editor {
  padding: var(--s3) var(--s4);
  background: var(--surface-2);
  display: grid;
  gap: var(--s2);
}

.cap-input-row {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-wrap: wrap;
}

.cap-input {
  width: 120px;
  flex: 1 1 100px;
  background: var(--surface);
}

/* Claude plan limits: a native <meter> (no inline style), blue, then yellow from 75% and red from 90%. */
.plan-card {
  gap: var(--s3);
}

.plan-meter {
  display: grid;
  gap: var(--s1);
  min-width: 0;
}

.plan-meter-top {
  display: flex;
  justify-content: space-between;
  gap: var(--s2);
  font-size: var(--fs-sm);
}

.plan-meter-label {
  color: var(--text);
}

.plan-meter-pct {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.plan-meter-sub {
  font-size: var(--fs-xs);
  color: var(--muted);
}

.plan-meter-bar {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  overflow: hidden;
}

.plan-meter.compact .plan-meter-top {
  font-size: var(--fs-xs);
}

.plan-meter.compact .plan-meter-bar {
  height: 6px;
}

.plan-meter-bar::-webkit-meter-bar {
  background: var(--surface-2);
  border: 0;
  border-radius: var(--r-pill);
  height: 100%;
}

.plan-meter-bar::-webkit-meter-optimum-value {
  background: var(--accent);
  border-radius: var(--r-pill);
}

.plan-meter-bar::-webkit-meter-suboptimum-value {
  background: var(--warn);
  border-radius: var(--r-pill);
}

.plan-meter-bar::-webkit-meter-even-less-good-value {
  background: var(--danger);
  border-radius: var(--r-pill);
}

.plan-meter-bar::-moz-meter-bar {
  background: var(--accent);
  border-radius: var(--r-pill);
}

.plan-meter-bar:-moz-meter-sub-optimum::-moz-meter-bar {
  background: var(--warn);
}

.plan-meter-bar:-moz-meter-sub-sub-optimum::-moz-meter-bar {
  background: var(--danger);
}

.plan-limit-reached {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--danger);
}

.today-plan {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s3);
  margin-top: var(--s1);
}

/* App update bar above the tab bar */
.update-bar {
  position: fixed;
  left: var(--s4);
  right: var(--s4);
  bottom: calc(68px + env(safe-area-inset-bottom));
  max-width: 640px;
  margin: 0 auto;
  z-index: 26;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s2) var(--s3) var(--s2) var(--s4);
  font-size: var(--fs-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
}

body.no-tabs .update-bar {
  bottom: calc(var(--s4) + env(safe-area-inset-bottom));
}

.update-bar-text {
  flex: 1;
  min-width: 0;
}

/* Toggle switch */
.toggle {
  -webkit-appearance: none;
  appearance: none;
  width: 46px;
  height: 28px;
  min-height: 28px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--line);
  position: relative;
  cursor: pointer;
  flex: none;
  margin: 0;
  padding: 0;
  transition: background-color 0.15s, border-color 0.15s, opacity 0.15s;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 0.15s;
}

.toggle:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle:checked::after {
  transform: translateX(18px);
  background: var(--accent-text);
}

.toggle:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Machine Updates card */
.updates-card {
  gap: var(--s3);
}

.updates-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  font-size: var(--fs-md);
  font-weight: 500;
}

.updates-status {
  font-size: var(--fs-sm);
  color: var(--muted);
  line-height: 1.4;
}

.updates-status.err {
  color: var(--danger);
}

.updates-actions {
  display: flex;
  align-items: center;
  gap: var(--s2);
}

