:root {
  color-scheme: light dark;
  --viewport-height: 100dvh;
  --keyboard-inset: 0px;
  --composer-height: 76px;
  --composer-lift: 0px;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --panel-strong: #f1f4f8;
  --ink: #17202a;
  --muted: #617083;
  --line: #dfe5ec;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: #d9f4ef;
  --warn: #b42318;
  --link: #0f766e;
  --code-bg: #10151f;
  --code-ink: #eef2f7;
  --code-border: #263141;
  --shadow: 0 18px 60px rgba(30, 41, 59, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.sidebar-open,
body.detail-drawer-open,
body.picker-open {
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  width: 100%;
  min-height: 100vh;
  padding: 18px;
}

.sidebar,
.chat-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.sidebar-overlay {
  display: none;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  border-radius: 8px;
  padding: 18px;
}

.brand {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  width: 48px;
  height: 48px;
  padding: 8px;
  border-radius: 8px;
  background: #17202a;
}

.brand-mark span {
  border-radius: 3px;
  background: var(--accent-soft);
}

.brand-mark span:nth-child(2) {
  background: #f6c177;
}

.brand-mark span:nth-child(3) {
  background: #7dd3fc;
}

.brand h1,
.chat-header h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 24px;
  line-height: 1.05;
}

.brand p,
.chat-header span {
  display: block;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.brand p.warn {
  color: var(--warn);
}

.control-group {
  display: grid;
  gap: 7px;
}

.thread-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px 42px;
  gap: 10px;
}

.thread-filter-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.thread-filter-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--muted);
  padding: 0 7px;
  font-size: 12px;
  font-weight: 700;
}

.thread-filter-button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.filter-label,
.filter-count {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-count {
  min-width: 18px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
  padding: 1px 5px;
  color: inherit;
  font-size: 11px;
  line-height: 1.35;
}

.thread-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 7px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
  -webkit-overflow-scrolling: touch;
}

.thread-group-title {
  position: sticky;
  top: 0;
  z-index: 1;
  margin-top: 3px;
  padding: 7px 4px 4px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.thread-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  overflow: hidden;
  text-align: left;
}

.thread-item:hover,
.thread-item.active {
  border-color: #93c5bd;
  background: #f2fbf9;
}

.thread-item.running {
  border-color: #5eead4;
  box-shadow: inset 3px 0 0 #14b8a6;
}

.thread-item.pinned {
  border-color: #ecd49b;
  background: #fffaf0;
}

.thread-main {
  display: grid;
  align-content: center;
  gap: 5px;
  min-width: 0;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 10px 8px 10px 10px;
  text-align: left;
}

.thread-name,
.thread-cwd {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-name {
  font-size: 14px;
  font-weight: 650;
  line-height: 1.28;
}

.thread-cwd {
  color: var(--muted);
  font-size: 12px;
}

.thread-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.thread-state.running {
  color: var(--accent);
  font-weight: 700;
}

.thread-state.sync {
  color: #b7791f;
  font-weight: 700;
}

.thread-state.warn {
  color: var(--warn);
  font-weight: 700;
}

.thread-state-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}

.thread-state-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pin-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #8a98a8;
}

.pin-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pin-button:hover,
.pin-button.pinned {
  background: #fff2cf;
  color: #a16207;
}

.pin-button.pinned svg {
  fill: currentColor;
}

.thread-empty {
  border: 1px dashed var(--line);
  border-radius: 7px;
  color: var(--muted);
  padding: 13px;
  text-align: center;
}

.control-group label {
  color: var(--muted);
  font-size: 13px;
}

.text-input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-strong);
  color: var(--ink);
  padding: 0 11px;
  outline: none;
}

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

.side-actions,
.header-actions {
  display: flex;
  gap: 10px;
  margin-top: auto;
}

.header-actions {
  margin-top: 0;
}

.mobile-thread-button,
.sidebar-close {
  display: none;
}

.ghost-button,
.icon-button,
.send-button {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
}

.ghost-button,
.icon-button {
  position: relative;
  width: 42px;
  height: 42px;
}

.icon-button.has-badge::after {
  content: attr(data-hidden-count);
  position: absolute;
  right: -4px;
  top: -5px;
  min-width: 18px;
  height: 18px;
  border: 1px solid var(--panel);
  border-radius: 9px;
  background: var(--accent);
  color: #ffffff;
  padding: 0 5px;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
}

.ghost-button svg,
.icon-button svg,
.send-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ghost-button:hover,
.icon-button:hover,
.icon-button.active {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.icon-button.active {
  background: var(--accent-soft);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: calc(100vh - 36px);
  border-radius: 8px;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 74px;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
  background: linear-gradient(90deg, #ffffff 0%, #f5faf9 100%);
}

.chat-header > div:first-child {
  min-width: 0;
}

.thread-heading {
  flex: 1;
  min-width: 0;
}

.chat-header h2 {
  overflow: hidden;
  font-size: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-controls {
  display: grid;
  grid-template-columns: minmax(120px, 0.58fr) minmax(118px, 0.56fr) minmax(126px, 0.6fr) minmax(250px, 1.25fr);
  gap: 8px;
  align-items: stretch;
  min-width: 0;
  border-bottom: 1px solid var(--line);
  background: #f7fafb;
  padding: 8px 18px;
}

.select-field {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 2px;
  min-width: 0;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 6px 10px 7px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}

.select-field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

.runtime-select {
  appearance: none;
  width: 100%;
  min-width: 0;
  height: 24px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  padding: 0 22px 0 0;
  outline: none;
  font-size: 13px;
  font-weight: 650;
  line-height: 24px;
  text-overflow: ellipsis;
}

.runtime-select:focus {
  box-shadow: none;
}

.select-field:focus-within,
.quota-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.quota-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  align-items: center;
  min-width: 0;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 6px 9px 7px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
  position: relative;
}

.quota-button {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 24px;
  height: 24px;
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent);
}

.quota-button svg {
  width: 15px;
  height: 15px;
}

.quota-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding-right: 28px;
}

.quota-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

.quota-summary {
  display: block;
  min-width: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
  padding: 8px 18px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.session-controls,
.activity-bar {
  scrollbar-width: none;
}

.session-controls::-webkit-scrollbar,
.activity-bar::-webkit-scrollbar {
  display: none;
}

.activity-bar.hidden {
  display: none;
}

.activity-status,
.activity-chip {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  max-width: min(460px, 80vw);
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--muted);
  padding: 5px 9px;
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
}

.activity-status {
  color: var(--ink);
  font-weight: 650;
}

.activity-status.warn {
  border-color: #f0b8b2;
  background: #fff2f0;
  color: var(--warn);
}

.activity-status.active {
  border-color: #b7dad5;
  background: #edf9f6;
  color: var(--accent-strong);
}

.activity-dot {
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: currentColor;
}

.activity-status.active .activity-dot,
.activity-status.warn .activity-dot {
  animation: pulse 1s infinite ease-in-out;
}

.activity-chip {
  overflow: hidden;
  max-width: 280px;
  text-overflow: ellipsis;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.history-banner {
  display: flex;
  align-self: center;
  align-items: center;
  justify-content: center;
  gap: 9px;
  max-width: min(620px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfd;
  color: var(--muted);
  padding: 8px 10px;
  font-size: 13px;
}

.inline-button {
  min-height: 30px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 10px;
}

.inline-button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.message {
  display: grid;
  gap: 7px;
  min-width: 0;
  max-width: min(820px, 92%);
}

.message.user {
  align-self: flex-end;
}

.message.assistant {
  align-self: flex-start;
}

.message-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.message-action-button {
  min-height: 30px;
  border: 1px solid #b7dad5;
  border-radius: 7px;
  background: var(--panel);
  color: var(--accent-strong);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
}

.message-action-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.role {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.bubble {
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--panel);
  line-height: 1.58;
  overflow-x: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.user .bubble {
  border-color: #b7dad5;
  background: var(--accent-soft);
}

.assistant .bubble {
  background: #ffffff;
}

.bubble.pending::after {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 0.55em;
  margin-left: 0.2em;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1s infinite ease-in-out;
}

.bubble.rich-text {
  white-space: normal;
}

.rich-text > *:first-child {
  margin-top: 0;
}

.rich-text > *:last-child {
  margin-bottom: 0;
}

.rich-text p {
  margin: 0 0 10px;
  white-space: pre-wrap;
}

.rich-text h3,
.rich-text h4,
.rich-text h5,
.rich-text h6 {
  margin: 14px 0 7px;
  font-size: 1em;
  line-height: 1.35;
}

.rich-text ul,
.rich-text ol {
  margin: 0 0 10px;
  padding-left: 1.25em;
}

.rich-text li {
  margin: 4px 0;
  padding-left: 0.15em;
}

.rich-text blockquote {
  margin: 0 0 10px;
  border-left: 3px solid var(--accent);
  background: var(--panel-strong);
  color: var(--muted);
  padding: 8px 10px;
}

.rich-text a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.rich-text code {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel-strong);
  padding: 0.08em 0.32em;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.rich-text pre {
  margin: 0 0 12px;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--code-border);
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--code-ink);
  padding: 11px 12px;
  -webkit-overflow-scrolling: touch;
}

.rich-text pre code {
  display: block;
  min-width: max-content;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: 0.9em;
  line-height: 1.6;
  white-space: pre;
}

.bubble.error {
  border-color: #f0b8b2;
  background: #fff2f0;
  color: var(--warn);
}

.event .bubble,
.event-bubble {
  background: #f7f8fa;
  color: var(--muted);
  font-size: 13px;
}

.event-clickable {
  cursor: pointer;
}

.event-clickable:focus-visible .bubble,
.event-clickable:hover .bubble {
  border-color: var(--accent);
  color: var(--ink);
}

.reconnect-bubble {
  border-color: #d7c8aa;
  background: #fffaf0;
  color: #4b5563;
  font-family:
    "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.72;
}

.composer {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 14px;
  background: var(--panel);
}

.composer textarea {
  width: 100%;
  max-height: 220px;
  min-height: 48px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  outline: none;
  line-height: 1.45;
  background: var(--panel);
  color: var(--ink);
}

.send-button {
  width: 48px;
  height: 48px;
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  touch-action: manipulation;
}

.send-button:hover {
  background: var(--accent-strong);
}

.composer-tool-button {
  width: 48px;
  height: 48px;
  background: var(--panel-strong);
}

.detail-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: none;
  background: rgba(15, 23, 42, 0.34);
}

.detail-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 40;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(480px, 92vw);
  border-left: 1px solid var(--line);
  background: var(--panel);
  box-shadow: -18px 0 50px rgba(15, 23, 42, 0.16);
  transform: translateX(104%);
  transition: transform 180ms ease;
}

body.detail-drawer-open .detail-drawer-overlay {
  display: block;
}

body.detail-drawer-open .detail-drawer {
  transform: translateX(0);
}

.picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 42;
  display: none;
  background: rgba(15, 23, 42, 0.34);
}

.picker-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 45;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  width: min(520px, 94vw);
  border-left: 1px solid var(--line);
  background: var(--panel);
  box-shadow: -18px 0 50px rgba(15, 23, 42, 0.16);
  transform: translateX(104%);
  transition: transform 180ms ease;
}

body.picker-open .picker-overlay {
  display: block;
}

body.picker-open .picker-drawer {
  transform: translateX(0);
}

.picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 14px;
}

.picker-header h2 {
  margin: 0;
  font-size: 18px;
}

.picker-header p {
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-roots {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  overflow-x: auto;
}

.picker-root {
  flex: 0 0 auto;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-strong);
  color: var(--ink);
  padding: 0 10px;
}

.picker-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
}

.picker-entry {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 10px;
  text-align: left;
}

.picker-entry:hover {
  border-color: var(--accent);
  background: #f2fbf9;
}

.picker-entry.folder {
  background: var(--panel);
}

.picker-entry-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 24px;
  border-radius: 5px;
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.picker-entry-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 16px;
  text-align: center;
}

.picker-empty.error {
  border-color: #f0b8b2;
  color: var(--warn);
}

.picker-footer {
  border-top: 1px solid var(--line);
  padding: 12px;
}

.picker-footer .inline-button {
  width: 100%;
  min-height: 42px;
  font-weight: 700;
}

.detail-drawer-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

.detail-drawer-header h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.detail-drawer-header p {
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-drawer-body {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px 18px;
}

.detail-section {
  display: grid;
  gap: 8px;
}

.detail-section h3 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.2;
}

.detail-kv {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 7px 12px;
  margin: 0;
  font-size: 13px;
}

.detail-kv dt {
  color: var(--muted);
}

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

.detail-pre {
  max-width: 100%;
  margin: 0;
  overflow-x: auto;
  border: 1px solid var(--code-border);
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--code-ink);
  padding: 11px 12px;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre;
  -webkit-overflow-scrolling: touch;
}

.detail-file-list {
  display: grid;
  gap: 10px;
}

.detail-file-item {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel-strong);
}

.detail-file-name {
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 700;
}

.detail-file-meta,
.detail-muted {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(0.7);
    opacity: 0.45;
  }

  50% {
    transform: scale(1);
    opacity: 1;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1014;
    --panel: #171a20;
    --panel-strong: #20252d;
    --ink: #f2f5f8;
    --muted: #9da8b6;
    --line: #303741;
    --accent: #2dd4bf;
    --accent-strong: #5eead4;
    --accent-soft: #113c38;
    --warn: #ff8a80;
    --link: #67e8f9;
    --code-bg: #0a0c10;
    --code-ink: #e9edf2;
    --code-border: #343c48;
    --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  }

  .brand-mark {
    background: #0b0d11;
  }

  .chat-header {
    background: linear-gradient(90deg, #171a20 0%, #14201e 100%);
  }

  .session-controls,
  .activity-bar {
    background: #12151a;
  }

  .thread-group-title,
  .thread-item,
  .thread-filter-button,
  .ghost-button,
  .icon-button,
  .picker-entry,
  .picker-root,
  .select-field,
  .quota-field,
  .activity-status,
  .activity-chip,
  .bubble,
  .composer,
  .inline-button {
    background: var(--panel);
  }

  .runtime-select,
  .quota-summary {
    background: transparent;
  }

  .text-input {
    background: var(--panel-strong);
    color: var(--ink);
  }

  .thread-item:hover,
  .thread-item.active,
  .picker-entry:hover {
    border-color: #2dd4bf;
    background: #102622;
  }

  .thread-item.running {
    border-color: #2dd4bf;
    box-shadow: inset 3px 0 0 #2dd4bf;
  }

  .thread-filter-button.active {
    border-color: #2dd4bf;
    background: #103c38;
    color: var(--accent-strong);
  }

  .filter-count {
    background: rgba(45, 212, 191, 0.15);
  }

  .picker-entry.folder {
    background: var(--panel);
  }

  .thread-item.pinned {
    border-color: #a78335;
    background: #2a2415;
  }

  .pin-button:hover,
  .pin-button.pinned {
    background: #332811;
    color: #f5c86a;
  }

  .activity-status.active {
    border-color: #21756d;
    background: #103c38;
    color: var(--accent-strong);
  }

  .activity-status.warn,
  .bubble.error {
    border-color: #7f332f;
    background: #2a1616;
    color: var(--warn);
  }

  .event .bubble,
  .event-bubble {
    background: #12151a;
  }

  .message-action-button {
    border-color: #21756d;
    background: var(--panel);
    color: var(--accent-strong);
  }

  .message-action-button:hover {
    background: #103c38;
  }

  .assistant .bubble {
    background: #171a20;
  }

  .user .bubble {
    border-color: #24766d;
    background: #123d38;
  }

  .history-banner {
    background: #141820;
  }

  .detail-drawer {
    background: var(--panel);
    box-shadow: -18px 0 50px rgba(0, 0, 0, 0.44);
  }

  .detail-file-item {
    background: var(--panel-strong);
  }
}

@media (max-width: 760px) {
  :root {
    --composer-lift: 0px;
  }

  body.keyboard-open {
    --composer-lift: 32px;
  }

  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .app-shell {
    display: block;
    width: 100vw;
    max-width: 100vw;
    min-height: var(--viewport-height);
    overflow-x: hidden;
    padding: 0;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: min(88vw, 380px);
    max-width: 100%;
    border-radius: 0;
    padding: 12px;
    transform: translateX(-104%);
    transition: transform 180ms ease;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 15;
    display: block;
    pointer-events: none;
    background: rgba(15, 23, 42, 0);
    transition: background 180ms ease;
  }

  body.sidebar-open .sidebar-overlay {
    pointer-events: auto;
    background: rgba(15, 23, 42, 0.34);
  }

  .mobile-thread-button,
  .sidebar-close {
    display: inline-grid;
  }

  .brand {
    grid-column: auto;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .thread-list {
    flex: 1;
    gap: 8px;
    min-height: 0;
    max-height: none;
    padding-right: 0;
  }

  .thread-filter-bar {
    gap: 7px;
  }

  .thread-filter-button {
    min-height: 36px;
    padding: 0 5px;
  }

  .thread-group-title {
    padding: 9px 3px 5px;
    font-size: 13px;
  }

  .thread-item {
    grid-template-columns: minmax(0, 1fr) 42px;
    min-height: 70px;
  }

  .thread-main {
    min-height: 70px;
    padding: 10px 6px 10px 10px;
  }

  .thread-name {
    display: -webkit-box;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 15px;
    line-height: 1.36;
    overflow-wrap: anywhere;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  .thread-cwd {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.45;
    white-space: nowrap;
  }

  .thread-state {
    font-size: 12px;
  }

  .pin-button {
    width: 36px;
    height: 36px;
    justify-self: center;
  }

  .pin-button svg {
    width: 21px;
    height: 21px;
  }

  .chat-panel {
    width: 100vw;
    max-width: 100vw;
    min-height: var(--viewport-height);
    height: var(--viewport-height);
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overflow-x: hidden;
  }

  .chat-header {
    width: 100%;
    max-width: 100vw;
    min-height: 64px;
    padding: 10px 12px;
    overflow: hidden;
    backdrop-filter: blur(10px);
  }

  .thread-heading {
    min-width: 0;
  }

  .chat-header span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .session-controls {
    display: grid;
    grid-template-columns: minmax(46px, 0.62fr) minmax(52px, 0.72fr) minmax(52px, 0.72fr) minmax(118px, 1.94fr);
    align-items: stretch;
    width: 100%;
    max-width: 100vw;
    gap: 5px;
    padding: 7px 8px;
    overflow: hidden;
    overflow-y: hidden;
  }

  .select-field {
    min-width: 0;
    min-height: 44px;
    padding: 5px 6px 6px;
  }

  .runtime-select {
    height: 21px;
    padding: 0;
    font-size: 11.5px;
    line-height: 22px;
  }

  .select-field span,
  .quota-label {
    font-size: 10px;
  }

  .quota-field {
    min-height: 44px;
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
    padding: 5px 6px 6px;
  }

  .quota-button {
    top: 4px;
    right: 4px;
    width: 21px;
    height: 21px;
  }

  .quota-summary {
    max-width: none;
    padding: 0;
    font-size: 11px;
  }

  .quota-copy {
    padding-right: 22px;
  }

  .activity-bar {
    width: 100%;
    max-width: 100vw;
    gap: 6px;
    padding: 7px 10px;
    overscroll-behavior-x: contain;
  }

  .activity-status,
  .activity-chip {
    max-width: 78vw;
    min-height: 26px;
    padding: 4px 8px;
    font-size: 12px;
  }

  .activity-chip {
    max-width: 54vw;
  }

  .messages {
    width: 100%;
    max-width: 100vw;
    padding: 12px 10px;
    padding-bottom: calc(var(--composer-height) + var(--composer-lift) + 22px);
    overflow-x: hidden;
    overscroll-behavior: contain;
  }

  .message {
    width: 100%;
    max-width: 100%;
    gap: 5px;
  }

  .message.user {
    width: auto;
    max-width: 94%;
  }

  .message.user .role {
    text-align: right;
  }

  .bubble {
    width: 100%;
    padding: 11px 12px;
    font-size: 15px;
    line-height: 1.62;
  }

  .rich-text pre {
    margin-right: -2px;
    margin-left: -2px;
  }

  .event {
    align-self: stretch;
  }

  .event .role {
    display: none;
  }

  .event .bubble,
  .event-bubble {
    border-style: dashed;
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.38;
  }

  .composer {
    position: fixed;
    right: 0;
    bottom: var(--composer-lift);
    left: 0;
    z-index: 5;
    grid-template-columns: 44px minmax(0, 1fr) 52px;
    width: 100%;
    max-width: 100vw;
    gap: 8px;
    padding: 10px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    overflow: hidden;
    box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.08);
  }

  .composer textarea {
    min-width: 0;
    min-height: 46px;
    max-height: 35dvh;
    padding: 12px;
    font-size: 16px;
  }

  .send-button {
    width: 52px;
    height: 46px;
  }

  .composer-tool-button {
    width: 44px;
    height: 46px;
  }

  .detail-drawer,
  .picker-drawer {
    inset: auto 0 0 0;
    width: 100vw;
    max-height: min(72vh, calc(var(--viewport-height) - 22px));
    border-top: 1px solid var(--line);
    border-left: 0;
    border-radius: 8px 8px 0 0;
    transform: translateY(104%);
  }

  body.detail-drawer-open .detail-drawer,
  body.picker-open .picker-drawer {
    transform: translateY(0);
  }

  .detail-drawer-header,
  .picker-header {
    padding: 12px;
  }

  .detail-drawer-body,
  .picker-list {
    padding: 12px 12px max(18px, env(safe-area-inset-bottom));
  }

  .picker-roots {
    padding: 9px 10px;
  }

  .picker-entry {
    min-height: 48px;
  }

  .picker-footer {
    padding: 10px 10px max(12px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 520px) {
  .sidebar {
    grid-template-columns: 1fr;
  }

  .chat-header {
    gap: 10px;
    padding: 12px;
  }

  .chat-header h2 {
    font-size: 17px;
  }

  .header-actions {
    flex-shrink: 0;
    gap: 6px;
  }

  .header-actions .icon-button {
    width: 36px;
    height: 36px;
  }

  #copyButton {
    display: none;
  }

  .history-banner {
    align-items: stretch;
    flex-direction: column;
    text-align: center;
  }

  .side-actions {
    justify-content: flex-start;
  }
}

@media (prefers-color-scheme: dark) and (max-width: 760px) {
  .composer {
    box-shadow: 0 -12px 34px rgba(0, 0, 0, 0.42);
  }
}
