:root {
  --bg: #212121;
  --panel: #171717;
  --panel-2: #262626;
  --surface: #2f2f2f;
  --surface-hover: #383838;
  --text: #ececec;
  --muted: #a7a7a7;
  --border: rgba(255,255,255,.08);
  --border-strong: rgba(255,255,255,.14);
  --accent: #ffffff;
  --accent-text: #171717;
  --user-bubble: #303030;
  --shadow: 0 12px 38px rgba(0,0,0,.30);
  --sidebar-width: 260px;
  --composer-width: 780px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

body {
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, textarea, input {
  font: inherit;
}

button {
  color: inherit;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

textarea,
input {
  -webkit-user-select: text;
  user-select: text;
}

img,
picture,
svg,
canvas,
video {
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  user-drag: none;
}

.app {
  display: flex;
  width: 100%;
  height: 100dvh;
}

.telegram-only {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  gap: 10px;
  padding: 28px;
  text-align: center;
  background: var(--bg);
  color: var(--text);
}

.telegram-only-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  justify-self: center;
  border-radius: 15px;
  background: var(--text);
  color: var(--bg);
  font-weight: 800;
}

.telegram-only h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.telegram-only p {
  max-width: 320px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  z-index: 40;
}

.sidebar-top {
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
}

.brand:hover {
  background: transparent;
}

.brand-mark,
.hero-logo,
.model-icon {
  display: grid;
  place-items: center;
  font-weight: 800;
}

.brand-mark {
  width: 25px;
  height: 25px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
}

.brand-name {
  font-weight: 650;
  font-size: 14px;
}

.new-chat,
.profile-row {
  width: 100%;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 10px;
  color: var(--text);
}

.new-chat {
  height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  font-weight: 560;
  font-size: 14px;
}

.new-chat:hover,
.profile-row:hover {
  background: var(--surface-hover);
}

.new-chat svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-section {
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
  padding-top: 8px;
}

.chat-list {
  --pull-distance: 0px;
  --pull-angle: 0deg;
  position: relative;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 14px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.22) transparent;
}

.chat-list::-webkit-scrollbar {
  width: 7px;
}

.chat-list::-webkit-scrollbar-track {
  background: transparent;
}

.chat-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255,255,255,.18);
}

.chat-pull-refresh {
  position: sticky;
  top: 0;
  justify-self: center;
  width: 34px;
  height: 34px;
  margin-top: -34px;
  margin-bottom: 0;
  display: none;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 999px;
  background: rgba(43,43,43,.94);
  box-shadow: 0 10px 28px rgba(0,0,0,.28);
  transform: translateY(calc(var(--pull-distance) - 42px)) scale(.88);
  transition:
    opacity 180ms ease,
    transform 280ms cubic-bezier(.22, .8, .28, 1);
  z-index: 2;
}

.chat-pull-refresh span {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,.2);
  border-top-color: #ffffff;
  border-radius: 999px;
  transform: rotate(var(--pull-angle));
}

.chat-list.pulling .chat-pull-refresh,
.chat-list.refreshing .chat-pull-refresh {
  opacity: 1;
  transform: translateY(calc(var(--pull-distance) - 36px)) scale(1);
}

.chat-list.refreshing .chat-pull-refresh span {
  animation: chatRefreshSpin 680ms linear infinite;
}

.chat-section {
  display: grid;
  gap: 5px;
}

.chat-section-title {
  min-height: 24px;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 10px;
  color: #bfc4d4;
  font-size: 12px;
  font-weight: 560;
}

.chat-section-title svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .8;
}

.chat-section-list {
  display: grid;
  gap: 3px;
}

.chat-row {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 9px;
  cursor: pointer;
  min-width: 0;
  transition:
    padding-right .12s ease,
    background .12s ease,
    opacity .35s ease,
    translate .35s ease;
}

.chat-row.chat-hidden-below {
  opacity: 0;
  translate: 0 24px;
  pointer-events: none;
}

.chat-row.chat-hidden-above {
  opacity: 0;
  translate: 0 -24px;
  pointer-events: none;
}

.chat-row.chat-visible {
  opacity: 1;
  translate: 0 0;
  pointer-events: auto;
}

.chat-row.chat-refresh-reveal {
  animation: chatRowRefreshReveal .54s cubic-bezier(.22, .8, .28, 1) both;
}

.chat-row:hover,
.chat-row.active {
  background: var(--surface-hover);
}

@media (hover: hover) and (pointer: fine) {
  .chat-row:hover {
    padding-right: 61px;
  }
}

.chat-title {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 13.5px;
}

.chat-actions {
  position: absolute;
  top: 50%;
  right: 5px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 1px;
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(to right, transparent, var(--surface-hover) 9px);
}

.chat-pin,
.chat-delete {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  opacity: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #ef4444;
  cursor: pointer;
}

.chat-pin {
  color: #c9c9cd;
}

@media (hover: hover) and (pointer: fine) {
  .chat-row:hover .chat-actions {
    opacity: 1;
    pointer-events: auto;
  }

  .chat-row:hover .chat-pin,
  .chat-row:hover .chat-delete {
    opacity: 1;
  }
}

.chat-pin:hover {
  background: var(--panel-2);
  color: var(--text);
}

.chat-row.pinned .chat-pin {
  color: #ffffff;
}

.chat-delete:hover {
  background: rgba(239, 68, 68, .11);
  color: #dc2626;
}

.chat-context-menu {
  position: fixed;
  z-index: 95;
  display: none;
  min-width: 154px;
  padding: 6px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 13px;
  background: #2f2f2f;
  color: var(--text);
  box-shadow: 0 16px 38px rgba(0,0,0,.32);
}

.chat-context-menu.open {
  display: grid;
}

.chat-context-menu button {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  font-size: 13.5px;
  font-weight: 560;
}

.chat-context-menu button:hover {
  background: var(--surface-hover);
}

.chat-context-menu button.danger {
  color: #ff6b6b;
}

.chat-context-menu svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-pin svg,
.chat-delete svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 0;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.chat-delete svg {
  fill: none;
  stroke-width: 1.9;
}

.sidebar-footer {
  display: grid;
  gap: 4px;
}

.profile-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px;
  border: 1px solid rgba(255,255,255,.06);
  background: rgba(255,255,255,.035);
  text-align: left;
}

.profile-row:hover {
  border-color: rgba(255,255,255,.10);
}

.profile-wrap {
  position: relative;
}

.avatar.small {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #8b5cf6;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  overflow: hidden;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  pointer-events: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
  user-select: none;
  user-drag: none;
}

.settings-profile .avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  overflow: hidden;
  border-radius: 50%;
  background: #8b5cf6;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.profile-copy {
  min-width: 0;
  flex: 1;
  display: grid;
}

.profile-copy strong {
  font-size: 13px;
  font-weight: 720;
  color: #f4f4f6;
}

.profile-copy small {
  color: #b7b7bc;
  font-size: 11px;
  margin-top: 1px;
}

.dots {
  width: 18px;
  height: 18px;
  fill: currentColor;
  color: #d4d4d8;
}

.profile-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 6px);
  z-index: 70;
  display: none;
  padding: 9px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 18px;
  background: #303030;
  color: #f5f5f5;
  box-shadow: 0 16px 44px rgba(0,0,0,.28);
}

.profile-menu.open {
  display: grid;
}

.profile-menu-head,
.profile-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.profile-menu-head {
  min-height: 44px;
  gap: 9px;
  padding: 3px 4px 10px;
}

.profile-menu .avatar.small {
  background: #21b99a;
  color: #fff;
}

.profile-menu .profile-copy strong {
  color: #fff;
}

.profile-menu .profile-copy small {
  color: #b7b7b7;
}

.profile-menu-separator {
  display: block;
  height: 1px;
  margin: 0 4px 7px;
  background: rgba(255,255,255,.13);
}

.profile-menu-item {
  min-height: 36px;
  gap: 11px;
  padding: 7px 6px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 560;
}

.profile-menu-item:hover {
  background: rgba(255,255,255,.08);
}

.profile-menu-item svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: #f3f3f3;
}

.profile-menu-item svg.filled-icon {
  fill: currentColor;
  stroke: none;
}

.main {
  position: relative;
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.topbar {
  position: relative;
  z-index: 30;
  height: 60px;
  flex: 0 0 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
}

.icon-button,
.composer-icon {
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 9px;
}

.icon-button:hover,
.composer-icon:hover {
  background: var(--surface-hover);
}

.icon-button svg,
.composer-icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.model-picker-wrap {
  position: relative;
}

.model-picker {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 155px;
  padding: 6px 9px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.model-picker:hover {
  background: var(--surface-hover);
}

.model-picker > span {
  display: grid;
  gap: 0;
}

.model-picker strong {
  font-size: 14px;
  line-height: 17px;
  font-weight: 680;
}

.model-picker small {
  color: var(--muted);
  font-size: 10px;
  line-height: 13px;
}

.model-picker svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.model-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  width: 270px;
  display: none;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  z-index: 85;
}

.model-menu.open {
  display: grid;
}

.model-option {
  display: grid;
  grid-template-columns: 34px 1fr 20px;
  align-items: center;
  gap: 9px;
  padding: 9px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.model-option:hover {
  background: var(--surface-hover);
}

.model-icon {
  width: 31px;
  height: 31px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--panel);
  font-size: 12px;
}

.model-option > span:nth-child(2) {
  display: grid;
  gap: 2px;
}

.model-option strong {
  font-size: 13px;
  font-weight: 650;
}

.model-option small {
  color: var(--muted);
  font-size: 11px;
}

.check {
  opacity: 0;
  font-size: 13px;
}

.model-option.active .check {
  opacity: 1;
}

.conversation {
  position: relative;
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.empty-state {
  width: min(730px, calc(100% - 40px));
  min-height: calc(100% - 40px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 0 145px;
}

.hero-logo {
  --pet-eye-x: 0px;
  --pet-eye-y: 0px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 15px;
  background: var(--text);
  color: var(--bg);
  margin-bottom: 16px;
  cursor: pointer;
}

.hero-logo span {
  width: 4px;
  height: 19px;
  border-radius: 999px;
  background: currentColor;
  transform-origin: center;
  animation: petBlink 5.8s ease-in-out infinite;
}

.hero-logo span:nth-child(2) {
  animation-delay: .04s;
}

.hero-logo.pet-react span {
  animation: petReact .62s steps(1) both;
}

.hero-logo.pet-react span:nth-child(2) {
  animation-delay: .03s;
}

.hero-logo.pet-mad {
  animation: petMad .42s linear both;
}

.hero-logo.pet-mobile-tap {
  animation:
    petMad .42s linear both,
    petMobileTap .48s ease-out both;
}

.empty-state h1 {
  margin: 0 0 28px;
  font-size: clamp(26px, 4vw, 34px);
  letter-spacing: 0;
  font-weight: 650;
  line-height: 1.14;
  text-align: center;
}

.hero-name {
  color: #82aaff;
  font-family: Georgia, "Times New Roman", Times, serif;
  font-weight: 700;
  font-style: italic;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 5px;
}

.suggestions {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.suggestion {
  min-height: 76px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 14px 15px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.suggestion:hover {
  background: var(--surface-hover);
}

.suggestion span {
  font-weight: 600;
  font-size: 13px;
}

.suggestion small {
  color: var(--muted);
  font-size: 11.5px;
}

.messages {
  width: min(760px, calc(100% - 38px));
  margin: 0 auto;
  padding: 22px 0 185px;
}

.message {
  display: flex;
  width: 100%;
  margin: 0 0 32px;
}

.message,
.message * {
  -webkit-touch-callout: default;
  -webkit-user-select: text;
  user-select: text;
}

.message.user {
  justify-content: flex-end;
  flex-direction: column;
  align-items: flex-end;
}

.message.assistant {
  justify-content: flex-start;
}

.user-bubble {
  max-width: min(78%, 620px);
  padding: 10px 15px;
  border-radius: 19px;
  background: var(--user-bubble);
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.assistant-message {
  width: 100%;
  font-size: 15px;
  line-height: 1.72;
  overflow-wrap: anywhere;
}

.assistant-message p {
  margin: 0 0 14px;
}

.assistant-message p:last-child {
  margin-bottom: 0;
}

.assistant-message h1,
.assistant-message h2,
.assistant-message h3 {
  margin: 24px 0 10px;
  line-height: 1.25;
}

.assistant-message h1 { font-size: 24px; }
.assistant-message h2 { font-size: 20px; }
.assistant-message h3 { font-size: 17px; }

.assistant-message ul,
.assistant-message ol {
  padding-left: 23px;
  margin: 8px 0 15px;
}

.assistant-message li {
  margin: 5px 0;
}

.assistant-message blockquote {
  margin: 12px 0;
  padding-left: 14px;
  border-left: 3px solid var(--border-strong);
  color: var(--muted);
}

.assistant-message .markdown-divider {
  height: 1px;
  margin: 18px 0;
  border: 0;
  background: var(--border-strong);
}

.assistant-message .table-wrap {
  max-width: 100%;
  margin: 14px 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255,255,255,.025);
}

.assistant-message table {
  width: 100%;
  min-width: 420px;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.45;
}

.assistant-message th,
.assistant-message td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.assistant-message th:last-child,
.assistant-message td:last-child {
  border-right: 0;
}

.assistant-message tr:last-child td {
  border-bottom: 0;
}

.assistant-message th {
  color: var(--text);
  background: rgba(255,255,255,.055);
  font-weight: 650;
}

.assistant-message a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.assistant-message code:not(pre code) {
  padding: 2px 5px;
  border-radius: 6px;
  background: var(--surface-hover);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: .9em;
}

.math-inline {
  display: inline-block;
  max-width: 100%;
  padding: 1px 5px;
  border-radius: 6px;
  background: rgba(255,255,255,.055);
  font-family: "Cambria Math", "Times New Roman", serif;
  overflow-x: auto;
  vertical-align: baseline;
}

.math-block {
  max-width: 100%;
  margin: 14px 0;
  padding: 13px 15px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255,255,255,.035);
  color: var(--text);
  font-family: "Cambria Math", "Times New Roman", serif;
  font-size: 15px;
  line-height: 1.55;
  white-space: pre;
}

.code-wrap {
  margin: 14px 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #171717;
  color: #ececec;
}

.code-head {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  color: #aaa;
  font-size: 11px;
}

.copy-code {
  border: 0;
  background: transparent;
  color: #cfcfcf;
  cursor: pointer;
  font-size: 11px;
}

.copy-code:hover {
  color: #fff;
}

.code-wrap pre {
  margin: 0;
  padding: 14px;
  overflow-x: auto;
}

.code-wrap code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
}

.message-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 10px;
  opacity: .78;
}

.user-message-tools {
  margin-top: 5px;
  margin-right: 4px;
  opacity: .58;
}

.message.user:hover .user-message-tools {
  opacity: .9;
}

.message-edit {
  width: min(100%, 770px);
  padding: 18px 20px 15px;
  border-radius: 23px;
  background: var(--user-bubble);
}

.message-edit-input {
  width: 100%;
  min-height: 58px;
  max-height: 220px;
  padding: 0;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  line-height: 1.55;
}

.message-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 16px;
}

.message-edit-cancel,
.message-edit-submit {
  min-height: 34px;
  padding: 0 16px;
  border-radius: 999px;
  font-weight: 650;
  cursor: pointer;
}

.message-edit-cancel {
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
}

.message-edit-submit {
  border: 0;
  background: var(--text);
  color: var(--bg);
}

.assistant-status {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 24px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.assistant-status-icon {
  width: 24px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 0 0 auto;
  opacity: .8;
}

.assistant-status-icon i {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: currentColor;
  animation: statusDot 1.05s ease-in-out infinite;
}

.assistant-status-icon i:nth-child(2) {
  animation-delay: .12s;
}

.assistant-status-icon i:nth-child(3) {
  animation-delay: .24s;
}

.assistant-status-text {
  min-width: 0;
  background:
    linear-gradient(
      90deg,
      var(--muted) 0%,
      var(--muted) 42%,
      color-mix(in srgb, var(--text) 86%, white 14%) 50%,
      var(--muted) 58%,
      var(--muted) 100%
    );
  background-size: 280% 100%;
  background-position: 140% 0;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: statusTextSweep 1.45s linear infinite;
}

/* Activity panel: the live, then collapsible, record of what Niro did. */
.activity-panel {
  margin: 2px 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  overflow: hidden;
}

.activity-summary {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  cursor: pointer;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  user-select: none;
}

.activity-summary::-webkit-details-marker { display: none; }

.activity-summary:hover { color: var(--text); }

.activity-summary-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: .8;
}

.activity-summary-icon svg { width: 15px; height: 15px; }
.activity-summary-icon.is-error { color: #e5686b; opacity: 1; }

/* A running step turns its own icon into the spinner, so there is exactly
   one thing moving on screen rather than a row of competing animations. */
.is-spinning svg { animation: activitySpin .9s linear infinite; }

@keyframes activitySpin { to { transform: rotate(360deg); } }

.activity-summary-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-panel[open] .activity-summary {
  border-bottom: 1px solid var(--border);
}

.activity-steps {
  margin: 0;
  padding: 4px 0 0;
  list-style: none;
  display: flex;
  flex-direction: column;
}

/* Each step owns the rail segment below its own icon, so the line connects
   the run without needing to match the panel background behind the marks. */
.activity-step {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0 0 10px 26px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
}

.activity-step::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 19px;
  bottom: -1px;
  width: 1px;
  /* --border is tuned for panel edges and vanishes as a hairline here, and
     these segments are short, so the value is set explicitly rather than
     derived from a token meant for something else. */
  background: rgba(255, 255, 255, .2);
}

.activity-step:last-child { padding-bottom: 2px; }
.activity-step:last-child::before { display: none; }

.activity-step-mark {
  position: absolute;
  left: 0;
  top: 1px;
  width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.activity-step-mark svg { width: 14px; height: 14px; }

.activity-step.activity-done .activity-step-mark { color: #58c479; }
.activity-step.activity-error .activity-step-mark { color: #e5686b; }
.activity-step.activity-error .activity-step-text { color: var(--text); }

.activity-step-text {
  min-width: 0;
  word-break: break-word;
}

.activity-step-note {
  display: block;
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
}

.activity-step-target {
  padding: 1.5px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-hover) 55%, transparent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: var(--text);
  word-break: break-all;
}

/* Files Niro sent back — a download card per file. */
.file-cards {
  margin: 12px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-preview {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--panel);
  line-height: 0;
}

.file-preview img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  cursor: zoom-in;
}

.file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  text-decoration: none;
  color: var(--text);
  transition: background .14s ease, border-color .14s ease;
}

.file-card:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.file-card-icon {
  flex: 0 0 auto;
  font-size: 18px;
  line-height: 1;
}

.file-card-info {
  min-width: 0;
  flex: 1;
  display: grid;
  text-decoration: none;
}

.file-card-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 13px;
}

.file-card-meta {
  color: var(--muted);
  font-size: 11px;
}

.file-card-download {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-hover);
  color: var(--text);
  font-size: 15px;
}

/* --- work log: plan, steps, foldable output --- */
.activity-summary-chevron {
  margin-left: auto;
  flex: 0 0 auto;
  display: inline-flex;
  color: var(--faint, var(--muted));
  transition: transform .16s ease;
}

.activity-summary-chevron svg { width: 15px; height: 15px; }

.activity-panel[open] .activity-summary-chevron { transform: rotate(90deg); }

.activity-body { padding: 8px 12px 10px; }

.activity-plan {
  margin: 8px 0 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface-hover) 45%, transparent);
}

.activity-plan-title {
  font-size: 11.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 7px;
}

.activity-plan-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.activity-plan-step {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
}

.activity-plan-mark {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  display: grid;
  place-items: center;
  position: relative;
  top: 2px;
}

.activity-plan-mark svg { width: 13px; height: 13px; }
.activity-plan-step.plan-done   { color: var(--muted); }
.activity-plan-step.plan-done .activity-plan-mark { color: #58c479; }
.activity-plan-step.plan-done span:last-child { text-decoration: line-through; }
.activity-plan-step.plan-active { color: var(--text); font-weight: 550; }
.activity-plan-step.plan-active .activity-plan-mark { color: #e0913a; }
.activity-plan-step.plan-todo   { color: var(--muted); }

.activity-step-head { display: block; }

.activity-step-output {
  margin: 5px 0 0;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: color-mix(in srgb, var(--surface-hover) 45%, transparent);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.activity-step-more { margin: 5px 0 0; }

.activity-step-more summary {
  cursor: pointer;
  list-style: none;
  color: var(--muted);
  font-size: 11.5px;
}

.activity-step-more summary::-webkit-details-marker { display: none; }
.activity-step-more summary::before { content: "▸ "; }
.activity-step-more[open] summary::before { content: "▾ "; }
.activity-step-more summary:hover { color: var(--text); }

.activity-step-more pre {
  margin: 5px 0 0;
  padding: 8px 10px;
  max-height: 220px;
  overflow: auto;
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 11.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-tool {
  width: 30px;
  height: 30px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .14s ease, color .14s ease, transform .14s ease;
}

.message-tool:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.message-tool:active {
  transform: scale(.94);
}

.message-tool svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

@keyframes statusDot {
  0%, 70%, 100% {
    opacity: .28;
    transform: translateY(0);
  }
  35% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

@keyframes statusTextSweep {
  0% {
    background-position: 140% 0;
  }
  100% {
    background-position: -140% 0;
  }
}

@keyframes petBlink {
  0%, 7%, 11%, 100% {
    transform: translate(var(--pet-eye-x), var(--pet-eye-y)) scaleY(1);
  }
  8.5%, 9.5% {
    transform: translate(var(--pet-eye-x), var(--pet-eye-y)) scaleY(.16);
  }
}

@keyframes petReact {
  0%, 100% {
    transform: translate(var(--pet-eye-x), var(--pet-eye-y)) scaleY(1);
  }
  12% {
    transform: translate(calc(var(--pet-eye-x) - 4px), calc(var(--pet-eye-y) - 1px)) scaleY(1.12);
  }
  24% {
    transform: translate(calc(var(--pet-eye-x) + 4px), calc(var(--pet-eye-y) + 1px)) scaleY(.18);
  }
  36% {
    transform: translate(calc(var(--pet-eye-x) - 3px), calc(var(--pet-eye-y) + 2px)) scaleY(1.2);
  }
  48% {
    transform: translate(calc(var(--pet-eye-x) + 3px), calc(var(--pet-eye-y) - 2px)) scaleY(.16);
  }
  60% {
    transform: translate(calc(var(--pet-eye-x) - 2px), var(--pet-eye-y)) scaleY(1.18);
  }
  72% {
    transform: translate(calc(var(--pet-eye-x) + 2px), var(--pet-eye-y)) scaleY(.2);
  }
}

@keyframes petMad {
  0%, 100% {
    transform: translate(0, 0) rotate(0deg);
  }
  14% {
    transform: translate(-2px, 1px) rotate(-2deg);
  }
  28% {
    transform: translate(2px, -1px) rotate(2deg);
  }
  42% {
    transform: translate(-2px, -1px) rotate(-2deg);
  }
  56% {
    transform: translate(2px, 1px) rotate(2deg);
  }
  70% {
    transform: translate(-1px, 0) rotate(-1deg);
  }
  84% {
    transform: translate(1px, 0) rotate(1deg);
  }
}

@keyframes petMobileTap {
  0% {
    box-shadow: 0 0 0 0 rgba(255,255,255,.24);
  }
  42% {
    transform: scale(.94);
    box-shadow: 0 0 0 8px rgba(255,255,255,.12);
  }
  100% {
    box-shadow: 0 0 0 14px rgba(255,255,255,0);
  }
}

@keyframes chatRefreshSpin {
  from {
    transform: rotate(var(--pull-angle));
  }
  to {
    transform: rotate(calc(var(--pull-angle) + 360deg));
  }
}

@keyframes chatRowRefreshReveal {
  0% {
    opacity: 0;
    transform: translateY(28px) scale(.985);
  }
  58% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.composer-zone {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 16px 18px 10px;
  background: linear-gradient(to top, var(--bg) 78%, color-mix(in srgb, var(--bg) 0%, transparent));
}

.composer-shell {
  width: min(var(--composer-width), 100%);
  margin: 0 auto;
  border: 1px solid var(--border-strong);
  border-radius: 25px;
  background: var(--surface);
  box-shadow: 0 2px 10px rgba(0,0,0,.04);
}

.composer {
  min-height: 52px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 7px 8px 7px 9px;
}

.composer-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  margin-bottom: 0;
  border-radius: 50%;
}

#promptInput {
  width: 100%;
  max-height: 190px;
  min-height: 38px;
  resize: none;
  overflow-y: auto;
  padding: 8px 6px 7px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  line-height: 1.45;
  font-size: 15px;
}

#promptInput::placeholder {
  color: var(--muted);
}

.send-button {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  margin-left: 3px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  transition: transform .12s ease, opacity .12s ease;
}

.send-button:hover:not(:disabled) {
  transform: scale(1.03);
}

.send-button:disabled {
  opacity: .28;
  cursor: default;
}

.send-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stop-icon {
  display: none;
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: currentColor;
}

.send-button.generating .send-icon {
  display: none;
}

.send-button.generating .stop-icon {
  display: block;
}

.attachment-chips {
  margin: 10px 10px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-chips[hidden] {
  display: none;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 260px;
  padding: 6px 8px 6px 10px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
}

.attachment-chip-icon {
  flex: 0 0 auto;
  font-size: 14px;
  line-height: 1;
}

.attachment-chip-name {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12px;
  color: var(--text);
}

.attachment-chip-meta {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 10px;
}

.attachment-chip-remove {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-hover);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.attachment-chip-remove:hover {
  background: var(--border-strong);
}

.composer-shell.drag-over {
  outline: 2px dashed var(--border-strong);
  outline-offset: 2px;
  border-radius: 16px;
}

.composer-note {
  width: min(var(--composer-width), 100%);
  margin: 7px auto 0;
  color: var(--muted);
  text-align: center;
  font-size: 10.5px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 102px;
  z-index: 220;
  transform: translate(-50%, 10px);
  max-width: calc(100vw - 32px);
  padding: 10px 14px 10px 13px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  background: rgba(29,29,29,.96);
  color: #f4f4f4;
  box-shadow: 0 16px 38px rgba(0,0,0,.34);
  font-size: 12px;
  font-weight: 620;
  opacity: 0;
  pointer-events: none;
  transition: .18s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.settings-backdrop {
  position: absolute;
  inset: 0;
  z-index: 92;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0,0,0,.42);
  backdrop-filter: blur(10px);
}

.settings-backdrop[hidden] {
  display: none;
}

.settings-card {
  width: min(780px, 100%);
  min-height: 430px;
  max-height: min(620px, calc(100dvh - 36px));
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 22px;
  background: #2f2f2f;
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0,0,0,.42);
}

.settings-head {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px 0 22px;
}

.settings-head h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1;
  font-weight: 680;
  letter-spacing: 0;
}

.settings-close {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.settings-close:hover {
  background: rgba(255,255,255,.08);
}

.settings-close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.settings-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 20px;
  padding: 4px 28px 28px 18px;
}

.settings-tabs {
  display: grid;
  align-content: start;
  gap: 6px;
}

.settings-tab {
  height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  font-weight: 620;
}

.settings-tab:hover,
.settings-tab.active {
  background: rgba(255,255,255,.11);
}

.settings-tab svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings-tab svg.filled-icon {
  fill: currentColor;
  stroke: none;
}

.settings-content {
  min-width: 0;
  overflow: auto;
  margin-right: -10px;
  padding-right: 10px;
  scrollbar-gutter: stable;
}

.settings-panel {
  display: none;
}

.settings-panel.active {
  display: grid;
  gap: 12px;
}

.settings-panel h3 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 680;
  letter-spacing: 0;
}

.settings-row,
.settings-profile {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0;
  border-top: 1px solid rgba(255,255,255,.08);
}

.settings-row:first-of-type,
.settings-profile:first-of-type {
  border-top: 0;
}

.settings-row strong,
.settings-profile strong,
.settings-field strong {
  display: block;
  font-size: 14px;
  line-height: 1.25;
}

.settings-row small,
.settings-profile small,
.settings-field small {
  display: block;
  max-width: 420px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
}

.settings-profile {
  justify-content: flex-start;
  gap: 12px;
}

.settings-pill,
.settings-danger,
.settings-save {
  min-width: 82px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 620;
}

.settings-danger {
  border-color: #ef4444;
  color: #ff6b6b;
}

.settings-save {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

.settings-save:disabled {
  border-color: rgba(255,255,255,.1);
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.38);
  cursor: default;
}

.settings-pill:hover {
  background: rgba(255,255,255,.08);
}

.settings-danger:hover {
  background: rgba(239, 68, 68, .12);
}

.settings-select {
  width: min(210px, 42vw);
  height: 38px;
  padding: 0 36px 0 12px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px;
  outline: 0;
  appearance: none;
  -webkit-appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, #cfcfd2 50%) calc(100% - 18px) 16px / 6px 6px no-repeat,
    linear-gradient(135deg, #cfcfd2 50%, transparent 50%) calc(100% - 12px) 16px / 6px 6px no-repeat,
    #242424;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 560;
  cursor: pointer;
  transition: border-color .14s ease, background-color .14s ease;
}

.settings-select:focus,
.settings-input:focus,
.settings-textarea:focus,
.report-note:focus {
  border-color: rgba(255,255,255,.28);
}

.settings-select option {
  background: #242424;
  color: var(--text);
}

.settings-select option:checked {
  background: #3a3a3a;
  color: #fff;
}

.settings-choice {
  position: relative;
  width: min(230px, 42vw);
}

.settings-choice-button {
  width: 100%;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 10px 0 12px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px;
  background: #242424;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  font-weight: 560;
}

.settings-choice-button:hover,
.settings-choice.open .settings-choice-button {
  border-color: rgba(255,255,255,.28);
  background: #292929;
}

.settings-choice-button span {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.settings-choice-button svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .75;
  transition: transform .14s ease;
}

.settings-choice.open .settings-choice-button svg {
  transform: rotate(180deg);
}

.settings-choice-menu {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  right: 0;
  width: max(100%, 220px);
  max-height: 238px;
  display: none;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 13px;
  background: #242424;
  box-shadow: 0 16px 42px rgba(0,0,0,.36);
}

.settings-choice.open .settings-choice-menu {
  display: grid;
  gap: 2px;
}

.settings-choice-menu button {
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  font-weight: 540;
}

.settings-choice-menu button:hover,
.settings-choice-menu button.active {
  background: rgba(255,255,255,.09);
}

.settings-field {
  display: grid;
  gap: 10px;
  padding: 14px 0 0;
  border-top: 1px solid rgba(255,255,255,.08);
}

.settings-input,
.settings-textarea,
.report-note {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 13px;
  outline: 0;
  background: #262626;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  line-height: 1.45;
}

.settings-input {
  height: 40px;
}

.settings-textarea,
.report-note {
  min-height: 96px;
  resize: none;
}

.settings-textarea[data-pref="instructions"] {
  min-height: 168px;
}

.settings-field .settings-textarea {
  margin-bottom: 6px;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 16px;
}

.settings-actions.split {
  justify-content: space-between;
}

.contribution-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 9px;
  background: #1f1f1f;
}

.profile-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.profile-stat-grid div {
  min-width: 0;
  min-height: 56px;
  padding: 7px 7px 6px;
  border-radius: 5px;
  background: #303030;
}

.profile-stat-grid span {
  display: block;
  overflow: hidden;
  color: #929292;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12px;
}

.profile-stat-grid strong {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  color: #eeeeee;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 16px;
  line-height: 1;
}

.contribution-head {
  display: none;
}

/* Kept for screen readers and future layout variants. */
.contribution-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.contribution-head strong {
  display: block;
  font-size: 14px;
}

.contribution-head small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12.5px;
}

.contribution-total {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.contribution-wrap {
  position: relative;
  overflow-x: auto;
  padding-top: 2px;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.18) transparent;
}

.contribution-months {
  display: grid;
  grid-template-columns: 0 repeat(24, 17px);
  gap: 5px;
  min-width: max-content;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
}

.contribution-body {
  display: flex;
  gap: 0;
  min-width: max-content;
}

.contribution-days {
  display: none;
}

.contribution-grid {
  display: flex;
  gap: 5px;
}

.contribution-week {
  display: grid;
  grid-template-rows: repeat(7, 17px);
  gap: 5px;
}

.contribution-cell,
.contribution-legend i {
  width: 17px;
  height: 17px;
  border-radius: 3px;
  background: #303030;
}

.contribution-cell {
  position: relative;
  display: block;
  outline: 0;
}

.contribution-cell.is-empty {
  background: transparent;
  pointer-events: none;
}

.contribution-cell[data-level="1"],
.contribution-legend i[data-level="1"] {
  background: #0e4429;
}

.contribution-cell[data-level="2"],
.contribution-legend i[data-level="2"] {
  background: #006d32;
}

.contribution-cell[data-level="3"],
.contribution-legend i[data-level="3"] {
  background: #26a641;
}

.contribution-cell[data-level="4"],
.contribution-legend i[data-level="4"] {
  background: #39d353;
}

.contribution-tooltip {
  position: fixed;
  z-index: 170;
  left: 0;
  top: 0;
  padding: 6px 8px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 7px;
  background: #303030;
  color: var(--text);
  box-shadow: 0 12px 26px rgba(0,0,0,.38);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 650;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity .12s ease, transform .12s ease;
}

.contribution-tooltip.show {
  opacity: 1;
  transform: translateY(0);
}

.contribution-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
}

.contribution-legend {
  display: inline-flex;
  gap: 3px;
}

.contribution-legend i {
  width: 10px;
  height: 10px;
}

.settings-switch {
  position: relative;
  width: 45px;
  height: 28px;
  flex: 0 0 45px;
}

.settings-switch input {
  position: absolute;
  opacity: 0;
  inset: 0;
}

.settings-switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #6b7280;
  cursor: pointer;
  transition: background .16s ease;
}

.settings-switch span::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #fff;
  transition: transform .16s ease;
}

.settings-switch input:checked + span {
  background: #21b99a;
}

.settings-switch input:checked + span::after {
  transform: translateX(17px);
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 180;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0,0,0,.38);
  backdrop-filter: blur(10px);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(390px, 100%);
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.modal-card h2 {
  margin: 0 0 14px;
  font-size: 18px;
  line-height: 1.25;
  font-weight: 680;
  letter-spacing: 0;
}

.modal-card p {
  margin: -4px 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.modal-options {
  display: grid;
  gap: 7px;
}

.modal-options label {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
}

.modal-options label:has(input:checked) {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.modal-options input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.modal-options span {
  font-size: 13.5px;
}

.report-note {
  margin-top: 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.modal-button {
  min-width: 92px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 650;
}

.modal-button:hover {
  background: var(--surface-hover);
}

.modal-button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

.modal-button.danger {
  border-color: #ef4444;
  background: #ef4444;
  color: #fff;
}

.sidebar-overlay {
  display: none;
}

.desktop-hidden,
.mobile-only {
  display: none;
}

@media (max-width: 820px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .toast {
    box-shadow: none;
  }

  .profile-menu.open,
  .settings-layout,
  .settings-card {
    box-shadow: none;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 35;
    display: block;
    background: rgba(0,0,0,.28);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }

  .sidebar-overlay.show {
    opacity: 1;
    pointer-events: auto;
  }

  .desktop-hidden,
  .mobile-only {
    display: grid;
  }

  .topbar {
    padding-left: 8px;
    justify-content: center;
  }

  #openSidebar {
    position: absolute;
    left: 8px;
  }

  .model-picker {
    min-width: 0;
    max-width: calc(100vw - 72px);
  }

  .model-picker small {
    display: none;
  }

  .model-menu {
    position: fixed;
    top: 58px;
    left: 10px;
    right: 10px;
    width: auto;
    max-height: min(360px, calc(100dvh - 76px));
    overflow-y: auto;
  }

  .settings-backdrop {
    padding: 8px;
    place-items: end center;
  }

  .settings-card {
    width: 100%;
    min-height: 0;
    height: min(720px, calc(100dvh - 16px));
    max-height: calc(100dvh - 16px);
    border-radius: 18px;
  }

  .settings-head {
    height: 52px;
    padding: 0 10px 0 16px;
    border-bottom: 1px solid rgba(255,255,255,.06);
  }

  .settings-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    gap: 0;
    min-height: 0;
    padding: 0;
  }

  .settings-tabs {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 10px 12px;
    background: #2f2f2f;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.28) transparent;
  }

  .settings-tabs::-webkit-scrollbar {
    display: block;
    height: 5px;
  }

  .settings-tabs::-webkit-scrollbar-track {
    background: transparent;
  }

  .settings-tabs::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(255,255,255,.26);
  }

  .settings-tab {
    flex: 0 0 auto;
    height: 36px;
    padding: 0 10px;
    border-radius: 10px;
    font-size: 13px;
  }

  .settings-tab svg {
    width: 16px;
    height: 16px;
    flex-basis: 16px;
  }

  .settings-content {
    min-height: 0;
    overflow-y: auto;
    margin-right: 0;
    padding: 0 14px 16px;
  }

  .settings-panel.active {
    gap: 8px;
  }

  .settings-panel h3 {
    margin-bottom: 2px;
  }

  .settings-row {
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    align-items: start;
    padding: 12px 0;
  }

  .settings-row small {
    max-width: none;
  }

  .settings-select,
  .settings-choice,
  .settings-pill,
  .settings-danger,
  .settings-save {
    width: 100%;
  }

  .settings-choice-menu {
    left: 0;
    right: auto;
    width: 100%;
  }

  .settings-switch {
    justify-self: start;
  }

  .settings-field {
    padding-top: 12px;
  }

  .settings-actions {
    margin: 0 -14px -16px;
    padding: 20px 14px 16px;
    background: transparent;
  }

  .settings-actions.split {
    display: grid;
    grid-template-columns: 1fr;
  }

  .chat-row {
    min-height: 40px;
    padding-right: 10px;
  }

  .chat-title {
    font-size: 13.5px;
  }

  .chat-list {
    scrollbar-width: none;
  }

  .chat-pull-refresh {
    display: grid;
    box-shadow: none;
  }

  .user-message-tools {
    opacity: .86;
  }

  .chat-list::-webkit-scrollbar {
    display: none;
    width: 0;
  }

  .chat-actions {
    display: none;
  }

  .profile-row {
    min-height: 48px;
    background: rgba(255,255,255,.06);
    border-color: rgba(255,255,255,.09);
  }

  .profile-copy strong {
    font-size: 13.5px;
  }

  .empty-state {
    width: min(620px, calc(100% - 28px));
    padding-bottom: 160px;
  }

  .messages {
    width: min(760px, calc(100% - 24px));
  }

  .composer-zone {
    padding-inline: 10px;
  }
}

@media (max-width: 560px) {
  .topbar {
    height: 54px;
    flex-basis: 54px;
  }

  .suggestions {
    grid-template-columns: 1fr;
  }

  .suggestion:nth-child(n+3) {
    display: none;
  }

  .empty-state h1 {
    margin-bottom: 20px;
    max-width: min(100%, 330px);
    font-size: 26px;
    line-height: 1.18;
  }

  .hero-name {
    display: block;
    margin-bottom: 2px;
    font-size: 30px;
  }

  .hero-logo {
    width: 43px;
    height: 43px;
    border-radius: 13px;
  }

  .user-bubble {
    max-width: 88%;
  }

  .message-edit {
    width: 100%;
    padding: 15px 16px 13px;
    border-radius: 21px;
  }

  .message-edit-actions {
    margin-top: 13px;
  }

  .message {
    margin-bottom: 26px;
  }

  .messages {
    padding-top: 12px;
    padding-bottom: 160px;
  }

  .assistant-message,
  .user-bubble,
  .message-edit-input {
    font-size: 14.5px;
  }

  .composer-zone {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .composer-note {
    font-size: 9.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
  }

  .assistant-status-text {
    background: none;
    color: var(--muted);
  }
}

/* Context window gauge -------------------------------------------------- */
/* A ring in the topbar, filled by the tokens the last request carried. */
.context-ring {
  position: relative;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  margin-left: auto;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.context-ring[hidden] { display: none; }
.context-ring svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.context-ring circle {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
}
.context-ring-track { stroke: var(--stroke, rgba(255,255,255,.16)); }
.context-ring-fill {
  stroke: var(--accent, #4c8dff);
  stroke-dasharray: 97.4;
  stroke-dashoffset: 97.4;
  transition: stroke-dashoffset .45s ease, stroke .45s ease;
}
.context-ring.is-warn .context-ring-fill { stroke: #e0a33e; }
.context-ring.is-high .context-ring-fill { stroke: #e0603e; }
.context-ring-value {
  position: relative;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: -.02em;
  opacity: .85;
}

.context-card { max-width: 420px; }
.context-subtitle {
  margin: -4px 0 14px;
  font-size: 13px;
  opacity: .7;
}
/* One bar, split the way the request actually was: cached, then fresh. */
.context-bar {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--stroke, rgba(255,255,255,.12));
  margin-bottom: 16px;
}
/* At 0.7% of a 922k window a truthfully scaled segment is sub-pixel and
   vanishes. A floor keeps it visible without misstating the scale. */
.context-bar span { display: block; height: 100%; min-width: 3px; }
.context-bar .seg-cached { background: #4c8dff; }
.context-bar .seg-fresh  { background: #7bb0ff; }
.context-rows {
  margin: 0 0 14px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px 10px;
  align-items: center;
  font-size: 13px;
}
.context-rows dt {
  display: contents;
}
.context-swatch {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  background: currentColor;
}
.context-rows .label { opacity: .8; }
.context-rows .value {
  font-variant-numeric: tabular-nums;
  opacity: .95;
}
/* How the context grew across the calls this turn. */
.context-trail {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 34px;
  margin-bottom: 14px;
}
/* Slim bars, left aligned: with two calls a stretched pair reads as two
   slabs rather than a trail. */
.context-trail i {
  flex: 0 0 auto;
  width: 14px;
  border-radius: 2px 2px 0 0;
  background: var(--accent, #4c8dff);
  opacity: .55;
}
.context-trail i:last-child { opacity: 1; }
.context-trail[hidden] { display: none; }
.context-note {
  margin: 0 0 14px;
  font-size: 12px;
  line-height: 1.45;
  opacity: .6;
}
