:root {
  color-scheme: light;
  --bg: #f6f5f2;
  --panel: #ffffff;
  --panel-soft: #f0efeb;
  --border: #dedbd4;
  --text: #22211f;
  --muted: #77716a;
  --accent: #1f6f62;
  --accent-soft: #dcece8;
  --user: #e8f0ff;
  --assistant: #ffffff;
  --tool: #f4efe6;
  --notice: #fff4d8;
  --interaction: #fff0f0;
  --shadow: 0 10px 26px rgba(38, 35, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(246, 245, 242, 0.92);
  padding: 18px;
}

.auth-gate[hidden] {
  display: none;
}

.auth-card {
  display: grid;
  width: min(100%, 340px);
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 22px;
}

.auth-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
}

.auth-card h2 {
  white-space: normal;
}

.auth-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.auth-input-wrap {
  position: relative;
}

.auth-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  outline: none;
  padding: 10px 44px 10px 12px;
}

.auth-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.auth-reveal {
  position: absolute;
  top: 50%;
  right: 6px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  transform: translateY(-50%);
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.auth-reveal:hover,
.auth-reveal[aria-pressed="true"] {
  background: var(--panel-soft);
  color: var(--text);
}

.auth-reveal svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.remember-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.remember-toggle input {
  width: 15px;
  height: 15px;
}

.auth-button {
  border: 1px solid #145b50;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 650;
  padding: 10px 14px;
}

.auth-button:disabled {
  cursor: default;
  opacity: 0.62;
}

.auth-error {
  min-height: 16px;
  color: #b42318;
  font-size: 12px;
}

.shell {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.shell.sidebar-collapsed {
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
}

.sidebar {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: #fff;
  font-weight: 400;
  overflow: hidden;
  transform: translateX(0);
  transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 240ms ease;
}

.shell.sidebar-collapsed .sidebar {
  transform: translateX(0);
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 16px 12px;
}

.sidebar-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 500;
}

h2 {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 18px;
  font-weight: 680;
}

.sidebar-top p,
.conversation-header p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.icon-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  line-height: 1;
}

.icon-button:hover {
  border-color: #c7c1b8;
}

.refresh-button {
  border-color: #d8dde3;
  background: #f7f8fa;
  color: #69727d;
  opacity: 0.9;
}

.refresh-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.1;
}

.refresh-button:hover {
  border-color: #bfc7d0;
  background: #fff;
  color: #4e5965;
  opacity: 1;
}

.drawer-tab {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 20;
  display: none;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.shell.sidebar-collapsed .drawer-tab {
  display: none;
}

.drawer-overlay {
  display: none;
}

.thread-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin: 0 16px 12px;
}

.search {
  width: calc(100% - 32px);
  margin: 0 16px 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  outline: none;
}

.thread-search-row .search {
  width: 100%;
  min-width: 0;
  margin: 0;
}

.search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.new-thread-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: #29477f;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  padding: 0 13px;
  white-space: nowrap;
}

.new-thread-button span:first-child {
  font-size: 22px;
  font-weight: 500;
  line-height: 0.8;
}

.new-thread-button:disabled {
  cursor: default;
  opacity: 0.62;
}

.thread-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 4px 8px 14px;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}

.thread-list::-webkit-scrollbar {
  display: none;
}

.thread-item {
  width: 100%;
  min-height: 44px;
  margin: 0 0 6px;
  padding: 10px 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 400;
  text-align: left;
}

.thread-item:hover {
  background: #f6f7f8;
}

.thread-item.active {
  border-color: #dde4ec;
  background: #f4f7fb;
  box-shadow: none;
}

.thread-item.draft .thread-title {
  color: var(--accent);
}

.thread-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 400;
}

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

.conversation-header {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.82);
  padding: 12px 22px;
}

.shell.sidebar-collapsed .conversation-header {
  padding-left: 64px;
}

.conversation-title {
  flex: 1 1 auto;
  min-width: 0;
}

.conversation-actions {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

.toggle {
  display: inline-flex;
  width: 34px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  border: 1px solid #d8dde3;
  border-radius: 8px;
  background: #f7f8fa;
  color: #8a929c;
  cursor: pointer;
  font-size: 16px;
  opacity: 0.78;
  padding: 0;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, color 160ms ease, opacity 160ms ease;
  white-space: nowrap;
}

.toggle:hover {
  border-color: #bfc7d0;
  background: #fff;
  color: #5f6873;
  opacity: 1;
}

.toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.toggle:has(input:checked) {
  border-color: #2c7a6f;
  background: #2f8a7e;
  box-shadow: 0 2px 7px rgba(47, 138, 126, 0.24);
  color: #fff;
  opacity: 1;
}

.toggle:has(input:checked):hover {
  border-color: #236a60;
  background: #28786d;
  color: #fff;
}

.message-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 22px 22px 14px;
  overscroll-behavior: contain;
}

.scroll-to-bottom-button {
  position: absolute;
  right: 28px;
  bottom: calc(var(--composer-height, 128px) + 16px);
  z-index: 8;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid #d8dde3;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 24px rgba(31, 41, 55, 0.16);
  color: #334155;
  cursor: pointer;
  opacity: 1;
  transition:
    transform 0.16s ease,
    opacity 0.16s ease,
    box-shadow 0.16s ease;
}

.scroll-to-bottom-button[hidden] {
  display: none;
}

.scroll-to-bottom-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(31, 41, 55, 0.2);
}

.scroll-to-bottom-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.empty-state {
  margin: 18vh auto 0;
  max-width: 360px;
  color: var(--muted);
  text-align: center;
}

.message {
  display: grid;
  grid-template-columns: 92px minmax(0, 820px);
  gap: 12px;
  margin: 0 auto 14px;
  max-width: 1040px;
}

.role {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding-top: 10px;
}

.role-badge {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  color: var(--muted);
}

.role-icon-image,
.role-icon-svg,
.role-icon-fallback {
  flex: 0 0 auto;
  display: block;
  width: 24px;
  height: 24px;
}

.role-icon-image {
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(38, 35, 31, 0.16);
}

.role-icon-svg {
  color: #5f5a53;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.role-icon-fallback {
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
}

.role-text {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bubble {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--assistant);
  padding: 12px 14px;
  line-height: 1.55;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

.message-meta {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.message-meta-top {
  margin-bottom: 8px;
}

.message-meta-bottom {
  margin-top: 10px;
  text-align: right;
}

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

.message-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  object-fit: contain;
}

.message-image-open {
  display: block;
  width: min(520px, 100%);
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.image-preview {
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 32px);
  padding: 44px 12px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.image-preview::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.image-preview-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 32px;
  height: 32px;
  font-size: 24px;
}

.image-preview-image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100dvh - 104px);
  object-fit: contain;
}

.generated-image {
  width: min(520px, 100%);
  max-height: none;
  margin-top: 8px;
  object-fit: contain;
}

.message-image-pill {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  padding: 6px 8px;
}

.message-videos {
  margin-top: 12px;
}

.message-video + .message-video {
  margin-top: 16px;
}

.message-video-player {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: #111;
}

.message-video-caption {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.message.user .bubble {
  grid-column: 1;
  grid-row: 1;
  background: var(--user);
  border-color: #d5dff1;
}

.message.user {
  grid-template-columns: minmax(0, 820px) 92px;
}

.message.user .role {
  grid-column: 2;
  grid-row: 1;
  justify-content: flex-start;
}

.message.user .role-badge {
  justify-content: flex-start;
}

.message.pending .bubble {
  box-shadow: inset 0 0 0 1px rgba(31, 111, 98, 0.12);
}

.message.tool .bubble {
  background: var(--tool);
  color: #5b5348;
}

.message.tool-image .message-images {
  margin-top: 0;
}

.message.tool-image .message-image {
  width: min(520px, 100%);
  max-height: none;
  object-fit: contain;
}

.message.interaction .bubble {
  border-color: #e1aaa6;
  background: var(--interaction);
  color: #4a211f;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02), inset 3px 0 0 #c75b55;
}

.message.question .bubble {
  border-color: var(--border);
  background: var(--panel);
  color: var(--text);
  box-shadow: none;
}

.question-answer-form + .question-answer-form,
.question-result + .question-title {
  margin-top: 18px;
}

.question-title {
  margin: 0 0 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.question-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.question-option,
.question-submit {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  text-align: left;
  max-width: 100%;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.question-submit {
  margin-top: 8px;
}

.question-answer-input {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.question-result {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.question-error {
  color: #a32d2d;
  overflow-wrap: anywhere;
}

.question-option:disabled,
.question-submit:disabled,
.question-answer-input:disabled {
  opacity: 0.55;
  cursor: default;
}

.message.interaction .message-meta {
  color: #95524d;
}

.interaction-icon {
  color: #b13b35;
}

.message.notice .bubble {
  border-color: #d8b75a;
  background: var(--notice);
  color: #3d3216;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02), inset 3px 0 0 #d5a82d;
}

.message.notice .message-meta {
  color: #806724;
}

.notice-icon {
  color: #a27308;
}

.message.tool.hidden {
  display: none;
}

.thinking-bubble {
  color: var(--muted);
}

.thinking-bubble p {
  display: inline-flex;
  align-items: baseline;
}

.thinking-dots::after {
  display: inline-block;
  width: 1.5em;
  content: "...";
  animation: thinking-dots 1.1s steps(4, end) infinite;
  overflow: hidden;
  vertical-align: bottom;
}

@keyframes thinking-dots {
  0% {
    width: 0;
  }
  100% {
    width: 1.5em;
  }
}

.bubble pre {
  overflow: auto;
  margin: 8px 0;
  padding: 12px;
  border-radius: 8px;
  background: #25231f;
  color: #f7f3ea;
}

.bubble code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.bubble p {
  margin: 0 0 10px;
}

.bubble p:last-child {
  margin-bottom: 0;
}

.tool-title {
  margin-bottom: 8px;
  color: #776c5e;
  font-size: 12px;
  font-weight: 700;
}

.interaction-title {
  margin-bottom: 8px;
  color: #7d2c28;
  font-size: 13px;
  font-weight: 750;
}

.approval-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.approval-action {
  min-height: 32px;
  border: 1px solid rgba(134, 103, 23, 0.28);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.72);
  color: #5b4510;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.1;
  padding: 7px 12px;
}

.approval-action.primary {
  border-color: rgba(39, 112, 92, 0.28);
  background: #eaf4ef;
  color: #1f5f50;
}

.approval-action.secondary {
  color: #6d4c18;
}

.approval-action:disabled {
  cursor: default;
  opacity: 0.55;
}

.approval-result {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-top: 12px;
  border: 1px solid rgba(39, 112, 92, 0.18);
  border-radius: 7px;
  background: rgba(234, 244, 239, 0.82);
  color: #1f5f50;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  padding: 6px 10px;
}

.approval-result.pending {
  border-color: rgba(134, 103, 23, 0.22);
  background: rgba(255, 255, 255, 0.62);
  color: #6d4c18;
}

.notice-title {
  color: #5e470d;
  font-size: 13px;
  font-weight: 750;
}

.notice-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 8px;
}

.notice-collapse-button {
  flex: 0 0 auto;
  min-height: 28px;
  border: 1px solid rgba(94, 71, 13, 0.18);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.68);
  color: #5e470d;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 6px 9px;
}

.composer {
  position: relative;
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  padding: 12px 22px 14px;
}

.composer-input {
  width: 100%;
  max-height: 170px;
  min-height: 52px;
  resize: none;
  overflow-y: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  outline: none;
  padding: 10px 12px;
}

.composer-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.plugin-mention-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.plugin-mention-tray[hidden] {
  display: none;
}

.plugin-chip,
.message-plugin-ref {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  gap: 7px;
  border: 1px solid #d7ddd8;
  border-radius: 8px;
  background: #f6faf8;
  color: #213a34;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.2;
  vertical-align: middle;
}

.plugin-chip {
  min-height: 32px;
  cursor: pointer;
  padding: 5px 8px 5px 6px;
}

.plugin-chip:hover {
  border-color: #b9cbc4;
  background: #edf6f2;
}

.plugin-chip span,
.message-plugin-ref {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plugin-chip small {
  display: inline-grid;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 5px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
}

.plugin-chip:hover small {
  background: rgba(33, 58, 52, 0.08);
  color: var(--text);
}

.plugin-chip-icon,
.message-plugin-icon {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 6px;
  object-fit: cover;
}

.plugin-chip-icon {
  width: 22px;
  height: 22px;
}

.message-plugin-icon {
  width: 18px;
  height: 18px;
}

.plugin-chip-icon.fallback,
.message-plugin-icon.fallback {
  background: #dcece8;
  color: #1f6f62;
  font-size: 11px;
  font-weight: 800;
}

.message-plugin-ref {
  margin: 0 2px;
  padding: 3px 7px 3px 5px;
}

.plugin-mention-menu {
  position: absolute;
  right: 22px;
  bottom: calc(100% - 8px);
  left: 22px;
  z-index: 20;
  max-height: min(310px, 45vh);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
  padding: 7px;
}

.plugin-mention-menu[hidden] {
  display: none;
}

.plugin-mention-heading,
.plugin-mention-state {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  padding: 7px 8px;
}

.plugin-mention-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  width: 100%;
  min-height: 46px;
  column-gap: 9px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  line-height: 1.25;
  padding: 8px 9px;
  text-align: left;
}

.plugin-mention-icon {
  grid-row: span 2;
  align-self: center;
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 7px;
  object-fit: cover;
}

.plugin-mention-icon.fallback {
  background: #dcece8;
  color: #1f6f62;
  font-size: 12px;
  font-weight: 800;
}

.plugin-mention-item:hover,
.plugin-mention-item.active {
  border-color: rgba(31, 111, 98, 0.2);
  background: var(--accent-soft);
}

.plugin-mention-item strong,
.plugin-mention-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plugin-mention-item strong {
  font-size: 13px;
  font-weight: 700;
}

.plugin-mention-item span {
  color: var(--muted);
  font-size: 12px;
}

.attachment-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-tray[hidden] {
  display: none;
}

.attachment-item {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  width: min(100%, 220px);
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f7f6f2;
  padding: 5px 30px 5px 5px;
}

.attachment-item img {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  object-fit: cover;
}

.attachment-item span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-item button {
  position: absolute;
  top: 5px;
  right: 5px;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.attachment-item button:hover {
  color: var(--text);
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.composer-left {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}

.send-status {
  min-height: 0;
  overflow: hidden;
  color: #b42318;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.send-status:empty {
  display: none;
}

.composer-buttons {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.attach-button {
  font-size: 22px;
  line-height: 1;
}

.attach-button:disabled {
  cursor: default;
  opacity: 0.55;
}

.image-picker-menu {
  position: absolute;
  right: 48px;
  bottom: calc(100% + 8px);
  z-index: 40;
  display: grid;
  min-width: 116px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.14);
  padding: 4px;
}

.image-picker-menu[hidden] {
  display: none;
}

.image-picker-menu button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  line-height: 1.2;
  padding: 9px 10px;
  text-align: left;
}

.image-picker-menu button:hover {
  background: #f3f6f4;
}

.account-widget {
  display: inline-flex;
  flex: 0 1 auto;
  min-width: 0;
  align-items: center;
  gap: 5px;
}

.account-summary {
  display: inline-flex;
  min-width: 0;
  max-width: min(30vw, 240px);
  align-items: center;
  gap: 6px;
  border: 1px solid #e5e1d9;
  border-radius: 7px;
  background: rgba(247, 246, 242, 0.72);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  padding: 5px 7px;
  font-size: 12px;
  line-height: 1.2;
  transition: background 160ms ease, border-color 160ms ease;
}

.account-summary:hover,
.account-summary.expanded {
  border-color: #d8d2c8;
  background: rgba(247, 246, 242, 0.96);
}

.account-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
}

.account-plan {
  flex: 0 0 auto;
  border-left: 1px solid #e2ded6;
  color: var(--muted);
  padding-left: 6px;
}

.plugin-picker-button {
  display: inline-flex;
  height: 28px;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  border: 1px solid #e5e1d9;
  border-radius: 7px;
  background: rgba(247, 246, 242, 0.72);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  line-height: 1;
  padding: 0 7px;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.plugin-picker-dots {
  display: grid;
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  grid-template-columns: repeat(2, 5px);
  grid-template-rows: repeat(2, 5px);
  place-content: center;
  gap: 4px;
}

.plugin-picker-dots span {
  width: 5px;
  height: 5px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  background: transparent;
}

.plugin-picker-label {
  color: currentColor;
  font-weight: 650;
  white-space: nowrap;
}

.plugin-picker-button:hover,
.plugin-picker-button.active {
  border-color: #d8d2c8;
  background: rgba(247, 246, 242, 0.96);
  color: var(--text);
}

.plugin-picker-button:disabled {
  cursor: default;
  opacity: 0.55;
}

.skill-picker-button {
  color: var(--muted);
}

.skill-picker-icon {
  display: inline-grid;
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
}

.skill-chip {
  border-color: #ddd8e7;
  background: #f8f6fb;
  color: #332c46;
}

.skill-chip:hover {
  border-color: #c8bfd8;
  background: #f1edf8;
}

.skill-chip-icon.fallback,
.skill-mention-icon.fallback {
  background: #e9e3f2;
  color: #5b4280;
  font-size: 13px;
}

.account-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f7f6f2;
  padding: 9px 10px;
}

.usage-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.usage-row {
  min-width: 0;
  border-left: 2px solid #c8d8d4;
  padding-left: 9px;
}

.usage-row span,
.usage-row small {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.usage-row strong {
  display: block;
  margin: 1px 0;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.usage-empty {
  color: var(--muted);
  font-size: 12px;
}

.send-button {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #145b50;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  padding: 0;
}

.send-icon {
  display: block;
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.4;
}

.send-stop-icon {
  display: none;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: currentColor;
}

.send-button.stop-mode {
  border-color: #33302c;
  background: #33302c;
}

.send-button.stop-mode .send-icon {
  display: none;
}

.send-button.stop-mode .send-stop-icon {
  display: block;
}

.send-button:disabled {
  border-color: #c9c4ba;
  background: #ddd9d0;
  color: #8f887d;
  cursor: default;
}

@media (max-width: 760px) and (orientation: portrait) {
  .shell {
    grid-template-columns: 1fr;
    height: 100dvh;
  }

  .shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: min(82vw, 360px);
    border-right: 0;
    border-bottom: 0;
    box-shadow: 16px 0 34px rgba(38, 35, 31, 0.18);
  }

  .shell.sidebar-collapsed .sidebar {
    transform: translateX(calc(-100% - 18px));
    pointer-events: none;
  }

  .drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 25;
    display: block;
    border: 0;
    background: rgba(34, 33, 31, 0.24);
    opacity: 1;
    cursor: pointer;
    transition: opacity 220ms ease;
  }

  .shell.sidebar-collapsed .drawer-overlay {
    opacity: 0;
    pointer-events: none;
  }

  .drawer-tab {
    display: grid;
  }

  .shell.sidebar-collapsed .drawer-tab {
    display: grid;
  }

  .shell:not(.sidebar-collapsed) .drawer-tab {
    opacity: 0;
    pointer-events: none;
  }

  .sidebar-top {
    padding: 12px 12px 8px;
  }

  h1 {
    font-size: 19px;
  }

  .thread-search-row {
    gap: 6px;
    margin: 0 12px 8px;
  }

  .search {
    width: 100%;
    margin: 0;
    padding: 9px 10px;
  }

  .new-thread-button {
    min-height: 36px;
    gap: 5px;
    font-size: 13px;
    padding: 0 10px;
  }

  .thread-list {
    padding: 2px 6px 10px;
  }

  .thread-item {
    min-height: 42px;
    margin-bottom: 4px;
    padding: 8px 9px;
  }

  .conversation-header {
    min-height: 58px;
    padding: 10px 14px;
  }

  .conversation-header,
  .shell.sidebar-collapsed .conversation-header {
    padding-left: 58px;
  }

  h2 {
    max-width: min(62vw, calc(100vw - 174px));
    font-size: 15px;
  }

  .conversation-actions {
    gap: 7px;
  }

  .conversation-actions .icon-button {
    width: 32px;
    height: 32px;
  }

  .toggle {
    width: 32px;
    min-height: 32px;
    font-size: 15px;
  }

  .message-list {
    padding: 14px 14px 10px;
  }

  .message {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .message.user {
    grid-template-columns: 1fr;
  }

  .role {
    justify-content: flex-start;
    padding-top: 0;
  }

  .message.user .role,
  .message.user .bubble {
    grid-column: auto;
    grid-row: auto;
  }

  .message.user .role {
    justify-content: flex-end;
  }

  .role-badge {
    justify-content: flex-start;
  }

  .message.user .role-badge {
    justify-content: flex-end;
  }

  .role-icon-image,
  .role-icon-svg,
  .role-icon-fallback {
    width: 22px;
    height: 22px;
  }

  .composer {
    padding: 10px 12px 12px;
  }

  .plugin-mention-menu {
    right: 12px;
    left: 12px;
    max-height: min(280px, 42vh);
  }

  .plugin-mention-item {
    min-height: 50px;
  }

  .composer-input {
    max-height: 120px;
    min-height: 46px;
    padding: 9px 10px;
  }

  .composer-actions {
    gap: 8px;
  }

  .composer-left {
    gap: 6px;
  }

  .composer-buttons {
    gap: 6px;
  }

  .attach-button {
    width: 36px;
    height: 36px;
  }

  .attachment-item {
    width: min(100%, 190px);
  }

  .account-summary {
    max-width: 34vw;
    padding: 5px 6px;
  }

  .plugin-picker-button {
    height: 28px;
    gap: 5px;
    padding: 0 6px;
  }

  .usage-grid {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .send-button {
    width: 36px;
    height: 36px;
  }
}
