/* TETRANUX web UI — Claude-style enterprise interface.
   Theming is driven by CSS custom properties switched via [data-theme]. */

:root {
  --bg: #faf9f5;
  --bg-sidebar: #f0eee6;
  --bg-elevated: #ffffff;
  --bg-hover: #ecebe2;
  --bg-active: #e4e2d6;
  --text: #1a1a18;
  --text-muted: #73726a;
  --text-faint: #9a988e;
  --border: #e6e3d8;
  --border-strong: #d8d4c5;
  --accent: #d97757;
  --accent-hover: #c25e3e;
  --accent-soft: #f6e6df;
  --user-bubble: #f0eee6;
  --code-bg: #f4f2ea;
  --code-border: #e6e3d8;
  --danger: #c0392b;
  --ok: #3a9d5d;
  --shadow: 0 1px 3px rgba(40, 38, 30, 0.08), 0 8px 24px rgba(40, 38, 30, 0.06);
  /* Solid bottom edges that give buttons their 3D depth. */
  --btn-edge: #c7c2b0;
  --btn-edge-accent: #a8472b;
  --btn-ambient: rgba(40, 38, 30, 0.16);
  --radius: 12px;
  --radius-sm: 8px;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

[data-theme="dark"] {
  --bg: #262624;
  --bg-sidebar: #1f1e1d;
  --bg-elevated: #30302e;
  --bg-hover: #333230;
  --bg-active: #3c3b38;
  --text: #f3f1ea;
  --text-muted: #a3a199;
  --text-faint: #76746c;
  --border: #3a3a37;
  --border-strong: #46453f;
  --accent: #e08a6c;
  --accent-hover: #ec9c81;
  --accent-soft: #3a2f29;
  --user-bubble: #34332f;
  --code-bg: #1b1b1a;
  --code-border: #3a3a37;
  --danger: #e06b5e;
  --ok: #5fbf81;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 28px rgba(0, 0, 0, 0.32);
  --btn-edge: #121110;
  --btn-edge-accent: #8f3f22;
  --btn-ambient: rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button {
  cursor: pointer;
  background: none;
  border: none;
}

/* The `hidden` attribute must win over class selectors that set `display`
   (e.g. .send-btn, .stop-btn, .attachments). */
[hidden] {
  display: none !important;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
  background-clip: padding-box;
  border: 2px solid transparent;
}

/* ---------- Layout ---------- */

.app {
  display: grid;
  grid-template-columns: 268px 1fr;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

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

/* ---------- Sidebar ---------- */

.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand__mark {
  display: flex;
}

.brand__name {
  font-size: 15.5px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.new-chat {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 6px 12px 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  font-weight: 500;
  font-size: 14px;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

.new-chat:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.new-chat:active {
  transform: scale(0.99);
}

.new-chat .kbd,
.kbd {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-faint);
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
}

.sessions {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sessions__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 10px 8px 4px;
}

.session {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.12s, color 0.12s;
  min-width: 0;
}

.session:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.session.active {
  background: var(--bg-active);
  color: var(--text);
  font-weight: 500;
}

.session__title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13.5px;
}

.session__del {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  color: var(--text-faint);
  opacity: 0;
  transition: opacity 0.12s, background 0.12s, color 0.12s;
}

.session:hover .session__del {
  opacity: 1;
}

.session__del:hover {
  background: var(--bg-active);
  color: var(--danger);
}

.sessions__empty {
  padding: 16px 10px;
  font-size: 13px;
  color: var(--text-faint);
  text-align: center;
}

.sidebar__foot {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-muted);
  min-width: 0;
}

.status__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}

.status__dot.is-ok {
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent);
}

.status__dot.is-warn {
  background: var(--accent);
}

.status__dot.is-down {
  background: var(--danger);
}

.status__text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 12.5px;
  transition: background 0.15s, color 0.15s;
}

.ghost-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* ---------- Main ---------- */

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
}

.topbar__menu {
  display: none;
}

/* The collapse toggle lives inside the sidebar, so once the sidebar is
   collapsed to zero width it is unreachable. Surface the topbar menu
   button while collapsed so the sidebar can always be brought back. */
.app.sidebar-collapsed .topbar__menu {
  display: inline-flex;
}

.topbar__spacer {
  flex: 1;
}

.usage {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 11px;
  /* The meter must stay on one line and never be squeezed by the model
     picker — the picker truncates instead. */
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.35;
}

.usage strong {
  color: var(--text);
  font-weight: 650;
}

/* ---------- Thread ---------- */

.thread {
  flex: 1 1 auto;
  /* Without this, a tall message list refuses to shrink and shoves the
     composer below the viewport. min-height:0 lets the thread scroll
     internally and keeps the composer pinned. */
  min-height: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.welcome {
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(40px, 12vh, 120px) 24px 32px;
  text-align: center;
}

.welcome__mark {
  display: inline-flex;
  margin-bottom: 18px;
}

.welcome__title {
  font-family: var(--serif);
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 500;
  letter-spacing: -0.01em;
}

.welcome__sub {
  color: var(--text-muted);
  margin-top: 8px;
  font-size: 15px;
}

.suggestions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 28px;
  text-align: left;
}

.suggestion {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 13px 15px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}

.suggestion:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.suggestion:active {
  transform: scale(0.99);
}

.suggestion strong {
  font-size: 14px;
  font-weight: 600;
}

.suggestion span {
  font-size: 12.5px;
  color: var(--text-muted);
}

.messages {
  max-width: 768px;
  margin: 0 auto;
  padding: 24px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.msg {
  display: flex;
  gap: 14px;
  animation: rise 0.22s ease;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg__avatar {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.msg--assistant .msg__avatar {
  background: var(--accent);
  color: #fff;
}

.msg--user .msg__avatar {
  background: var(--bg-active);
  color: var(--text-muted);
}

.msg__body {
  flex: 1;
  min-width: 0;
}

.msg__role {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.msg--user .msg__content {
  background: var(--user-bubble);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 15px;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.msg__content {
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.msg__actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.15s;
}

.msg:hover .msg__actions {
  opacity: 1;
}

.msg__action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-muted);
  transition: background 0.12s, color 0.12s;
}

.msg__action:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* ---------- Thinking block ---------- */

.thinking {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  margin-bottom: 12px;
  overflow: hidden;
}

.thinking__toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
}

.thinking__toggle:hover {
  background: var(--bg-hover);
}

.thinking__caret {
  transition: transform 0.15s;
}

.thinking.open .thinking__caret {
  transform: rotate(90deg);
}

.thinking__body {
  display: none;
  padding: 4px 12px 12px;
  font-size: 13px;
  color: var(--text-muted);
  white-space: pre-wrap;
  border-top: 1px solid var(--border);
}

.thinking.open .thinking__body {
  display: block;
}

/* ---------- Agentic tool steps ---------- */

.tool-steps {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.tool-step {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 12.5px;
}

.tool-step__icon {
  flex-shrink: 0;
}

.tool-step strong {
  font-weight: 600;
}

.tool-step__action {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-muted);
}

.tool-step__state {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}

.tool-step--running {
  border-color: var(--accent);
}

.tool-step--done .tool-step__icon {
  color: var(--ok);
}

.tool-step--done .tool-step__state {
  color: var(--ok);
}

.tool-step--error {
  border-color: var(--danger);
}

.tool-step--error .tool-step__icon,
.tool-step--error .tool-step__state {
  color: var(--danger);
}

/* ---------- "Working…" heartbeat ---------- */

.msg__working {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.msg__working-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  animation: working-pulse 1s ease-in-out infinite;
}

@keyframes working-pulse {
  0%,
  100% {
    opacity: 0.3;
    transform: scale(0.7);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ---------- Markdown ---------- */

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

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

.md p {
  margin: 0 0 12px;
}

.md h1,
.md h2,
.md h3,
.md h4 {
  margin: 20px 0 10px;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.md h1 {
  font-size: 1.45em;
}

.md h2 {
  font-size: 1.28em;
}

.md h3 {
  font-size: 1.13em;
}

.md h4 {
  font-size: 1em;
}

.md ul,
.md ol {
  margin: 0 0 12px;
  padding-left: 25px;
}

.md li {
  margin: 3px 0;
}

.md li > ul,
.md li > ol {
  margin: 3px 0;
}

.md blockquote {
  border-left: 3px solid var(--accent);
  margin: 0 0 12px;
  padding: 2px 14px;
  color: var(--text-muted);
}

.md a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.md a:hover {
  color: var(--accent-hover);
}

.md hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}

.md code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 5px;
  padding: 1px 5px;
}

.md table {
  border-collapse: collapse;
  margin: 0 0 12px;
  font-size: 0.93em;
  display: block;
  overflow-x: auto;
}

.md th,
.md td {
  border: 1px solid var(--border-strong);
  padding: 6px 11px;
  text-align: left;
}

.md th {
  background: var(--bg-hover);
  font-weight: 600;
}

.md strong {
  font-weight: 650;
}

.codeblock {
  margin: 0 0 14px;
  border: 1px solid var(--code-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--code-bg);
}

.codeblock__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px 5px 12px;
  border-bottom: 1px solid var(--code-border);
  font-size: 11.5px;
  color: var(--text-muted);
}

.codeblock__lang {
  font-family: var(--mono);
  text-transform: lowercase;
}

.codeblock__copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11.5px;
  color: var(--text-muted);
  transition: background 0.12s, color 0.12s;
}

.codeblock__copy:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.codeblock pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
}

.codeblock pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 12.8px;
  line-height: 1.65;
}

/* ---------- Cursor / typing ---------- */

.cursor {
  display: inline-block;
  width: 7px;
  height: 1.05em;
  background: var(--accent);
  border-radius: 1px;
  vertical-align: text-bottom;
  margin-left: 1px;
  animation: blink 1s steps(2) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.typing {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}

.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: bounce 1.2s infinite;
}

.typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* ---------- Composer ---------- */

.composer-wrap {
  flex: 0 0 auto;
  padding: 8px 24px 14px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  max-width: 768px;
  width: 100%;
  margin: 0 auto;
}

.composer {
  position: relative;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.composer:focus-within {
  border-color: var(--accent);
}

.composer__input {
  width: 100%;
  resize: none;
  border: none;
  background: none;
  outline: none;
  padding: 14px 16px 4px;
  font-size: 15px;
  line-height: 1.55;
  max-height: 280px;
  overflow-y: auto;
}

.composer__input::placeholder {
  color: var(--text-faint);
}

.composer__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 8px 16px;
}

.composer__hint {
  font-size: 11.5px;
  color: var(--text-faint);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer__count {
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: var(--mono);
  margin-left: auto;
}

.send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  transition: background 0.15s, transform 0.05s, opacity 0.15s;
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.send-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.stop-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 9px;
  background: var(--bg-active);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s;
}

.stop-btn:hover {
  background: var(--border-strong);
}

/* ---------- Agent button & panel ---------- */

.agent-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.8px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-muted);
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.05s;
}

.agent-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--accent);
}

.agent-btn:active {
  transform: scale(0.92);
}

.agent-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.agent-panel {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 8px;
  width: 280px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px 16px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.agent-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text);
}

.agent-panel__close {
  font-size: 18px;
  line-height: 1;
  color: var(--text-faint);
  padding: 0 2px;
}

.agent-panel__close:hover { color: var(--text); }

.agent-panel__label {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.agent-panel__input {
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: var(--mono);
  box-sizing: border-box;
}

.agent-panel__input:focus {
  outline: none;
  border-color: var(--accent);
}
.agent-panel__textarea {
  resize: vertical;
  min-height: 66px;
  font-family: inherit;
  line-height: 1.45;
}

.agent-panel__run {
  margin-top: 4px;
  padding: 8px 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  width: 100%;
  transition: background 0.15s;
}

.agent-panel__run:hover { background: var(--accent-hover); }

.agent-panel__run:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.disclaimer {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 8px;
}

/* ---------- Toasts ---------- */

.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  font-size: 13px;
  max-width: 340px;
  animation: rise 0.2s ease;
}

.toast--error {
  border-left: 3px solid var(--danger);
}

.toast--info {
  border-left: 3px solid var(--accent);
}

.toast--ok {
  border-left: 3px solid var(--ok);
}

/* ---------- Scrim (mobile) ---------- */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(20, 19, 16, 0.45);
  z-index: 40;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ---------- Composer tools, attachments, media ---------- */

.composer-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}

.composer-tool:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.composer-tool.active {
  background: var(--accent);
  color: #fff;
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px 0;
}

.attachment {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  flex-shrink: 0;
}

.attachment img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.attachment__label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 4px;
  font-size: 10px;
  line-height: 1.2;
  word-break: break-all;
  text-align: center;
  color: var(--text-muted);
  overflow: hidden;
}

.attachment__remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(20, 19, 16, 0.78);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.attachment__remove:hover {
  background: var(--danger);
}

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

.msg__media--attached img {
  max-width: 220px;
  max-height: 220px;
}

.msg__figure {
  margin: 4px 0 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elevated);
}

.msg__media img,
.msg__figure img {
  display: block;
  max-width: 100%;
  border-radius: 8px;
}

.msg__figure img {
  border-radius: 0;
  max-width: 512px;
  width: 100%;
}

.msg__figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 12px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.msg__figcaption a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.msg__figcaption a:hover {
  text-decoration: underline;
}

.composer.image-mode {
  border-color: var(--accent);
}

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  margin-bottom: 4px;
}

/* ---------- Composer modes ---------- */

.composer__modes {
  display: flex;
  gap: 4px;
  padding: 9px 9px 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.composer__modes::-webkit-scrollbar {
  display: none;
}

.mode-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.mode-chip:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.mode-chip--active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.mode-chip--active:hover {
  background: var(--accent-hover);
  color: #fff;
}

.mode-chip svg {
  flex-shrink: 0;
}

/* ---------- Code-mode shortcuts ---------- */

.composer__shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 9px 2px;
}

.shortcut {
  display: inline-flex;
  align-items: stretch;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  box-shadow: 0 2px 0 var(--btn-edge), 0 3px 7px var(--btn-ambient);
  transition: transform 0.07s ease, box-shadow 0.12s ease, border-color 0.15s;
}

.shortcut:hover {
  border-color: var(--accent);
}

.shortcut:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 var(--btn-edge);
}

.shortcut__main {
  padding: 5px 5px 5px 11px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}

.shortcut__edit {
  padding: 5px 8px;
  font-size: 11px;
  color: var(--text-faint);
}

.shortcut__edit:hover {
  color: var(--accent);
}

.shortcut--empty {
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-strong);
  background: var(--bg);
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 2px 0 var(--btn-edge), 0 3px 7px var(--btn-ambient);
  transition: transform 0.07s ease, box-shadow 0.12s ease, color 0.15s, border-color 0.15s;
}

.shortcut--empty:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.shortcut--empty:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 var(--btn-edge);
}

.key-dialog__textarea {
  resize: vertical;
  min-height: 66px;
  font-family: inherit;
  line-height: 1.5;
}

/* Code-related integrations light up while Code mode is active. */
.connector-card--highlight {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* On touch devices there is no hover, so per-message actions (Copy,
   Regenerate) must be visible at rest. */
@media (hover: none) {
  .msg__actions {
    opacity: 1;
  }
}

/* ---------- Primary text button ---------- */

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- 3D buttons ---------- */
/* Every button carries a solid bottom edge and a soft ambient shadow, then
   physically presses down on :active. */

.new-chat,
.ghost-btn,
.icon-btn,
.composer-tool,
.stop-btn,
.suggestion,
.sidebar-tab,
.mode-chip,
.connector-action-btn,
.connector-configure-btn,
.codeblock__copy,
.thinking__toggle,
.msg__action,
.send-btn,
.btn-primary {
  box-shadow: 0 2px 0 var(--btn-edge), 0 3px 7px var(--btn-ambient);
  transition: transform 0.07s ease, box-shadow 0.12s ease, background 0.15s,
    color 0.15s, border-color 0.15s;
}

.new-chat:active,
.ghost-btn:active,
.icon-btn:active,
.composer-tool:active,
.stop-btn:active,
.suggestion:active,
.sidebar-tab:active,
.mode-chip:active,
.connector-action-btn:active:not(:disabled),
.connector-configure-btn:active,
.codeblock__copy:active,
.thinking__toggle:active,
.msg__action:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 var(--btn-edge);
}

/* Accent buttons get a deeper, coloured edge. */
.send-btn,
.btn-primary,
.mode-chip--active {
  box-shadow: 0 3px 0 var(--btn-edge-accent), 0 5px 12px rgba(217, 119, 87, 0.32);
}

.send-btn:active:not(:disabled),
.btn-primary:active:not(:disabled),
.mode-chip--active:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--btn-edge-accent);
}

/* Disabled buttons sit flat — no depth, no press. */
.send-btn:disabled,
.btn-primary:disabled,
.connector-action-btn:disabled {
  box-shadow: none;
  transform: none;
}

/* ---------- Integration on/off toggle ---------- */

.connector-toggle {
  position: relative;
  flex-shrink: 0;
  width: 38px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background 0.16s ease;
}

.connector-toggle[aria-checked="true"] {
  background: var(--ok);
}

.connector-toggle__knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: transform 0.16s ease;
}

.connector-toggle[aria-checked="true"] .connector-toggle__knob {
  transform: translateX(16px);
}

.connector-card--off {
  opacity: 0.62;
}

.connector-card--off .connector-icon,
.connector-card--off .connector-name {
  filter: grayscale(1);
}

.connector-status--off {
  background: color-mix(in srgb, var(--text-muted) 14%, transparent);
  color: var(--text-muted);
}

/* ---------- Library: Files / Pictures / My Code ---------- */

#panel-files,
#panel-pictures,
#panel-code {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 8px 12px;
}

.lib-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 2px 8px;
}

.lib-toolbar__hint {
  flex: 1;
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.35;
}

.lib-upload-btn {
  flex: 1;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
}

.lib-upload-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.lib-clear-btn {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 12px;
}

.lib-clear-btn:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.lib-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.lib-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

.lib-item__icon {
  font-size: 15px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.lib-item__body {
  flex: 1;
  min-width: 0;
}

.lib-item__name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lib-item__meta {
  font-size: 10.5px;
  color: var(--text-faint);
}

.lib-item__act {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--text-faint);
}

.lib-item__act:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.lib-item__act--del:hover {
  color: var(--danger);
}

.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 6px;
}

.lib-pic {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

.lib-pic img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.lib-pic__del {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(20, 19, 16, 0.78);
  color: #fff;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.12s;
}

.lib-pic:hover .lib-pic__del {
  opacity: 1;
}

.lib-empty {
  padding: 30px 14px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-faint);
  line-height: 1.5;
}

@media (hover: none) {
  .lib-pic__del {
    opacity: 1;
  }
}

/* ---------- Chat favourites & projects ---------- */

.sessions__group {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 12px 8px 4px;
}

.session__star {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  color: var(--text-faint);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.12s, color 0.12s, background 0.12s;
}

.session:hover .session__star {
  opacity: 1;
}

.session__star--on {
  opacity: 1;
  color: var(--accent);
}

.session__star:hover {
  background: var(--bg-active);
  color: var(--accent);
}

@media (hover: none) {
  .session__star {
    opacity: 1;
  }
}

.codeblock__save {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11.5px;
  color: var(--text-muted);
  transition: background 0.12s, color 0.12s;
}

.codeblock__save:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.codeblock__tools {
  display: inline-flex;
  gap: 2px;
}

/* ---------- Responsive ---------- */

/* Wide desktop — let the conversation breathe a little more. */
@media (min-width: 1500px) {
  .messages,
  .composer-wrap,
  .welcome {
    max-width: 860px;
  }
}

/* Tablet — keep the sidebar docked but trim it and the gutters. */
@media (min-width: 861px) and (max-width: 1100px) {
  .app {
    grid-template-columns: 240px 1fr;
  }

  .messages,
  .composer-wrap,
  .welcome {
    padding-left: 20px;
    padding-right: 20px;
  }
}

/* Tablet portrait & phones — sidebar collapses into an overlay drawer. */
@media (max-width: 860px) {
  .app,
  .app.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(86vw, 320px);
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 0 0 48px rgba(20, 19, 16, 0.32);
  }

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

  /* The in-sidebar collapse button is meaningless in drawer mode. */
  #collapse-btn {
    display: none;
  }

  .topbar__menu {
    display: inline-flex;
  }

  .suggestions {
    grid-template-columns: 1fr;
  }

  .composer-wrap,
  .messages,
  .welcome {
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* Phones — compact spacing, drop non-essential chrome, avoid iOS zoom. */
@media (max-width: 560px) {
  body {
    font-size: 14.5px;
  }

  .topbar {
    padding: 8px 12px;
    gap: 8px;
  }

  .messages {
    padding: 16px 14px 28px;
    gap: 20px;
  }

  .welcome {
    padding-top: clamp(28px, 9vh, 72px);
  }

  .welcome__title {
    font-size: clamp(22px, 7vw, 28px);
  }

  .composer-wrap {
    padding: 6px 12px 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  /* 16px keeps mobile Safari from zooming the viewport on focus. */
  .composer__input {
    font-size: 16px;
    padding: 12px 14px 4px;
  }

  .composer__bar {
    gap: 6px;
    padding: 6px 6px 8px 12px;
  }

  /* Compact the mode chips so all five fit a phone width — the text
     labels alone stay perfectly legible without the icons. */
  .composer__modes {
    gap: 4px;
    padding: 8px 7px 2px;
  }

  .mode-chip {
    flex: 1 1 0;
    justify-content: center;
    padding: 6px 4px;
    font-size: 12px;
  }

  .mode-chip svg {
    display: none;
  }

  .disclaimer {
    margin-top: 6px;
    font-size: 10.5px;
  }

  .msg {
    gap: 10px;
  }

  .msg__figure img {
    max-width: 100%;
  }

  .toast-stack {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .toast {
    max-width: none;
  }

  .key-dialog,
  .action-dialog {
    width: calc(100vw - 24px);
    padding: 22px 18px 18px;
  }

  .action-result-pre {
    max-height: 40vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Sidebar tab switcher ──────────────────────────────────── */
.sidebar__tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 8px 10px 0;
}

.sidebar-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 8px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.sidebar-tab:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.sidebar-tab--active {
  background: var(--bg-active);
  color: var(--text);
}

/* ── Integrations panel ────────────────────────────────────── */
#panel-integrations {
  flex: 1;
  overflow-y: auto;
  padding: 8px 6px;
}

.integrations-loading {
  padding: 24px 12px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.connector-card {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  margin-bottom: 8px;
  overflow: hidden;
}

.connector-card__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
}

.connector-card__head:hover {
  background: var(--bg-hover);
}

.connector-icon {
  font-size: 16px;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}

.connector-info {
  flex: 1;
  min-width: 0;
}

.connector-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.connector-desc {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.connector-status {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.connector-status--ready {
  background: color-mix(in srgb, var(--ok) 15%, transparent);
  color: var(--ok);
}

.connector-status--unset {
  background: color-mix(in srgb, var(--text-muted) 10%, transparent);
  color: var(--text-muted);
}

.connector-chevron {
  flex-shrink: 0;
  color: var(--text-faint);
  transition: transform 0.15s;
}

.connector-card--open .connector-chevron {
  transform: rotate(180deg);
}

.connector-card__body {
  display: none;
  padding: 0 12px 12px;
  border-top: 1px solid var(--border);
}

.connector-card--open .connector-card__body {
  display: block;
}

.connector-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
}

.connector-action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s, border-color 0.1s;
}

.connector-action-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.connector-action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.connector-action-name {
  font-weight: 600;
  flex-shrink: 0;
}

.connector-action-desc {
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.connector-configure-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 7px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: background 0.1s;
}

.connector-configure-btn:hover {
  background: var(--accent-soft);
}

/* ── Doc / Activate links on a connector card ──────────────────────── */
.connector-links {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.connector-link-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  box-shadow: 0 2px 0 var(--btn-edge), 0 3px 7px var(--btn-ambient);
  transition: transform 0.07s ease, box-shadow 0.12s ease, background 0.15s,
    border-color 0.15s;
}

.connector-link-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.connector-link-btn:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 var(--btn-edge);
}

.connector-link-btn--activate {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 3px 0 var(--btn-edge-accent), 0 5px 12px rgba(217, 119, 87, 0.32);
}

.connector-link-btn--activate:hover {
  background: var(--accent-hover);
  color: #fff;
}

.connector-link-btn--activate:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--btn-edge-accent);
}

.connector-note {
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--text-faint);
}

/* ── Key dialog ────────────────────────────────────────────── */
.key-dialog,
.action-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 28px 28px 24px;
  max-width: 460px;
  width: calc(100vw - 40px);
  box-shadow: var(--shadow);
  outline: none;
}

.key-dialog::backdrop,
.action-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
}

.key-dialog__title,
.action-dialog__title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 6px;
}

.key-dialog__desc,
.action-dialog__desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.key-dialog__label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.key-dialog__input {
  display: block;
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  margin-bottom: 20px;
  transition: border-color 0.12s;
}

.key-dialog__input:focus {
  outline: none;
  border-color: var(--accent);
}

.key-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Action dialog params ──────────────────────────────────── */
.action-dialog {
  max-width: 560px;
}

.action-dialog__params {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.action-param {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.action-param__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.action-param__label span.required {
  color: var(--accent);
  margin-left: 3px;
}

.action-param__input {
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}

.action-param__input:focus {
  outline: none;
  border-color: var(--accent);
}

.action-param__hint {
  font-size: 11px;
  color: var(--text-faint);
}

/* ── Action result ─────────────────────────────────────────── */
.action-dialog__result {
  padding-top: 16px;
  border-top: 1px solid var(--border);
  margin-top: 16px;
}

.action-dialog__result h3 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.action-result-pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 12px;
  font-family: var(--mono);
  overflow: auto;
  max-height: 300px;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 14px;
  color: var(--text);
}

/* ── Sidebar tab row moved to the bottom ───────────────────── */
#panel-chat {
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
#panel-chat:not([hidden]) {
  display: flex;
}
.sidebar__tabs {
  order: 8;
  border-top: 1px solid var(--border);
  padding: 8px 10px;
}
.sidebar__foot {
  order: 9;
}

/* ── Slide-out side rails (placeholder controls) ───────────── */
.side-rail {
  position: absolute;
  top: 50%;
  z-index: 45;
  display: flex;
  align-items: center;
  transform: translateY(-50%);
}
.side-rail--left {
  left: 0;
}
.side-rail--right {
  right: 0;
  flex-direction: row-reverse;
}

.side-rail__handle {
  width: 22px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-sidebar);
  color: var(--text-muted);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
}
.side-rail__handle:hover {
  color: var(--text);
  background: var(--bg-hover);
}
.side-rail--left .side-rail__handle {
  border-left: none;
  border-radius: 0 9px 9px 0;
}
.side-rail--right .side-rail__handle {
  border-right: none;
  border-radius: 9px 0 0 9px;
}
.side-rail__handle svg {
  transition: transform 0.18s ease;
}
.side-rail--open .side-rail__handle svg {
  transform: rotate(180deg);
}

.side-rail__panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 150px;
  max-width: 0;
  padding: 0;
  border: 0 solid var(--border);
  background: var(--bg-sidebar);
  opacity: 0;
  overflow: hidden;
  transition: max-width 0.18s ease, opacity 0.18s ease, padding 0.18s ease;
}
.side-rail--left .side-rail__panel {
  border-left-width: 0;
  border-radius: 0 10px 10px 0;
}
.side-rail--right .side-rail__panel {
  border-right-width: 0;
  border-radius: 10px 0 0 10px;
}
.side-rail--open .side-rail__panel {
  max-width: 180px;
  padding: 9px;
  border-width: 1px;
  opacity: 1;
}

.side-rail__btn {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.12s;
}
.side-rail__btn:hover {
  background: var(--bg-hover);
}
