* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.35 var(--sans);
}

body { min-height: 100dvh; }

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

button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding:
    calc(16px + env(safe-area-inset-top))
    18px
    calc(28px + env(safe-area-inset-bottom));
}

.app.has-dock {
  position: fixed;
  top: var(--vv-offset);
  left: 0;
  right: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: var(--app-height);
  min-height: 0;
  overflow: hidden;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

body:has(.app.has-dock) {
  overflow: hidden;
  height: var(--app-height);
}

.app.has-dock > [data-screen] {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 8px;
}

h1 {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-head { margin-bottom: 18px; }

.home-head {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.view-toggle {
  display: flex;
  width: 100%;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--card);
}

.view-btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 0 4px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.view-btn[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
}

.app.has-dock > [data-screen].home-cards {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 0;
}

.carousel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  touch-action: pan-x;
}

.carousel.dragging {
  scroll-snap-type: none;
  scroll-behavior: auto;
}

.carousel::-webkit-scrollbar { display: none; }

.carousel-card {
  flex: 0 0 100%;
  width: 100%;
  min-width: 100%;
  height: 100%;
  min-height: 0;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: 28px;
  padding: 4px 8px 8px;
}

.carousel-card .bot-head,
.carousel-card .routine-block,
.carousel-card .stage-head,
.carousel-card .stage-hint {
  flex: none;
  touch-action: pan-x;
}

.carousel-card .routine-block button,
.carousel-card .stage-head button { touch-action: pan-x; }

.carousel-card .routine-block { border-bottom: 1px solid var(--line); }

.carousel-body,
.carousel-body button {
  touch-action: pan-y;
}

.carousel-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.carousel-body .task-line { border-top: 1px solid var(--line); }

.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: none;
  min-height: 44px;
  padding-top: 4px;
}

.pager-dot {
  position: relative;
  width: 36px;
  height: 44px;
  border: 0;
  padding: 0;
  background: transparent;
  display: grid;
  place-items: center;
}

.pager-dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--bot);
}

.pager-dot[aria-selected="true"]::before { width: 18px; }

.pager-dot .dot {
  position: absolute;
  top: 11px;
  right: 5px;
  width: 8px;
  height: 8px;
  margin: 0;
  border: 1.5px solid var(--bg);
}

.home-cards .foot-links { margin-top: 0; }

.stage-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 10px 8px 0;
}

.stage-count {
  color: var(--muted);
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stage-hint { margin: 0 8px 8px; }

.kanban-card {
  display: block;
  width: 100%;
  margin: 0 0 8px;
  padding: 12px;
  border: 0;
  border-radius: 16px;
  background: var(--raised);
  color: inherit;
  text-align: left;
  user-select: none;
  -webkit-touch-callout: none;
}

.kanban-top {
  display: flex;
  align-items: center;
  gap: 2px;
}

.kanban-open {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.kanban-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.kanban-title {
  font-weight: 600;
  line-height: 1.25;
}

.kanban-card.done .kanban-title {
  color: var(--muted);
  font-weight: 500;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.demo {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.banner {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
}

.bot {
  margin: 0 0 8px;
  padding: 4px 0 8px;
  background: transparent;
  border: 0;
}

.bot-head, .identity, .static-head {
  width: 100%;
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border: 0;
  background: transparent;
  text-align: left;
  color: inherit;
}

.bot-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.id-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.chev {
  margin-left: auto;
  color: var(--muted);
  font-size: 28px;
  line-height: 1;
  font-weight: 400;
}

.bot-icon {
  width: var(--icon);
  height: var(--icon);
  display: block;
  flex: none;
}

.bot-icon.sm {
  width: 28px;
  height: 28px;
}

.marker, .meta, .hint, .when {
  color: var(--muted);
  font-size: 15px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 10px;
  line-height: 1.2;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: var(--pill);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--wait);
  display: inline-block;
  flex: none;
}

.bot-name .dot { margin-left: 8px; }

.hint { margin: 0 0 6px; }

.current, .task-row {
  width: 100%;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  text-align: left;
  color: inherit;
}

.group .task-row,
.group .current,
.group .queue-label,
.group .empty-line {
  padding-left: 56px;
}

.current { border-radius: 0; margin: 0; }

.current .label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 2px;
}

.task-title {
  display: block;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}

.task-line {
  display: flex;
  align-items: center;
  min-height: 52px;
}

.task-line .task-row,
.task-line .current {
  flex: 1;
  min-width: 0;
  border-top: 0;
}

.group .task-line { border-top: 1px solid var(--line); }

.group .task-line .task-row,
.group .task-line .current { padding-left: 4px; }

.tick {
  width: 48px;
  height: 48px;
  flex: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  display: grid;
  place-items: center;
}

.ring {
  width: 24px;
  height: 24px;
  display: block;
  overflow: visible;
}

.ring-track,
.ring-value {
  fill: none;
  stroke-width: 2.25;
}

.ring-track { stroke: color-mix(in srgb, var(--ink) 28%, transparent); }

.ring-value {
  stroke-linecap: round;
  transform-box: fill-box;
  transform-origin: center;
  transform: rotate(-90deg);
  transition: stroke-dashoffset 480ms ease;
}

.ring.waiting .ring-value { animation: ring-wait 2.8s ease-in-out infinite; }
.ring.paused .ring-value { opacity: 0.45; }

.ring-closed {
  fill: none;
  stroke-width: 2.25;
}

.ring-check {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@keyframes ring-wait {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.checked .task-title {
  color: var(--muted);
  font-weight: 500;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

@media (prefers-reduced-motion: reduce) {
  .ring-value { transition: none; }
  .ring.waiting .ring-value { animation: none; }
}

.done-note {
  margin: 0 0 10px 52px;
  color: var(--muted);
}

.queue-label {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.routine-card {
  margin: 0 0 12px;
  border: 0;
  border-radius: 18px;
  background: transparent;
  outline: 1px solid var(--line);
  outline-offset: -1px;
}

.routine-card { padding: 0; }

.routine-open {
  flex: 1;
  min-width: 0;
  min-height: 52px;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 8px;
  padding: 10px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.group .routine-open { padding-left: 4px; }

.repeat-slot {
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

.routine-name {
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
}

.routine-name .dot { margin-left: 6px; }

.routine-open .when { font-size: 14px; }

.empty-line {
  margin: 0 0 8px;
  color: var(--muted);
}

.back {
  min-height: 48px;
  margin: 0 0 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
}

.stack { display: flex; flex-direction: column; gap: 10px; }

.choice, .check-row, .primary, .secondary, .tiny, .text-btn {
  min-height: var(--tap);
  border-radius: 999px;
}

.choice, .check-row, .secondary, .tiny {
  border: 0;
  background: var(--card);
}

.choice, .check-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  text-align: left;
}

.choice[aria-pressed="true"],
.check-row[aria-checked="true"] {
  background: var(--raised);
}

.choice:disabled {
  opacity: 0.4;
}

.choice-label { font-weight: 600; }

.box {
  width: 22px;
  height: 22px;
  margin-left: auto;
  border-radius: 999px;
  border: 1.5px solid var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  font-size: 14px;
}

.choice[aria-pressed="true"] .box,
.check-row[aria-checked="true"] .box {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

.field {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 0;
  background: var(--card);
}

textarea.field { min-height: 76px; resize: vertical; }

.line-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }

.line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 48px;
  padding: 8px 8px 8px 14px;
  border-radius: 16px;
  background: var(--card);
}

.icon-x {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
}

.primary {
  width: 100%;
  border: 0;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
}

.primary:disabled { opacity: 0.45; }

.secondary { padding: 0 14px; width: 100%; }

.tiny {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
}

.row { display: flex; gap: 8px; }

.text-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 4px;
}

.logout { margin-top: 4px; }

.block { margin-top: 16px; }

.meta-block {
  margin: 10px 0 0;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.result {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--card);
}

.result p { margin: 6px 0 0; }

.thread { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }

.bubble {
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--card);
  height: auto;
  max-height: none;
  overflow: visible;
}

.bubble.from-bot,
.bubble.sarah,
.bubble.note {
  margin: 0;
  background: var(--card);
}

.who {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}

.bubble p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: visible;
  max-height: none;
  display: block;
}

.when { display: block; margin-top: 6px; font-size: 13px; }

.working {
  margin-top: 16px;
  padding: 16px;
  border-radius: 18px;
  background: var(--card);
  color: var(--muted);
}

.dock {
  position: relative;
  flex: none;
  padding: 10px 0 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
}

.dock-inner { max-width: 444px; margin: 0 auto; }

.sheet-back {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 5;
  padding: 16px;
}

.sheet {
  width: min(444px, 100%);
  background: var(--card);
  color: var(--ink);
  border-radius: 28px;
  padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sheet h2 { font-size: 24px; }
.sheet p { margin: 0 0 6px; }

.login { padding-top: 14vh; }
.login h1 { margin-bottom: 8px; }

.login .lede {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 18px;
}

.center-note {
  margin-top: 30vh;
  color: var(--muted);
}

.done-toggle {
  width: 100%;
  min-height: 52px;
  margin-top: 8px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  text-align: left;
  color: var(--muted);
  padding: 12px 0;
}

.description {
  margin: 4px 0 8px;
  font-size: 17px;
  line-height: 1.35;
  white-space: pre-wrap;
  overflow: visible;
  max-height: none;
}

.notice {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px 14px;
  margin-bottom: 12px;
}

.notice .task-row,
.notice .description,
.notice .row,
.notice .block,
.notice .queue-label,
.notice .empty-line {
  margin-left: 0;
  padding-left: 0;
}

.notice .task-row { border-top: 0; min-height: 0; padding-top: 8px; }
.notice .task-line { min-height: 48px; }

.notice .identity { min-height: 52px; padding: 0; }

.suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.context summary {
  min-height: var(--tap);
  display: flex;
  align-items: center;
  cursor: pointer;
  font-weight: 600;
}

.context textarea { margin-bottom: 8px; }

.foot-links {
  display: flex;
  gap: 16px;
  margin-top: 12px;
}

.segment {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--bg);
}

.segment button {
  flex: 1;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
}

.segment button[aria-checked="true"] {
  background: var(--primary);
  color: var(--on-primary);
}

.task-title, .line span, h1, h2, .bubble p, .bot-name {
  overflow-wrap: anywhere;
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
