/* Agent Kit web UI — calm, dark-first.
   --bg-top, --bg-bottom, --ink, --accent, --accent-strong and --agent-font are set by app.js from the agent's
   validated theme (lib.js deriveTheme guarantees readable contrast); everything else derives from them. */

:root {
  --bg-top: #0d1224;
  --bg-bottom: #19223d;
  --ink: #eef2ff;
  --accent: #7c6cf6;
  --accent-strong: #6a5be0;
  --agent-font: "Inter";
  color-scheme: dark;

  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --ink-2: color-mix(in srgb, var(--ink) 82%, var(--bg-bottom));
  --ink-3: color-mix(in srgb, var(--ink) 66%, var(--bg-bottom));
  --link: color-mix(in srgb, var(--accent) 58%, var(--ink));
  --surface-1: color-mix(in srgb, var(--ink) 4%, transparent);
  --surface-2: color-mix(in srgb, var(--ink) 7%, transparent);
  --surface-3: color-mix(in srgb, var(--ink) 12%, transparent);
  --panel: color-mix(in srgb, var(--bg-bottom) 94%, var(--ink));
  --field: color-mix(in srgb, var(--bg-top) 55%, transparent);
  --border: color-mix(in srgb, var(--ink) 13%, transparent);
  --border-strong: color-mix(in srgb, var(--ink) 22%, transparent);
  --focus: var(--accent);

  /* Status colors are fixed (never themed) and always paired with an icon or a label. */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --info: #4ea1ff;
  --danger-strong: #c92a2a;
  --diff-add: #2ea043;
  --diff-del: #f85149;

  --radius-s: 8px;
  --radius: 12px;
  --radius-l: 18px;
  --shadow: 0 12px 32px rgb(0 0 0 / 0.32);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

:root[data-scheme="light"] {
  color-scheme: light;
  --shadow: 0 12px 32px rgb(0 0 0 / 0.14);
  --field: color-mix(in srgb, var(--bg-top) 70%, white);
}

/* ------------------------------------------------------------------ base */

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

[hidden] {
  display: none !important;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  font: 15px/1.55 var(--font-ui);
  color: var(--ink);
  background-color: var(--bg-bottom);
  background-image:
    radial-gradient(1100px 560px at 12% -8%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 62%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

::selection {
  background: color-mix(in srgb, var(--accent) 42%, transparent);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

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

h1,
h2,
h3,
h4 {
  line-height: 1.25;
}

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

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.agent-font {
  font-family: var(--agent-font), var(--font-ui);
}

.muted {
  color: var(--ink-3);
}

.noscript {
  margin: 20vh auto;
  max-width: 420px;
  text-align: center;
}

body:not([data-role="owner"]) .owner-only,
body:not([data-role="viewer"]) .viewer-only,
body.no-chat .chat-only {
  display: none !important;
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon--fill {
  fill: currentColor;
}

/* ------------------------------------------------------------------ orb */

.orb {
  --size: 34px;
  display: inline-block;
  width: var(--size);
  height: var(--size);
  flex: none;
  border-radius: 50%;
  background: radial-gradient(
    circle at 34% 28%,
    rgb(255 255 255 / 0.92),
    color-mix(in srgb, var(--accent) 52%, white) 30%,
    var(--accent) 64%,
    color-mix(in srgb, var(--accent) 55%, var(--bg-top)) 100%
  );
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--ink) 22%, transparent),
    0 0 22px color-mix(in srgb, var(--accent) 42%, transparent);
}

.orb--lg {
  --size: 64px;
}

.orb--xl {
  --size: 92px;
}

.splash .orb,
.login .orb {
  animation: float 5s ease-in-out infinite;
}

.app[data-activity="chat"] .orb,
.app[data-activity="updating"] .orb {
  animation: breathe 1.9s var(--ease) infinite;
}

.app[data-activity="autonomy"] .orb {
  animation: breathe-own 2.6s var(--ease) infinite;
}

@keyframes breathe {
  50% {
    transform: scale(1.07);
    box-shadow:
      0 0 0 2px color-mix(in srgb, var(--ink) 40%, transparent),
      0 0 36px color-mix(in srgb, var(--accent) 72%, transparent);
  }
}

@keyframes breathe-own {
  50% {
    transform: scale(1.05);
    box-shadow:
      0 0 0 2px color-mix(in srgb, var(--warning) 60%, transparent),
      0 0 34px color-mix(in srgb, var(--warning) 45%, var(--accent));
  }
}

@keyframes float {
  50% {
    transform: translateY(-4px);
  }
}

/* ------------------------------------------------------------------ buttons & fields */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.btn:hover {
  background: var(--surface-3);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn .icon {
  width: 18px;
  height: 18px;
}

.btn--primary {
  background: var(--accent-strong);
  border-color: transparent;
  color: #fff;
}

.btn--primary:hover {
  background: color-mix(in srgb, var(--accent-strong) 86%, white);
}

.btn--danger {
  background: var(--danger-strong);
  border-color: transparent;
  color: #fff;
}

.btn--danger:hover {
  background: color-mix(in srgb, var(--danger-strong) 86%, white);
}

.btn--ghost {
  background: transparent;
}

.btn--small {
  min-height: 32px;
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 13.5px;
}

.btn--block {
  width: 100%;
}

.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.icon-btn[aria-pressed="false"] {
  color: var(--ink-3);
}

.icon-btn[aria-pressed="false"]::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 1.8px;
  border-radius: 1px;
  background: currentColor;
  transform: rotate(-45deg);
}

.icon-btn--sm {
  width: 32px;
  height: 32px;
}

.icon-btn--sm .icon {
  width: 17px;
  height: 17px;
}

.badge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent-strong);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--bg-top);
}

.dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--critical);
  box-shadow: 0 0 0 2px var(--bg-top);
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.field__hint {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-3);
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--field);
  color: var(--ink);
}

select option {
  background: var(--bg-bottom);
  color: var(--ink);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 600;
}

.switch input {
  appearance: none;
  position: relative;
  width: 42px;
  height: 24px;
  margin: 0;
  flex: none;
  border-radius: 12px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  cursor: pointer;
  transition: background 0.2s;
}

.switch input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink);
  transition: transform 0.2s var(--ease);
}

.switch input:checked {
  background: var(--accent-strong);
}

.switch input:checked::after {
  transform: translateX(18px);
  background: #fff;
}

.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 8px 14px;
  border: 0;
  border-radius: 8px;
  background: var(--accent-strong);
  color: #fff;
  font-weight: 600;
  transform: translateY(-160%);
}

.skip-link:focus-visible {
  transform: none;
}

/* ------------------------------------------------------------------ splash & login */

.splash,
.login {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  padding: 16px;
}

.splash__text {
  margin: 0;
  color: var(--ink-3);
}

.login__card {
  display: grid;
  justify-items: center;
  gap: 14px;
  width: min(400px, 100%);
  padding: 32px 24px 26px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: color-mix(in srgb, var(--bg-bottom) 72%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.login__title {
  margin: 4px 0 0;
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.login__hint {
  margin: 0;
  text-align: center;
  color: var(--ink-3);
  font-size: 14px;
}

.login__field {
  width: 100%;
}

.login__msg {
  min-height: 1.4em;
  margin: 0;
  text-align: center;
  font-size: 14px;
}

/* ------------------------------------------------------------------ app shell & header */

.app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.topbar {
  position: relative;
  z-index: 20;
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-top) 74%, transparent);
  backdrop-filter: blur(14px) saturate(1.15);
}

.topbar__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-areas: "brand nav actions";
  align-items: center;
  gap: 12px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 10px 16px;
}

.brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand__home {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
  border-radius: 999px;
}

.brand__name {
  overflow: hidden;
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 360px;
  padding: 3px 10px 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-1);
  color: var(--ink-2);
  font-size: 12.5px;
  white-space: nowrap;
}

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

.pill__label {
  font-weight: 600;
  color: var(--ink);
}

.pill__text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill__text:empty {
  display: none;
}

.pill[data-state="idle"] .pill__dot {
  background: var(--good);
}

.pill[data-state="chat"] .pill__dot {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 1.4s ease-in-out infinite;
}

.pill[data-state="autonomy"] .pill__dot {
  background: var(--warning);
  box-shadow: 0 0 8px var(--warning);
  animation: pulse 1.8s ease-in-out infinite;
}

.pill[data-state="updating"] .pill__dot,
.pill[data-state="connecting"] .pill__dot {
  background: var(--info);
  animation: pulse 1.2s ease-in-out infinite;
}

.pill[data-state="reconnecting"] .pill__dot,
.pill[data-state="restarting"] .pill__dot,
.pill[data-state="offline"] .pill__dot {
  background: var(--serious);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.35;
    transform: scale(0.78);
  }
}

.nav {
  grid-area: nav;
  display: flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-1);
}

.nav__link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 15px;
  border-radius: 999px;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.nav__link .icon {
  width: 17px;
  height: 17px;
}

.nav__link:hover {
  color: var(--ink);
}

.nav__link[aria-current="page"] {
  background: var(--surface-3);
  color: var(--ink);
}

.actions {
  grid-area: actions;
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.main {
  position: relative;
  min-height: 0;
  outline: none;
}

.view {
  height: 100%;
  min-height: 0;
}

/* ------------------------------------------------------------------ hub */

.hub {
  overflow-y: auto;
}

.hub__inner {
  max-width: 980px;
  margin: 0 auto;
  padding: clamp(28px, 7vh, 72px) 16px 48px;
}

.hub__hello {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin-bottom: clamp(24px, 5vh, 40px);
  text-align: center;
}

.hub__title {
  margin: 10px 0 0;
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 500;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.hub__mood {
  margin: 0;
  color: var(--ink-3);
  font-style: italic;
}

.hub__cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 18px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 250px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  background: var(--surface-1);
  color: inherit;
  text-decoration: none;
  transition: transform 0.2s var(--ease), border-color 0.2s, background 0.2s;
}

.card:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  transform: translateY(-2px);
}

.card__icon {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--link);
}

.card__title {
  margin: 4px 0 0;
  font-size: 21px;
  font-weight: 650;
}

.card__link {
  color: inherit;
  text-decoration: none;
}

.card__link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.card__hint,
.card__preview {
  margin: 0;
  color: var(--ink-2);
}

.card__preview {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}

.card__preview strong {
  color: var(--ink);
}

.card__activity {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
}

.card__activity::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.4s ease-in-out infinite;
}

.card__activity[data-source="autonomy"]::before {
  background: var(--warning);
}

.card__cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: auto;
  color: var(--link);
  font-weight: 600;
}

.card__cta .icon {
  width: 16px;
  height: 16px;
}

.recent {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 2px;
  margin: 0 -8px;
  padding: 0;
  list-style: none;
}

.recent a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 7px 8px;
  border-radius: 8px;
  color: var(--ink-2);
  text-decoration: none;
}

.recent a:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.recent .icon {
  width: 18px;
  height: 18px;
  color: var(--ink-3);
}

.recent__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.recent__time {
  flex: none;
  font-size: 12.5px;
  color: var(--ink-3);
}

.recent__empty {
  padding: 7px 8px;
  color: var(--ink-3);
}

/* ------------------------------------------------------------------ chat */

.chat {
  position: relative;
  display: flex;
  flex-direction: column;
}

.chat__stage {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.chat__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.chat__inner {
  display: flex;
  flex-direction: column;
  max-width: 820px;
  margin: 0 auto;
  padding: 20px 16px 28px;
}

.chat__more {
  align-self: center;
  margin-bottom: 14px;
}

.chat__empty {
  margin: 18vh 0 0;
  text-align: center;
  color: var(--ink-3);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.msg {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  animation: rise 0.28s var(--ease) both;
}

.msg__body {
  min-width: 0;
  overflow-wrap: anywhere;
}

.msg--user {
  align-self: flex-end;
  align-items: flex-end;
  max-width: min(86%, 640px);
}

.msg--user .msg__body {
  padding: 10px 15px;
  border-radius: 18px 18px 6px 18px;
  background: var(--surface-3);
  white-space: pre-wrap;
}

.msg--assistant .msg__body,
.msg--proactive .msg__body {
  font-size: 16px;
  line-height: 1.68;
}

.msg--system {
  align-self: center;
  align-items: center;
  max-width: min(94%, 640px);
}

.msg--system .msg__body {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  background: var(--surface-1);
  color: var(--ink-2);
  font-size: 13.5px;
  white-space: pre-wrap;
}

.msg--system .msg__body .icon {
  width: 17px;
  height: 17px;
  margin-top: 2px;
  color: var(--info);
}

.msg--autonomy {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid color-mix(in srgb, var(--warning) 75%, transparent);
  border-radius: 6px 14px 14px 6px;
  background: var(--surface-1);
}

.msg--autonomy .msg__body {
  font-size: 14.5px;
  color: var(--ink-2);
}

.msg__label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.msg__label .icon {
  width: 15px;
  height: 15px;
}

.msg__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  color: var(--ink-3);
  font-size: 12px;
}

.msg__stop {
  font-weight: 600;
}

.day-sep {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 600;
}

.day-sep::before,
.day-sep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.jump {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transform: translateX(-50%);
}

.jump .icon {
  width: 16px;
  height: 16px;
}

.viewer-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-bottom) 80%, transparent);
  color: var(--ink-2);
  font-size: 13.5px;
  text-align: center;
}

.viewer-banner .icon {
  width: 17px;
  height: 17px;
  color: var(--info);
}

/* thinking, tool chips, live card */

.thinking {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  color: var(--ink-2);
  font-size: 13.5px;
}

.thinking > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  color: var(--ink-3);
  font-weight: 600;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.thinking > summary::-webkit-details-marker {
  display: none;
}

.thinking > summary .icon {
  width: 16px;
  height: 16px;
}

.thinking > summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: 2px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s;
}

.thinking[open] > summary::after {
  transform: rotate(45deg);
}

.thinking__body {
  max-height: 46vh;
  overflow-y: auto;
  padding: 2px 14px 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.thinking__body.is-plain,
.live__text.is-plain {
  white-space: pre-wrap;
}

.thinking__note,
.live__note {
  margin: 0;
  color: var(--ink-3);
  font-size: 12.5px;
}

/* inside a Thinking section: lined up with its text */
.thinking > .thinking__note,
.thinking > .live__note {
  padding: 0 14px 10px;
}

.thinking__note .btn {
  margin-left: 4px;
}

body.hide-thoughts .thinking {
  display: none;
}

.tools {
  display: grid;
  gap: 6px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 10px 3px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-1);
  color: var(--ink-2);
  font: 500 12.5px/1.4 var(--font-mono);
  cursor: pointer;
}

.chip:hover,
.chip[aria-expanded="true"] {
  background: var(--surface-3);
  color: var(--ink);
}

.chip__state {
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  flex: none;
}

.chip__state .icon {
  width: 14px;
  height: 14px;
  stroke-width: 2.4;
}

.chip[data-state="ok"] .chip__state {
  color: var(--good);
}

.chip[data-state="error"] {
  border-color: color-mix(in srgb, var(--critical) 55%, transparent);
}

.chip[data-state="error"] .chip__state {
  color: var(--critical);
}

.chip[data-state="running"] .chip__state::before {
  content: "";
  width: 11px;
  height: 11px;
  border: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.chip__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-detail {
  margin: 0;
  padding: 8px 10px;
  border-radius: var(--radius-s);
  background: var(--surface-1);
  color: var(--ink-2);
  font: 12.5px/1.5 var(--font-mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.live {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 38%, var(--border));
  border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  animation: rise 0.3s var(--ease) both;
}

.live--autonomy {
  border-color: color-mix(in srgb, var(--warning) 42%, var(--border));
  background: color-mix(in srgb, var(--warning) 6%, transparent);
}

.live__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  color: var(--ink-2);
  font-size: 13px;
}

.live__head strong {
  color: var(--ink);
  font-weight: 650;
}

.live__status {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink-3);
}

.live__dots {
  display: inline-flex;
  gap: 4px;
}

.live__dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

.live__dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.live__dots span:nth-child(3) {
  animation-delay: 0.3s;
}

.live--autonomy .live__dots span {
  background: var(--warning);
}

.live__text {
  font-size: 16px;
  line-height: 1.68;
  overflow-wrap: anywhere;
}

.live__text:empty {
  display: none;
}

.live__foot {
  color: var(--ink-3);
  font-size: 12px;
}

.live__foot:empty {
  display: none;
}

/* composer */

.composer {
  flex: none;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-bottom) 82%, transparent);
  backdrop-filter: blur(12px);
}

.composer__box {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  max-width: 820px;
  margin: 0 auto;
  padding: 5px 5px 5px 15px;
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  background: var(--field);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.composer__box:focus-within {
  border-color: color-mix(in srgb, var(--accent) 70%, var(--border-strong));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 24%, transparent);
}

.composer textarea {
  flex: 1;
  min-height: 38px;
  max-height: 40vh;
  padding: 8px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  line-height: 1.5;
  resize: none;
}

.composer textarea:focus-visible {
  outline: none;
}

.icon-btn--send {
  background: var(--accent-strong);
  color: #fff;
}

.icon-btn--send:hover {
  background: color-mix(in srgb, var(--accent-strong) 86%, white);
  color: #fff;
}

.icon-btn--stop {
  background: var(--surface-3);
  color: var(--ink);
}

.composer__info {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 14px;
  max-width: 820px;
  margin: 6px auto 0;
  padding: 0 6px;
  color: var(--ink-3);
  font-size: 12px;
}

#budget-line[data-level="warning"]::before,
#budget-line[data-level="critical"]::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--warning);
}

#budget-line[data-level="critical"]::before {
  background: var(--critical);
}

@media (hover: none) {
  .composer__keys {
    display: none;
  }
}

/* ------------------------------------------------------------------ markdown */

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

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

.md p,
.md ul,
.md ol,
.md pre,
.md blockquote {
  margin: 0 0 0.75em;
}

.md h1,
.md h2,
.md h3,
.md h4 {
  margin: 1.1em 0 0.45em;
  font-weight: 650;
}

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

.md h2 {
  font-size: 1.25em;
}

.md h3 {
  font-size: 1.1em;
}

.md h4 {
  font-size: 1em;
}

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

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

.md li > ul,
.md li > ol {
  margin: 0.25em 0 0;
}

.md a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: from-font;
  text-underline-offset: 2px;
}

.md code {
  padding: 0.12em 0.38em;
  border-radius: 5px;
  background: var(--surface-3);
  font-family: var(--font-mono);
  font-size: 0.88em;
  overflow-wrap: anywhere;
}

.md pre {
  overflow-x: auto;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 13.5px;
  line-height: 1.5;
}

.md pre code {
  padding: 0;
  background: none;
  font-size: inherit;
  white-space: pre;
  overflow-wrap: normal;
}

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

.md--doc {
  max-width: 820px;
  margin: 0 auto;
  font-size: 15.5px;
  line-height: 1.7;
}

/* ------------------------------------------------------------------ workspace */

.ws {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
}

.ws.is-dropping {
  outline: 2px dashed var(--accent);
  outline-offset: -6px;
}

.ws__tree {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-top) 32%, transparent);
}

.ws__tree-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 10px 6px 18px;
}

.ws__heading {
  margin: 0;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ws__note {
  margin: 0;
  padding: 8px 18px 14px;
  color: var(--ink-3);
  font-size: 12.5px;
}

.tree {
  flex: 1;
  overflow: auto;
  padding: 2px 8px 18px;
}

.tree ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tree ul ul {
  margin-left: 13px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

.tree__empty {
  margin: 8px 10px;
  color: var(--ink-3);
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 32px;
  padding: 4px 8px 4px 4px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.tree-row:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.tree-row[aria-current="true"] {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--ink);
}

.tree-row .icon {
  width: 17px;
  height: 17px;
  color: var(--ink-3);
}

.tree-row .chev {
  width: 14px;
  height: 14px;
  transition: transform 0.15s;
}

.tree-row[aria-expanded="true"] .chev {
  transform: rotate(90deg);
}

.tree-row__spacer {
  width: 14px;
  flex: none;
}

.tree-row__name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.ws__preview {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.ws__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.crumbs {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  min-width: 0;
  font-size: 14px;
}

.crumbs a,
.crumbs span[aria-current] {
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--ink-2);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.crumbs a:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.crumbs span[aria-current] {
  color: var(--ink);
  font-weight: 650;
}

.crumbs__sep {
  color: var(--ink-3);
}

.ws__tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ws__info {
  margin: 0;
  padding: 6px 16px;
  color: var(--ink-3);
  font-size: 12.5px;
}

.ws__info:empty {
  display: none;
}

.ws__body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px;
}

.ws__body--frame {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

/* Always above an agent-made page: it can draw anything, including a fake sign-in form. */
.preview-notice {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 6px 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--warning) 12%, var(--panel));
  color: var(--ink-2);
  font-size: 12.5px;
}

.preview-notice .icon {
  width: 16px;
  height: 16px;
  color: var(--warning);
}

.preview-frame {
  flex: 1;
  width: 100%;
  min-height: 320px;
  border: 0;
  background: #fff;
}

.preview-media {
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 100%;
}

.preview-img {
  display: block;
  max-width: 100%;
  max-height: 75vh;
  border-radius: var(--radius-s);
  background: repeating-conic-gradient(var(--surface-3) 0 25%, transparent 0 50%) 0 0 / 18px 18px;
}

.preview-media video,
.preview-media audio {
  max-width: 100%;
}

.preview-media video {
  max-height: 72vh;
  border-radius: var(--radius-s);
  background: #000;
}

.code-view {
  margin: 0;
  padding: 0;
  counter-reset: line;
  list-style: none;
  font: 13px/1.6 var(--font-mono);
}

.code-view li {
  position: relative;
  min-height: 1.6em;
  padding-left: 4.4em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.code-view li::before {
  content: counter(line);
  counter-increment: line;
  position: absolute;
  left: 0;
  width: 3.4em;
  color: var(--ink-3);
  text-align: right;
  user-select: none;
}

.listing {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.listing a {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink-2);
  text-decoration: none;
}

.listing a:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.listing .icon {
  color: var(--ink-3);
}

.listing__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.listing__size,
.listing__time {
  color: var(--ink-3);
  font-size: 12.5px;
  white-space: nowrap;
}

.site-callout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 48px 16px;
  color: var(--ink-3);
  text-align: center;
}

.empty .icon {
  width: 30px;
  height: 30px;
}

.empty p {
  max-width: 420px;
  margin: 0;
}

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

/* ------------------------------------------------------------------ drawer */

body.drawer-open .app {
  overflow: hidden;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.drawer__backdrop {
  position: absolute;
  inset: 0;
  background: rgb(0 0 0 / 0.45);
  animation: fade 0.2s both;
}

.drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: min(720px, 100vw);
  border-left: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
  animation: slide-in 0.26s var(--ease) both;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

@keyframes slide-in {
  from {
    transform: translateX(36px);
    opacity: 0;
  }
}

.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 12px 6px 20px;
}

.drawer__title {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
}

.tabs {
  display: flex;
  gap: 2px;
  padding: 0 12px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}

.tab {
  position: relative;
  padding: 10px 12px 11px;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
}

.tab:hover {
  color: var(--ink);
}

.tab[aria-selected="true"] {
  color: var(--ink);
}

.tab__count {
  color: var(--link);
}

.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  right: 10px;
  bottom: -1px;
  left: 10px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.tabpanel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 20px calc(32px + env(safe-area-inset-bottom));
}

/* A click into a panel focuses it (tabindex=0): no ring then, but keep the :focus-visible ring for keyboards. */
.tabpanel:focus:not(:focus-visible) {
  outline: none;
}

.loading {
  padding: 32px 0;
  color: var(--ink-3);
  text-align: center;
}

.section {
  margin: 0 0 28px;
}

.section__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.section__count {
  font-weight: 600;
  letter-spacing: 0;
}

.subhead {
  margin: 22px 0 10px;
  font-size: 15px;
  font-weight: 650;
}

.stack {
  display: grid;
  gap: 10px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.entry {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
}

.entry__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  color: var(--ink-3);
  font-size: 12.5px;
}

.entry__title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.entry__body {
  overflow-wrap: anywhere;
}

.entry__text {
  margin: 0;
  color: var(--ink-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tag {
  --tone: var(--ink-3);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.tag::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tone);
}

.tag[data-tone="accent"] {
  --tone: var(--accent);
}

.tag[data-tone="info"] {
  --tone: var(--info);
}

.tag[data-tone="good"] {
  --tone: var(--good);
}

.tag[data-tone="warning"] {
  --tone: var(--warning);
}

.tag[data-tone="serious"] {
  --tone: var(--serious);
}

.tag[data-tone="critical"] {
  --tone: var(--critical);
}

.memory {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

.memory:last-child {
  border-bottom: 0;
}

.memory__text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.memory__meta {
  color: var(--ink-3);
  font-size: 12px;
  white-space: nowrap;
}

.memory[data-archived="true"] .memory__text {
  color: var(--ink-3);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
  margin: 0;
}

.stat-grid div {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-1);
}

.stat-grid dt {
  color: var(--ink-3);
  font-size: 12px;
}

.stat-grid dd {
  margin: 2px 0 0;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.filter {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.filter[aria-pressed="true"] {
  border-color: transparent;
  background: var(--surface-3);
  color: var(--ink);
}

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

.confidence .meter {
  width: 120px;
}

.kpi .meter {
  margin-top: 4px;
}

.row select {
  flex: 1;
  width: auto;
  min-width: 0;
}

/* changes */

.proposal-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.proposal-row:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.proposal-row__title {
  font-weight: 650;
  overflow-wrap: anywhere;
}

.proposal-row__meta {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  color: var(--ink-3);
  font-size: 12.5px;
}

.proposal-row__tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.proposal__title {
  margin: 10px 0 8px;
  font-size: 19px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.banner .icon {
  margin-top: 1px;
}

.banner p {
  margin: 0;
}

.banner--critical {
  border-color: color-mix(in srgb, var(--critical) 70%, transparent);
  background: color-mix(in srgb, var(--critical) 13%, transparent);
}

.banner--critical .icon {
  color: var(--critical);
}

.banner--warning {
  border-color: color-mix(in srgb, var(--warning) 60%, transparent);
  background: color-mix(in srgb, var(--warning) 10%, transparent);
}

.banner--warning .icon {
  color: var(--warning);
}

.banner--info .icon {
  color: var(--info);
}

.badge-sensitive {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--danger-strong);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-sensitive .icon {
  width: 13px;
  height: 13px;
}

.file-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.file-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  font-size: 13.5px;
}

.file-list__path {
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}

.diff-file {
  margin: 12px 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.diff-file__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px;
}

.diff-file__path {
  font-family: var(--font-mono);
  font-weight: 650;
  overflow-wrap: anywhere;
}

.diff-file__counts {
  display: inline-flex;
  gap: 8px;
  font-family: var(--font-mono);
  font-weight: 650;
}

.charcount {
  color: var(--ink-3);
  font-size: 12px;
}

.charcount--warn {
  padding: 1px 8px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--critical) 22%, transparent);
  color: var(--ink);
  font-weight: 650;
}

.diff-lines {
  font: 12.5px/1.55 var(--font-mono);
}

.dl {
  display: grid;
  grid-template-columns: 3.3em 3.3em 1.5em minmax(0, 1fr);
}

.dl__no {
  padding-right: 0.6em;
  color: var(--ink-3);
  text-align: right;
  user-select: none;
}

.dl__mark {
  color: var(--ink-3);
  font-weight: 700;
  text-align: center;
  user-select: none;
}

.dl__text {
  min-width: 0;
  padding-right: 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.dl--add {
  background: color-mix(in srgb, var(--diff-add) 17%, transparent);
}

.dl--add .dl__mark {
  color: var(--diff-add);
}

.dl--del {
  background: color-mix(in srgb, var(--diff-del) 17%, transparent);
}

.dl--del .dl__mark {
  color: var(--diff-del);
}

.dl--hunk {
  background: color-mix(in srgb, var(--info) 10%, transparent);
  color: var(--ink-3);
}

.dl--meta {
  color: var(--ink-3);
  font-style: italic;
}

.cp {
  display: inline-block;
  margin: 0 1px;
  padding: 0 4px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--info) 22%, transparent);
  outline: 1px solid color-mix(in srgb, var(--info) 60%, transparent);
  color: var(--ink);
  font-size: 0.86em;
  line-height: 1.4;
  white-space: nowrap;
}

.cp--bidi,
.cp--invisible,
.cp--control {
  background: color-mix(in srgb, var(--critical) 34%, transparent);
  outline-color: var(--critical);
  font-weight: 700;
}

.decision {
  display: grid;
  gap: 12px;
  margin: 18px 0 8px;
  padding: 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.decision p {
  margin: 0;
}

.decision__digest {
  color: var(--ink-3);
  font: 12px var(--font-mono);
  overflow-wrap: anywhere;
}

.decision__note {
  color: var(--ink-2);
  font-size: 13.5px;
}

/* The SSH rollback command: easy to select and copy. */
.decision__note code,
.overlay__hint code,
.field__hint code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-3);
  font: 12px var(--font-mono);
  overflow-wrap: anywhere;
  user-select: all;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-weight: 600;
  cursor: pointer;
}

.check input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  flex: none;
  accent-color: var(--accent-strong);
}

.timeline {
  display: grid;
  gap: 0;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.timeline__step {
  position: relative;
  padding: 0 0 14px 26px;
}

.timeline__step::before {
  content: "";
  position: absolute;
  top: 5px;
  left: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ink-3);
}

.timeline__step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 18px;
  bottom: 2px;
  left: 8px;
  width: 2px;
  background: var(--border-strong);
}

.timeline__step[data-state="done"]::before {
  background: var(--good);
}

.timeline__step[data-state="failed"]::before {
  background: var(--critical);
}

.timeline__step[data-state="warning"]::before {
  background: var(--serious);
}

.timeline__step[data-state="current"]::before {
  background: var(--info);
  animation: pulse 1.2s ease-in-out infinite;
}

.timeline__label {
  font-weight: 650;
}

.timeline__when {
  margin-left: 8px;
  color: var(--ink-3);
  font-size: 12.5px;
}

.log {
  max-height: 320px;
  margin: 8px 0 0;
  overflow: auto;
  padding: 10px 12px;
  border-radius: var(--radius-s);
  background: var(--surface-2);
  font: 12px/1.5 var(--font-mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

details.more > summary {
  color: var(--ink-3);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

/* settings */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 14px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.form-error {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
}

.form-error:not(:empty)::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--critical);
}

.kv {
  display: grid;
  grid-template-columns: minmax(120px, auto) minmax(0, 1fr);
  gap: 6px 16px;
  margin: 0;
  font-size: 14px;
}

.kv dt {
  color: var(--ink-3);
}

.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.kpi {
  display: grid;
  gap: 4px;
  align-content: start;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
}

.kpi__label {
  color: var(--ink-3);
  font-size: 12.5px;
}

.kpi__value {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.kpi__sub {
  color: var(--ink-3);
  font-size: 12px;
}

.meter {
  --fill: var(--accent);
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: color-mix(in srgb, var(--fill) 20%, transparent);
}

.meter__fill {
  width: var(--pct, 0%);
  height: 100%;
  border-radius: 4px;
  background: var(--fill);
}

.meter[data-level="warning"] {
  --fill: var(--warning);
}

.meter[data-level="critical"] {
  --fill: var(--critical);
}

.chart {
  margin: 14px 0 0;
}

.chart__title {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 650;
}

.cols {
  position: relative;
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  align-items: end;
  gap: 4px;
  height: 128px;
  padding-top: 22px;
  border-bottom: 1px solid var(--border-strong);
}

.col {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 100%;
  border-radius: 6px 6px 0 0;
  outline-offset: 0;
}

.col__bar {
  width: min(24px, 70%);
  height: var(--h, 0%);
  min-height: 2px;
  border-radius: 4px 4px 0 0;
  background: var(--accent);
  transition: filter 0.15s;
}

.col:hover .col__bar,
.col:focus-visible .col__bar {
  filter: brightness(1.25);
}

.col__value {
  position: absolute;
  bottom: calc(var(--h, 0%) + 4px);
  color: var(--ink-2);
  font-size: 11px;
  white-space: nowrap;
}

.col__tip {
  position: absolute;
  bottom: calc(var(--h, 0%) + 6px);
  z-index: 2;
  padding: 5px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
}

.col__tip strong {
  display: block;
  font-size: 13px;
}

.col:hover .col__tip,
.col:focus-visible .col__tip {
  opacity: 1;
}

.col:hover .col__value,
.col:focus-visible .col__value {
  opacity: 0;
}

.cols__labels {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 4px;
  margin-top: 4px;
  color: var(--ink-3);
  font-size: 11px;
  text-align: center;
}

.table {
  width: 100%;
  margin-top: 8px;
  border-collapse: collapse;
  font-size: 13px;
}

.table th,
.table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.table td.num,
.table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.problems {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.problems li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-1);
  overflow-wrap: anywhere;
}

.problems li[data-level="error"] {
  border-color: color-mix(in srgb, var(--critical) 60%, transparent);
}

.problems li[data-level="error"] .icon {
  color: var(--critical);
}

.problems li[data-level="warning"] .icon {
  color: var(--warning);
}

.problems strong {
  margin-right: 6px;
}

.result {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 0 0;
  font-size: 13.5px;
  overflow-wrap: anywhere;
}

.result[data-ok="true"] .icon {
  color: var(--good);
}

.result[data-ok="false"] .icon {
  color: var(--critical);
}

/* ------------------------------------------------------------------ overlay, dialog, toasts */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
  background: color-mix(in srgb, var(--bg-top) 80%, transparent);
  backdrop-filter: blur(8px);
}

.overlay__card {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(460px, 100%);
  padding: 28px 24px 22px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
  text-align: center;
}

.overlay__title {
  margin: 6px 0 0;
  font-size: 20px;
}

.overlay__text,
.overlay__status,
.overlay__elapsed {
  margin: 0;
  color: var(--ink-2);
}

.overlay__status:empty,
.overlay__elapsed:empty {
  display: none;
}

.overlay__hint {
  margin: 0;
  color: var(--ink-3);
  font-size: 13px;
}

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

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--surface-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgb(0 0 0 / 0.5);
}

.dialog__form {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.dialog__title {
  margin: 0;
  font-size: 18px;
}

.dialog__text {
  margin: 0;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.dialog__text:empty {
  display: none;
}

.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.toasts {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 90;
  display: grid;
  gap: 8px;
  width: min(460px, calc(100vw - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  --tone: var(--info);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 8px 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 14px;
  pointer-events: auto;
  animation: rise 0.25s var(--ease) both;
}

.toast::before {
  content: "";
  align-self: stretch;
  width: 4px;
  flex: none;
  border-radius: 2px;
  background: var(--tone);
}

.toast[data-tone="ok"] {
  --tone: var(--good);
}

.toast[data-tone="warning"] {
  --tone: var(--warning);
}

.toast[data-tone="error"] {
  --tone: var(--critical);
}

.toast__text {
  flex: 1;
  margin: 2px 0;
  overflow-wrap: anywhere;
}

.toast__close {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
}

.toast__close:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.toast__close .icon {
  width: 16px;
  height: 16px;
}

/* ------------------------------------------------------------------ responsive */

@media (max-width: 760px) {
  .ws {
    grid-template-columns: minmax(0, 1fr);
  }

  .ws__tree {
    border-right: 0;
  }

  .ws[data-pane="tree"] .ws__preview,
  .ws[data-pane="preview"] .ws__tree {
    display: none;
  }

  .ws__bar {
    padding: 8px 12px;
  }

  .ws__body {
    padding: 12px;
  }

  .ws__body--frame {
    padding: 0;
  }

  .dl {
    grid-template-columns: 2.6em 2.6em 1.3em minmax(0, 1fr);
  }

  .tabpanel {
    padding: 16px 16px calc(28px + env(safe-area-inset-bottom));
  }
}

@media (min-width: 761px) {
  .ws__back {
    display: none;
  }
}

@media (max-width: 720px) {
  /* Phones: [orb + name | actions] over [nav | status pill]. */
  .topbar__row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "home actions"
      "nav status";
    gap: 8px 10px;
    padding: 8px 12px;
  }

  .brand {
    display: contents;
  }

  .brand__home {
    grid-area: home;
  }

  .brand .pill {
    grid-area: status;
    justify-self: end;
  }

  .nav {
    justify-self: stretch;
    min-width: 0;
  }

  .nav__link {
    flex: 1;
    justify-content: center;
    padding: 6px 10px;
  }

  .pill__text {
    display: none;
  }

  .brand__name {
    font-size: 16px;
  }

  .actions {
    gap: 0;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
  }

  .chat__inner {
    padding: 14px 12px 22px;
  }

  .msg--user {
    max-width: 92%;
  }

  .composer {
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  }

  /* At the bottom, toasts would cover Send and Stop. */
  .toasts {
    top: calc(8px + env(safe-area-inset-top));
    bottom: auto;
  }

  .hub__inner {
    padding-inline: 12px;
  }

  .card {
    min-height: 0;
    padding: 18px;
  }
}

@media (max-width: 420px) {
  .brand .pill {
    padding: 3px 8px;
  }

  .pill__label {
    max-width: 96px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .nav__link .icon {
    display: none;
  }

  .kv {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .kv dd {
    margin-bottom: 8px;
  }
}

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

@media (forced-colors: active) {
  .tag::before,
  .pill__dot,
  .meter__fill,
  .col__bar {
    forced-color-adjust: none;
  }

  .cp {
    outline: 1px solid CanvasText;
  }
}
