/*
 * chat.eaon.dev: Eaon's Chat in a browser.
 *
 * The tokens are the desktop app's (src/renderer/src/styles/tokens.css) with
 * the Cobalt theme: every surface, border and text tone is mixed from --bg,
 * --fg and --contrast, so the web chat re-tones exactly like the app does.
 * The layout follows the desktop Chat tab: a floating sidebar panel, one
 * centred conversation column, steps folded into a summary row, and the
 * composer with + at one end, send at the other, and what Eaon may do and
 * the model under it. On phones the sidebar becomes a drawer.
 */

:root {
  --bg: #ffffff;
  --fg: #1a1c1f;
  --accent: #0a84ff;
  --accent-fill: #006fe8;
  --on-accent: #ffffff;
  --brand: #0169cc;
  --contrast: 45;
  --u: calc(var(--contrast) * 0.055%);

  --canvas: var(--bg);
  --sidebar: color-mix(in srgb, var(--bg), var(--fg) calc(var(--u) * 1.1));
  --surface-1: color-mix(in srgb, var(--bg), var(--fg) calc(var(--u) * 1.5));
  --surface-2: color-mix(in srgb, var(--bg), var(--fg) calc(var(--u) * 2.4));
  --surface-3: color-mix(in srgb, var(--bg), #ffffff 65%);
  --menu-bg: color-mix(in srgb, var(--surface-3), transparent 18%);
  --toggle-off: color-mix(in srgb, var(--bg), var(--fg) 17%);

  --hover: color-mix(in srgb, var(--fg) 5%, transparent);
  --hover-strong: color-mix(in srgb, var(--fg) 7.8%, transparent);
  --active: color-mix(in srgb, var(--fg) 11%, transparent);
  --border: color-mix(in srgb, var(--fg) 11%, transparent);
  --border-soft: color-mix(in srgb, var(--fg) 7.8%, transparent);
  --border-strong: color-mix(in srgb, var(--fg) 17.8%, transparent);

  --text: var(--fg);
  --text-2: color-mix(in srgb, var(--fg), var(--bg) 34%);
  --text-3: color-mix(in srgb, var(--fg), var(--bg) 52%);
  --text-4: color-mix(in srgb, var(--fg), var(--bg) 66%);

  --danger: #e5342a;
  --danger-soft: rgba(229, 52, 42, 0.1);
  --link: color-mix(in srgb, var(--accent), #000000 18%);
  --send-bg: var(--fg);
  --send-fg: var(--bg);
  --code-bg: color-mix(in srgb, var(--bg), var(--fg) 4%);
  --focus-ring: color-mix(in srgb, var(--accent), transparent 10%);
  --scrollbar: color-mix(in srgb, var(--fg) 22%, transparent);
  --scrim: color-mix(in srgb, var(--fg) 28%, transparent);
  --shadow-ink: color-mix(in srgb, var(--fg), #000000 45%);
  --edge-light: inset 0 1px 0 color-mix(in srgb, #fff 85%, transparent);
  --shadow-menu: var(--edge-light), 0 0 0 0.5px color-mix(in srgb, var(--shadow-ink) 13%, transparent),
    0 18px 44px -10px color-mix(in srgb, var(--shadow-ink) 18%, transparent),
    0 4px 12px -3px color-mix(in srgb, var(--shadow-ink) 10%, transparent);
  --shadow-composer: var(--edge-light), 0 0 0 1px var(--border-soft), 0 10px 30px -18px rgb(0 0 0 / 0.35);

  --font-ui: ui-sans-serif, -apple-system, system-ui, 'Segoe UI', Helvetica, 'Apple Color Emoji', Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, monospace;
  --fs-base: 15px;
  --fs-sm: 14px;
  --fs-xs: 13px;
  --fs-xxs: 12px;
  --fs-title: 28px;

  --sidebar-w: 260px;
  --sidebar-gap: 8px;
  --column-w: 680px;
  --r-panel: 14px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 12px;
  --r-xl: 14px;
  --r-pill: 999px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --dur: 160ms;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #111111;
    --fg: #fcfcfc;
    --brand: #339cff;
    --contrast: 60;
    --canvas: color-mix(in srgb, var(--bg), #000000 22%);
    --sidebar: var(--bg);
    --surface-1: color-mix(in srgb, var(--bg), var(--fg) calc(var(--u) * 1.6));
    --surface-2: color-mix(in srgb, var(--bg), var(--fg) calc(var(--u) * 2.6));
    --surface-3: color-mix(in srgb, var(--bg), var(--fg) calc(var(--u) * 4.2));
    --menu-bg: color-mix(in srgb, var(--surface-3), transparent 24%);
    --toggle-off: color-mix(in srgb, var(--bg), var(--fg) 17.5%);
    --hover: color-mix(in srgb, var(--fg) 5.5%, transparent);
    --hover-strong: color-mix(in srgb, var(--fg) 9%, transparent);
    --active: color-mix(in srgb, var(--fg) 13%, transparent);
    --border: color-mix(in srgb, var(--bg), var(--fg) 8%);
    --border-soft: color-mix(in srgb, var(--fg) 6%, transparent);
    --border-strong: color-mix(in srgb, var(--fg) 14%, transparent);
    --text-2: color-mix(in srgb, var(--fg), var(--bg) 38%);
    --text-3: color-mix(in srgb, var(--fg), var(--bg) 58%);
    --text-4: color-mix(in srgb, var(--fg), var(--bg) 72%);
    --danger: #ff453a;
    --danger-soft: rgba(255, 69, 58, 0.14);
    --link: color-mix(in srgb, var(--accent), #ffffff 26%);
    --send-bg: color-mix(in srgb, var(--fg) 70%, var(--bg));
    --send-fg: color-mix(in srgb, var(--bg), var(--fg) 4%);
    --code-bg: color-mix(in srgb, var(--bg), #000000 22%);
    --scrollbar: color-mix(in srgb, var(--fg) 16%, transparent);
    --scrim: rgb(0 0 0 / 0.55);
    --shadow-ink: color-mix(in srgb, var(--bg), #000000 80%);
    --edge-light: inset 0 1px 0 color-mix(in srgb, #fff 7%, transparent);
    --shadow-menu: var(--edge-light), 0 0 0 0.5px color-mix(in srgb, var(--shadow-ink) 60%, transparent),
      0 18px 44px -10px color-mix(in srgb, var(--shadow-ink) 55%, transparent),
      0 4px 12px -3px color-mix(in srgb, var(--shadow-ink) 32%, transparent);
    --shadow-composer: var(--edge-light), 0 0 0 1px var(--border-soft), 0 10px 30px -18px rgb(0 0 0 / 0.55);
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --bg: #111111;
  --fg: #fcfcfc;
  --brand: #339cff;
  --contrast: 60;
  --canvas: color-mix(in srgb, var(--bg), #000000 22%);
  --sidebar: var(--bg);
  --surface-1: color-mix(in srgb, var(--bg), var(--fg) calc(var(--u) * 1.6));
  --surface-2: color-mix(in srgb, var(--bg), var(--fg) calc(var(--u) * 2.6));
  --surface-3: color-mix(in srgb, var(--bg), var(--fg) calc(var(--u) * 4.2));
  --menu-bg: color-mix(in srgb, var(--surface-3), transparent 24%);
  --toggle-off: color-mix(in srgb, var(--bg), var(--fg) 17.5%);
  --hover: color-mix(in srgb, var(--fg) 5.5%, transparent);
  --hover-strong: color-mix(in srgb, var(--fg) 9%, transparent);
  --active: color-mix(in srgb, var(--fg) 13%, transparent);
  --border: color-mix(in srgb, var(--bg), var(--fg) 8%);
  --border-soft: color-mix(in srgb, var(--fg) 6%, transparent);
  --border-strong: color-mix(in srgb, var(--fg) 14%, transparent);
  --text-2: color-mix(in srgb, var(--fg), var(--bg) 38%);
  --text-3: color-mix(in srgb, var(--fg), var(--bg) 58%);
  --text-4: color-mix(in srgb, var(--fg), var(--bg) 72%);
  --danger: #ff453a;
  --danger-soft: rgba(255, 69, 58, 0.14);
  --link: color-mix(in srgb, var(--accent), #ffffff 26%);
  --send-bg: color-mix(in srgb, var(--fg) 70%, var(--bg));
  --send-fg: color-mix(in srgb, var(--bg), var(--fg) 4%);
  --code-bg: color-mix(in srgb, var(--bg), #000000 22%);
  --scrollbar: color-mix(in srgb, var(--fg) 16%, transparent);
  --scrim: rgb(0 0 0 / 0.55);
  --shadow-ink: color-mix(in srgb, var(--bg), #000000 80%);
  --edge-light: inset 0 1px 0 color-mix(in srgb, #fff 7%, transparent);
  --shadow-menu: var(--edge-light), 0 0 0 0.5px color-mix(in srgb, var(--shadow-ink) 60%, transparent),
    0 18px 44px -10px color-mix(in srgb, var(--shadow-ink) 55%, transparent),
    0 4px 12px -3px color-mix(in srgb, var(--shadow-ink) 32%, transparent);
  --shadow-composer: var(--edge-light), 0 0 0 1px var(--border-soft), 0 10px 30px -18px rgb(0 0 0 / 0.55);
  color-scheme: dark;
}

/* ---------- Base ---------- */

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

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--canvas);
  color: var(--text);
  font: var(--fs-base) / 1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
}

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

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:disabled {
  cursor: default;
}

a {
  color: var(--link);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

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

[hidden] {
  display: none !important;
}

svg.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

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

.icon-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  color: var(--text-2);
  flex: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-btn:hover,
.icon-btn[aria-expanded='true'] {
  background: var(--hover);
  color: var(--text);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), filter var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.btn--primary {
  background: var(--accent-fill);
  color: var(--on-accent);
}
.btn--primary:hover {
  filter: brightness(1.08);
}
.btn--dark {
  background: var(--fg);
  color: var(--bg);
}
.btn--dark:hover {
  opacity: 0.88;
}
.btn--ghost {
  box-shadow: 0 0 0 1px var(--border);
  color: var(--text);
}
.btn--ghost:hover {
  background: var(--hover);
}
.btn--quiet {
  color: var(--text-2);
}
.btn--quiet:hover {
  background: var(--hover);
  color: var(--text);
}
.btn:disabled {
  opacity: 0.5;
}
.btn--wide {
  width: 100%;
  height: 42px;
  font-size: var(--fs-base);
}

/* A connector's icon on its tile, as the desktop Plugins page draws them. */
.tile {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #1d1d20;
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.06);
}
.tile img {
  width: 58%;
  height: 58%;
  object-fit: contain;
}
.tile svg.icon {
  width: 58%;
  height: 58%;
  stroke-width: 1.9;
}
.tile--lg {
  width: 42px;
  height: 42px;
  border-radius: 11px;
}
.tile--sm {
  width: 18px;
  height: 18px;
  border-radius: 5px;
}
.tile[data-tone='mail'] {
  background: #c5221f;
}
.tile[data-tone='calendar'] {
  background: #1a73e8;
}
.tile[data-tone='web'] {
  background: var(--accent-fill);
}

.spinner {
  width: 13px;
  height: 13px;
  flex: none;
  border-radius: 50%;
  border: 1.75px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: currentColor;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.shimmer {
  background: linear-gradient(90deg, var(--text-3) 0%, var(--text-3) 35%, var(--text) 50%, var(--text-3) 65%, var(--text-3) 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 1.8s linear infinite;
}
@keyframes shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: -150% 0;
  }
}

.switch {
  position: relative;
  width: 32px;
  height: 20px;
  flex: none;
  border-radius: var(--r-pill);
  background: var(--toggle-off, color-mix(in srgb, var(--bg), var(--fg) 17%));
  transition: background var(--dur) var(--ease);
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.25);
  transition: transform var(--dur) var(--ease);
}
[aria-checked='true'] > .switch,
.switch[aria-checked='true'] {
  background: var(--accent);
}
[aria-checked='true'] > .switch::after,
.switch[aria-checked='true']::after {
  transform: translateX(12px);
}

/* ---------- Shell ---------- */

.app {
  height: 100%;
  display: flex;
}

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  display: flex;
  flex-direction: column;
  margin: var(--sidebar-gap);
  margin-left: max(var(--sidebar-gap), env(safe-area-inset-left));
  padding: 6px 8px 8px;
  border-radius: var(--r-panel);
  background: var(--sidebar);
  box-shadow: 0 0 0 1px var(--border-soft);
  min-height: 0;
  transition: margin-left 240ms var(--ease), opacity 200ms var(--ease);
}
.app[data-sidebar='closed'] .sidebar {
  margin-left: calc((var(--sidebar-w) + var(--sidebar-gap)) * -1);
  opacity: 0;
}

.sidebar__head {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 40px;
  padding: 0 0 0 6px;
}
.sidebar__head .brand {
  margin-right: auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.brand:hover {
  text-decoration: none;
}
.brand__mark {
  width: 20px;
  height: 20px;
  fill: var(--brand);
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  margin: 4px 0 2px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  background: var(--hover);
  color: var(--text-3);
}
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: none;
  font-size: var(--fs-sm);
  color: var(--text);
}
.search input::placeholder {
  color: var(--text-3);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: var(--fs-sm);
  text-align: left;
  transition: background var(--dur) var(--ease);
}
.nav-item svg.icon {
  color: var(--text-2);
}
.nav-item:hover {
  background: var(--hover);
}
.nav-item[aria-current='page'] {
  background: var(--active);
}
.nav-item__kbd {
  margin-left: auto;
  font: inherit;
  font-size: var(--fs-xxs);
  color: var(--text-4);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.nav-item:hover .nav-item__kbd {
  opacity: 1;
}
.nav-item__count {
  margin-left: auto;
  font-size: var(--fs-xxs);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.history {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0 -4px;
  padding: 0 4px 10px;
}
.history__label {
  font-size: var(--fs-xs);
  color: var(--text-3);
  padding: 18px 10px 6px;
}
.history__item {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: var(--r-sm);
  transition: background var(--dur) var(--ease);
}
.history__item:hover,
.history__item:focus-within {
  background: var(--hover);
}
.history__item[aria-current='true'] {
  background: var(--active);
}
.history__open {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-align: left;
  font-size: var(--fs-sm);
  color: var(--text);
}
.history__open > span {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history__pin {
  width: 13px;
  height: 13px;
  color: var(--text-3);
}
.history__busy {
  margin-right: 10px;
  color: var(--text-3);
}
.history__more {
  flex: none;
  width: 26px;
  height: 26px;
  margin-right: 4px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--text-3);
  opacity: 0;
}
.history__more svg.icon {
  width: 16px;
  height: 16px;
}
.history__item:hover .history__more,
.history__item:focus-within .history__more,
.history__item[aria-current='true'] .history__more,
.history__more[aria-expanded='true'] {
  opacity: 1;
}
.history__more:hover,
.history__more[aria-expanded='true'] {
  color: var(--text);
  background: var(--hover-strong);
}
.history__rename {
  height: 32px;
  margin: 1px 0;
  flex: 1;
}
.history__empty {
  color: var(--text-3);
  font-size: var(--fs-xs);
  padding: 2px 10px;
}

.sidebar__foot {
  position: relative;
  padding-top: 6px;
}

.account {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 8px;
  border-radius: var(--r-md);
  text-align: left;
  transition: background var(--dur) var(--ease);
}
.account:hover,
.account[aria-expanded='true'] {
  background: var(--hover);
}
.avatar {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--accent-fill);
  color: var(--on-accent);
  font-size: 13px;
  font-weight: 600;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.account__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.account__name {
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account__sub {
  font-size: var(--fs-xxs);
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account svg.icon {
  color: var(--text-3);
  width: 16px;
  height: 16px;
}

.signin-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: var(--r-lg);
  background: var(--surface-2);
}
.signin-card p {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--text-2);
  line-height: 1.4;
}
.signin-card .btn {
  height: 32px;
}
.foot-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 10px;
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.foot-note svg.icon {
  width: 15px;
  height: 15px;
}

.scrim,
.sidebar__close {
  display: none;
}

/* ---------- Menus ---------- */

.menu {
  position: absolute;
  z-index: 30;
  min-width: 240px;
  max-width: min(360px, calc(100vw - 24px));
  max-height: min(440px, 70vh);
  overflow-y: auto;
  padding: 6px;
  border-radius: var(--r-xl);
  background: var(--menu-bg, var(--surface-3));
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  backdrop-filter: blur(28px) saturate(180%);
  box-shadow: var(--shadow-menu);
  animation: menu-in 160ms var(--ease) both;
}
.menu--down {
  top: calc(100% + 6px);
  left: 0;
  transform-origin: top left;
}
.menu--up {
  bottom: calc(100% + 6px);
  left: 0;
  transform-origin: bottom left;
}
.menu--right {
  left: auto;
  right: 0;
  transform-origin: bottom right;
}
.menu__head {
  font-size: var(--fs-xxs);
  color: var(--text-3);
  padding: 6px 10px 4px;
}
.menu__sep {
  height: 1px;
  margin: 6px 4px;
  background: var(--border-soft);
}
.menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  text-align: left;
  font-size: var(--fs-sm);
}
.menu__item:hover,
.menu__item:focus-visible {
  background: var(--hover);
}
.menu__item > svg.icon {
  color: var(--text-2);
}
.menu__item--danger,
.menu__item--danger > svg.icon {
  color: var(--danger);
}
.menu__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.menu__name {
  font-weight: 500;
}
.menu__desc {
  font-size: var(--fs-xxs);
  color: var(--text-3);
}
.menu__check {
  color: var(--accent);
  visibility: hidden;
}
.menu__item[aria-checked='true'] .menu__check,
.menu__item[aria-selected='true'] .menu__check {
  visibility: visible;
}
.menu .theme-switch {
  margin: 4px 4px 2px;
}

@keyframes menu-in {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
}

.theme-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 3px;
  border-radius: var(--r-md);
  background: var(--hover);
}
.theme-switch button {
  height: 28px;
  border-radius: 7px;
  font-size: var(--fs-xxs);
  color: var(--text-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.theme-switch button[aria-checked='true'] {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: 0 0 0 0.5px var(--border), 0 1px 2px rgb(0 0 0 / 0.08);
}

/* ---------- Main column ---------- */

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

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  height: calc(56px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(14px, env(safe-area-inset-right)) 0 14px;
}
.topbar__title {
  min-width: 0;
  margin: 0 2px 0 6px;
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar__spacer {
  flex: 1;
}
.topbar .icon-btn[data-show='closed'] {
  display: none;
}
.app[data-sidebar='closed'] .topbar .icon-btn[data-show='closed'] {
  display: grid;
}
.topbar__menu {
  position: relative;
}

.preview-pill {
  font-size: var(--fs-xxs);
  color: var(--text-2);
  background: var(--hover);
  border-radius: var(--r-pill);
  padding: 4px 10px;
  white-space: nowrap;
}
.preview-pill b {
  color: var(--text);
  font-weight: 600;
}

/* ---------- Home ---------- */

.home {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 0 16px 9vh;
}
.home__mark {
  width: 40px;
  height: 40px;
  fill: var(--brand);
}
.home__title {
  margin: 0;
  max-width: 100%;
  text-align: center;
  text-wrap: balance;
  font-size: clamp(25px, 3.2vw, 31px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.home__slot {
  order: 2;
  width: var(--column-w);
  max-width: 100%;
}
.chips {
  order: 3;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: var(--column-w);
  max-width: 100%;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px 0 10px;
  border-radius: var(--r-pill);
  box-shadow: 0 0 0 1px var(--border);
  color: var(--text-2);
  font-size: var(--fs-xs);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.chip:hover {
  background: var(--hover);
  color: var(--text);
}
.chip .tile {
  width: 20px;
  height: 20px;
  border-radius: 6px;
}

/* ---------- Thread ---------- */

.thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.thread__inner {
  width: var(--column-w);
  max-width: calc(100% - 32px);
  margin: 0 auto;
  padding: 8px 0 32px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.msg-row {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.msg-row--user {
  align-items: flex-end;
}
.msg--user {
  max-width: 82%;
  background: var(--surface-2);
  border-radius: 20px;
  padding: 10px 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

/* An assistant turn: how long it worked, its steps folded into one row, the
   actions it took, and the reply. */
.turn {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.turn__worked {
  font-size: var(--fs-sm);
  color: var(--text-3);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-soft);
}
.turn__live {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  font-size: var(--fs-sm);
  color: var(--text-3);
}
.turn__live .live-text {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.steps-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  max-width: 100%;
  color: var(--text-2);
  font-size: var(--fs-sm);
  text-align: left;
  border-radius: 6px;
  padding: 1px 2px 1px 0;
}
.steps-row:hover {
  color: var(--text);
}
.steps-row > svg.icon:first-child {
  width: 17px;
  height: 17px;
  color: var(--text-3);
}
.steps-row__chev {
  width: 15px !important;
  height: 15px !important;
  color: var(--text-3);
  transition: transform var(--dur) var(--ease);
}
.steps-row[aria-expanded='true'] .steps-row__chev {
  transform: rotate(90deg);
}
.steps {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: -4px 0 0 8px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
}

.step {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.step__head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  max-width: 100%;
  color: var(--text-2);
  font-size: var(--fs-sm);
  text-align: left;
  border-radius: 6px;
}
button.step__head:hover {
  color: var(--text);
}
.step__head > svg.icon {
  width: 16px;
  height: 16px;
  color: var(--text-3);
}
.step__label {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.step__target {
  min-width: 0;
  max-width: 50%;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-2);
  background: var(--code-bg);
  box-shadow: 0 0 0 1px var(--border-soft);
  border-radius: 6px;
  padding: 1px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.step__status {
  flex: none;
  display: inline-flex;
  color: var(--text-3);
}
.step__status svg.icon {
  width: 15px;
  height: 15px;
}
.step__status--error {
  color: var(--danger);
}
.step__chev {
  width: 14px !important;
  height: 14px !important;
  color: var(--text-4) !important;
  transition: transform var(--dur) var(--ease);
}
.step__head[aria-expanded='true'] .step__chev {
  transform: rotate(90deg);
}
.step__body {
  margin: 4px 0 8px;
}
.step__detail {
  margin: 0;
  max-height: 260px;
  overflow: auto;
  padding: 10px 12px;
  border-radius: var(--r-lg);
  box-shadow: 0 0 0 1px var(--border);
  font: 12.5px / 1.55 var(--font-mono);
  color: var(--text-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.step__detail b {
  color: var(--text);
  font-weight: 500;
}

/* Thinking: one row per step, each titled with a summary of what it was
   about; the full text is under each. */
.think-step {
  display: flex;
  flex-direction: column;
}
.think-step .step__head {
  min-height: 28px;
}
.think-step .step__head > .dot {
  width: 16px;
  display: grid;
  place-items: center;
}
.think-step .step__head > .dot::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-4);
}
.think-step__text {
  margin: 2px 0 8px 24px;
  color: var(--text-3);
  font-size: var(--fs-sm);
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* An action Eaon took (anything that changes something), shown in the turn
   rather than folded away, as the desktop shows edits and commands. */
.action {
  display: flex;
  flex-direction: column;
}
.action > .step__head {
  color: var(--text);
}

.msg--assistant {
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.msg__actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: -4px;
  min-height: 30px;
  color: var(--text-3);
}
.msg-row--user .msg__actions {
  margin-top: 4px;
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.msg-row--user:hover .msg__actions,
.msg-row--user .msg__actions:focus-within {
  opacity: 1;
}
.msg__actions .icon-btn {
  width: 30px;
  height: 30px;
  color: var(--text-3);
}
.msg__actions .icon-btn svg.icon {
  width: 16px;
  height: 16px;
}
.msg__actions .icon-btn:hover {
  color: var(--text);
}
.msg__actions .icon-btn[aria-pressed='true'] {
  color: var(--text);
}
.msg__meta {
  font-size: var(--fs-xxs);
  color: var(--text-4);
  margin-left: 10px;
  font-variant-numeric: tabular-nums;
}

.msg__error {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-size: var(--fs-sm);
  line-height: 1.45;
}
.msg__error button {
  flex: none;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.msg__stopped {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

/* A connector the request needs, offered right where it's needed. */
.inline-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-xl);
  background: var(--surface-1);
  box-shadow: 0 0 0 1px var(--border-soft);
}
.inline-card__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.35;
}
.inline-card__title {
  font-size: var(--fs-sm);
  font-weight: 500;
}
.inline-card__sub {
  font-size: var(--fs-xs);
  color: var(--text-2);
}
.inline-card .btn {
  flex: none;
}
.inline-card__mark {
  width: 26px;
  height: 26px;
  flex: none;
  fill: var(--brand);
}

/* ---------- Markdown ---------- */

.md > :first-child {
  margin-top: 0;
}
.md > :last-child {
  margin-bottom: 0;
}
.md p,
.md ul,
.md ol,
.md blockquote,
.md .code,
.md .table-wrap,
.md hr {
  margin: 0 0 14px;
}
.md h2,
.md h3,
.md h4,
.md h5,
.md h6 {
  margin: 22px 0 8px;
  line-height: 1.3;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.md h2 {
  font-size: 20px;
  font-weight: 600;
}
.md h3 {
  font-size: 17px;
  font-weight: 600;
}
.md h4,
.md h5,
.md h6 {
  font-size: var(--fs-base);
  font-weight: 600;
}
.md ul,
.md ol {
  padding-left: 22px;
}
.md li {
  margin: 5px 0;
}
.md li > p {
  margin: 0 0 6px;
}
.md li > p:last-child {
  margin-bottom: 0;
}
.md li > ul,
.md li > ol {
  margin: 4px 0 0;
}
.md li::marker {
  color: var(--text-3);
}
.md .task {
  list-style: none;
  margin-left: -20px;
}
.md .task input {
  margin: 0 8px 0 0;
  vertical-align: -1px;
  accent-color: var(--accent);
}
.md strong {
  font-weight: 600;
}
.md blockquote {
  padding-left: 14px;
  border-left: 3px solid var(--border-strong);
  color: var(--text-2);
}
.md hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}
.md code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--code-bg);
  box-shadow: 0 0 0 1px var(--border-soft);
  border-radius: 5px;
  padding: 1px 5px;
}
.md .code {
  border-radius: var(--r-lg);
  background: var(--code-bg);
  box-shadow: 0 0 0 1px var(--border-soft);
  overflow: hidden;
}
.code__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 34px;
  padding: 0 6px 0 14px;
  font-size: var(--fs-xxs);
  color: var(--text-3);
  border-bottom: 1px solid var(--border-soft);
}
.code__copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 8px;
  border-radius: 6px;
  color: var(--text-3);
  font-size: var(--fs-xxs);
}
.code__copy svg.icon {
  width: 14px;
  height: 14px;
}
.code__copy:hover {
  background: var(--hover);
  color: var(--text);
}
.md pre {
  margin: 0;
  padding: 12px 14px 14px;
  overflow-x: auto;
  line-height: 1.55;
}
.md pre code {
  background: none;
  box-shadow: none;
  padding: 0;
  font-size: 13px;
  white-space: pre;
  overflow-wrap: normal;
}
.md .table-wrap {
  overflow-x: auto;
  border-radius: var(--r-md);
  box-shadow: 0 0 0 1px var(--border);
}
.md table {
  border-collapse: collapse;
  width: 100%;
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
.md th,
.md td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}
.md th {
  font-weight: 600;
  background: var(--surface-1);
}
.md tr:last-child td {
  border-bottom: 0;
}
.md a {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--link), transparent 55%);
  text-underline-offset: 2px;
}
.md .cursor {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 4px;
  border-radius: 50%;
  background: var(--text);
  vertical-align: 1px;
  animation: blink 1s ease-in-out infinite;
}
@keyframes blink {
  50% {
    opacity: 0.2;
  }
}

/* ---------- Composer ---------- */

.dock {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 16px max(6px, env(safe-area-inset-bottom));
}
.composer-wrap {
  width: var(--column-w);
  max-width: 100%;
  position: relative;
}

.composer__above {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.composer__above:empty {
  display: none;
}
.active-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 6px 0 7px;
  border-radius: var(--r-pill);
  box-shadow: 0 0 0 1px var(--border);
  background: var(--canvas);
  color: var(--text-2);
  font-size: var(--fs-xs);
}
.tool-chip .tile {
  width: 20px;
  height: 20px;
  border-radius: 6px;
}
.tool-chip button {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-3);
}
.tool-chip button:hover {
  background: var(--hover);
  color: var(--text);
}
.tool-chip button svg.icon {
  width: 13px;
  height: 13px;
}

.composer {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 5px;
  border-radius: 25px;
  background: var(--surface-2);
  box-shadow: var(--shadow-composer);
  transition: box-shadow var(--dur) var(--ease);
}
.composer:focus-within {
  box-shadow: var(--edge-light), 0 0 0 1px var(--border-strong), 0 10px 30px -18px rgb(0 0 0 / 0.45);
}
.composer__round {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-2);
  background: color-mix(in srgb, var(--fg) 6%, transparent);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.composer__round:hover,
.composer__round[aria-expanded='true'] {
  background: color-mix(in srgb, var(--fg) 11%, transparent);
  color: var(--text);
}
.composer__input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: none;
  resize: none;
  min-height: 36px;
  max-height: 240px;
  padding: 8px 4px 7px;
  font-size: var(--fs-base);
  line-height: 1.45;
  color: var(--text);
  overflow-y: auto;
  scrollbar-width: none;
}
.composer__input::placeholder {
  color: var(--text-3);
}
.send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--send-bg);
  color: var(--send-fg);
  flex: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.send svg.icon {
  stroke-width: 2.2;
}
.send:disabled {
  opacity: 0.3;
}
.send:not(:disabled):active {
  transform: scale(0.94);
}

/* Under the box: what Eaon may do on the left, the model on the right. */
.composer__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 38px;
  padding: 0 6px;
}
.meta-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: var(--fs-sm);
  max-width: 100%;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.meta-btn span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.meta-btn:hover,
.meta-btn[aria-expanded='true'] {
  background: var(--hover);
  color: var(--text);
}
.meta-btn svg.icon {
  width: 16px;
  height: 16px;
}
.meta-btn .chev {
  width: 14px;
  height: 14px;
  color: var(--text-3);
}
.meta-slot {
  position: relative;
  display: flex;
  flex: 0 1 auto;
  min-width: 0;
}

.fine {
  margin: 0 0 4px;
  font-size: var(--fs-xxs);
  color: var(--text-4);
  text-align: center;
  text-wrap: balance;
}

/* Approval, docked above the composer so a run never waits unseen. */
.approval {
  padding: 14px;
  border-radius: 18px;
  background: var(--surface-3);
  box-shadow: var(--shadow-menu);
  animation: menu-in 200ms var(--ease) both;
}
.approval__head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.approval__title {
  font-size: var(--fs-base);
  font-weight: 600;
  line-height: 1.3;
}
.approval__sub {
  font-size: var(--fs-xs);
  color: var(--text-2);
}
.approval__fields {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: var(--r-lg);
  background: var(--canvas);
  box-shadow: 0 0 0 1px var(--border-soft);
  font-size: var(--fs-sm);
}
.approval__fields dt {
  color: var(--text-3);
}
.approval__fields dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}
.approval__fields dd.long {
  grid-column: 1 / -1;
  white-space: pre-wrap;
  max-height: 150px;
  overflow: auto;
  color: var(--text-2);
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
}
.approval__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}
.approval__note {
  margin-right: auto;
  font-size: var(--fs-xxs);
  color: var(--text-3);
}

.human {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-xs);
  color: var(--text-2);
}

/* ---------- Connectors page ---------- */

.page {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.page__inner {
  width: 760px;
  max-width: calc(100% - 32px);
  margin: 0 auto;
  padding: 8px 0 48px;
}
.page__title {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.page__sub {
  margin: 6px 0 0;
  color: var(--text-2);
  font-size: var(--fs-sm);
  max-width: 60ch;
}
.page__tools {
  display: flex;
  gap: 8px;
  margin: 18px 0 6px;
}
.page__tools .search {
  flex: 1;
  margin: 0;
  height: 38px;
  border-radius: var(--r-md);
}
.section-label {
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin: 22px 0 8px 2px;
}
.plugin-list {
  border-radius: 16px;
  background: var(--surface-1);
  box-shadow: 0 0 0 1px var(--border-soft);
  overflow: hidden;
}
.plugin {
  border-bottom: 1px solid var(--border-soft);
}
.plugin:last-child {
  border-bottom: 0;
}
.plugin__row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
}
.plugin__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.35;
}
.plugin__name {
  font-weight: 600;
  font-size: var(--fs-base);
  display: flex;
  align-items: center;
  gap: 8px;
}
.plugin__summary {
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.plugin__state {
  font-size: var(--fs-xs);
  color: var(--text-3);
  white-space: nowrap;
}
.plugin__state--on {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
}
.plugin__state--on::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #30a46c;
}
.plugin__account {
  font-size: var(--fs-xxs);
  color: var(--text-3);
  font-weight: 400;
}
.plugin__form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 16px 16px 72px;
}
.plugin__form p {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--text-2);
}
.plugin__form .field {
  display: flex;
  gap: 8px;
}
.input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 12px;
  border: 0;
  outline: none;
  border-radius: var(--r-md);
  background: var(--canvas);
  box-shadow: 0 0 0 1px var(--border);
  font-size: var(--fs-sm);
}
.input:focus {
  box-shadow: 0 0 0 1.5px var(--accent);
}
.empty-note {
  padding: 18px 16px;
  color: var(--text-3);
  font-size: var(--fs-sm);
}

/* ---------- Sign in ---------- */

.modal {
  position: fixed;
  z-index: 60;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--scrim);
  animation: fade-in 160ms var(--ease) both;
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
.dialog {
  position: relative;
  width: 380px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 30px 26px 22px;
  border-radius: 22px;
  background: var(--surface-3);
  box-shadow: var(--shadow-menu);
  text-align: center;
  animation: menu-in 200ms var(--ease) both;
}
.dialog__mark {
  width: 36px;
  height: 36px;
  fill: var(--brand);
  margin-bottom: 4px;
}
.dialog h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.dialog p {
  margin: 0 0 10px;
  color: var(--text-2);
  font-size: var(--fs-sm);
  text-wrap: balance;
}
.dialog .btn--wide + .btn--wide {
  margin-top: 0;
}
.dialog__fine {
  margin-top: 8px !important;
  font-size: var(--fs-xxs) !important;
  color: var(--text-3) !important;
}
.dialog__close {
  position: absolute;
  top: 10px;
  right: 10px;
}

.toast {
  position: fixed;
  z-index: 70;
  left: 50%;
  bottom: calc(110px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: var(--r-pill);
  background: var(--fg);
  color: var(--bg);
  font-size: var(--fs-xs);
  font-weight: 500;
  box-shadow: var(--shadow-menu);
  animation: toast-in 200ms var(--ease) both;
  max-width: calc(100vw - 32px);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 6px);
  }
}

/* ---------- Floating menus, buttons ---------- */

.menu--floating {
  position: fixed;
  z-index: 70;
  min-width: 200px;
}
.btn--danger {
  color: var(--danger);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--danger) 35%, transparent);
}
.btn--danger:hover {
  background: var(--danger-soft);
}
.btn[data-armed] {
  background: var(--danger);
  color: #fff;
  box-shadow: none;
}
.menu__item[data-armed] {
  background: var(--danger-soft);
}
.btn svg.icon {
  width: 16px;
  height: 16px;
}

.workspace-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 1px var(--border-soft);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.workspace-btn:hover,
.workspace-btn[aria-pressed='true'] {
  background: var(--hover);
  color: var(--text);
}

/* ---------- Files and artifacts in the thread ---------- */

.artifact-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(100%, 440px);
  margin: 10px 0;
  padding: 10px 14px 10px 10px;
  border-radius: var(--r-lg);
  background: var(--surface-1);
  box-shadow: 0 0 0 1px var(--border-soft);
  text-align: left;
  transition: box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}
.artifact-card:hover {
  box-shadow: 0 0 0 1px var(--border-strong);
}
.artifact-card[aria-pressed='true'] {
  box-shadow: 0 0 0 1.5px var(--accent);
}
.artifact-card__icon {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-2);
}
.artifact-card__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.35;
}
.artifact-card__title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.artifact-card__sub {
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.artifact-card__open {
  font-size: var(--fs-xs);
  color: var(--text-2);
}

.msg__files {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: 6px;
}
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 260px;
  height: 30px;
  padding: 0 10px;
  border-radius: var(--r-md);
  background: var(--surface-1);
  box-shadow: 0 0 0 1px var(--border-soft);
  font-size: var(--fs-xs);
  color: var(--text-2);
}
.file-chip span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-chip svg.icon,
.tool-chip--file > svg.icon {
  width: 15px;
  height: 15px;
}
.file-chip:hover {
  color: var(--text);
}
.tool-chip--file {
  padding-left: 10px;
  max-width: 260px;
}
.tool-chip__name {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drop {
  position: absolute;
  z-index: 25;
  inset: 8px;
  display: grid;
  place-items: center;
  border-radius: var(--r-panel);
  background: color-mix(in srgb, var(--canvas) 82%, transparent);
  box-shadow: inset 0 0 0 2px var(--accent);
  pointer-events: none;
}
.drop__inner {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}

/* ---------- The side panel ---------- */

.panel {
  flex: none;
  width: clamp(360px, 44vw, 760px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin: var(--sidebar-gap);
  margin-left: 0;
  margin-right: max(var(--sidebar-gap), env(safe-area-inset-right));
  border-radius: var(--r-panel);
  background: var(--sidebar);
  box-shadow: 0 0 0 1px var(--border-soft);
  overflow: hidden;
}
.app[data-panel='wide'] .panel {
  width: clamp(420px, 62vw, 1200px);
}
.panel__top {
  flex: none;
}
.panel__head {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 48px;
  padding: 0 8px 0 10px;
}
.panel__tabs {
  display: flex;
  gap: 2px;
}
.panel__tabs button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.panel__tabs button span {
  font-size: var(--fs-xxs);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.panel__tabs button[aria-selected='true'] {
  background: var(--active);
  color: var(--text);
}
.panel__tabs button:disabled {
  opacity: 0.45;
}
.panel__bar {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 4px 8px 4px 12px;
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
}
.panel__name {
  min-width: 0;
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.panel__pick {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 50%;
}
.panel__pick select {
  appearance: none;
  min-width: 0;
  max-width: 100%;
  height: 30px;
  padding: 0 28px 0 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--hover);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-overflow: ellipsis;
  cursor: pointer;
}
.panel__pick svg.icon {
  position: absolute;
  right: 7px;
  width: 15px;
  height: 15px;
  pointer-events: none;
  color: var(--text-3);
}
.versions {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
}
.versions .icon-btn {
  width: 26px;
  height: 26px;
}
.versions .icon-btn:disabled {
  opacity: 0.35;
}
.versions__label {
  font-size: var(--fs-xxs);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  padding: 0 2px;
}
.segmented {
  display: inline-flex;
  padding: 2px;
  border-radius: var(--r-pill);
  background: var(--hover);
}
.segmented button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  color: var(--text-2);
}
.segmented button[aria-checked='true'] {
  background: var(--canvas);
  color: var(--text);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.12), 0 0 0 0.5px var(--border);
}
.segmented--sm button {
  height: 26px;
  padding: 0 10px;
}
.segmented svg.icon {
  width: 15px;
  height: 15px;
}
.panel__error {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 14px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: var(--fs-xs);
}
.panel__error span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.panel__error .btn {
  height: 30px;
  color: var(--text);
  flex: none;
}
.panel__body {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.panel__frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
.panel__doc {
  padding: 20px 24px 40px;
  max-width: 760px;
}
.panel__code {
  margin: 0;
  min-height: 100%;
  padding: 16px 18px 40px;
  background: var(--code-bg);
  font: 12.5px/1.6 var(--font-mono);
  white-space: pre;
  tab-size: 2;
}
.file-list {
  padding: 6px;
}
.file-row {
  display: flex;
  align-items: center;
  border-radius: var(--r-sm);
}
.file-row:hover {
  background: var(--hover);
}
.file-row__open {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 10px;
  text-align: left;
  font-size: var(--fs-sm);
}
.file-row__open svg.icon {
  color: var(--text-3);
}
.file-row__name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.file-row__size {
  font-size: var(--fs-xxs);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* ---------- Settings ---------- */

.settings-list {
  border-radius: 16px;
  background: var(--surface-1);
  box-shadow: 0 0 0 1px var(--border-soft);
}
.setting {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.setting:last-child {
  border-bottom: 0;
}
.setting__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.4;
}
.setting__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}
.setting__title svg.icon {
  width: 16px;
  height: 16px;
  color: var(--text-2);
}
.setting__title .tile {
  width: 20px;
  height: 20px;
}
.setting__desc {
  font-size: var(--fs-xs);
  color: var(--text-2);
}
.setting__control {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.setting--stack {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.setting--stack .input {
  flex: none;
}
.textarea {
  height: auto;
  min-height: 110px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.5;
}
.setting__count {
  align-self: flex-end;
  font-size: var(--fs-xxs);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.switch-btn {
  display: inline-flex;
  padding: 4px;
  margin: -4px;
  border-radius: var(--r-pill);
}
.settings-list .theme-switch {
  margin: 0;
  min-width: 210px;
  border-radius: var(--r-pill);
}
.settings-list .theme-switch button {
  height: 28px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
}
.keys {
  display: grid;
  grid-template-columns: auto auto;
  gap: 4px 14px;
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--text-2);
}
.keys dd {
  margin: 0;
  text-align: right;
}
kbd {
  font: inherit;
  font-size: var(--fs-xxs);
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--hover-strong);
  color: var(--text-2);
}
.page__fine {
  margin: 14px 2px 0;
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.plugin--off .plugin__row > .tile {
  opacity: 0.55;
}
.plugin__note {
  margin-top: 2px;
  font-size: var(--fs-xxs);
  color: var(--text-3);
}

/* ---------- Artifacts gallery ---------- */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 22px;
}
.gallery__card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 8px 12px;
  border-radius: 16px;
  background: var(--surface-1);
  box-shadow: 0 0 0 1px var(--border-soft);
  text-align: left;
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.gallery__card:hover {
  box-shadow: 0 0 0 1px var(--border-strong);
}
.gallery__thumb {
  position: relative;
  display: grid;
  place-items: center;
  height: 110px;
  margin-bottom: 8px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-3);
}
.gallery__thumb svg.icon {
  width: 30px;
  height: 30px;
  stroke-width: 1.4;
}
.gallery__kind {
  position: absolute;
  left: 8px;
  bottom: 8px;
  font-size: var(--fs-xxs);
  color: var(--text-2);
  padding: 1px 8px;
  border-radius: var(--r-pill);
  background: var(--canvas);
}
.gallery__title,
.gallery__chat {
  padding: 0 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gallery__title {
  font-weight: 600;
}
.gallery__chat {
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 28px;
  padding: 40px 16px;
  border-radius: 16px;
  background: var(--surface-1);
  box-shadow: 0 0 0 1px var(--border-soft);
  color: var(--text-3);
}
.empty-state p {
  margin: 0;
}
.empty-state > svg.icon {
  width: 30px;
  height: 30px;
  stroke-width: 1.4;
}

/* ---------- Desktop-only touches ---------- */

@media (min-width: 861px) {
  .home__body {
    display: contents;
  }
  .home .composer {
    flex-wrap: wrap;
    padding: 8px;
    border-radius: 22px;
  }
  .home .composer__input {
    order: -1;
    flex-basis: 100%;
    min-height: 64px;
    padding: 8px 8px 6px;
  }
  .home .composer .send {
    margin-left: auto;
  }
}

/* ---------- Phones and narrow windows ---------- */

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    z-index: 40;
    inset: 0 auto 0 0;
    width: min(300px, 86vw);
    margin: 0;
    border-radius: 0 var(--r-panel) var(--r-panel) 0;
    padding-top: max(6px, env(safe-area-inset-top));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    transform: translateX(-102%);
    transition: transform 260ms var(--ease);
    box-shadow: var(--shadow-menu);
  }
  .app[data-drawer='open'] .sidebar {
    transform: none;
  }
  .app[data-sidebar='closed'] .sidebar {
    margin-left: 0;
    opacity: 1;
  }
  .scrim {
    display: block;
    position: fixed;
    z-index: 35;
    inset: 0;
    background: var(--scrim);
    opacity: 0;
    pointer-events: none;
    transition: opacity 260ms var(--ease);
  }
  .app[data-drawer='open'] .scrim {
    opacity: 1;
    pointer-events: auto;
  }
  .topbar .icon-btn[data-show='closed'],
  .app[data-sidebar='closed'] .topbar .icon-btn[data-show='closed'] {
    display: grid;
  }
  .topbar {
    padding-left: 8px;
    padding-right: max(8px, env(safe-area-inset-right));
  }
  .sidebar__collapse {
    display: none;
  }
  .sidebar__close {
    display: grid;
  }
  .home {
    justify-content: flex-end;
    padding-bottom: 6px;
  }
  .home__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
  }
  .chips {
    order: 2;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    margin: 0 -16px;
    padding: 2px 16px;
    width: auto;
    max-width: none;
    align-self: stretch;
    scrollbar-width: none;
  }
  .chip {
    flex: none;
  }
  .home__slot {
    order: 3;
  }
  .composer__input {
    font-size: 16px;
  }
  .msg--user {
    max-width: 88%;
  }
  .plugin__form {
    padding-left: 16px;
  }
  .plugin__row {
    gap: 12px;
    padding: 12px 14px;
  }
  .step__target {
    max-width: 45%;
  }
  .inline-card {
    flex-wrap: wrap;
  }
  .inline-card .btn {
    margin-left: 42px;
  }
}

@media (max-width: 420px) {
  .preview-pill span {
    display: none;
  }
  .plugin__state {
    display: none;
  }
}

/* Touch screens keep :hover after a tap; only real pointers get hover fills. */
@media (hover: none) {
  .icon-btn:hover:not([aria-expanded='true']),
  .nav-item:hover,
  .chip:hover,
  .meta-btn:hover:not([aria-expanded='true']),
  .composer__round:hover:not([aria-expanded='true']) {
    background: none;
  }
  .composer__round:hover:not([aria-expanded='true']) {
    background: color-mix(in srgb, var(--fg) 6%, transparent);
  }
}

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

/* ---------- The panel and settings on narrow screens ---------- */

@media (max-width: 1100px) and (min-width: 861px) {
  .app[data-panel='open'] .sidebar,
  .app[data-panel='wide'] .sidebar {
    margin-left: calc((var(--sidebar-w) + var(--sidebar-gap)) * -1);
    opacity: 0;
  }
  .app[data-panel='open'] .topbar .icon-btn[data-show='closed'],
  .app[data-panel='wide'] .topbar .icon-btn[data-show='closed'] {
    display: grid;
  }
}

@media (max-width: 860px) {
  .panel,
  .app[data-panel='wide'] .panel {
    position: fixed;
    z-index: 45;
    inset: 0;
    width: auto;
    margin: 0;
    border-radius: 0;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .panel__wide {
    display: none;
  }
  .setting {
    flex-wrap: wrap;
  }
  .setting__control {
    flex: 1 1 100%;
    justify-content: flex-start;
  }
  .setting__control:has(.switch-btn) {
    flex: none;
  }
  .history__more {
    opacity: 1;
  }
  .nav-item__kbd {
    display: none;
  }
}
