/* Klod chat — Claude-like layout, light cream palette */

/* Defensive defaults — SVG never balloons even if a rule below is missed */
.chat-body svg { width: 1em; height: 1em; flex-shrink: 0; }
.chat-body button { font: inherit; color: inherit; background: transparent; border: 0; cursor: pointer; }

.chat-body {
  background: var(--bg);
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: 280px 1fr;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  overflow: hidden;
  transition: grid-template-columns 260ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Sidebar ─── */
.chat-side {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 14px 10px 12px;
  gap: 4px;
  height: 100vh;
  height: 100dvh;
  /* No overflow here — would clip popouts (profile menu, language submenu).
     The only growable child is .chat-side__history which has its own overflow-y. */
  font-size: 14px;
  transition: padding 260ms cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-side__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 6px;
  margin-bottom: 6px;
}
.chat-side__wordmark {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 540;
  letter-spacing: -0.018em;
  color: var(--text);
  text-decoration: none;
  line-height: 1;
  padding: 4px 2px;
}
.chat-side__logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 540;
  letter-spacing: -0.018em;
  line-height: 1;
}
.chat-side__mark { width: 22px; height: 22px; display: block; flex-shrink: 0; pointer-events: none; }
.chat-side__collapse {
  width: 28px; height: 28px;
  border-radius: 6px;
  color: var(--text-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, color 120ms ease;
}
.chat-side__collapse:hover { background: var(--hover-bg); color: var(--text); }

.chat-side__new {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text);
  text-align: left;
  transition: background 120ms ease;
  margin-bottom: 6px;
}
.chat-side__new:hover { background: var(--hover-bg); }
.chat-side__new svg { width: 20px; height: 20px; color: var(--text-soft); }

.chat-side__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chat-side__item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 14.5px;
  text-decoration: none;
  color: var(--text);
  transition: background 120ms ease;
  white-space: nowrap;
}
.chat-side__item:hover { background: var(--hover-bg); }
.chat-side__item.is-active { background: rgba(31, 30, 28, 0.10); font-weight: 500; }
.chat-side__item svg { width: 20px; height: 20px; color: var(--text-soft); }

/* Header icon buttons (search + collapse) */
.chat-side__head-actions { display: inline-flex; align-items: center; gap: 2px; }
.chat-side__icon-btn {
  width: 28px; height: 28px;
  border-radius: 7px;
  color: var(--text-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  transition: background 120ms ease, color 120ms ease;
}
.chat-side__icon-btn:hover { background: var(--hover-bg); color: var(--text); }

/* "Products" group + section labels — claude.ai uses calm normal-case labels */
.chat-side__group { display: flex; flex-direction: column; gap: 2px; margin-top: 12px; }
.chat-side__group-label {
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-muted);
  padding: 8px 12px 4px;
}

/* Lab/beta badge on a product row (e.g. Design) */
.chat-side__lab {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.chat-side__lab svg { width: 14px; height: 14px; }

/* "Recents" header row with a sort/filter button */
.chat-side__recents-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-right: 4px;
}
.chat-side__recents-head .chat-side__group-label { padding-bottom: 2px; }
.chat-side__recents-filter { width: 26px; height: 26px; color: var(--text-muted); }

.chat-side__more {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding: 9px 12px;
  font-size: 13.5px;
  color: var(--text-soft);
  background: transparent;
  border-radius: 10px;
  transition: background 120ms ease, color 120ms ease;
  margin-top: 6px;
  text-align: left;
}
.chat-side__more:hover { background: var(--hover-bg); color: var(--text); }
.chat-side__more svg { transition: transform 160ms ease; }
.chat-side__more[aria-expanded="true"] svg { transform: rotate(180deg); }

.chat-side__placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text-muted);
  padding: 28px 10px;
  text-align: center;
}

/* ─── Chat history list in sidebar ─── */
.chat-side__history {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
  margin-top: 2px;
  padding-right: 2px;
  min-height: 0;
  /* claude.ai: no visible scrollbar in the recents list (overlay-style) */
  scrollbar-width: none;
}
.chat-side__history::-webkit-scrollbar { display: none; }
.chat-side__history-label {
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 8px 10px 6px;
}

.chat-side__chat {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: 9px;
  transition: background 120ms ease;
}
.chat-side__chat:hover { background: var(--hover-bg); }
.chat-side__chat.is-active { background: var(--hover-bg); }
.chat-side__chat.is-active .chat-side__chat-link { font-weight: 500; }

.chat-side__chat-link {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-side__chat-kebab {
  width: 26px;
  height: 26px;
  margin-right: 4px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-soft);
  background: transparent;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, background 120ms ease, color 120ms ease;
}
.chat-side__chat:hover .chat-side__chat-kebab,
.chat-side__chat.is-active .chat-side__chat-kebab {
  opacity: 1;
  pointer-events: auto;
}
.chat-side__chat-kebab:hover {
  background: rgba(31, 30, 28, 0.08);
  color: var(--text);
}
:root[data-theme="dark"] .chat-side__chat-kebab:hover {
  background: rgba(245, 242, 234, 0.10);
}

.chat-side__chat-menu {
  position: absolute;
  top: calc(100% + 2px);
  right: 4px;
  min-width: 160px;
  background: var(--card-bg);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 4px;
  display: none;
  flex-direction: column;
  gap: 1px;
  box-shadow: 0 18px 48px -22px rgba(0, 0, 0, 0.40);
  z-index: 30;
}
.chat-side__chat-menu.is-open { display: flex; }
.chat-side__chat-menuitem {
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--font-sans);
  font-size: 13.5px;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--text);
  background: transparent;
  transition: background 120ms ease;
  cursor: pointer;
}
.chat-side__chat-menuitem:hover { background: var(--hover-bg); }
.chat-side__chat-menuitem.is-danger { color: #C75A4D; }
.chat-side__chat-menuitem.is-danger:hover { background: rgba(199, 90, 77, 0.10); }

/* Collapsed-sidebar: hide history (kebab menus would overflow anyway) */
.chat-side.is-collapsed .chat-side__history,
.chat-side.is-collapsed .chat-side__history-label,
.chat-side.is-collapsed .chat-side__chat {
  display: none;
}

.chat-side__foot {
  position: relative;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: auto;
}
/* "Get the app" download icon — sits between the user name and the caret,
   like claude.ai's footer. Absolutely positioned over the trigger row. */
.chat-side__dl {
  position: absolute;
  right: 32px;
  bottom: 9px;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-soft);
  z-index: 2;
  transition: background 120ms ease, color 120ms ease;
}
.chat-side__dl:hover { background: var(--hover-bg); color: var(--text); }
.chat-side__user {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  transition: background 120ms ease;
}
.chat-side__user:hover { background: var(--hover-bg); }
.chat-side__avatar {
  width: 30px; height: 30px;
  border-radius: 999px;
  background: var(--accent);
  color: #FBF4EE;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13.5px;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.chat-side__userblock {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.chat-side__username {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-side__plan {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-side__usercaret { color: var(--text-muted); flex-shrink: 0; }

.chat-side__menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 18px 48px -22px rgba(31, 30, 28, 0.32);
  z-index: 10;
}
.chat-side__menu.is-open { display: flex; }

.chat-side__menumail {
  font-size: 12.5px;
  color: var(--text-muted);
  padding: 8px 12px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-side__menugroup {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.chat-side__menusep {
  height: 1px;
  background: var(--border);
  margin: 4px 6px;
}

.chat-side__menuitem {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--text);
  text-decoration: none;
  background: transparent;
  transition: background 120ms ease;
}
.chat-side__menuitem:hover { background: rgba(31, 30, 28, 0.05); }
.chat-side__menuitem svg { color: var(--text-soft); flex-shrink: 0; }
.chat-side__menulabel { flex: 1; }
.chat-side__menukbd {
  font-family: var(--font-sans);
  font-size: 11.5px;
  color: var(--text-muted);
  background: rgba(31, 30, 28, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.chat-side__menucaret {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 160ms ease;
}
.chat-side__menuitem--toggle[aria-expanded="true"] .chat-side__menucaret {
  transform: rotate(90deg);
}

/* Language submenu — flies out to the side of the profile menu */
.chat-side__menu-langwrap {
  position: relative;
}
.chat-side__submenu {
  position: absolute;
  left: calc(100% + 6px);
  top: 0;
  min-width: 180px;
  background: var(--card-bg);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  box-shadow: 0 18px 48px -22px rgba(0, 0, 0, 0.40);
  z-index: 50;
}
.chat-side__submenu[hidden] { display: none; }
.chat-side__menuitem--sub {
  padding: 8px 12px;
  font-size: 14px;
  justify-content: space-between;
}
.chat-side__menuitem--sub .chat-side__menucheck {
  color: var(--text);
  opacity: 0;
  flex-shrink: 0;
  margin-left: auto;
}
.chat-side__menuitem--sub.is-active .chat-side__menucheck {
  opacity: 1;
}
.chat-side__menuitem--sub.is-active .chat-side__menulabel {
  font-weight: 500;
}

/* Topbar plan badge — only shown for Free users, centered in topbar */
.chat-topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.chat-topbar__spacer { grid-column: 1; }
.chat-topbar__plan {
  grid-column: 2;
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: var(--hover-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease;
}
/* HTML `hidden` attribute is just display:none from the user-agent stylesheet —
   any author-set display value (inline-flex above) wins. Re-assert display:none
   for the hidden state so applyPlanBadge() actually hides the upsell on paid
   plans. */
.chat-topbar__plan[hidden] {
  display: none;
}
.chat-topbar__plan:hover {
  background: var(--card-bg);
  border-color: var(--border-strong);
}
.chat-topbar__plan-name {
  color: var(--text-soft);
  font-weight: 500;
}
.chat-topbar__plan-sep {
  color: var(--text-muted);
}
.chat-topbar__plan-cta {
  color: var(--accent);
  font-weight: 500;
  transition: color 120ms ease;
}
.chat-topbar__plan:hover .chat-topbar__plan-cta {
  color: var(--text);
}
.chat-topbar__avatar {
  grid-column: 3;
  justify-self: end;
}

/* ─── Main column ───
   Flex column with the composer pinned at the bottom. The middle row
   is occupied by either chat-hub (empty state) or chat-stream (conversation),
   never both — toggling the `hidden` attribute swaps them. */
.chat-main {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}
.chat-topbar { flex: 0 0 auto; }
.chat-hub { flex: 0 0 auto; min-height: 0; }
.chat-stream { flex: 1 1 0; min-height: 0; }

/* Empty/home state: greeting + composer + chips form ONE group sitting
   together in the upper-middle (like claude.ai), instead of the greeting
   floating mid-screen and the composer pinned to the floor.
   `.chat-stream` is [hidden] here, so the only flex children below the
   topbar are .chat-hub and .chat-bottom. A fixed top offset on the hub
   places the cluster, `margin-bottom:auto` on the composer dumps the
   leftover space at the floor — the topbar stays pinned at the very top.
   In conversation state #hub is hidden → this selector stops matching →
   the composer pins to the bottom as usual. */
.chat-main:has(#hub:not([hidden])) .chat-hub {
  margin-top: clamp(48px, 25vh, 260px);
  padding-bottom: 12px;
}
.chat-main:has(#hub:not([hidden])) .chat-bottom { margin-bottom: auto; }
.chat-bottom {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 24px 18px;
  gap: 14px;
}
.chat-bottom .chat-composer { width: 100%; max-width: 680px; }
.chat-bottom .chat-chips { width: 100%; max-width: 680px; justify-content: center; }
/* Empty state: chips below composer; conversation state: chips hidden. */
.chat-bottom .chat-chips[hidden] { display: none; }

.chat-topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 14px 22px 0;
}
.chat-topbar__spacer { flex: 1; }
.chat-topbar__avatar {
  width: 32px; height: 32px;
  border-radius: 999px;
  background: var(--accent);
  color: #FBF4EE;
  /* Hidden on desktop — the sidebar already has the same profile widget.
     Shown on mobile (≤880px) because there it doubles as the drawer trigger. */
  display: none;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: filter 120ms ease;
}
.chat-topbar__avatar:hover { filter: brightness(0.95); }

/* Conversation title at the top — clicking it renames the chat */
.chat-topbar__title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-soft);
  white-space: nowrap;
  max-width: 42%;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 120ms ease, color 120ms ease;
}
.chat-topbar__title:hover { background: var(--hover-bg); color: var(--text); }
.chat-topbar__title > span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-topbar__title svg { flex-shrink: 0; color: var(--text-muted); }
.chat-topbar__title[hidden] { display: none; }

/* Share button (conversation state only) */
.chat-topbar__share {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  background: transparent;
  transition: background 120ms ease;
}
.chat-topbar__share:hover { background: var(--hover-bg); }
.chat-topbar__share[hidden] { display: none; }

/* "Klod is AI and can make mistakes" footer under the composer */
.chat-disclaimer {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* Inbox / notifications icon at the top-right (claude.ai parity, data-soon) */
.chat-topbar__inbox {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--text-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, color 120ms ease;
}
.chat-topbar__inbox:hover { background: var(--hover-bg); color: var(--text); }
@media (max-width: 880px) {
  .chat-topbar__avatar { display: inline-flex; }
}

/* Hamburger menu button (mobile only — hidden by default, shown via @media) */
.chat-topbar__menu {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 8px;
  color: var(--text-soft);
  flex-shrink: 0;
  transition: background 120ms ease, color 120ms ease;
}
.chat-topbar__menu:hover { background: var(--hover-bg); color: var(--text); }
.chat-topbar__menu svg { width: 22px; height: 22px; }

/* Backdrop for mobile sidebar drawer */
.chat-side-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}
.chat-side-backdrop.is-open { opacity: 1; pointer-events: auto; }
.chat-side-backdrop[hidden] { display: block; }
:root[data-theme="dark"] .chat-side-backdrop { background: rgba(0, 0, 0, 0.6); }

/* Central hub — grid with optical-center inner block */
.chat-hub {
  display: grid;
  place-items: center;
  padding: 0 24px;
  overflow: hidden;
}
.chat-hub[hidden] { display: none; }
.chat-hub__inner {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  margin-top: 0;
}

.chat-hello {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}
.chat-hello__mark { width: 44px; height: 44px; display: block; flex-shrink: 0; pointer-events: none; }
.chat-hello__spark { flex-shrink: 0; display: block; }
.chat-hello__text {
  font-family: var(--font-serif);
  font-size: clamp(32px, 3.4vw, 42px);
  font-weight: 460;
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 0;
  color: var(--text);
}

.chat-composer {
  width: 100%;
  max-width: 680px;
  background: var(--card-bg);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 12px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 1px 0 rgba(31, 30, 28, 0.02), 0 16px 40px -28px rgba(31, 30, 28, 0.14);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.chat-composer:focus-within {
  border-color: var(--text);
  box-shadow: 0 1px 0 rgba(31, 30, 28, 0.02), 0 20px 50px -28px rgba(31, 30, 28, 0.18);
}
.chat-composer__input {
  width: 100%;
  background: transparent;
  border: 0;
  resize: none;
  outline: none;
  /* claude.ai composer input is sans regardless of the chat-font setting
     (the setting still applies to rendered messages) */
  font-family: var(--font-sans);
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--text);
  padding: 6px 4px;
  min-height: 28px;
  max-height: 220px;
}
.chat-composer__input::placeholder { color: var(--text-muted); }

.chat-composer__bar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
}
.chat-composer__right { margin-left: auto; }

/* Web-search toggle (globe). ON = coral. */
.chat-composer__web[aria-checked="true"] {
  color: var(--accent);
  background: var(--accent-soft);
}
.chat-composer__web[aria-checked="true"]:hover:not(:disabled) {
  color: var(--accent);
  background: var(--accent-soft);
  filter: brightness(1.05);
}
.chat-composer__btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  color: var(--text-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  transition: background 120ms ease, color 120ms ease;
}
.chat-composer__btn:hover:not(:disabled) { background: var(--hover-bg); color: var(--text); }
.chat-composer__btn:disabled { opacity: 0.45; cursor: not-allowed; }

.chat-composer__right { display: inline-flex; align-items: center; gap: 8px; }

/* ─── "+" attach menu (upload / screenshot / GitHub) ─── */
.chat-composer__plus-wrap { position: relative; }
.chat-composer__plus[aria-expanded="true"] { background: var(--hover-bg); color: var(--text); }
.chat-composer__plus-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 230px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.10);
  padding: 6px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.chat-composer__plus-menu[hidden] { display: none; }
:root[data-theme="dark"] .chat-composer__plus-menu {
  background: #383836;
  border-color: rgba(255,255,255,0.10);
  box-shadow: 0 8px 32px rgba(0,0,0,0.45), 0 2px 8px rgba(0,0,0,0.25);
}
.plus-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text);
  text-align: left;
  transition: background 120ms ease;
}
.plus-menu__item:hover { background: var(--hover-bg); }
.plus-menu__item svg { color: var(--text-soft); flex-shrink: 0; }

.chat-composer__model-wrap { position: relative; }

.chat-composer__model {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-soft);
  background: transparent;
  transition: background 120ms ease, color 120ms ease;
  /* «Opus 4.8» ломался на две строки на 390px, когда composer тесный */
  white-space: nowrap;
  flex-shrink: 0;
}
.chat-composer__model:hover { background: var(--hover-bg); color: var(--text); }
.chat-composer__model[aria-expanded="true"] { background: var(--hover-bg); color: var(--text); }
.chat-composer__model-effort-badge {
  font-size: 13.5px;
  font-weight: 400;
  color: var(--text-muted);
}

/* ─── Model dropdown ─── */
.chat-composer__model-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  min-width: 260px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.10);
  padding: 6px;
  z-index: 40;
  flex-direction: column;
  gap: 1px;
}
:root[data-theme="dark"] .chat-composer__model-menu {
  background: #383836;
  border-color: rgba(255,255,255,0.10);
  box-shadow: 0 8px 32px rgba(0,0,0,0.45), 0 2px 8px rgba(0,0,0,0.25);
}
.chat-composer__model-menu.is-open { display: flex; }

.model-menu__sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.model-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: background 100ms ease;
  width: 100%;
}
.model-option:hover { background: var(--hover-bg); }
.model-option.is-disabled { opacity: 0.45; cursor: not-allowed; }
.model-option.is-disabled:hover { background: transparent; }

.model-option__body { flex: 1; min-width: 0; }
.model-option__name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.2;
}
.model-option__desc {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 2px;
  line-height: 1.3;
}
.model-option__check {
  flex-shrink: 0;
  color: #4A9EFF;
  opacity: 0;
  transition: opacity 100ms ease;
}
.model-option.is-selected .model-option__check { opacity: 1; }

/* Effort / More models rows */
.model-option--row .model-option__name { font-weight: 400; }
.model-option__row-right {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-soft);
  font-size: 13px;
  flex-shrink: 0;
}

/* ─── Effort submenu (floats to the right of model menu) ─── */
.effort-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  right: calc(100% + 6px); /* right of model-wrap */
  width: 240px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.10);
  padding: 12px 8px 8px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
:root[data-theme="dark"] .effort-menu {
  background: #383836;
  border-color: rgba(255,255,255,0.10);
  box-shadow: 0 8px 32px rgba(0,0,0,0.45), 0 2px 8px rgba(0,0,0,0.25);
}
.effort-menu[hidden] { display: none; }

.effort-menu__hint {
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.45;
  margin: 0 4px 10px;
  padding: 0;
}
.effort-menu__options {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.effort-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 100ms ease;
}
.effort-option:hover { background: var(--hover-bg); }
.effort-option__name {
  flex: 1;
  font-size: 13.5px;
  font-weight: 400;
  color: var(--text);
}
.effort-option__tag {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-right: 4px;
}
.effort-option__check {
  flex-shrink: 0;
  color: #4A9EFF;
  opacity: 0;
  transition: opacity 100ms ease;
}
.effort-option.is-selected .effort-option__check { opacity: 1; }

.effort-menu__sep {
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}
.effort-menu__thinking {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
}
.effort-menu__thinking-body { flex: 1; }
.effort-menu__thinking-label {
  display: block;
  font-size: 13.5px;
  font-weight: 400;
  color: var(--text);
}
.effort-menu__thinking-desc {
  display: block;
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 2px;
}

/* iOS-style toggle */
.effort-toggle {
  flex-shrink: 0;
  width: 42px;
  height: 26px;
  border-radius: 999px;
  background: var(--border-strong);
  position: relative;
  transition: background 200ms ease;
  cursor: pointer;
}
.effort-toggle[aria-checked="true"] { background: #4A9EFF; }
.effort-toggle__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform 200ms ease;
}
.effort-toggle[aria-checked="true"] .effort-toggle__thumb {
  transform: translateX(16px);
}

/* ─── Markdown rendering for assistant messages ─── */
.chat-msg__body p { margin: 0 0 0.85em; line-height: 1.65; }
.chat-msg__body p:last-child { margin-bottom: 0; }
.chat-msg__body ul:last-child,
.chat-msg__body ol:last-child { margin-bottom: 0; }
.chat-msg__body h1, .chat-msg__body h2, .chat-msg__body h3 {
  margin: 1.2em 0 0.5em;
  font-family: var(--font-serif);
  font-weight: 540;
  line-height: 1.25;
}
.chat-msg__body h1 { font-size: 1.5em; }
.chat-msg__body h2 { font-size: 1.3em; }
.chat-msg__body h3 { font-size: 1.13em; }
.chat-msg__body ul, .chat-msg__body ol { margin: 0.15em 0 0.85em 1.45em; padding: 0; }
.chat-msg__body li { margin-bottom: 0.35em; line-height: 1.6; }
.chat-msg__body li:last-child { margin-bottom: 0; }
.chat-msg__body strong { font-weight: 600; }
.chat-msg__body hr {
  border: 0;
  height: 1px;
  background: var(--border);
  margin: 1.1em 0;
}
.chat-msg__body em { font-style: italic; }
.chat-msg__body a { color: var(--accent, #d97757); text-decoration: underline; }
.chat-msg__body code {
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  font-size: 0.92em;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(31, 30, 28, 0.08);
}

/* Code block (artifact) */
.code-block {
  position: relative;
  margin: 0.9em 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(31, 30, 28, 0.03);
  overflow: hidden;
}
.code-block__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  background: rgba(31, 30, 28, 0.05);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-soft);
}
.code-block__lang { font-family: 'JetBrains Mono', monospace; text-transform: lowercase; }
.code-block__actions { display: flex; gap: 4px; }
.code-block__btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-soft);
  background: transparent;
  transition: background 120ms ease, color 120ms ease;
  cursor: pointer;
}
.code-block__btn:hover { background: var(--hover-bg); color: var(--text); }
.code-block__btn svg { width: 13px; height: 13px; }
.code-block pre {
  margin: 0;
  padding: 12px;
  overflow-x: auto;
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}
.code-block code { background: transparent; padding: 0; border-radius: 0; }
/* Dark theme: claude.ai code blocks sit a step DARKER than the page bg
   (the light-theme rgba() tints above are invisible on dark). */
:root[data-theme="dark"] .code-block {
  background: #1F1E1D;
  border-color: rgba(245, 242, 234, 0.08);
}
:root[data-theme="dark"] .code-block__head {
  background: #1A1918;
  border-bottom-color: rgba(245, 242, 234, 0.08);
}
:root[data-theme="dark"] .chat-msg__body code {
  background: rgba(245, 242, 234, 0.10);
}

/* Markdown tables (GFM) — wrap scrolls horizontally on narrow/mobile screens */
.chat-msg__body .md-table-wrap { overflow-x: auto; margin: 0.9em 0; -webkit-overflow-scrolling: touch; }
.chat-msg__body table { border-collapse: collapse; width: 100%; font-size: 0.92em; line-height: 1.5; }
.chat-msg__body th,
.chat-msg__body td { border: 1px solid var(--border); padding: 7px 11px; text-align: left; vertical-align: top; }
.chat-msg__body th { font-weight: 600; background: rgba(31, 30, 28, 0.05); white-space: nowrap; }
.chat-msg__body tbody tr:nth-child(even) td { background: rgba(31, 30, 28, 0.02); }
:root[data-theme="dark"] .chat-msg__body th { background: rgba(245, 242, 234, 0.06); }
:root[data-theme="dark"] .chat-msg__body tbody tr:nth-child(even) td { background: rgba(245, 242, 234, 0.03); }

/* Blockquote */
.chat-msg__body blockquote {
  border-left: 3px solid var(--border);
  margin: 0.7em 0;
  padding: 2px 0 2px 14px;
  color: var(--text-soft);
}


.chat-composer__send,
.chat-composer__stop {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 140ms ease, transform 80ms ease, opacity 120ms ease;
}
.chat-composer__send:hover:not(:disabled) { background: #C96846; }
.chat-composer__send:active:not(:disabled) { transform: translateY(1px); }
.chat-composer__stop:hover { background: #C96846; }
.chat-composer__stop:active { transform: translateY(1px); }
.chat-composer__stop[hidden],
.chat-composer__send[hidden] { display: none; }
.chat-composer__send:disabled {
  background: rgba(31, 30, 28, 0.15);
  color: rgba(31, 30, 28, 0.4);
  cursor: not-allowed;
}

.chat-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 680px;
}
.chat-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  background: var(--card-bg);
  border: 1px solid var(--border);
  transition: background 120ms ease, border-color 120ms ease;
}
.chat-chip:hover {
  background: var(--hover-bg);
  border-color: var(--border-strong);
}
.chat-chip svg { color: var(--text-soft); }

.chat-stream {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 24px 0;
  gap: 4px;
  /* claude.ai: slim unobtrusive scrollbar in the conversation */
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
  overflow-y: auto;
}
.chat-stream[hidden] { display: none; }
.chat-msg {
  width: 100%;
  max-width: 680px;  /* claude.ai: message column shares edges with composer */
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 0;
}
.chat-msg__role {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.chat-msg__body {
  font-family: var(--chat-font);
  font-size: var(--chat-font-size-msg);
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
}

/* Streaming cursor — small caret blink after the live-typed text */
/* Soft breathing dot at the stream tail — calmer than a hard blinking block */
.chat-msg__body.is-streaming::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--accent);
  vertical-align: baseline;
  animation: chat-stream-breathe 1.2s ease-in-out infinite;
}
@keyframes chat-stream-breathe {
  0%, 100% { opacity: 0.35; transform: scale(0.8); }
  50%      { opacity: 1;    transform: scale(1); }
}

/* ─── Web-search activity card (above the assistant text) ─── */
.chat-activity {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-bg);
  margin-bottom: 12px;
  overflow: hidden;
}
.chat-activity__head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  color: var(--text-soft);
  text-align: left;
  transition: background 120ms ease;
}
.chat-activity__head:hover { background: var(--hover-bg); }
.chat-activity__head svg { flex-shrink: 0; color: var(--text-muted); }
.chat-activity__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-activity__dot {
  width: 7px; height: 7px;
  border-radius: 999px;
  background: var(--accent);
  animation: chat-stream-breathe 1.2s ease-in-out infinite;
  flex-shrink: 0;
}
.chat-activity.is-done .chat-activity__dot { display: none; }
.chat-activity__caret { transition: transform 160ms ease; }
.chat-activity__head[aria-expanded="true"] .chat-activity__caret { transform: rotate(180deg); }

.chat-activity__details {
  border-top: 1px solid var(--border);
  padding: 10px 14px 12px;
}
.chat-activity__details[hidden] { display: none; }
.chat-activity__query {
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0 0 8px;
}
.chat-activity__results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.chat-activity__results li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
  min-width: 0;
}
.chat-activity__results a {
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.chat-activity__results a:hover { text-decoration: underline; }
.chat-activity__domain {
  color: var(--text-muted);
  font-size: 11.5px;
  flex-shrink: 0;
}

/* Thought card variation: thinking text inside the expandable details */
.chat-thought__text {
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-soft);
  white-space: pre-wrap;
  max-height: 240px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

/* Source chips under a web-searched reply: «Источники: kp.ru · ria.ru» */
.chat-sources {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}
.chat-sources__label {
  font-size: 12px;
  color: var(--text-muted);
  margin-right: 2px;
}
.chat-sources__chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-soft);
  text-decoration: none;
  transition: background 120ms ease, color 120ms ease;
}
.chat-sources__chip:hover { background: var(--hover-bg); color: var(--text); }

/* Newly appeared block during streaming slides in gently (set by JS) */
.chat-msg__block-in {
  animation: chat-block-in 260ms ease both;
}
@keyframes chat-block-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .chat-msg__body.is-streaming::after { animation: none; opacity: 0.7; }
  .chat-msg__block-in { animation: none; }
}
@keyframes chat-stream-blink {
  to { visibility: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  .chat-msg__body.is-streaming::after { animation: none; opacity: 0.6; }
}

/* ─── Anthropic-style message layout ─── */
/* Role labels are kept in DOM for screen readers but visually hidden. */
.chat-msg__role {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* User message: compact soft bubble on the RIGHT (per the live claude.ai
   reference) — sans, no border, gentle rounded corners. */
.chat-msg--user {
  align-items: flex-end;
}
.chat-msg--user .chat-msg__body {
  background: var(--hover-bg);
  padding: 10px 16px;
  border-radius: 16px;
  max-width: min(75%, 560px);
  font-family: var(--font-sans);
  font-size: 15px;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.chat-msg--assistant {
  align-items: stretch;
}
.chat-msg--assistant .chat-msg__body {
  padding: 0;
  background: transparent;
  /* Markdown handles paragraphs/lists itself; pre-wrap here would turn every
     inter-tag newline into a visible blank line (the giant-gaps bug). */
  white-space: normal;
}

/* "Stopped" hint shown under partial output when the user cancels a stream. */
.chat-msg__stopped {
  font-size: 12.5px;
  color: var(--text-soft);
  margin-top: 8px;
  font-style: italic;
}

/* ─── Action toolbar under assistant messages (copy / like / dislike / retry) ─── */
/* Hidden by default, fades in on hover over the message — Claude-style.        */
.chat-msg__actions {
  display: flex;
  gap: 2px;
  margin-top: 8px;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 140ms ease, transform 140ms ease;
}
.chat-msg--assistant:hover .chat-msg__actions,
.chat-msg--assistant:focus-within .chat-msg__actions,
.chat-msg--assistant:last-child .chat-msg__actions {
  opacity: 1;
  transform: translateY(0);
}
.chat-msg__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, transform 80ms ease;
}
.chat-msg__action:hover {
  background: var(--hover-bg);
  color: var(--text);
}
.chat-msg__action:active {
  transform: scale(0.94);
}
.chat-msg__action svg {
  width: 16px;
  height: 16px;
}
.chat-msg__action.is-active {
  color: var(--accent, #d97757);
  background: rgba(217, 119, 87, 0.10);
}
.chat-msg__action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
/* Retry is server-restricted to the trailing assistant row (the server deletes
   the last assistant message before regenerating), so hide the button on any
   earlier assistant bubble — defence-in-depth alongside the JS guard. */
.chat-msg--assistant .chat-msg__action[data-msg-action="retry"] {
  display: none;
}
.chat-msg--assistant:last-child .chat-msg__action[data-msg-action="retry"] {
  display: inline-flex;
}

/* ─── Version pager (‹ N/M ›) — inside the action toolbar, before copy/like ─── */
/* The pager is part of the actions toolbar so it inherits the same hover-fade. */
.chat-msg__versions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-right: 6px;
  padding-right: 6px;
  border-right: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.chat-msg__ver-btn {
  width: 26px;
  height: 26px;
}
.chat-msg__ver-btn svg {
  width: 14px;
  height: 14px;
}
.chat-msg__ver-btn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
}
.chat-msg__ver-btn[disabled]:hover {
  background: transparent;
  color: var(--text-muted);
}
.chat-msg__ver-count {
  min-width: 28px;
  text-align: center;
  user-select: none;
}

/* ─── "Klod's response was interrupted" banner — replaces the small ⏸ note ─── */
/* Anthropic-style soft pill with an icon, message, and inline Try-again button. */
.chat-msg__interrupted {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--surface-2, rgba(255, 255, 255, 0.03));
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--text-muted);
}
.chat-msg__interrupted-icon {
  display: inline-flex;
  flex: 0 0 auto;
  color: var(--text-muted);
}
.chat-msg__interrupted-text {
  flex: 1 1 auto;
  color: var(--text);
  line-height: 1.4;
}
.chat-msg__interrupted-btn {
  flex: 0 0 auto;
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.14));
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.chat-msg__interrupted-btn:hover {
  background: var(--hover-bg, rgba(255, 255, 255, 0.06));
  border-color: var(--accent, #d97757);
  color: var(--accent, #d97757);
}
.chat-msg__interrupted-btn:focus-visible {
  outline: 2px solid var(--accent, #d97757);
  outline-offset: 2px;
}
/* Try-again works only for the trailing assistant — hide on earlier bubbles
   to mirror the toolbar retry-button rule. The banner text stays visible. */
.chat-msg--assistant:not(:last-child) .chat-msg__interrupted-btn {
  display: none;
}

/* ─── Inline runnable preview (HTML / SVG) — sandboxed iframe under code ─── */
.code-block__btn--run {
  color: var(--accent, #d97757);
}
.code-block__btn--run.is-active {
  background: rgba(217, 119, 87, 0.12);
  color: var(--accent, #d97757);
}
.code-block__preview {
  margin: 0;
  padding: 0;
  background: #fff;
  border-top: 1px solid var(--border);
}
.code-block__preview iframe {
  display: block;
  width: 100%;
  height: 360px;
  border: 0;
  background: #fff;
  border-radius: 0 0 var(--radius-sm, 8px) var(--radius-sm, 8px);
}
@media (max-width: 760px) {
  .code-block__preview iframe { height: 280px; }
}

/* ─── Artifacts: premium file creation (claude.ai-style) ─── */

/* File card in chat: icon + title + «Код · HTML» + Скачать. Click → panel. */
.artifact-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-bg, #fff);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}
.artifact-card:hover { border-color: var(--border-strong, var(--border)); background: var(--hover-bg, rgba(31,30,28,0.04)); }
.artifact-card:active { transform: translateY(1px); }
.artifact-card.is-active { border-color: var(--accent); }
.artifact-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.artifact-card__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft, rgba(31,30,28,0.03));
  color: #87837b;
}
.artifact-card__icon svg { width: 20px; height: 20px; }
.artifact-card__meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.artifact-card__title {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.artifact-card__sub { font-size: 12.5px; color: #6e6b64; }
.artifact-card__dl {
  flex-shrink: 0;
  padding: 7px 14px;
  border: 1px solid var(--border-strong, var(--border));
  border-radius: 8px;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: background 120ms ease, border-color 120ms ease;
}
.artifact-card__dl:hover { background: var(--hover-bg, rgba(31,30,28,0.05)); }
.artifact-card__source { display: none; }

/* Streaming theater: step row («Создаю файл…» → имя файла) + auto-scrolling
   code window showing the tail of what the model writes — claude.ai-style. */
.artifact-progress { margin: 12px 0; }
.artifact-progress__step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: #87837b;
  margin-bottom: 10px;
}
.artifact-progress__icon { display: inline-flex; }
.artifact-progress__icon svg { width: 15px; height: 15px; }
.artifact-progress__label { font-weight: 500; }
.artifact-progress__win {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft, rgba(31,30,28,0.03));
  max-height: 180px;
  overflow: hidden;
}
.artifact-progress__win::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 38px;
  background: linear-gradient(var(--bg) 15%, transparent);
  pointer-events: none;
  z-index: 1;
}
/* The step row has its own pulsing dot — kill the generic breathing dot
   that would otherwise float orphaned under the code window. */
.chat-msg__body.is-streaming.chat-msg__body--artifact-streaming::after {
  display: none;
}
.artifact-progress__code {
  margin: 0;
  padding: 12px 16px;
  font-family: var(--font-mono, ui-monospace, Menlo, Consolas, monospace);
  font-size: 11.5px;
  line-height: 1.55;
  color: #6e6b64;
  white-space: pre;
  overflow: hidden;
}
/* The window lives inside .chat-msg__body, whose inline-`code` rule paints
   grey pills behind every line box — neutralize it here. */
.chat-msg__body .artifact-progress__code code {
  background: none;
  padding: 0;
  border-radius: 0;
  font: inherit;
  color: inherit;
}

/* ─── Artifact side panel: split view with превью / код toggle ─── */
:root { --artifact-panel-w: min(46vw, 760px); }
.artifact-panel {
  position: fixed;
  top: 12px;
  right: 12px;
  bottom: 12px;
  width: var(--artifact-panel-w);
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 4px 12px rgba(31,30,28,0.06), 0 18px 48px rgba(31,30,28,0.12);
  transform: translateX(calc(100% + 24px));
  transition: transform 260ms cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}
.artifact-panel.is-open { transform: translateX(0); }
.chat-main { transition: margin-right 260ms cubic-bezier(0.4, 0, 0.2, 1); }
body.has-artifact-panel .chat-main { margin-right: calc(var(--artifact-panel-w) + 12px); }

.artifact-panel__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.artifact-panel__tabs {
  display: flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft, rgba(31,30,28,0.03));
  flex-shrink: 0;
}
.artifact-panel__tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 24px;
  border-radius: 6px;
  color: #87837b;
  transition: background 120ms ease, color 120ms ease;
}
.artifact-panel__tab.is-active {
  background: var(--card-bg, #fff);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(31,30,28,0.12);
}
.artifact-panel__tab[hidden] { display: none; }
.artifact-panel__tabs[hidden] { display: none; }
.artifact-panel__iconbtn.artifact-panel__copyicon { display: none; }
.artifact-panel__tab svg { width: 15px; height: 15px; }
.artifact-panel__titles {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.artifact-panel__title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.artifact-panel__badge {
  font-size: 11px;
  letter-spacing: 0.05em;
  color: #6e6b64;
  font-family: var(--font-mono, ui-monospace, monospace);
  flex-shrink: 0;
}
.artifact-panel__actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.artifact-panel__copy {
  padding: 5px 12px;
  border: 1px solid var(--border-strong, var(--border));
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  transition: background 120ms ease;
}
.artifact-panel__copy:hover { background: var(--hover-bg, rgba(31,30,28,0.05)); }
.artifact-panel__iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: #87837b;
  transition: background 120ms ease, color 120ms ease;
}
.artifact-panel__iconbtn:hover { background: var(--hover-bg, rgba(31,30,28,0.05)); color: var(--text); }
.artifact-panel__iconbtn[hidden] { display: none; }
.artifact-panel__iconbtn svg { width: 15px; height: 15px; }
.artifact-panel__body { flex: 1; min-height: 0; position: relative; background: #fff; }
.artifact-panel__frame { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.artifact-panel__code {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  padding: 18px 20px;
  box-sizing: border-box;
  font-family: var(--font-mono, ui-monospace, Menlo, Consolas, monospace);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg-soft, #faf9f5);
  white-space: pre;
}
.artifact-panel[data-mode="preview"] .artifact-panel__code { display: none; }
.artifact-panel[data-mode="code"] .artifact-panel__frame { display: none; }

/* Syntax highlighting (panel code view) — cream-friendly muted palette */
.artifact-panel__code .hl-com  { color: #8B8578; font-style: italic; }
.artifact-panel__code .hl-str  { color: #B3582F; }
.artifact-panel__code .hl-kw   { color: #7C5CBF; }
.artifact-panel__code .hl-num  { color: #2E7D6B; }
.artifact-panel__code .hl-tag  { color: #C24D38; }
.artifact-panel__code .hl-attr { color: #8A6E2F; }
.artifact-panel__code .hl-prop { color: #8A6E2F; }
:root[data-theme="dark"] .artifact-panel__code .hl-com  { color: #8f8a80; }
:root[data-theme="dark"] .artifact-panel__code .hl-str  { color: #d08862; }
:root[data-theme="dark"] .artifact-panel__code .hl-kw   { color: #a48fd8; }
:root[data-theme="dark"] .artifact-panel__code .hl-num  { color: #6cb8a4; }
:root[data-theme="dark"] .artifact-panel__code .hl-tag  { color: #d97757; }
:root[data-theme="dark"] .artifact-panel__code .hl-attr { color: #c4ad72; }
:root[data-theme="dark"] .artifact-panel__code .hl-prop { color: #c4ad72; }

/* Dark theme */
:root[data-theme="dark"] .artifact-card { background: #1F1E1D; }
:root[data-theme="dark"] .artifact-progress__win { background: #1F1E1D; }
:root[data-theme="dark"] .artifact-progress__code { color: #9c978c; }
:root[data-theme="dark"] .artifact-panel {
  background: #262624;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
}
:root[data-theme="dark"] .artifact-panel__tab.is-active { background: #33322f; box-shadow: none; }
:root[data-theme="dark"] .artifact-panel__code { background: #1F1E1D; }
:root[data-theme="dark"] .artifact-panel__body { background: #262624; }

/* Mobile: panel becomes a full-screen overlay; chat doesn't shrink. */
@media (max-width: 640px) {
  .artifact-panel__copy { display: none; }
  .artifact-panel__iconbtn.artifact-panel__copyicon { display: inline-flex; }
  .artifact-panel__code { padding-right: 28px; }
}
@media (max-width: 1100px) {
  .artifact-panel {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    border: 0;
    border-radius: 0;
  }
  body.has-artifact-panel .chat-main { margin-right: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .artifact-panel, .chat-main, .artifact-card { transition: none; }
}

/* Pre-/post-artifact text containers — render markdown text wrapped around
   the artifact iframe, mirroring Anthropic's flow. */
.chat-msg__pre-artifact:not(:empty)  { margin-bottom: 12px; }
.chat-msg__post-artifact:not(:empty) { margin-top: 12px; }
/* During streaming we set the divs via .textContent (plain text + literal
   newlines), so pre-wrap is needed to preserve them. After finalize, the
   divs hold rendered markdown blocks — pre-wrap would add stray gaps,
   so we scope it to the .is-streaming state. */
.chat-msg__body.is-streaming .chat-msg__pre-artifact,
.chat-msg__body.is-streaming .chat-msg__post-artifact {
  white-space: pre-wrap;
}
.chat-msg__pre-artifact:empty,
.chat-msg__post-artifact:empty { display: none; }

/* ─── "Claude is thinking" indicator (Anthropic-style pulsing logo) ─── */
.chat-thinking {
  display: inline-flex;
  align-items: center;
  padding: 4px 0;
}
/* Visually-hidden status text for screen readers */
.chat-thinking__sr {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.chat-thinking__mark {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: block;
  animation: chat-thinking-pulse 1.8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  will-change: transform, opacity;
}
@keyframes chat-thinking-pulse {
  0%, 100% {
    opacity: 0.45;
    transform: scale(0.88) rotate(-6deg);
  }
  50% {
    opacity: 1;
    transform: scale(1.08) rotate(6deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .chat-thinking__mark { animation: none; opacity: 0.75; }
}

/* ─── Error banner (quota / upstream) — inlined in assistant bubble ─── */
.chat-msg__error-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--alert-bg, rgba(217, 119, 87, 0.12));
  border: 1px solid var(--alert-bd, rgba(232, 180, 164, 0.3));
  border-radius: 10px;
  font-size: 14px;
  color: var(--text);
  flex-wrap: wrap;
}
.chat-msg__error-icon { flex-shrink: 0; font-size: 18px; }
.chat-msg__error-text { flex: 1 1 auto; min-width: 0; }
.chat-msg__error-btn {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  background: var(--accent, #d97757);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 120ms ease;
}
.chat-msg__error-btn:hover { filter: brightness(0.92); }
/* The banner lives inside .chat-msg__body whose generic `a { color: accent }`
   rule otherwise wins on specificity → coral-on-coral invisible label. */
.chat-msg__body a.chat-msg__error-btn {
  color: #fff;
  text-decoration: none;
}

/* ─── Collapsed sidebar (icon-only rail) ─── */
.chat-body.is-side-collapsed { grid-template-columns: 60px 1fr; }

.chat-side.is-collapsed {
  padding: 16px 8px 14px;
  gap: 6px;
  align-items: center;
}
.chat-side.is-collapsed .chat-side__head {
  flex-direction: column;
  gap: 10px;
  padding: 0;
  margin-bottom: 6px;
  align-items: center;
}
.chat-side.is-collapsed .chat-side__logo {
  gap: 0;
  font-size: 0;
  padding: 0;
}
.chat-side.is-collapsed .chat-side__mark { width: 24px; height: 24px; }
.chat-side.is-collapsed .chat-side__wordmark,
.chat-side.is-collapsed .chat-side__logo > span,
.chat-side.is-collapsed .chat-side__new > span,
.chat-side.is-collapsed .chat-side__item > span,
.chat-side.is-collapsed .chat-side__more > span,
.chat-side.is-collapsed .chat-side__placeholder,
.chat-side.is-collapsed .chat-side__userblock,
.chat-side.is-collapsed .chat-side__usercaret,
.chat-side.is-collapsed .chat-side__group-label,
.chat-side.is-collapsed .chat-side__recents-head,
.chat-side.is-collapsed .chat-side__lab,
.chat-side.is-collapsed .chat-side__dl,
.chat-side.is-collapsed .chat-side__head-actions > .chat-side__icon-btn:not(.chat-side__collapse) {
  display: none;
}
.chat-side.is-collapsed .chat-side__group { align-items: center; gap: 4px; margin-top: 6px; }

/* Square 40×40 hit-area for every rail item */
.chat-side.is-collapsed .chat-side__collapse,
.chat-side.is-collapsed .chat-side__new,
.chat-side.is-collapsed .chat-side__item,
.chat-side.is-collapsed .chat-side__more,
.chat-side.is-collapsed .chat-side__user {
  width: 40px;
  height: 40px;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  gap: 0;
}
.chat-side.is-collapsed .chat-side__nav {
  align-items: center;
  gap: 4px;
}

/* Bigger icons inside the rail */
.chat-side.is-collapsed .chat-side__new svg,
.chat-side.is-collapsed .chat-side__item svg,
.chat-side.is-collapsed .chat-side__more svg,
.chat-side.is-collapsed .chat-side__collapse svg {
  width: 20px;
  height: 20px;
}

.chat-side.is-collapsed .chat-side__avatar { width: 32px; height: 32px; font-size: 14px; }

.chat-side.is-collapsed .chat-side__foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 10px;
}
.chat-side.is-collapsed .chat-side__menu {
  left: calc(100% + 6px);
  right: auto;
  bottom: 0;
  width: 240px;
}

/* ─── Toast (pop-up notice for not-yet-available sections) ─── */
.chat-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--text);
  color: var(--btn-fg);
  padding: 11px 18px;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.005em;
  box-shadow: 0 20px 48px -18px rgba(31, 30, 28, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 880px) {
  .chat-body { grid-template-columns: 1fr; font-size: 15px; }

  /* Sidebar → off-canvas drawer */
  .chat-side {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(86vw, 320px);
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 240ms cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18);
    border-right: 1px solid var(--border);
  }
  .chat-side.is-mobile-open { transform: translateX(0); }

  /* Show hamburger on mobile */
  .chat-topbar__menu { display: inline-flex; }

  /* Restore left-alignment for hamburger, push rest to the right */
  .chat-topbar { padding: 12px 16px 0; justify-content: flex-start; gap: 8px; }
  .chat-topbar__spacer { flex: 1; }

  /* Lock body scroll when drawer is open (applied via JS) */
  body.is-side-drawer-open { overflow: hidden; }

  /* Hub paddings */
  .chat-hub { padding: 0 18px; }
  .chat-hub__inner { gap: 22px; margin-top: 0; }
  .chat-hello { gap: 10px; }
  .chat-hello__mark { width: 36px; height: 36px; }
  .chat-chips { gap: 6px; }
  /* Lower top offset on phones so the keyboard doesn't clip the cluster */
  .chat-main:has(#hub:not([hidden])) .chat-hub { margin-top: clamp(32px, 14vh, 140px); }

  /* iOS zooms the page when a focused input is <16px */
  .chat-composer__input { font-size: 16px; }

  /* Tighter shell paddings on phones */
  .chat-bottom { padding: 10px 12px 14px; }
  .chat-stream { padding: 16px 14px 0; }

  /* Greeting scales down so "Good afternoon, Name" fits a 390px screen */
  .chat-hello__text { font-size: clamp(24px, 7vw, 32px); }

  /* Floating menus must never overflow the viewport */
  .chat-composer__model-menu { max-width: calc(100vw - 32px); }
  .chat-composer__plus-menu  { max-width: calc(100vw - 32px); }
  .effort-menu               { max-width: calc(100vw - 32px); }
}

@media (prefers-reduced-motion: reduce) {
  .chat-side { transition: none !important; }
  .chat-side-backdrop { transition: none !important; }
}

/* ─── Composer attachments (image previews above textarea) ─── */
.chat-composer__attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 4px;
}
.composer-attach {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.composer-attach__thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.composer-attach__remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
  transition: opacity 120ms ease;
}
.composer-attach:hover .composer-attach__remove { opacity: 1; }
.composer-attach__remove svg { width: 10px; height: 10px; flex-shrink: 0; }

/* ─── Images inside user chat bubbles ─── */
.chat-msg__images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.chat-msg__image {
  max-width: 260px;
  max-height: 200px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
  display: block;
}
