:root {
  color-scheme: dark;
  --bg: #090b0f;
  --surface: #10141b;
  --surface-2: #151a23;
  --surface-3: #1d2430;
  --ink: #f4efe5;
  --ink-soft: #cfc7ba;
  --muted: #8d98a8;
  --line: rgba(221, 229, 239, 0.16);
  --line-strong: rgba(221, 229, 239, 0.3);
  --accent: #ff9f5a;
  --accent-blue: #8bc7ff;
  --success: #8fe58c;
  --danger: #ff746d;
  --font-ui-latin: "Avenir Next", "DIN Alternate", "Gill Sans", "Trebuchet MS";
  --font-ui: var(--font-ui-latin), "PingFang SC", "Hiragino Sans GB", sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  --font-sidebar: "SF Pro Text", "Helvetica Neue", "Avenir Next", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --font-meta: "SF Pro Text", "Avenir Next", "DIN Alternate", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --font-mono: "SFMono-Regular", "JetBrains Mono", "Cascadia Code", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-ui);
  background:
    linear-gradient(90deg, rgba(255, 159, 90, 0.06) 0 1px, transparent 1px 100%),
    linear-gradient(180deg, rgba(139, 199, 255, 0.05) 0 1px, transparent 1px 100%),
    linear-gradient(135deg, #07090d 0%, #0c1118 55%, #0b0d12 100%);
  background-size: 96px 96px, 96px 96px, auto;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #161c25;
  color: var(--ink);
  font: inherit;
}

button {
  min-height: 34px;
  padding: 7px 10px;
  cursor: pointer;
  font-weight: 900;
  letter-spacing: 0.01em;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

button:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: #202938;
}

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

input,
textarea,
select {
  min-height: 36px;
  padding: 8px 10px;
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

input::placeholder,
textarea::placeholder {
  color: rgba(141, 152, 168, 0.68);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(139, 199, 255, 0.6);
  background: #1b2330;
}

textarea {
  min-height: 40px;
  resize: none;
}

select option {
  color: #111720;
}

input[type="checkbox"] {
  display: inline-grid;
  width: 18px;
  min-height: 24px;
  padding: 0;
  appearance: none;
  place-items: center;
  background: #111720;
}

input[type="checkbox"]:checked {
  border-color: rgba(255, 159, 90, 0.9);
  background: var(--accent);
}

input[type="checkbox"]:checked::after {
  content: "";
  width: 8px;
  height: 8px;
  background: #180d07;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: rgba(8, 10, 14, 0.72);
}

#workspace-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(248px, var(--session-sidebar-width, 320px)) minmax(0, 1fr);
  overflow: hidden;
}

#session-column,
#conversation-column {
  min-height: 0;
  overflow: hidden;
}

#session-column {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line-strong);
  background: rgba(13, 17, 24, 0.94);
  font-family: var(--font-sidebar);
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

#conversation-column {
  display: grid;
  position: relative;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: rgba(11, 14, 20, 0.86);
}

.sidebar-head,
.chat-head {
  border-bottom: 1px solid var(--line-strong);
  background: rgba(14, 18, 25, 0.88);
}

.sidebar-head {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-height: 64px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-strong);
  background: rgba(14, 18, 25, 0.92);
}

.icon-button {
  width: auto;
  min-width: 0;
  min-height: 30px;
  padding: 5px 8px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  text-transform: uppercase;
}

.section-title,
.chat-title {
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 1.06rem;
  line-height: 1.05;
  letter-spacing: -0.035em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.create-panel {
  display: grid;
  border-bottom: 1px solid var(--line-strong);
  background: rgba(18, 23, 31, 0.72);
}

.create-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  list-style: none;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.create-panel summary::-webkit-details-marker {
  display: none;
}

.create-panel summary::after {
  content: "+";
  color: var(--muted);
}

.create-panel[open] summary::after {
  content: "-";
}

.summary-hint {
  color: var(--muted);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
}

.label,
.eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.create-grid,
.field-grid,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.create-grid {
  padding: 0 12px 12px;
}

.create-grid .wide,
.field-grid .wide,
.settings-grid .wide {
  grid-column: 1 / -1;
}

.inline-actions,
.composer-actions,
.permission-actions {
  display: grid;
  gap: 7px;
}

.inline-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.new-session-row {
  display: none;
}

.session-toolbar {
  display: none;
}

.session-count {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 900;
}

.session-count::before {
  content: "";
  width: 7px;
  height: 7px;
  background: var(--accent-blue);
}

#session-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.session-empty,
.transcript-empty,
.tool-empty {
  margin: 10px 12px;
  padding: 10px;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
  font-size: 0.84rem;
}

.session-card {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px 8px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  overflow: hidden;
  min-height: 38px;
}

.session-card:hover:not(:disabled),
.session-card.is-selected {
  background: rgba(255, 159, 90, 0.08);
}

.session-card.is-running {
  color: #d9ffd7;
}

.session-card-title {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  background: var(--muted);
}

.session-dot.status-running {
  background: var(--success);
  box-shadow: 0 0 10px rgba(143, 229, 140, 0.58);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag,
.message-badge {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 2px 5px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.tag.status-running {
  color: #d9ffd7;
  border-color: rgba(143, 229, 140, 0.38);
}

.tag.status-attached {
  color: #ffe1c8;
  border-color: rgba(255, 159, 90, 0.42);
}

.chat-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 64px;
  padding: 10px 16px;
}

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

#session-meta {
  margin-top: 4px;
  color: var(--muted);
  font-family: var(--font-meta);
  font-size: 0.78rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.012em;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  min-width: min(430px, 100%);
}

.conversation-actions button {
  width: auto;
  min-width: 70px;
}

.composer-hint {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  white-space: nowrap;
}

#transcript-list {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  padding: 14px clamp(14px, 2.4vw, 32px);
}

.message-card {
  display: grid;
  gap: 7px;
  max-width: min(78%, 880px);
  padding: 12px 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.045);
}

.message-card.role-user {
  align-self: flex-end;
  border-color: rgba(255, 159, 90, 0.38);
  background: rgba(255, 159, 90, 0.11);
}

.message-card.role-assistant,
.message-card.role-tool,
.message-card.role-system {
  align-self: flex-start;
}

.message-card.role-tool,
.message-card.role-system {
  max-width: min(92%, 980px);
  border-style: dashed;
  background: rgba(139, 199, 255, 0.055);
}

.message-card.is-streaming {
  border-color: rgba(139, 199, 255, 0.55);
}

.message-card.is-running,
.message-card.kind-tool-running {
  border-style: dashed;
  border-color: rgba(255, 200, 120, 0.55);
  background: rgba(255, 200, 120, 0.07);
  opacity: 0.92;
}

.message-card.kind-tool-running .message-content {
  color: var(--muted);
  font-style: italic;
}

.message-card.kind-tool-running .running-dot {
  color: rgba(255, 180, 100, 0.95);
  animation: tool-running-pulse 1.4s ease-in-out infinite;
}

.message-card.is-reasoning-only {
  border-style: dashed;
  border-color: rgba(139, 199, 255, 0.35);
  background: rgba(139, 199, 255, 0.04);
  opacity: 0.9;
}

.message-card.is-reasoning-only .message-reasoning {
  border-left-color: rgba(139, 199, 255, 0.6);
}

.message-reasoning.is-collapsed {
  font-size: 0.78rem;
  opacity: 0.85;
  font-style: italic;
}

@keyframes tool-running-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.message-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.message-content {
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.58;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-reasoning {
  padding: 9px 10px;
  border-left: 3px solid var(--accent-blue);
  background: rgba(139, 199, 255, 0.07);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.composer-panel {
  border-top: 1px solid var(--line-strong);
  background: rgba(14, 18, 25, 0.96);
}

.slash-suggestions {
  display: grid;
  gap: 0;
  max-height: 176px;
  overflow: auto;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 13, 19, 0.94);
}

.slash-suggestions[style*="display: none"] {
  display: none !important;
}

.slash-option {
  display: grid;
  grid-template-columns: minmax(120px, 0.45fr) minmax(0, 1fr);
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.74rem;
}

.slash-option:last-child {
  border-bottom: 0;
}

.slash-option:hover {
  background: rgba(255, 159, 90, 0.08);
}

.slash-option span,
.slash-option small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slash-option span {
  color: var(--accent);
  font-weight: 900;
}

.slash-option small {
  color: var(--muted);
}

.command-dock {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 136px 92px;
  gap: 8px;
  align-items: end;
  padding: 10px 14px 12px;
}

.composer-grid {
  display: contents;
}

.primary {
  border-color: rgba(255, 159, 90, 0.72);
  background: var(--accent);
  color: #1a0d05;
}

.primary:hover:not(:disabled) {
  background: #ffb171;
}

.secondary {
  border-color: rgba(139, 199, 255, 0.32);
  background: rgba(139, 199, 255, 0.12);
  color: #ddf0ff;
}

.ghost {
  background: rgba(255, 255, 255, 0.045);
}

.danger {
  border-color: rgba(255, 116, 109, 0.32);
  background: rgba(255, 116, 109, 0.12);
  color: #ffd5d2;
}

.settings-page,
.create-dialog {
  box-sizing: border-box;
  width: min(920px, calc(100vw - 32px));
  max-height: calc(100vh - 42px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: #0d1118;
  color: var(--ink);
  box-shadow: 0 26px 90px rgba(0, 0, 0, 0.58);
}

.settings-page::backdrop,
.create-dialog::backdrop {
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(4px);
}

.settings-page[hidden],
.create-dialog[hidden] {
  display: none;
}

.create-dialog {
  width: min(700px, calc(100vw - 32px));
}

.create-dialog-body {
  display: grid;
  gap: 14px;
  padding: 16px 18px 18px;
}

.create-kind-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--line);
}

.create-kind-switch label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 8px 10px;
  color: var(--muted);
  cursor: pointer;
}

.create-kind-switch label + label {
  border-left: 1px solid var(--line);
}

.create-kind-switch label.is-active {
  background: rgba(255, 159, 90, 0.12);
  color: var(--ink);
}

.create-kind-switch input {
  width: 16px;
  min-height: 16px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-strong);
  background: #111720;
}

.settings-head button {
  width: auto;
  min-width: 120px;
}

.settings-body {
  display: grid;
  gap: 0;
  width: 100%;
  max-height: calc(100vh - 130px);
  overflow: auto;
}

.settings-section {
  width: 100%;
  padding: 16px 18px 18px;
  border-bottom: 1px solid var(--line);
}

.settings-section:last-child {
  border-bottom: 0;
}

.settings-grid {
  gap: 12px;
  margin-top: 12px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  color: var(--ink-soft);
}

.check-row input {
  width: 18px;
  min-height: 24px;
}

.permission-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255, 159, 90, 0.24);
  background: rgba(255, 159, 90, 0.08);
}

.permission-title {
  font-weight: 900;
}

.permission-copy {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.permission-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.microcopy {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

#cron-list,
#permission-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

/* Final layout refinements live near the end so older utility rules stay reusable. */
.session-card {
  position: relative;
  gap: 8px;
  padding: 8px 12px 8px 14px;
  min-height: 36px;
}

.session-card::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: transparent;
}

.session-card.is-selected::before {
  background: var(--accent);
}

.session-card.is-attached::before {
  background: var(--success);
}

.session-card.is-selected,
.session-card.is-attached {
  box-shadow: none;
  padding-left: 14px;
}

.session-card.is-selected {
  background: rgba(255, 159, 90, 0.14);
}

.session-card.is-selected .session-card-title {
  color: var(--accent);
}

.session-toolbar-hint {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  text-transform: uppercase;
}

.dialog-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 18px;
  width: 100%;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--line-strong);
  background:
    linear-gradient(90deg, rgba(255, 159, 90, 0.09), transparent 54%),
    #111720;
}

.dialog-close-button {
  width: auto;
  min-width: 94px;
}

.settings-page,
.create-dialog {
  margin: auto;
  overflow: hidden;
}

.settings-page {
  width: min(760px, calc(100vw - 32px));
}

.settings-body {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
  padding: 14px;
  max-height: min(640px, calc(100vh - 106px));
}

.settings-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.settings-card:first-child {
  grid-column: 1 / -1;
}

.settings-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.settings-card-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.96rem;
  line-height: 1;
  letter-spacing: -0.02em;
}

.settings-card-head code {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.inline-status {
  margin-bottom: 12px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  background: rgba(139, 199, 255, 0.045);
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.settings-grid-single {
  grid-template-columns: 1fr;
}

.settings-page {
  width: 100vw;
  height: 100vh;
  max-height: 100vh;
  margin: 0;
  border-left: 0;
  border-right: 0;
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 159, 90, 0.12), transparent 32%),
    radial-gradient(circle at 100% 18%, rgba(139, 199, 255, 0.1), transparent 30%),
    #0b0f15;
}

.settings-dialog-head {
  align-items: center;
  min-height: 72px;
  background:
    linear-gradient(90deg, rgba(255, 159, 90, 0.1), transparent 45%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent),
    #101720;
}

.settings-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-status-pill,
.config-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  width: fit-content;
  padding: 3px 7px;
  border: 1px solid rgba(221, 229, 239, 0.15);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.settings-status-pill[data-tone="good"],
.config-chip[data-tone="good"] {
  border-color: rgba(143, 229, 140, 0.28);
  background: rgba(143, 229, 140, 0.08);
  color: var(--success);
}

.settings-fullscreen-body {
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  height: calc(100vh - 72px);
  max-height: none;
  padding: 14px;
  background:
    linear-gradient(90deg, rgba(255, 159, 90, 0.045) 0 1px, transparent 1px 100%),
    linear-gradient(180deg, rgba(139, 199, 255, 0.035) 0 1px, transparent 1px 100%);
  background-size: 80px 80px;
}

.settings-rail,
.settings-main {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.settings-rail {
  position: sticky;
  top: 0;
}

.settings-main {
  grid-template-columns: 1fr;
}

.settings-card {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 110px),
    rgba(13, 17, 24, 0.88);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.settings-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 2px;
  background: linear-gradient(180deg, var(--accent), rgba(139, 199, 255, 0.22));
  opacity: 0.65;
}

.settings-card-wide {
  grid-column: 1 / -1;
}

.api-config-grid {
  grid-template-columns: minmax(220px, 1.3fr) minmax(170px, 1fr) minmax(170px, 1fr) auto;
  align-items: end;
}

.api-config-save {
  min-height: 42px;
  white-space: nowrap;
}

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

.settings-kv-grid > div,
.provider-detail-grid > div {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.settings-kv-grid span,
.provider-detail-grid span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.settings-kv-grid strong,
.provider-detail-grid strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.provider-list,
.model-config-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.provider-card,
.model-config-row {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.provider-card {
  padding: 12px;
}

.provider-card-head,
.model-config-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.provider-card-head {
  margin-bottom: 10px;
}

.provider-card h4 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 1.04rem;
  letter-spacing: -0.02em;
}

.provider-meta-line,
.model-feature-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.provider-use-button,
.model-use-button {
  width: auto;
  min-width: 90px;
}

.model-provider-label {
  margin-top: 4px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.model-config-row {
  grid-template-columns: minmax(180px, 0.9fr) minmax(240px, 1.4fr) auto;
  padding: 10px;
}

.model-config-main {
  min-width: 0;
}

.model-config-main strong,
.model-config-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-config-main strong {
  color: var(--ink);
  font-size: 0.9rem;
}

.model-config-main span {
  margin-top: 3px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.66rem;
}

.settings-empty {
  margin-top: 12px;
  padding: 18px;
  border: 1px dashed var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.create-dialog {
  width: min(680px, calc(100vw - 32px));
}

.create-dialog-body {
  gap: 16px;
  padding: 16px 18px 18px;
}

.create-kind-switch {
  gap: 0;
  background: rgba(255, 255, 255, 0.025);
}

.create-kind-switch label {
  min-height: 60px;
}

.create-kind-switch input {
  margin: 0;
}

.create-kind-switch span {
  display: grid;
  gap: 3px;
}

.create-kind-switch strong {
  color: var(--ink);
}

.create-kind-switch small {
  color: var(--muted);
  font-size: 0.72rem;
}

.dialog-fieldset {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.dialog-fieldset .wide {
  grid-column: 1 / -1;
}

.dialog-field {
  min-width: 0;
}

.dialog-actions {
  padding-top: 2px;
}

@media (max-width: 1060px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
  }

  #workspace-shell {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  #session-column,
  #conversation-column {
    min-height: auto;
    overflow: visible;
  }

  #session-column {
    border-right: 0;
    border-bottom: 1px solid var(--line-strong);
  }

  #session-list {
    flex: 0 1 auto;
    max-height: 42vh;
  }

  #conversation-column {
    min-height: 70vh;
  }

  #transcript-list {
    max-height: 58vh;
  }

  .settings-body {
    grid-template-columns: 1fr;
  }

  .settings-card,
  .settings-card:first-child {
    grid-column: 1;
  }

  .settings-rail {
    position: static;
  }

  .settings-kv-grid,
  .provider-detail-grid,
  .model-config-row {
    grid-template-columns: 1fr;
  }

  .provider-card-head {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .create-grid,
  .field-grid,
  .settings-grid,
  .inline-actions,
  .conversation-actions,
  .command-strip,
  .command-dock,
  .chat-head,
  .dialog-head,
  .dialog-fieldset,
  .dialog-actions,
  .create-kind-switch {
    grid-template-columns: 1fr;
  }

  .create-kind-switch label + label {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

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

  .message-card {
    max-width: 100%;
  }
}

/* Settings uses a self-contained desktop-style layout with persistent navigation. */
.settings-page {
  width: min(1520px, calc(100vw - 48px));
  height: min(960px, calc(100vh - 48px));
  max-height: calc(100vh - 48px);
  margin: auto;
  overflow: hidden;
  border: 1px solid rgba(221, 229, 239, 0.18);
  border-radius: 24px;
  background: #0e1217;
  color: var(--ink);
  box-shadow: 0 32px 100px rgba(0, 0, 0, 0.66), 0 0 0 1px rgba(255, 255, 255, 0.025);
}

.settings-page::backdrop {
  background: rgba(4, 6, 9, 0.78);
  backdrop-filter: blur(10px);
}

.settings-page button,
.settings-page input,
.settings-page select {
  border-radius: 10px;
}

.settings-page button {
  font-weight: 650;
}

.settings-page .primary {
  font-weight: 760;
}

.settings-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  width: 100%;
  height: 100%;
  min-height: 0;
}

.settings-sidebar {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  padding: 28px 18px 20px;
  border-right: 1px solid rgba(221, 229, 239, 0.1);
  background: #11161d;
  font-family: var(--font-sidebar);
}

.settings-sidebar-title {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 10px 26px;
}

.settings-sidebar-title h2 {
  font-family: var(--font-sidebar);
  font-size: 1.32rem;
  font-weight: 720;
  letter-spacing: -0.03em;
}

.settings-nav {
  display: grid;
  gap: 4px;
}

.settings-nav-label {
  margin: 18px 11px 7px;
  color: #707b8a;
  font-family: var(--font-meta);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.settings-nav-label:first-child {
  margin-top: 0;
}

.settings-nav-item {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: #aeb7c3;
  font-size: 0.91rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-align: left;
}

.settings-nav-item:hover:not(:disabled) {
  border-color: transparent;
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink);
}

.settings-nav-item.is-active {
  background: rgba(255, 255, 255, 0.095);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035);
}

.settings-nav-item.is-active svg {
  color: var(--accent);
}

.settings-nav-item:focus-visible {
  outline: 2px solid rgba(255, 159, 90, 0.5);
  outline-offset: -2px;
}

.settings-nav-item svg,
.settings-close-button svg {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.settings-sidebar-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: auto 10px 0;
  padding-top: 20px;
  color: var(--muted);
}

.settings-sidebar-status div {
  display: grid;
  gap: 2px;
}

.settings-sidebar-status strong {
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 700;
}

.settings-sidebar-status span:last-child {
  font-family: var(--font-mono);
  font-size: 0.62rem;
}

.settings-status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 999px;
  background: #596271;
  box-shadow: 0 0 0 4px rgba(89, 98, 113, 0.12);
}

.settings-status-dot[data-tone="good"] {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(143, 229, 140, 0.11);
}

.settings-content {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #0e1217;
}

.settings-close-button {
  position: absolute;
  z-index: 2;
  top: 24px;
  right: 28px;
  display: grid;
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  place-items: center;
  border: 0;
  background: transparent;
  color: #929cab;
}

.settings-close-button:hover:not(:disabled) {
  border-color: transparent;
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
}

.settings-content-scroll {
  height: 100%;
  padding: 66px clamp(40px, 5.2vw, 78px) 72px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.settings-content-heading {
  max-width: 880px;
  margin-bottom: 42px;
}

.settings-content-heading h2 {
  margin: 0;
  font-family: var(--font-sidebar);
  font-size: clamp(1.7rem, 2.35vw, 2.35rem);
  font-weight: 760;
  letter-spacing: -0.045em;
}

.settings-content-heading p {
  margin-top: 10px;
  color: #8993a1;
  font-size: 0.95rem;
  line-height: 1.55;
}

.settings-section-content {
  display: grid;
  max-width: 1080px;
  gap: 26px;
}

.settings-card,
.settings-card:first-child {
  grid-column: auto;
}

.settings-panel {
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(221, 229, 239, 0.12);
  border-radius: 18px;
  background: #141920;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.025), 0 12px 34px rgba(0, 0, 0, 0.1);
}

.settings-panel::before {
  display: none;
}

.settings-panel-heading {
  display: flex;
  min-height: 88px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 23px 26px 20px;
}

.settings-panel-heading h3 {
  margin: 0;
  font-family: var(--font-sidebar);
  font-size: 1rem;
  font-weight: 720;
  letter-spacing: -0.02em;
}

.settings-panel-heading p {
  margin-top: 6px;
  color: #828c9a;
  font-size: 0.82rem;
  line-height: 1.45;
}

.settings-status-pill,
.settings-count-badge,
.config-chip {
  display: inline-flex;
  width: fit-content;
  min-height: 24px;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid rgba(221, 229, 239, 0.13);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  color: #8e98a6;
  font-family: var(--font-meta);
  font-size: 0.64rem;
  font-weight: 750;
  letter-spacing: 0.025em;
  text-transform: none;
  white-space: nowrap;
}

.settings-status-pill[data-tone="good"],
.config-chip[data-tone="good"] {
  border-color: rgba(143, 229, 140, 0.24);
  background: rgba(143, 229, 140, 0.08);
  color: var(--success);
}

.settings-list {
  border-top: 1px solid rgba(221, 229, 239, 0.09);
}

.settings-form-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(260px, 420px);
  gap: 36px;
  min-height: 92px;
  align-items: center;
  padding: 18px 26px;
}

.settings-form-row + .settings-form-row {
  border-top: 1px solid rgba(221, 229, 239, 0.09);
}

.settings-row-copy {
  min-width: 0;
}

.settings-row-copy label,
.settings-row-copy span {
  display: block;
}

.settings-row-copy label {
  color: #f1eee8;
  font-size: 0.9rem;
  font-weight: 680;
}

.settings-row-copy span {
  margin-top: 5px;
  color: #7f8997;
  font-size: 0.76rem;
  line-height: 1.45;
}

.settings-form-row input,
.settings-form-row select,
.settings-row-control {
  width: 100%;
  max-width: 420px;
}

.settings-form-row input,
.settings-form-row select {
  min-height: 42px;
  border-color: rgba(221, 229, 239, 0.14);
  background: #1a2029;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.settings-form-row input:focus,
.settings-form-row select:focus {
  border-color: rgba(255, 159, 90, 0.62);
  background: #1c232d;
  box-shadow: 0 0 0 3px rgba(255, 159, 90, 0.1);
}

.settings-panel-actions {
  display: flex;
  justify-content: flex-end;
  padding: 16px 26px 20px;
  border-top: 1px solid rgba(221, 229, 239, 0.09);
}

.settings-panel-actions button {
  width: auto;
  min-width: 132px;
  min-height: 40px;
  padding-right: 18px;
  padding-left: 18px;
}

.settings-overview-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid rgba(221, 229, 239, 0.12);
  border-radius: 15px;
  background: rgba(20, 25, 32, 0.72);
}

.settings-overview-strip > div {
  min-width: 0;
  padding: 16px 18px;
}

.settings-overview-strip > div + div {
  border-left: 1px solid rgba(221, 229, 239, 0.09);
}

.settings-overview-strip span,
.settings-overview-strip strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-overview-strip span,
.provider-detail-grid span {
  color: #77818f;
  font-family: var(--font-meta);
  font-size: 0.65rem;
  font-weight: 720;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.settings-overview-strip strong,
.provider-detail-grid strong {
  margin-top: 5px;
  color: #e8e5df;
  font-family: var(--font-mono);
  font-size: 0.73rem;
  font-weight: 650;
}

.settings-overview-in-panel {
  margin: 0 24px 22px;
  background: #11161d;
}

.provider-list,
.model-config-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0 24px 24px;
}

.provider-card,
.model-config-row {
  border: 1px solid rgba(221, 229, 239, 0.11);
  border-radius: 13px;
  background: #11161d;
}

.provider-card {
  padding: 18px;
}

.provider-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  margin-bottom: 16px;
}

.provider-card h4 {
  margin: 0 0 8px;
  font-family: var(--font-sidebar);
  font-size: 1rem;
  font-weight: 720;
  letter-spacing: -0.02em;
}

.provider-meta-line,
.model-feature-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.provider-use-button,
.model-use-button {
  width: auto;
  min-width: 92px;
  border-radius: 9px;
}

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

.provider-detail-grid > div {
  min-width: 0;
  padding: 10px 11px;
  border: 0;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
}

.provider-detail-grid strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-provider-label {
  margin: 8px 2px -2px;
  color: var(--accent);
  font-family: var(--font-meta);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.model-config-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(260px, 1.4fr) auto;
  gap: 18px;
  align-items: center;
  padding: 15px 16px;
}

.model-config-main {
  min-width: 0;
}

.model-config-main strong,
.model-config-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-config-main strong {
  color: #edeae4;
  font-size: 0.87rem;
  font-weight: 700;
}

.model-config-main span {
  margin-top: 4px;
  color: #76808e;
  font-family: var(--font-mono);
  font-size: 0.66rem;
}

.settings-empty {
  margin: 0 24px 24px;
  padding: 24px;
  border: 1px dashed rgba(221, 229, 239, 0.15);
  border-radius: 12px;
  color: #7e8896;
  font-size: 0.78rem;
  text-align: center;
}

.provider-config-workspace {
  gap: 18px;
}

.provider-config-toolbar,
.provider-config-toolbar-actions,
.provider-action-row,
.provider-models-head,
.model-editor-heading,
.model-editor-actions {
  display: flex;
  align-items: center;
}

.provider-config-toolbar {
  justify-content: space-between;
  gap: 24px;
  min-height: 50px;
}

.provider-config-toolbar > div:first-child {
  display: grid;
  gap: 4px;
}

.provider-config-toolbar strong {
  color: var(--ink);
  font-size: 0.9rem;
}

.provider-config-toolbar span:not(.settings-status-pill) {
  color: #7f8997;
  font-size: 0.75rem;
}

.provider-config-toolbar-actions {
  flex: 0 0 auto;
  gap: 10px;
}

.provider-config-toolbar-actions button {
  display: inline-flex;
  width: auto;
  min-height: 40px;
  align-items: center;
  gap: 7px;
  padding: 8px 15px;
}

.provider-config-toolbar-actions button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.config-editor {
  border-color: rgba(255, 159, 90, 0.24);
  box-shadow: 0 0 0 1px rgba(255, 159, 90, 0.04), 0 16px 40px rgba(0, 0, 0, 0.18);
}

.config-editor-heading {
  min-height: 76px;
}

.settings-inline-close {
  display: grid;
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  place-items: center;
  border: 0;
  background: transparent;
  color: #8d97a5;
  font-size: 1.25rem;
  line-height: 1;
}

.config-editor-body {
  display: grid;
  gap: 20px;
  padding: 22px 26px 24px;
  border-top: 1px solid rgba(221, 229, 239, 0.09);
}

.config-editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 17px;
}

.config-field {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.config-field-wide {
  grid-column: 1 / -1;
}

.config-field > span {
  color: #aab3bf;
  font-size: 0.72rem;
  font-weight: 680;
}

.config-field input,
.config-field select,
.config-field textarea {
  width: 100%;
  min-height: 42px;
  border-color: rgba(221, 229, 239, 0.14);
  border-radius: 10px;
  background: #1a2029;
}

.config-field textarea {
  min-height: 94px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.config-field input:focus,
.config-field select:focus,
.config-field textarea:focus {
  border-color: rgba(255, 159, 90, 0.62);
  background: #1c232d;
  box-shadow: 0 0 0 3px rgba(255, 159, 90, 0.1);
}

.config-toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 22px;
}

.config-check {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #b8c0ca;
  font-size: 0.78rem;
  cursor: pointer;
}

.config-check input {
  width: 18px;
  min-height: 18px;
  margin: 0;
  border-radius: 5px;
}

.config-check input:checked::after {
  border-radius: 2px;
}

.config-advanced {
  overflow: hidden;
  border: 1px solid rgba(221, 229, 239, 0.1);
  border-radius: 11px;
  background: rgba(7, 10, 14, 0.24);
}

.config-advanced summary {
  padding: 13px 15px;
  color: #aab3bf;
  font-size: 0.76rem;
  font-weight: 680;
  cursor: pointer;
  user-select: none;
}

.config-advanced[open] summary {
  border-bottom: 1px solid rgba(221, 229, 239, 0.09);
}

.config-advanced > .config-editor-grid {
  padding: 17px;
}

.config-editor-actions {
  gap: 9px;
}

.config-editor-actions button,
.model-editor-actions button {
  width: auto;
  min-width: 112px;
}

.provider-accordion-list {
  display: grid;
  gap: 12px;
}

.provider-accordion {
  overflow: hidden;
  border: 1px solid rgba(221, 229, 239, 0.12);
  border-radius: 16px;
  background: #141920;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.08);
}

.provider-accordion.is-default {
  border-color: rgba(255, 159, 90, 0.22);
}

.provider-accordion-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 76px;
  align-items: center;
  gap: 18px;
  padding-right: 20px;
}

.provider-accordion-trigger {
  display: flex;
  width: 100%;
  min-height: 76px;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border: 0;
  background: transparent;
  text-align: left;
}

.provider-accordion-trigger:hover:not(:disabled) {
  border-color: transparent;
  background: rgba(255, 255, 255, 0.025);
}

.accordion-chevron {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: #7f8996;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  transition: transform 150ms ease;
}

.provider-accordion.is-expanded .accordion-chevron {
  transform: rotate(90deg);
}

.provider-identity {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.provider-identity strong,
.provider-identity small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.provider-identity strong {
  color: #f0ede7;
  font-size: 0.98rem;
  font-weight: 720;
}

.provider-identity small {
  color: #77818e;
  font-family: var(--font-mono);
  font-size: 0.64rem;
}

.provider-accordion-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.provider-accordion-body {
  display: grid;
  gap: 18px;
  padding: 20px;
  border-top: 1px solid rgba(221, 229, 239, 0.09);
  background: #11161d;
}

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

.provider-summary-grid > div {
  min-width: 0;
  padding: 12px 13px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
}

.provider-summary-grid span,
.provider-summary-grid strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.provider-summary-grid span {
  color: #737d8a;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.provider-summary-grid strong {
  margin-top: 5px;
  color: #dcd9d3;
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

.provider-action-row {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.provider-action-row button,
.provider-models-head button,
.provider-model-actions button {
  width: auto;
  min-width: 0;
}

.provider-action-row button {
  min-height: 36px;
  padding: 7px 12px;
  font-size: 0.72rem;
}

.provider-models-head {
  justify-content: space-between;
  gap: 20px;
  padding-top: 4px;
}

.provider-models-head h4,
.provider-models-head p,
.model-editor-heading h5,
.model-editor-heading p {
  margin: 0;
}

.provider-models-head h4 {
  color: #ebe8e2;
  font-size: 0.9rem;
}

.provider-models-head p,
.model-editor-heading p {
  margin-top: 4px;
  color: #77818e;
  font-size: 0.7rem;
}

.provider-models-head button {
  min-height: 34px;
  padding: 6px 11px;
  font-size: 0.7rem;
}

.provider-model-list {
  display: grid;
  gap: 8px;
}

.provider-model-row {
  display: grid;
  grid-template-columns: minmax(170px, 0.8fr) minmax(220px, 1.2fr) auto;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid rgba(221, 229, 239, 0.09);
  border-radius: 11px;
  background: #151b23;
}

.provider-model-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.provider-model-actions button {
  min-height: 30px;
  padding: 5px 8px;
  border-radius: 7px;
  font-size: 0.65rem;
}

.model-editor {
  display: grid;
  gap: 18px;
  padding: 19px;
  border: 1px solid rgba(255, 159, 90, 0.2);
  border-radius: 13px;
  background: #171d25;
}

.model-editor-heading {
  justify-content: space-between;
  gap: 20px;
}

.model-editor-heading h5 {
  color: #eeeae4;
  font-size: 0.9rem;
}

.model-editor-actions {
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 1060px) {
  .settings-page {
    width: calc(100vw - 24px);
    height: calc(100vh - 24px);
    max-height: calc(100vh - 24px);
  }

  .settings-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .settings-content-scroll {
    padding-right: 34px;
    padding-left: 34px;
  }

  .settings-form-row {
    grid-template-columns: minmax(180px, 1fr) minmax(220px, 360px);
    gap: 24px;
  }

  .provider-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .model-config-row {
    grid-template-columns: minmax(160px, 0.8fr) minmax(220px, 1.4fr) auto;
  }

  .provider-model-row {
    grid-template-columns: minmax(160px, 0.8fr) minmax(190px, 1fr);
  }

  .provider-model-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 780px) {
  .settings-page {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .settings-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .settings-sidebar {
    display: block;
    padding: 16px 56px 12px 14px;
    overflow: hidden;
    border-right: 0;
    border-bottom: 1px solid rgba(221, 229, 239, 0.1);
  }

  .settings-sidebar-title {
    padding: 0 6px 12px;
  }

  .settings-sidebar-title h2 {
    font-size: 1.08rem;
  }

  .settings-nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .settings-nav::-webkit-scrollbar,
  .settings-nav-label,
  .settings-sidebar-status {
    display: none;
  }

  .settings-nav-item {
    width: auto;
    min-height: 38px;
    flex: 0 0 auto;
    padding: 8px 11px;
    font-size: 0.8rem;
  }

  .settings-nav-item svg {
    width: 17px;
    height: 17px;
    flex-basis: 17px;
  }

  .settings-content {
    overflow: hidden;
  }

  .settings-close-button {
    position: fixed;
    top: 13px;
    right: 12px;
  }

  .settings-content-scroll {
    padding: 32px 16px 42px;
  }

  .settings-content-heading {
    margin-bottom: 26px;
  }

  .settings-content-heading h2 {
    font-size: 1.55rem;
  }

  .settings-panel-heading {
    min-height: 0;
    padding: 20px;
  }

  .settings-form-row {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 18px 20px 20px;
  }

  .settings-form-row input,
  .settings-form-row select,
  .settings-row-control {
    max-width: none;
  }

  .settings-panel-actions {
    padding: 15px 20px 18px;
  }

  .settings-panel-actions button {
    width: 100%;
  }

  .settings-overview-strip {
    grid-template-columns: 1fr;
  }

  .settings-overview-strip > div + div {
    border-top: 1px solid rgba(221, 229, 239, 0.09);
    border-left: 0;
  }

  .settings-overview-in-panel,
  .settings-empty {
    margin-right: 20px;
    margin-left: 20px;
  }

  .provider-list,
  .model-config-list {
    padding-right: 20px;
    padding-left: 20px;
  }

  .provider-card-head,
  .model-config-row {
    grid-template-columns: 1fr;
  }

  .provider-use-button,
  .model-use-button {
    width: 100%;
  }

  .provider-detail-grid {
    grid-template-columns: 1fr;
  }

  .provider-config-toolbar,
  .provider-models-head {
    align-items: stretch;
    flex-direction: column;
  }

  .provider-config-toolbar-actions {
    justify-content: space-between;
  }

  .provider-config-toolbar-actions button {
    flex: 1 1 auto;
    justify-content: center;
  }

  .config-editor-grid,
  .provider-summary-grid,
  .provider-model-row {
    grid-template-columns: 1fr;
  }

  .config-field-wide,
  .provider-model-actions {
    grid-column: 1;
  }

  .provider-accordion-header {
    grid-template-columns: minmax(0, 1fr) auto;
    padding-right: 14px;
  }

  .provider-accordion-badges .config-chip:not([data-tone="good"]) {
    display: none;
  }

  .provider-accordion-body,
  .config-editor-body {
    padding: 17px;
  }

  .provider-action-row,
  .provider-model-actions {
    justify-content: flex-start;
  }

  .provider-action-row button {
    flex: 1 1 auto;
  }

  .model-editor-actions button,
  .config-editor-actions button {
    flex: 1 1 0;
  }
}

/* Compact rectangular settings language: flat surfaces, short rows, no decorative copy. */
.settings-page {
  width: min(1440px, calc(100vw - 24px));
  height: min(920px, calc(100vh - 24px));
  max-height: calc(100vh - 24px);
  border-color: rgba(221, 229, 239, 0.2);
  border-radius: 0;
  box-shadow: none;
}

.settings-page::backdrop {
  background: rgba(4, 6, 9, 0.84);
  backdrop-filter: none;
}

.settings-page,
.settings-page * {
  border-radius: 0 !important;
}

.settings-shell {
  grid-template-columns: 210px minmax(0, 1fr);
}

.settings-sidebar {
  padding: 16px 12px 12px;
  background: #10151b;
}

.settings-sidebar-title {
  padding: 2px 8px 14px;
}

.settings-sidebar-title h2 {
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.settings-nav {
  gap: 1px;
}

.settings-nav-item {
  min-height: 34px;
  gap: 9px;
  padding: 7px 9px;
  border: 0;
  border-left: 2px solid transparent;
  font-size: 0.78rem;
}

.settings-nav-item.is-active {
  border-left-color: var(--accent);
  background: rgba(255, 255, 255, 0.065);
  box-shadow: none;
}

.settings-nav-item:focus-visible {
  outline: 1px solid rgba(221, 229, 239, 0.28);
  outline-offset: -1px;
}

.settings-nav-item svg,
.settings-close-button svg {
  width: 16px;
  height: 16px;
  flex-basis: 16px;
}

.settings-sidebar-status {
  gap: 7px;
  margin: auto 8px 0;
  padding-top: 12px;
}

.settings-status-dot {
  width: 6px;
  height: 6px;
  flex-basis: 6px;
  box-shadow: none;
}

.settings-status-dot[data-tone="good"] {
  box-shadow: none;
}

.settings-content {
  background: #0e1217;
}

.settings-close-button {
  top: 12px;
  right: 14px;
  width: 28px;
  min-width: 28px;
  min-height: 28px;
}

.settings-content-scroll {
  padding: 22px 28px 32px;
}

.settings-content-heading {
  max-width: none;
  margin-bottom: 14px;
  padding-right: 36px;
}

.settings-content-heading h2 {
  font-size: 1.25rem;
  letter-spacing: -0.025em;
}

.settings-content-heading-actions {
  display: flex;
  min-height: 32px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.settings-add-provider {
  display: inline-flex;
  width: auto;
  min-height: 30px;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font-size: 0.7rem;
}

.settings-add-provider svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.settings-section-content {
  max-width: none;
  gap: 10px;
}

.settings-panel {
  border-color: rgba(221, 229, 239, 0.14);
  background: #12171d;
  box-shadow: none;
}

.settings-panel-heading {
  min-height: 42px;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
}

.settings-panel-heading h3 {
  font-size: 0.82rem;
  letter-spacing: 0;
}

.settings-status-pill,
.settings-count-badge,
.config-chip {
  min-height: 18px;
  padding: 1px 5px;
  background: transparent;
  font-size: 0.58rem;
  letter-spacing: 0;
}

.settings-status-pill[data-tone="good"],
.config-chip[data-tone="good"] {
  background: transparent;
}

.settings-form-row {
  grid-template-columns: minmax(150px, 0.55fr) minmax(260px, 1fr);
  gap: 16px;
  min-height: 50px;
  padding: 7px 12px;
}

.settings-row-copy label {
  font-size: 0.76rem;
}

.settings-form-row input,
.settings-form-row select,
.config-field input,
.config-field select {
  min-height: 32px;
}

.settings-form-row input,
.settings-form-row select {
  max-width: 520px;
  background: #171d24;
}

.settings-form-row input:focus,
.settings-form-row select:focus,
.config-field input:focus,
.config-field select:focus,
.config-field textarea:focus {
  background: #1a2028;
  box-shadow: none;
}

.settings-panel-actions {
  padding: 7px 12px;
}

.settings-panel-actions button {
  min-width: 88px;
  min-height: 30px;
  padding: 4px 10px;
  font-size: 0.7rem;
}

.provider-config-workspace {
  gap: 8px;
}

.config-editor {
  border-color: rgba(255, 159, 90, 0.32);
  box-shadow: none;
}

.config-editor-heading {
  min-height: 40px;
}

.settings-inline-close {
  width: 26px;
  min-width: 26px;
  min-height: 26px;
}

.config-editor-body {
  gap: 10px;
  padding: 10px 12px;
}

.config-editor-grid {
  gap: 10px 12px;
}

.config-field {
  gap: 4px;
}

.config-field > span {
  font-size: 0.65rem;
}

.config-field input,
.config-field select,
.config-field textarea {
  background: #171d24;
}

.config-field textarea {
  min-height: 70px;
}

.config-toggle-row {
  gap: 8px 16px;
}

.config-check {
  gap: 6px;
  font-size: 0.7rem;
}

.config-check input {
  width: 14px;
  min-height: 14px;
}

.config-advanced {
  background: rgba(7, 10, 14, 0.2);
}

.config-advanced summary {
  padding: 8px 10px;
  font-size: 0.68rem;
}

.config-advanced > .config-editor-grid {
  padding: 10px;
}

.provider-accordion-list {
  gap: 6px;
}

.provider-accordion {
  background: #12171d;
  box-shadow: none;
}

.provider-accordion.is-default {
  border-color: rgba(221, 229, 239, 0.14);
}

.provider-accordion-header {
  min-height: 44px;
  gap: 10px;
  padding-right: 10px;
}

.provider-accordion-trigger {
  min-height: 44px;
  gap: 9px;
  padding: 7px 10px;
}

.accordion-chevron {
  width: 14px;
  height: 14px;
  flex-basis: 14px;
}

.provider-identity {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.provider-identity strong {
  font-size: 0.82rem;
}

.provider-identity small {
  font-size: 0.58rem;
}

.provider-accordion-badges {
  gap: 4px;
}

.provider-accordion-body {
  gap: 8px;
  padding: 9px 10px 10px;
  background: #10151b;
}

.provider-meta-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 8px;
}

.provider-summary-grid {
  grid-template-columns: minmax(160px, 1.25fr) minmax(100px, 0.55fr) minmax(160px, 1fr);
  gap: 0;
  border: 1px solid rgba(221, 229, 239, 0.1);
}

.provider-summary-grid > div {
  padding: 5px 8px;
  background: transparent;
}

.provider-summary-grid > div + div {
  border-left: 1px solid rgba(221, 229, 239, 0.1);
}

.provider-summary-grid span {
  font-size: 0.54rem;
}

.provider-summary-grid strong {
  margin-top: 2px;
  font-size: 0.62rem;
}

.provider-action-row {
  flex-wrap: nowrap;
  align-self: center;
  gap: 4px;
}

.provider-action-row button {
  min-height: 28px;
  padding: 4px 7px;
  font-size: 0.62rem;
}

.provider-models-head {
  gap: 10px;
  padding-top: 1px;
}

.provider-models-head h4 {
  font-size: 0.76rem;
}

.provider-models-head button {
  min-height: 27px;
  padding: 3px 8px;
  font-size: 0.62rem;
}

.provider-model-list {
  gap: 0;
}

.provider-model-row {
  grid-template-columns: minmax(160px, 0.75fr) minmax(200px, 1.15fr) auto;
  gap: 8px;
  min-height: 42px;
  padding: 6px 8px;
  background: #141a21;
}

.provider-model-row + .provider-model-row {
  margin-top: -1px;
}

.model-config-main strong {
  font-size: 0.75rem;
}

.model-config-main span {
  margin-top: 1px;
  font-size: 0.59rem;
}

.model-feature-pills,
.provider-model-actions {
  gap: 4px;
}

.provider-model-actions {
  flex-wrap: nowrap;
}

.provider-model-actions button {
  min-height: 26px;
  padding: 3px 6px;
  font-size: 0.59rem;
}

.model-editor {
  gap: 10px;
  padding: 10px;
  background: #141a21;
}

.model-editor-heading h5 {
  font-size: 0.78rem;
}

@media (max-width: 1060px) {
  .settings-shell {
    grid-template-columns: 190px minmax(0, 1fr);
  }

  .settings-content-scroll {
    padding: 20px;
  }

  .provider-meta-row {
    grid-template-columns: 1fr;
  }

  .provider-action-row {
    justify-content: flex-end;
  }
}

@media (max-width: 780px) {
  .settings-sidebar {
    padding: 8px 44px 8px 8px;
  }

  .settings-sidebar-title {
    padding: 0 4px 6px;
  }

  .settings-nav {
    gap: 0;
  }

  .settings-nav-item {
    min-height: 32px;
    padding: 5px 8px;
  }

  .settings-close-button {
    top: 7px;
    right: 8px;
  }

  .settings-content-scroll {
    padding: 13px 10px 24px;
  }

  .settings-content-heading {
    margin-bottom: 10px;
  }

  .settings-content-heading h2 {
    font-size: 1.08rem;
  }

  .settings-panel-heading,
  .provider-accordion-body,
  .config-editor-body {
    padding: 8px 10px;
  }

  .settings-form-row {
    grid-template-columns: minmax(110px, 0.5fr) minmax(0, 1fr);
    gap: 10px;
    padding: 6px 10px;
  }

  .settings-panel-actions {
    padding: 6px 10px;
  }

  .settings-panel-actions button {
    width: auto;
  }

  .config-editor-grid {
    gap: 9px;
  }

  .provider-summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .provider-action-row,
  .provider-model-actions {
    justify-content: flex-end;
  }

  .provider-action-row button {
    flex: 0 1 auto;
  }

  .provider-model-row {
    grid-template-columns: minmax(130px, 0.75fr) minmax(150px, 1.25fr);
  }
}

@media (max-width: 480px) {
  .settings-form-row,
  .provider-summary-grid,
  .provider-model-row {
    grid-template-columns: 1fr;
  }

  .provider-summary-grid > div + div {
    border-top: 1px solid rgba(221, 229, 239, 0.1);
    border-left: 0;
  }
}

/* === Markdown rendering === */
.md-code-block {
  margin: 0.6rem 0;
  padding: 0.75rem 0.9rem;
  border-radius: 6px;
  background: #0d1117;
  border: 1px solid var(--line);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--ink-soft);
  white-space: pre;
}
.md-inline-code {
  padding: 0.12em 0.4em;
  border-radius: 3px;
  background: rgba(141,152,168,0.14);
  font-family: var(--font-mono);
  font-size: 0.88em;
  color: var(--accent-blue);
}
.md-heading {
  margin: 0.8rem 0 0.4rem;
  font-family: var(--font-display);
  color: var(--ink);
}
.md-heading:first-child { margin-top: 0; }
.md-table {
  margin: 0.6rem 0;
  border-collapse: collapse;
  width: 100%;
  font-size: 0.82rem;
}
.md-table th, .md-table td {
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--line);
  text-align: left;
}
.md-table th {
  background: rgba(139,199,255,0.08);
  color: var(--accent-blue);
}
a { color: var(--accent-blue); text-decoration: none; border-bottom: 1px solid rgba(139,199,255,0.3); }
a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* === Streaming cursor === */
.is-streaming .message-content::after {
  content: "\258C";
  animation: blink 1s step-end infinite;
  color: var(--accent);
  margin-left: 1px;
}
@keyframes blink { 50% { opacity: 0; } }

/* === Tool running card fold with gradient fade === */
.kind-tool-running .message-content {
  max-height: 3.2em;
  overflow: hidden;
  position: relative;
}
.kind-tool-running .message-content::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1.6em;
  background: linear-gradient(transparent, rgba(255, 200, 120, 0.07));
  pointer-events: none;
}
.kind-tool-running:hover .message-content {
  max-height: none;
}
.kind-tool-running:hover .message-content::after {
  display: none;
}

/* === Copy button (hover reveal) === */
.message-card { position: relative; }
.copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: auto;
  min-height: 0;
  padding: 2px 8px;
  border-radius: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  z-index: 1;
}
.copy-btn:hover {
  background: var(--surface-3);
  color: var(--ink);
  border-color: var(--line-strong);
}
.message-card:hover .copy-btn { opacity: 1; }

/* === Sidebar head search === */
.sidebar-head .session-search {
  width: 100%;
  min-height: 32px;
  padding: 5px 10px;
  font-size: 0.82rem;
  margin-bottom: 0;
}

/* === Chat head icon buttons === */
.head-icon-btn {
  display: inline-flex;
  flex: 0 0 30px;
  align-items: center;
  justify-content: center;
  width: 30px;
  min-width: 30px;
  max-width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.035);
}

.head-icon-btn svg {
  width: 15px;
  height: 15px;
  display: block;
}

.language-toggle-btn {
  flex-basis: 44px;
  width: 44px;
  min-width: 44px;
  max-width: 44px;
  color: var(--accent-blue);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.02em;
}

.chat-head-divider {
  display: inline-block;
  width: 1px;
  height: 24px;
  background: var(--line-strong);
  margin: 0 2px;
  vertical-align: middle;
}

/* === Session search === */
.session-search {
  padding: 5px 10px;
  font-size: 0.82rem;
  min-height: 30px;
  margin-bottom: 4px;
  border-radius: 0;
}

/* === Message card spacing === */
.message-card { margin-bottom: 0; }

/* === Custom scrollbar (dark theme) === */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(141, 152, 168, 0.22);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(141, 152, 168, 0.42);
}
::-webkit-scrollbar-corner {
  background: transparent;
}

/* === Role-based badge colors === */
.role-user .message-badge {
  color: var(--accent);
  border-color: rgba(255, 159, 90, 0.35);
}
.role-assistant .message-badge {
  color: var(--accent-blue);
  border-color: rgba(139, 199, 255, 0.3);
}
.role-tool .message-badge {
  color: var(--success);
  border-color: rgba(143, 229, 140, 0.25);
}
.role-system .message-badge {
  color: var(--muted);
}

/* === Chat head accent line === */
.chat-head {
  border-bottom: 1px solid var(--line-strong);
  border-image: linear-gradient(90deg, rgba(255,159,90,0.28), transparent 60%) 1;
}

.chat-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* === Composer toolbar (web-002) === */
.composer-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 16px 10px;
  flex-wrap: wrap;
}

.toolbar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 0;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
  flex: 0 0 auto;
}

.toolbar-icon-btn svg {
  width: 14px;
  height: 14px;
  display: block;
}

.toolbar-icon-btn:hover:not(:disabled) {
  color: var(--ink-soft);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
}

.toolbar-icon-btn.is-active {
  color: var(--accent);
  border-color: rgba(255, 159, 90, 0.5);
  background: rgba(255, 159, 90, 0.1);
}

.toolbar-icon-btn.is-active-blue {
  color: var(--accent-blue);
  border-color: rgba(139, 199, 255, 0.45);
  background: rgba(139, 199, 255, 0.08);
}

.toolbar-badge {
  position: absolute;
  bottom: 1px;
  right: 1px;
  min-width: 10px;
  height: 10px;
  padding: 0 2px;
  background: var(--accent);
  color: #1a0d05;
  font-family: var(--font-mono);
  font-size: 0.48rem;
  font-weight: 900;
  line-height: 10px;
  text-align: center;
  letter-spacing: 0;
  pointer-events: none;
}

.toolbar-divider {
  width: 1px;
  height: 16px;
  background: var(--line);
  margin: 0 2px;
  flex: 0 0 auto;
}

.toolbar-spacer {
  flex: 1;
}

.model-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
  flex: 0 0 auto;
  min-width: 0;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-chip:hover:not(:disabled) {
  color: var(--ink-soft);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
}

.model-chip.is-active {
  color: var(--accent-blue);
  border-color: rgba(139, 199, 255, 0.4);
}

.model-picker {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  z-index: 200;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.model-picker-item {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 7px 12px;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  text-align: left;
  cursor: pointer;
  border-radius: 0;
}

.model-picker-item:hover {
  background: rgba(255, 159, 90, 0.1);
  color: var(--ink);
}

.model-picker-item.is-selected {
  color: var(--accent-blue);
}

.file-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 6px 16px 0;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 6px 2px 8px;
  border: 1px solid rgba(139, 199, 255, 0.3);
  background: rgba(139, 199, 255, 0.07);
  color: var(--accent-blue);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  max-width: 180px;
}

.file-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.file-chip-thumb {
  width: 20px;
  height: 20px;
  object-fit: cover;
  border-radius: 2px;
  flex: 0 0 auto;
}

.file-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  min-height: 14px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.7rem;
  cursor: pointer;
  flex: 0 0 auto;
}

.file-chip-remove:hover {
  color: var(--danger);
  background: transparent;
  border: 0;
}

.composer-queue {
  display: grid;
  gap: 5px;
  padding: 8px 16px 0;
}

.composer-queue-item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px;
  align-items: center;
}

.composer-queue-item[draggable="true"] {
  cursor: grab;
}

.composer-queue-item.is-dragging {
  opacity: 0.62;
}

.composer-queue-line {
  min-width: 0;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid rgba(255, 206, 138, 0.24);
  background: rgba(255, 206, 138, 0.055);
  color: rgba(245, 225, 197, 0.86);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-queue-line:hover:not(:disabled) {
  border-color: rgba(255, 206, 138, 0.48);
  background: rgba(255, 206, 138, 0.09);
  color: var(--ink);
}

.composer-queue-item.is-running .composer-queue-line {
  border-color: rgba(255, 159, 90, 0.42);
  color: var(--accent);
}

.composer-queue-steer,
.composer-queue-btw,
.composer-btw-btn {
  height: 28px;
  min-height: 28px;
  width: auto;
  flex: 0 0 auto;
  padding: 0 10px;
  border-color: rgba(122, 224, 142, 0.55);
  background: rgba(122, 224, 142, 0.16);
  color: #aaf0b4;
  font-size: 0.72rem;
}

.composer-queue-btw:hover:not(:disabled),
.composer-btw-btn:hover:not(:disabled) {
  border-color: rgba(122, 224, 142, 0.78);
  background: rgba(122, 224, 142, 0.24);
  color: #d9ffdd;
}

.btw-panel {
  position: absolute;
  right: clamp(14px, 2.4vw, 32px);
  top: calc(64px + 14px);
  bottom: calc(var(--composer-panel-height, 120px) + 14px);
  z-index: 250;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 9px;
  width: min(420px, calc(100% - clamp(28px, 4.8vw, 64px)));
  max-height: none;
  overflow: hidden;
  padding: 12px;
  border: 1px solid rgba(122, 224, 142, 0.38);
  background: rgba(13, 19, 18, 0.98);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

.btw-panel .head-icon-btn {
  flex: none;
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
}

.btw-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #b8f7c0;
  font-family: var(--font-display);
}

.btw-panel-status {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  padding: 3px 7px;
  border: 1px solid rgba(122, 224, 142, 0.26);
  background: rgba(122, 224, 142, 0.1);
  color: #b8f7c0;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 800;
}

.btw-panel-status.is-loading {
  border-color: rgba(255, 206, 138, 0.32);
  background: rgba(255, 206, 138, 0.1);
  color: #ffce8a;
  animation: btw-status-pulse 1.1s ease-in-out infinite;
}

.btw-status-spinner {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 999px;
  background: currentColor;
  animation: btw-dot-pulse 0.82s ease-in-out infinite;
}

.btw-panel-status.is-error {
  border-color: rgba(255, 116, 109, 0.34);
  background: rgba(255, 116, 109, 0.1);
  color: #ffb7b2;
}

.btw-panel-question {
  padding: 8px 9px;
  border: 1px solid rgba(122, 224, 142, 0.16);
  background: rgba(255, 255, 255, 0.035);
  color: var(--ink);
  font-size: 0.82rem;
  line-height: 1.45;
  max-height: 92px;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
}

.btw-panel-answer,
.btw-panel-error {
  min-height: 0;
  max-height: none;
  overflow: auto;
  padding: 9px;
  border: 1px solid rgba(139, 199, 255, 0.18);
  background: rgba(139, 199, 255, 0.045);
  color: var(--ink);
  font-size: 0.84rem;
  line-height: 1.48;
}

.btw-panel-error {
  border-color: rgba(255, 116, 109, 0.34);
  background: rgba(255, 116, 109, 0.08);
  color: #ffd0cd;
}

@keyframes btw-status-pulse {
  0%, 100% {
    box-shadow: 0 0 0 rgba(255, 206, 138, 0);
  }
  50% {
    box-shadow: 0 0 0 3px rgba(255, 206, 138, 0.08);
  }
}

@keyframes btw-dot-pulse {
  0%, 100% {
    opacity: 0.42;
    transform: scale(0.82);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

.composer-queue-steer {
  border-color: rgba(255, 159, 90, 0.62);
  background: rgba(255, 159, 90, 0.16);
  color: #ffd4b2;
}

.composer-queue-steer:hover:not(:disabled) {
  border-color: rgba(255, 177, 113, 0.84);
  background: rgba(255, 159, 90, 0.26);
  color: #fff0e2;
}

.composer-queue-editor {
  position: fixed;
  left: calc(var(--session-sidebar-width) + (100vw - var(--session-sidebar-width)) / 2);
  bottom: 92px;
  transform: translateX(-50%);
  z-index: 120;
  display: grid;
  gap: 8px;
  width: min(720px, calc(100vw - var(--session-sidebar-width) - 64px));
  padding: 10px;
  border: 1px solid var(--line-strong);
  background: rgba(14, 18, 25, 0.98);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.44);
}

.composer-queue-editor textarea {
  width: 100%;
  min-height: 112px;
  resize: vertical;
}

.composer-queue-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.composer-queue-editor-actions button {
  width: auto;
  min-height: 28px;
  padding: 0 10px;
  font-size: 0.72rem;
}

.composer-textarea-wrap {
  padding: 10px 16px 0;
}

.composer-textarea-wrap textarea {
  width: 100%;
  transition: height 0.15s ease;
}

.composer-send-btn {
  height: 28px;
  min-height: 28px;
  padding: 0 14px;
  font-size: 0.78rem;
  flex: 0 0 72px;
  width: 72px;
  justify-content: center;
}

.composer-steer-btn {
  height: 28px;
  min-height: 28px;
  width: 72px;
  flex: 0 0 72px;
  padding: 0 12px;
  justify-content: center;
  font-size: 0.78rem;
}

.composer-send-btn.is-stop {
  border-color: rgba(255, 104, 104, 0.72);
  background: linear-gradient(180deg, rgba(255, 122, 122, 0.94), rgba(214, 72, 72, 0.94));
  color: #fff8f8;
}

.context-usage-chip {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  height: 28px;
  padding: 0 7px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  user-select: none;
  white-space: nowrap;
}

.model-picker-group {
  padding: 5px 12px 3px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-top: 1px solid var(--line);
}

.model-picker-group:first-child {
  border-top: 0;
}

.model-chip-wrap {
  position: relative;
}


/* === Message card entrance animation === */
@keyframes cardFadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-card {
  animation: cardFadeIn 0.18s ease-out;
}

/* === Streaming card shimmer === */
.is-streaming {
  border-color: rgba(139, 199, 255, 0.48);
  background: rgba(139, 199, 255, 0.04);
}

/* === Transcript empty state === */
.transcript-empty {
  text-align: center;
  padding: 24px 16px;
  font-size: 0.88rem;
}

/* === Permission card polish === */
.permission-card {
  border-radius: 0;
  transition: border-color 0.15s;
}
.permission-card:hover {
  border-color: rgba(255, 159, 90, 0.45);
}

/* === Better focus visible for accessibility === */
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 1px solid rgba(139, 199, 255, 0.5);
  outline-offset: -1px;
}

/* === Session card hover transition === */
.session-card {
  transition: background 0.12s ease;
}

/* === Running dot refinement === */
.running-dot {
  font-size: 0.55rem;
  margin-left: -2px;
}

/* === User message rounded corners === */
.message-card.role-user {
  border-radius: 14px 14px 4px 14px;
}

/* === Code block wrapper with language label and copy === */
.md-code-block-wrapper {
  position: relative;
  margin: 0.6rem 0;
}
.md-code-lang {
  position: absolute;
  top: 4px;
  left: 10px;
  padding: 1px 6px;
  background: rgba(139, 199, 255, 0.12);
  color: var(--accent-blue);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 2px;
  z-index: 1;
}
.md-code-copy {
  position: absolute;
  top: 4px;
  right: 6px;
  width: auto;
  min-height: 0;
  padding: 2px 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  z-index: 1;
}
.md-code-copy:hover {
  background: var(--surface-3);
  color: var(--ink);
  border-color: var(--line-strong);
}
.md-code-block-wrapper:hover .md-code-copy {
  opacity: 1;
}
.md-code-block-wrapper .md-code-block {
  margin: 0;
  padding-top: 1.8rem;
}

/* === Tool result collapse toggle === */
.collapse-toggle {
  width: auto;
  min-height: 0;
  padding: 1px 6px;
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 700;
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.12s, color 0.12s;
}
.collapse-toggle:hover {
  background: var(--surface-2);
  color: var(--ink);
}

/* === Collapsed tool result content === */
.message-content.is-collapsed {
  max-height: 4.5em;
  overflow: hidden;
  position: relative;
}
.message-content.is-collapsed::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2em;
  background: linear-gradient(transparent, rgba(139, 199, 255, 0.055));
  pointer-events: none;
}

/* === Context menu === */
.context-menu {
  position: fixed;
  z-index: 1000;
  min-width: 140px;
  padding: 4px 0;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.context-menu-item {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 6px 14px;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  border-radius: 0;
}
.context-menu-item:hover {
  background: rgba(255, 159, 90, 0.1);
  color: var(--ink);
}
.context-menu-item.danger {
  color: var(--danger);
}

/* === Productized session sidebar === */
#session-column {
  position: relative;
  isolation: isolate;
  background:
    radial-gradient(circle at 12% 0%, rgba(255, 159, 90, 0.12), transparent 32%),
    linear-gradient(180deg, rgba(16, 21, 30, 0.98), rgba(9, 12, 18, 0.96));
}

.sidebar-head {
  gap: 10px;
  min-height: 0;
  padding: 14px 14px 12px;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.03);
}

.session-search-wrap {
  position: relative;
  display: grid;
  align-items: center;
}

.session-search-wrap svg {
  position: absolute;
  left: 10px;
  z-index: 1;
  width: 13px;
  height: 13px;
  color: var(--muted);
  pointer-events: none;
}

.sidebar-head .session-search,
.session-search {
  min-height: 34px;
  margin: 0;
  padding: 7px 10px 7px 30px;
  border-color: rgba(221, 229, 239, 0.18);
  background: rgba(6, 9, 14, 0.52);
  font-size: 0.8rem;
}

.session-view-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
}

.session-view-tabs button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 24px;
  padding: 3px 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.64rem;
  text-transform: uppercase;
}

.session-view-tabs button.is-active {
  background: rgba(244, 239, 229, 0.055);
  color: var(--ink-soft);
}

.session-view-tabs span {
  min-width: auto;
  padding: 0 3px;
  background: transparent;
  color: var(--muted);
}

.session-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.session-toolbar-action {
  width: auto;
  min-height: 26px;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  text-transform: uppercase;
}

.session-toolbar-hint {
  display: block;
  min-height: 14px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

#session-list {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 10px;
  scrollbar-gutter: stable;
}

.session-empty {
  display: grid;
  gap: 4px;
  margin: 10px;
  padding: 12px;
  border-style: solid;
  background: rgba(255, 255, 255, 0.035);
}

.session-empty strong {
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.session-empty span {
  color: var(--muted);
  font-size: 0.78rem;
}

.session-card {
  display: block;
  min-height: 0;
  padding: 0;
  border: 1px solid rgba(221, 229, 239, 0.14);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.015)),
    rgba(11, 15, 22, 0.78);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}

.session-card:hover:not(:disabled) {
  border-color: rgba(255, 159, 90, 0.38);
  background:
    linear-gradient(135deg, rgba(255, 159, 90, 0.1), rgba(139, 199, 255, 0.035)),
    rgba(13, 18, 26, 0.88);
  transform: translateX(2px);
}

.session-card.is-selected,
.session-card.is-attached {
  border-color: rgba(255, 159, 90, 0.56);
  background:
    linear-gradient(135deg, rgba(255, 159, 90, 0.16), rgba(139, 199, 255, 0.045)),
    rgba(15, 20, 28, 0.94);
}

.session-card.is-attached::before {
  background: linear-gradient(180deg, var(--success), var(--accent));
}

.session-card.is-archived {
  opacity: 0.74;
}

.session-card-main {
  display: grid;
  gap: 6px;
  padding: 10px 10px 9px 12px;
}

.session-card-topline,
.session-card-meta {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

.session-card-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.86rem;
}

.session-card-time {
  flex: 0 0 auto;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 800;
  text-transform: uppercase;
}

.session-card-preview {
  overflow: hidden;
  color: rgba(244, 239, 229, 0.72);
  font-size: 0.76rem;
  font-weight: 550;
  line-height: 1.28;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-card-meta {
  flex-wrap: wrap;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.56rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.session-card-meta span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-resizer {
  position: absolute;
  top: 0;
  right: -4px;
  bottom: 0;
  z-index: 8;
  width: 8px;
  cursor: col-resize;
}

.sidebar-resizer::after {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 3px;
  width: 1px;
  background: transparent;
  transition: background 0.12s ease, box-shadow 0.12s ease;
}

.sidebar-resizer:hover::after,
#session-column.is-resizing .sidebar-resizer::after {
  background: var(--accent);
  box-shadow: 0 0 16px rgba(255, 159, 90, 0.6);
}

body.is-resizing-sidebar {
  cursor: col-resize;
  user-select: none;
}

.codex-sidebar {
  --sidebar-hover: rgba(244, 239, 229, 0.065);
  --sidebar-active: rgba(244, 239, 229, 0.095);
  --sidebar-border: rgba(244, 239, 229, 0.105);
}

#session-column.codex-sidebar {
  z-index: 12;
  overflow: visible;
}

.codex-sidebar-head {
  flex: 0 0 auto;
  justify-content: flex-start;
  gap: 0;
  max-height: none;
  padding: 10px 10px 9px;
  overflow: visible;
  background:
    linear-gradient(180deg, rgba(16, 18, 24, 0.98), rgba(10, 12, 17, 0.96)),
    rgba(10, 12, 17, 0.96);
}

.codex-sidebar .head-icon-btn {
  border-radius: 8px;
  background: transparent;
}

.sidebar-primary-actions {
  display: grid;
  gap: 2px;
  padding: 0;
}

.sidebar-entry {
  display: grid;
  grid-template-columns: 17px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  height: 36px;
  min-height: 36px;
  max-height: 36px;
  padding: 0 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--font-sidebar);
  font-size: 0.83rem;
  font-weight: 600;
  text-align: left;
}

.sidebar-entry svg {
  width: 15px;
  height: 15px;
  color: var(--muted);
}

.sidebar-entry span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-entry kbd {
  padding: 1px 5px;
  border: 1px solid rgba(244, 239, 229, 0.08);
  border-radius: 4px;
  background: rgba(244, 239, 229, 0.04);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.54rem;
  font-weight: 800;
}

.sidebar-entry:hover:not(:disabled),
.sidebar-entry.is-active {
  border: 0;
  background: var(--sidebar-active);
  color: var(--ink);
}

.sidebar-entry.is-active svg,
.sidebar-entry:hover:not(:disabled) svg {
  color: var(--ink-soft);
}

.codex-sidebar .session-search-wrap {
  border: 1px solid transparent;
  border-radius: 4px;
  background: rgba(244, 239, 229, 0.04);
}

.codex-sidebar .session-search-wrap.is-active,
.codex-sidebar .session-search-wrap:focus-within {
  border-color: rgba(139, 199, 255, 0.34);
  background: rgba(139, 199, 255, 0.055);
}

.codex-sidebar .session-search {
  border: 0;
  border-radius: 4px;
  background: transparent;
}

.sidebar-popover-layer {
  position: absolute;
  top: 8px;
  left: calc(100% + 12px);
  z-index: 40;
  width: min(390px, calc(100vw - var(--session-sidebar-width, 320px) - 28px));
  max-width: calc(100vw - 24px);
  pointer-events: none;
}

.sidebar-popover {
  position: relative;
  display: grid;
  gap: 12px;
  max-height: min(85vh, 1120px);
  padding: 14px;
  overflow: auto;
  border: 1px solid rgba(244, 239, 229, 0.13);
  border-radius: 8px;
  background:
    radial-gradient(circle at 18% 0%, rgba(139, 199, 255, 0.13), transparent 34%),
    linear-gradient(145deg, rgba(20, 24, 32, 0.98), rgba(8, 10, 15, 0.98));
  box-shadow:
    0 28px 78px rgba(0, 0, 0, 0.52),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset;
  pointer-events: auto;
  animation: sidebar-popover-enter 140ms ease-out;
}

.sidebar-popover::before {
  content: "";
  position: absolute;
  top: 22px;
  left: -7px;
  width: 12px;
  height: 12px;
  border-left: 1px solid rgba(244, 239, 229, 0.13);
  border-bottom: 1px solid rgba(244, 239, 229, 0.13);
  background: rgba(18, 22, 30, 0.98);
  transform: rotate(45deg);
}

.sidebar-popover .sidebar-panel-head,
.sidebar-popover .session-search-wrap,
.sidebar-popover .sidebar-panel-copy,
.sidebar-popover .sidebar-panel-actions,
.sidebar-popover .automation-mini-form,
.sidebar-popover .automation-job-list,
.sidebar-popover .panel-wide-button {
  position: relative;
  z-index: 1;
}

.sidebar-popover .sidebar-panel-copy {
  max-width: 32ch;
}

.sidebar-search-popover {
  top: 38px;
}

.sidebar-skills-popover {
  top: 74px;
}

.sidebar-automation-popover {
  top: 110px;
  width: min(430px, calc(100vw - var(--session-sidebar-width, 320px) - 28px));
}

@keyframes sidebar-popover-enter {
  from {
    opacity: 0;
    transform: translateX(-8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

.sidebar-panel {
  display: grid;
  gap: 9px;
  padding: 10px;
  border: 1px solid var(--sidebar-border);
  border-radius: 6px;
  background:
    linear-gradient(145deg, rgba(244, 239, 229, 0.055), rgba(244, 239, 229, 0.018)),
    rgba(5, 7, 11, 0.42);
}

.sidebar-panel-head,
.automation-job-actions,
.automation-job-main {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

.sidebar-panel-head {
  justify-content: space-between;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 850;
}

.sidebar-panel-copy,
.automation-empty {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.sidebar-panel-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.sidebar-panel-actions button,
.panel-wide-button,
.automation-mini-form button {
  min-height: 28px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  text-transform: uppercase;
}

.panel-mini-button {
  width: auto;
  min-height: 24px;
  padding: 3px 7px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.56rem;
  text-transform: uppercase;
}

.panel-mini-button.danger {
  color: var(--danger);
}

.automation-mini-form,
.automation-job-list,
.workspace-section,
.workspace-list {
  display: grid;
}

.automation-mini-form {
  gap: 6px;
}

.automation-mini-form input,
.automation-mini-form textarea {
  min-height: 30px;
  border-radius: 4px;
  background: rgba(5, 7, 11, 0.42);
  font-size: 0.72rem;
}

.automation-mini-form textarea {
  min-height: 56px;
}

.automation-job-list {
  gap: 4px;
  max-height: 540px;
  overflow: auto;
}

.automation-job {
  display: grid;
  gap: 5px;
  padding: 8px 10px;
  border: 1px solid rgba(244, 239, 229, 0.09);
  border-radius: 5px;
  background: rgba(244, 239, 229, 0.035);
}

.automation-job-main {
  justify-content: space-between;
}

.automation-job-main strong,
.automation-job-main span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.automation-job-main strong {
  color: var(--ink-soft);
  font-size: 0.76rem;
}

.automation-job-main span {
  flex: 0 1 auto;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.56rem;
}

.automation-job-header {
  display: flex;
  align-items: center;
  gap: 7px;
}

.automation-job-name {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.automation-job-badge {
  flex: 0 0 auto;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.56rem;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.badge-on {
  color: var(--success);
  background: rgba(143, 229, 140, 0.12);
}

.badge-off {
  color: var(--muted);
  background: rgba(141, 152, 168, 0.1);
}

.automation-job-schedule {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.64rem;
}

.automation-job-prompt {
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.72rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.automation-job-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.58rem;
}

.automation-job-meta em {
  font-style: normal;
}

.automation-job-actions {
  flex-wrap: wrap;
}

.workspace-section {
  gap: 6px;
}

.sidebar-section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.56rem;
  font-weight: 900;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.workspace-list {
  gap: 2px;
  max-height: 168px;
  overflow: auto;
}

.workspace-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-soft);
  text-align: left;
}

.workspace-item:hover:not(:disabled),
.workspace-item.is-active {
  background: var(--sidebar-active);
}

.workspace-avatar {
  display: inline-grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid rgba(244, 239, 229, 0.09);
  border-radius: 4px;
  background: rgba(244, 239, 229, 0.04);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 900;
}

.workspace-folder-icon {
  display: inline-grid;
  width: 18px;
  height: 24px;
  place-items: center;
  color: rgba(141, 152, 168, 0.92);
}

.workspace-folder-icon svg {
  width: 15px;
  height: 15px;
}

.workspace-item.is-active .workspace-avatar,
.workspace-item.is-active .workspace-folder-icon {
  border-color: rgba(255, 159, 90, 0.36);
  color: var(--accent);
}

.workspace-copy {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.workspace-name,
.workspace-path {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-name {
  color: var(--ink-soft);
  font-family: var(--font-sidebar);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  line-height: 32px;
}

.workspace-path {
  color: rgba(141, 152, 168, 0.76);
  font-family: var(--font-mono);
  font-size: 0.54rem;
  font-weight: 700;
}

.workspace-stats {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 900;
}

.workspace-running {
  min-width: 14px;
  padding: 1px 4px;
  border-radius: 999px;
  background: rgba(143, 229, 140, 0.12);
  color: var(--success);
  text-align: center;
}

.sidebar-session-strip {
  display: grid;
  flex: 0 0 auto;
  gap: 0;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(244, 239, 229, 0.055);
  background: rgba(6, 8, 12, 0.22);
}

.codex-sidebar .session-view-tabs,
.codex-sidebar .session-view-tabs button,
.codex-sidebar .session-view-tabs span,
.codex-sidebar .session-toolbar-action,
.codex-sidebar .context-menu,
.codex-sidebar .context-menu-item {
  border-radius: 4px;
}

.codex-sidebar .session-view-tabs {
  border-color: transparent;
  background: transparent;
}

.codex-sidebar .session-view-tabs button.is-active {
  background: rgba(244, 239, 229, 0.055);
  color: var(--ink-soft);
}

.codex-sidebar #session-list {
  gap: 1px;
  padding: 6px;
}

.codex-sidebar #session-empty {
  flex: 0 0 auto;
}

.codex-sidebar #session-list.session-workspace-list {
  flex: 1 1 0;
  min-height: 0;
  max-height: none;
  overflow: auto;
}

.session-workspace-group {
  display: grid;
  gap: 1px;
}

.session-workspace-toggle {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  height: 32px;
  min-height: 32px;
  max-height: 32px;
  padding: 0 4px;
  border: 0;
  border-radius: 4px;
  background: transparent;
}

.session-workspace-toggle.is-filtered {
  border-color: rgba(255, 159, 90, 0.28);
  background:
    linear-gradient(90deg, rgba(255, 159, 90, 0.11), rgba(244, 239, 229, 0.025)),
    rgba(244, 239, 229, 0.025);
}

.session-workspace-heading {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) 10px;
  align-items: center;
  gap: 6px;
  min-width: 0;
  height: 32px;
  min-height: 32px;
  max-height: 32px;
  padding: 0 2px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-soft);
  text-align: left;
}

.session-workspace-heading::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  color: rgba(141, 152, 168, 0.8);
  transform: rotate(45deg);
  transition: transform 120ms ease;
}

.session-workspace-heading[aria-expanded="false"]::after {
  transform: rotate(-45deg);
}

.session-workspace-heading:hover:not(:disabled) {
  border: 0;
  background: var(--sidebar-hover);
}

.session-workspace-items {
  display: grid;
  gap: 0;
  margin: 0 0 2px 12px;
  padding-left: 3px;
  border-left: 0;
}

#session-column.codex-sidebar .session-card {
  border: 0;
  border-radius: 4px;
  background: transparent;
  box-shadow: none;
  display: flex;
  align-items: center;
  height: 24px;
  min-height: 24px;
  max-height: 24px;
  padding: 0 6px 0 8px;
  overflow: hidden;
  transform: none;
}

#session-column.codex-sidebar .session-card::before {
  content: none;
}

#session-column.codex-sidebar .session-card:hover:not(:disabled),
#session-column.codex-sidebar .session-card.is-selected,
#session-column.codex-sidebar .session-card.is-attached {
  border: 0;
  background: var(--sidebar-active);
  padding-left: 8px;
  transform: none;
}

#session-column.codex-sidebar .session-card-main {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 0;
}

#session-column.codex-sidebar .session-card-topline {
  gap: 6px;
  height: 24px;
  min-height: 24px;
  line-height: 24px;
}

#session-column.codex-sidebar .session-card-title {
  font-family: var(--font-sidebar);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  line-height: 24px;
}

#session-column.codex-sidebar .session-card-time {
  font-size: 0.48rem;
  line-height: 24px;
}

.codex-sidebar .session-card-preview {
  color: rgba(207, 199, 186, 0.7);
  font-size: 0.72rem;
}

.codex-sidebar .session-card-meta {
  font-size: 0.52rem;
}

@media (max-width: 1060px) {
  .sidebar-resizer {
    display: none;
  }

  .sidebar-popover-layer {
    position: static;
    width: auto;
    max-width: none;
    padding: 0 14px 10px;
  }

  .sidebar-popover,
  .sidebar-automation-popover {
    top: auto;
    width: auto;
    max-height: none;
  }

  .sidebar-popover::before {
    display: none;
  }

  .session-toolbar {
    grid-template-columns: 1fr;
  }

  .codex-sidebar-head {
    max-height: none;
  }

  .workspace-list,
  .automation-job-list {
    max-height: 220px;
  }
}

/* === Disconnect banner === */
.disconnect-banner,
.connecting-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 16px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.disconnect-banner {
  background: rgba(255, 116, 109, 0.15);
  color: #ffd5d2;
  border-bottom: 1px solid rgba(255, 116, 109, 0.3);
}
.connecting-banner {
  background: rgba(139, 199, 255, 0.1);
  color: var(--accent-blue);
  border-bottom: 1px solid rgba(139, 199, 255, 0.2);
}
.disconnect-banner button {
  width: auto;
  min-height: 0;
  padding: 3px 10px;
  font-size: 0.7rem;
}

/* === Empty session guide === */
.empty-guide {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  flex: 1;
}
.empty-guide-icon {
  font-size: 2.4rem;
  margin-bottom: 12px;
  opacity: 0.6;
}
.empty-guide-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--ink);
}

/* === Send button spinner === */
.btn-spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border: 2px solid rgba(26, 13, 5, 0.3);
  border-top-color: #1a0d05;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   Chat stream v2 — message items, reasoning, tools, agents
   ============================================================ */

.msg {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  animation: cardFadeIn 0.18s ease-out;
}
.msg-assistant {
  align-self: stretch;
  max-width: min(96%, 1120px);
}
.msg-user {
  align-self: flex-end;
  max-width: min(82%, 900px);
  padding: 8px 12px;
  border: 1px solid rgba(255, 159, 90, 0.38);
  background: rgba(255, 159, 90, 0.11);
}
.msg-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.msg-role { color: var(--ink-soft); }
.msg-time { opacity: 0.75; }
.msg-body {
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.45;
  word-break: break-word;
}
.msg:hover .copy-btn { opacity: 1; }
/* PLACEHOLDER-CHAT-STREAM */

/* Markdown body (markdown-it output) */
.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body p { margin: 0.32rem 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  margin: 0.65rem 0 0.35rem;
  font-family: var(--font-display);
  color: var(--ink);
  line-height: 1.3;
}
.markdown-body h1 { font-size: 1.3rem; }
.markdown-body h2 { font-size: 1.15rem; }
.markdown-body h3 { font-size: 1.02rem; }
.markdown-body ul, .markdown-body ol { margin: 0.35rem 0; padding-left: 1.35rem; }
.markdown-body li { margin: 0.12rem 0; }
.markdown-body li.md-task-item { list-style: none; margin-left: -1.1rem; }
.markdown-body .md-task-checkbox { margin-right: 0.45rem; vertical-align: middle; }
.markdown-body blockquote {
  margin: 0.6rem 0;
  padding: 0.2rem 0.9rem;
  border-left: 3px solid var(--line-strong);
  color: var(--ink-soft);
}
.markdown-body code:not(.hljs) {
  padding: 0.12em 0.4em;
  border-radius: 3px;
  background: rgba(141, 152, 168, 0.14);
  font-family: var(--font-mono);
  font-size: 0.88em;
  color: var(--accent-blue);
}
.markdown-body table {
  margin: 0.6rem 0;
  border-collapse: collapse;
  width: 100%;
  font-size: 0.82rem;
}
.markdown-body th, .markdown-body td {
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--line);
  text-align: left;
}
.markdown-body th { background: rgba(139, 199, 255, 0.08); color: var(--accent-blue); }
.markdown-body pre.md-code-block { white-space: pre; }
/* PLACEHOLDER-REASONING */

/* Shared lightweight line used by both thinking and tool output.
   Same layout/spacing/typography — only icon glyph and color differ. */
.stream-line {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 0;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  text-align: left;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.32;
}
.stream-line-thinking {
  cursor: pointer;
  color: #83bdff;
}
.stream-line-thinking:hover {
  color: #b9d7ff;
}
/* Neutralize global button hover/focus chrome (higher-specificity rules) so
   the thinking line stays a plain inline row, not a filled button. */
.stream-line:hover:not(:disabled),
.stream-line:focus,
.stream-line:focus-visible {
  outline: none;
}
.stream-icon {
  flex: none;
  display: inline-flex;
  color: var(--muted);
}
.stream-icon svg { display: block; width: 14px; height: 14px; }
.stream-line-thinking .stream-icon { color: #83bdff; opacity: 0.92; }
.stream-icon-running,
.stream-icon-process-running {
  color: #ffce8a;
  animation: tool-running-pulse 1.4s ease-in-out infinite;
}
.stream-icon-process { color: rgba(255, 206, 138, 0.62); }
.stream-icon-success { color: rgba(143, 229, 140, 0.65); }
.stream-icon-guided { color: rgba(255, 206, 138, 0.72); }
.stream-icon-error { color: rgba(255, 116, 109, 0.65); }
.stream-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: break-word;
}
.stream-line-thinking .stream-text { font-style: italic; }
.stream-line-thinking.is-expanded {
  align-items: flex-start;
  padding: 7px 9px;
}
.stream-line-thinking.is-expanded .stream-text {
  overflow: visible;
  text-overflow: initial;
  white-space: pre-wrap;
}
/* Streaming cursor */
.is-streaming .msg-body::after {
  content: "\258C";
  animation: blink 1s step-end infinite;
  color: var(--accent);
  margin-left: 1px;
}
/* PLACEHOLDER-TOOL */

/* Tool call — uses the shared .stream-line; icon color reflects status */
.tool-line {
  align-self: stretch;
  max-width: min(96%, 1120px);
  font-size: 0.8rem;
}
.stream-line-tool {
  color: rgba(200, 239, 216, 0.65);
}
.tool-running .stream-line-tool {
  color: rgba(255, 206, 138, 0.65);
}
.tool-error .stream-line-tool {
  color: rgba(255, 116, 109, 0.65);
}
.stream-line-tool .stream-icon { margin-top: 0; }
.stream-line-tool .stream-text {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
/* Clickable tool line (non-running, has details) */
.stream-line-tool.is-clickable {
  cursor: pointer;
}
.stream-line-tool.is-clickable:hover {
  border-color: rgba(221, 236, 225, 0.14);
  background: rgba(255, 255, 255, 0.025);
}

.tool-toggle-hint {
  flex: none;
  color: rgba(221, 236, 225, 0.3);
  font-size: 0.56rem;
  margin-left: auto;
  opacity: 0;
  transition: opacity 0.15s;
}
.tool-line:hover .tool-toggle-hint {
  opacity: 1;
}
/* PLACEHOLDER-TOOL2 */

.tool-name {
  flex: none;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: rgba(131, 240, 165, 0.6);
  font-weight: 600;
  white-space: nowrap;
}
.tool-action {
  flex: 0 1 auto;
  min-width: 0;
  color: rgba(214, 233, 220, 0.6);
  font-size: 0.76rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tool-chip {
  flex: 1 1 90px;
  min-width: 0;
  overflow: hidden;
  padding-left: 6px;
  border-left: 1px solid rgba(221, 236, 225, 0.18);
  color: rgba(219, 238, 226, 0.72);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tool-chip-input { color: rgba(207, 224, 238, 0.68); }
.tool-chip-output { color: rgba(196, 238, 210, 0.78); }
.tool-chip-output.is-error { color: rgba(255, 164, 164, 0.86); }
.tool-toggle {
  flex: none;
  width: auto;
  min-height: 0;
  padding: 1px 6px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(221, 236, 225, 0.18);
  color: rgba(221, 236, 225, 0.7);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: lowercase;
  opacity: 0.78;
  transition: opacity 0.15s, color 0.15s, border-color 0.15s;
  cursor: pointer;
}
.tool-line:hover .tool-toggle { opacity: 1; }
.tool-toggle:hover { color: var(--ink); border-color: var(--line-strong); background: var(--surface-2); }
.tool-input {
  margin: 0 0 0 20px;
  padding: 2px 6px;
  border-left: 1px solid var(--line);
  background: #0d1117;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--ink-soft);
  overflow-x: auto;
  max-height: 260px;
}
.tool-output {
  margin: 0 0 0 20px;
  padding: 2px 6px;
  border-left: 1px solid var(--line);
  border-left: 2px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.38;
  color: var(--ink-soft);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow: auto;
}
.tool-output.is-error { color: var(--danger); border-left-color: var(--danger); }

.activity-summary {
  align-self: stretch;
  max-width: min(96%, 1120px);
  font-size: 0.8rem;
}

.activity-summary-line {
  cursor: pointer;
  color: rgba(131, 189, 255, 0.82);
}

.activity-running .activity-summary-line,
.activity-process-running .activity-summary-line {
  color: rgba(255, 206, 138, 0.78);
}

.activity-process .activity-summary-line {
  color: rgba(255, 206, 138, 0.72);
}

.activity-guided .activity-summary-line {
  color: rgba(255, 206, 138, 0.78);
}

.activity-error .activity-summary-line {
  color: rgba(255, 116, 109, 0.78);
}

.activity-summary-line.is-clickable:hover {
  border-color: rgba(139, 199, 255, 0.16);
  background: rgba(139, 199, 255, 0.035);
}

.activity-detail-list {
  display: grid;
  gap: 5px;
  margin: 2px 0 0 22px;
  padding-left: 10px;
  border-left: 1px solid rgba(139, 199, 255, 0.18);
}

.activity-detail {
  display: grid;
  gap: 3px;
  min-width: 0;
  color: rgba(207, 224, 238, 0.72);
}

.activity-detail-head {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}

.activity-detail-head.is-clickable {
  cursor: pointer;
}

.activity-detail-head.is-clickable:hover .activity-detail-title {
  color: rgba(232, 244, 238, 0.86);
}

.activity-detail-kind {
  flex: none;
  color: rgba(143, 229, 140, 0.68);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  text-transform: uppercase;
}

.activity-detail-title {
  min-width: 0;
  overflow: hidden;
  color: rgba(214, 233, 220, 0.7);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-detail-toggle {
  flex: none;
  margin-left: auto;
  color: rgba(148, 163, 184, 0.68);
  font-family: var(--font-mono);
  font-size: 0.62rem;
}

.activity-detail-thinking .activity-detail-kind,
.activity-detail-message .activity-detail-kind {
  color: rgba(131, 189, 255, 0.72);
}

.activity-detail-body {
  max-height: 220px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: rgba(207, 224, 238, 0.68);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  line-height: 1.35;
}
/* PLACEHOLDER-GROUP */

/* Agent identity badge */
.agent-badge { display: inline-flex; align-items: center; gap: 6px; text-transform: none; }
.agent-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  color: #0b0d12;
  font-size: 0.6rem;
  font-weight: 800;
}
.agent-name { color: var(--ink-soft); font-weight: 600; letter-spacing: 0.04em; }

/* System event — collapsed by default */
.msg-system { align-self: flex-start; max-width: min(92%, 980px); opacity: 0.85; }
.system-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: auto;
  min-height: 0;
  padding: 2px 0;
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  cursor: pointer;
}
.system-toggle:hover { color: var(--ink-soft); }
.system-icon { width: 12px; height: 12px; flex-shrink: 0; opacity: 0.7; }
.system-summary { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.system-body {
  margin: 4px 0 0;
  padding: 8px 10px;
  border-left: 2px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--ink-soft);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}



/* === Toast notifications === */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 220px;
  max-width: 360px;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  background: rgba(18, 23, 32, 0.96);
  backdrop-filter: blur(8px);
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  pointer-events: all;
  cursor: pointer;
  animation: toastIn 0.18s ease-out;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}

.toast-dot {
  flex: none;
  width: 7px;
  height: 7px;
  background: var(--muted);
}

.toast-msg {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.toast.is-expanded {
  align-items: flex-start;
  max-width: 420px;
}

.toast.is-expanded .toast-msg {
  white-space: pre-wrap;
  word-break: break-word;
  overflow: visible;
  text-overflow: unset;
}

.toast.is-expanded .toast-dot {
  margin-top: 3px;
}

.toast-close {
  flex: none;
  width: auto;
  min-height: 0;
  padding: 0 2px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 400;
  cursor: pointer;
  opacity: 0.6;
}
.toast-close:hover { opacity: 1; background: none; border: none; }

.toast-good .toast-dot {
  background: var(--success);
  box-shadow: 0 0 8px rgba(143, 229, 140, 0.6);
}
.toast-good { color: #d9ffd7; border-color: rgba(143, 229, 140, 0.25); }

.toast-error .toast-dot { background: var(--danger); }
.toast-error { color: #ffd4d0; border-color: rgba(255, 116, 109, 0.3); }

/* ─── Create Dialog v2 ─────────────────────────────────────────────────────── */

/* Dialog kind tabs (replaces create-kind-switch) */
.dialog-kind-tabs {
  display: flex;
  gap: 0;
  border: 1px solid var(--line);
  overflow: hidden;
}

.dialog-kind-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  padding: 7px 12px;
  color: var(--muted);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.dialog-kind-tab + .dialog-kind-tab {
  border-left: 1px solid var(--line);
}

.dialog-kind-tab.is-active {
  background: rgba(255, 159, 90, 0.13);
  color: var(--ink);
}

.dialog-kind-tab input[type="radio"] {
  display: none;
}

.dialog-kind-icon {
  flex: none;
  font-size: 1rem;
  opacity: 0.7;
}

.dialog-kind-tab.is-active .dialog-kind-icon {
  opacity: 1;
  color: var(--accent);
}

.dialog-kind-label {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.dialog-kind-label strong {
  font-size: 0.84rem;
  font-weight: 900;
  letter-spacing: 0.01em;
}

.dialog-kind-label small {
  font-size: 0.65rem;
  color: var(--muted);
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.dialog-kind-tab.is-active .dialog-kind-label small {
  color: var(--ink-soft);
}

.dialog-head-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.dialog-head-hint {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
  margin: 0;
}

/* Create field grid */
.create-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.create-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.create-field.wide {
  grid-column: 1 / -1;
}

.create-field-row {
  display: flex;
  gap: 0;
}

.create-field-row input,
.create-field-row select {
  flex: 1 1 auto;
  min-width: 0;
}

.create-browse-btn {
  flex: none;
  width: 36px;
  min-width: 0;
  min-height: 36px;
  padding: 0;
  font-size: 1rem;
  border-left: none;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.04);
}

.create-browse-btn:hover:not(:disabled) {
  background: rgba(139, 199, 255, 0.12);
  border-color: rgba(139, 199, 255, 0.4);
  color: var(--accent-blue);
}

/* Label with action button — scoped to create dialog fields */
.create-field .label {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.label-action {
  width: auto;
  min-height: 0;
  padding: 1px 6px;
  font-size: 0.6rem;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-color: transparent;
  background: transparent;
}

.label-action:hover:not(:disabled) {
  color: var(--accent);
  border-color: rgba(255, 159, 90, 0.3);
  background: rgba(255, 159, 90, 0.08);
}

.label-hint {
  font-weight: 400;
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  color: var(--muted);
}

/* Create dialog actions */
.create-dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}

/* Room agents multi-select chips */
.room-agents-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  background: #161c25;
  min-height: 42px;
}

.room-agent-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: background 100ms ease, border-color 100ms ease, color 100ms ease;
}

.room-agent-chip:hover {
  border-color: var(--line-strong);
  color: var(--ink-soft);
}

.room-agent-chip.is-selected {
  border-color: rgba(255, 159, 90, 0.55);
  background: rgba(255, 159, 90, 0.12);
  color: var(--accent);
}

.room-agent-chip input[type="checkbox"] {
  display: none;
}

.room-agents-summary {
  margin-top: 5px;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--muted);
  letter-spacing: 0.04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Workspace picker overlay (inside dialog) */
.workspace-picker-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgba(7, 9, 13, 0.88);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.workspace-picker-panel {
  width: min(480px, 90%);
  border: 1px solid var(--line-strong);
  background: #0f1420;
  box-shadow: 0 16px 52px rgba(0, 0, 0, 0.65);
  overflow: hidden;
}

.workspace-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #131825;
}

.workspace-picker-head .eyebrow {
  margin: 0;
}

.workspace-picker-list {
  max-height: 280px;
  overflow-y: auto;
}

.workspace-picker-empty {
  padding: 18px 14px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.workspace-picker-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  min-height: 54px;
  padding: 8px 14px;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  font-weight: 400;
  line-height: 1.25;
}

.workspace-picker-item:hover:not(:disabled) {
  background: rgba(139, 199, 255, 0.07);
  border-color: var(--line);
}

.workspace-picker-label,
.workspace-picker-cwd,
.workspace-picker-hint {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-picker-label {
  font-size: 0.82rem;
  color: var(--ink);
  font-weight: 700;
}

.workspace-picker-cwd,
.workspace-picker-hint {
  font-size: 0.68rem;
  color: var(--muted);
  font-family: var(--font-mono);
}

/* Make create-dialog use relative positioning for overlay */
.create-dialog {
  position: relative;
  overflow: hidden;
}

/* ─── Create Dialog cd-* classes ──────────────────────────────────────────── */

.create-dialog-inner {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
}

/* Header */
.cd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 0;
  border-bottom: 1px solid var(--line);
  background: #0c1018;
  flex-shrink: 0;
}

.cd-tabs {
  display: flex;
  flex: 1;
}

.cd-tab {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  padding: 11px 16px;
  cursor: pointer;
  color: var(--muted);
  border-right: 1px solid var(--line);
  transition: background 120ms ease, color 120ms ease;
  user-select: none;
}

.cd-tab:hover {
  background: rgba(255, 255, 255, 0.03);
}

.cd-tab.is-active {
  background: rgba(255, 159, 90, 0.08);
  color: var(--ink);
}

.cd-tab input[type="radio"] {
  display: none;
}

.cd-tab-icon {
  font-size: 1rem;
  opacity: 0.6;
  line-height: 1;
}

.cd-tab.is-active .cd-tab-icon {
  opacity: 1;
  color: var(--accent);
}

.cd-tab-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.cd-tab-body strong {
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.cd-tab-body small {
  font-size: 0.63rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: var(--font-mono);
}

.cd-tab.is-active .cd-tab-body small {
  color: var(--ink-soft);
}

.cd-close {
  flex: none;
  width: 30px;
  min-height: 30px;
  padding: 0;
  font-size: 0.8rem;
  color: var(--muted);
  border-color: transparent;
  background: transparent;
}

.cd-close:hover:not(:disabled) {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border-color: transparent;
}

/* Body / form */
.cd-body {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
  min-height: 320px;
  overflow-y: auto;
}

.cd-fields {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 14px 16px;
  flex: 1;
}

.cd-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.cd-field:last-child {
  border-bottom: none;
}

.cd-field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.69rem;
  font-family: var(--font-mono);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.cd-label-btn {
  width: auto;
  min-height: 0;
  padding: 1px 7px;
  font-size: 0.6rem;
  font-family: var(--font-mono);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  border-color: transparent;
  background: transparent;
  font-weight: 400;
}

.cd-label-btn:hover:not(:disabled) {
  color: var(--accent);
  border-color: rgba(255, 159, 90, 0.3);
  background: rgba(255, 159, 90, 0.07);
}

.cd-input {
  width: 100%;
  min-height: 32px;
  padding: 5px 9px;
  font-size: 0.82rem;
  box-sizing: border-box;
}

.cd-input-row {
  --cd-input-height: 34px;
  display: flex;
  gap: 0;
  align-items: stretch;
}

.cd-input-row .cd-input {
  flex: 1;
  min-width: 0;
  height: var(--cd-input-height);
  min-height: var(--cd-input-height);
  max-height: var(--cd-input-height);
}

.cd-row-btn {
  flex: none;
  width: var(--cd-input-height);
  min-width: var(--cd-input-height);
  height: var(--cd-input-height);
  min-height: var(--cd-input-height);
  max-height: var(--cd-input-height);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-left: none;
  color: var(--muted);
  box-sizing: border-box;
  line-height: 1;
}

.cd-row-btn svg {
  display: block;
  flex: none;
  width: 15px;
  height: 15px;
}

.cd-row-btn:hover:not(:disabled) {
  color: var(--accent-blue);
  background: rgba(139, 199, 255, 0.1);
  border-color: rgba(139, 199, 255, 0.35);
}

/* Agent select */
.cd-select {
  min-height: 32px;
  padding: 5px 9px;
  font-size: 0.82rem;
}

/* Room agent chips */
.cd-agents-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 7px;
  border: 1px solid var(--line);
  background: #161c25;
  min-height: 38px;
}

.cd-agent-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 0.72rem;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: background 100ms, border-color 100ms, color 100ms;
  width: auto;
  min-height: 0;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.cd-agent-chip:hover:not(:disabled) {
  border-color: var(--line-strong);
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.06);
}

.cd-agent-chip.is-selected {
  border-color: rgba(255, 159, 90, 0.5);
  background: rgba(255, 159, 90, 0.11);
  color: var(--accent);
}

.cd-agent-chip input[type="checkbox"] { display: none; }

.cd-agents-summary {
  margin-top: 4px;
  font-size: 0.67rem;
  font-family: var(--font-mono);
  color: var(--muted);
  letter-spacing: 0.04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Actions row */
.cd-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--line);
  background: #0c1018;
  flex-shrink: 0;
}

.cd-actions button {
  width: auto;
  min-height: 30px;
  padding: 5px 18px;
  font-size: 0.76rem;
  letter-spacing: 0.04em;
}
