@import './chat.css';

.card {
  border: 1px solid var(--border);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.04), transparent 65%),
    var(--panel);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.28);
  animation: rise 0.4s ease;
}

.card-title {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.card-sub {
  color: var(--muted);
  font-size: 12px;
}

.stat {
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.04), transparent 70%),
    var(--panel-strong);
  border-radius: 14px;
  padding: 12px;
  border: 1px solid var(--border-strong);
}

.stat-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-value {
  font-size: 18px;
  margin-top: 6px;
}

.stat-value.ok {
  color: var(--ok);
}

.stat-value.warn {
  color: var(--warn);
}

.stat-card {
  display: grid;
  gap: 6px;
}

.note-title {
  font-weight: 600;
  letter-spacing: 0.2px;
}

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

.status-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.06);
}

.status-list div:last-child {
  border-bottom: none;
}

.account-count {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--muted);
}

.account-card-list {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

.account-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.06), transparent),
    rgba(255, 255, 255, 0.03);
}

.account-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.account-card-title {
  font-weight: 600;
}

.account-card-id {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.account-card-status {
  margin-top: 8px;
  font-size: 13px;
}

.account-card-status div {
  padding: 4px 0;
}

.account-card-error {
  margin-top: 6px;
  color: var(--danger);
  font-size: 12px;
}

.label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-strong);
  padding: 6px 12px;
  border-radius: 999px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.06), transparent),
    var(--panel);
}

.theme-toggle {
  --theme-item: 28px;
  --theme-gap: 6px;
  --theme-pad: 6px;
  position: relative;
}

.theme-toggle__track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, var(--theme-item));
  gap: var(--theme-gap);
  padding: var(--theme-pad);
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
}

.theme-toggle__indicator {
  position: absolute;
  top: 50%;
  left: var(--theme-pad);
  width: var(--theme-item);
  height: var(--theme-item);
  border-radius: 999px;
  transform: translateY(-50%)
    translateX(calc(var(--theme-index, 0) * (var(--theme-item) + var(--theme-gap))));
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.12), transparent),
    var(--panel-strong);
  border: 1px solid var(--border-strong);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.25);
  transition: transform 180ms ease-out, background 180ms ease-out,
    box-shadow 180ms ease-out;
  z-index: 0;
}

.theme-toggle__button {
  height: var(--theme-item);
  width: var(--theme-item);
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: color 150ms ease-out, background 150ms ease-out;
}

.theme-toggle__button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.theme-toggle__button.active {
  color: var(--text);
}

.theme-icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pill.danger {
  border-color: rgba(255, 92, 92, 0.5);
  color: var(--danger);
}

.statusDot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--danger);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25);
}

.statusDot.ok {
  background: var(--ok);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25), 0 0 10px rgba(43, 217, 127, 0.4);
}

.btn {
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.btn.primary {
  border-color: rgba(245, 159, 74, 0.45);
  background: rgba(245, 159, 74, 0.2);
}

.btn.active {
  border-color: rgba(245, 159, 74, 0.55);
  background: rgba(245, 159, 74, 0.16);
}

.btn.danger {
  border-color: rgba(255, 107, 107, 0.45);
  background: rgba(255, 107, 107, 0.18);
}

.btn--sm {
  padding: 5px 10px;
  font-size: 12px;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

.field span {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.4px;
}

.field input,
.field textarea,
.field select {
  border: 1px solid var(--border-strong);
  background: rgba(0, 0, 0, 0.22);
  border-radius: 12px;
  padding: 9px 11px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease,
    background 150ms ease;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
  background: rgba(0, 0, 0, 0.28);
}

.field select {
  appearance: none;
  padding-right: 38px;
  background-color: var(--panel-strong);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%),
    linear-gradient(to right, transparent, transparent);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%,
    calc(100% - 38px) 50%;
  background-size: 6px 6px, 6px 6px, 1px 60%;
  background-repeat: no-repeat;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.field textarea {
  font-family: var(--mono);
  min-height: 180px;
  resize: vertical;
  white-space: pre;
}

.field textarea:focus {
  background: rgba(0, 0, 0, 0.32);
}

.field.checkbox {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.config-form .field.checkbox {
  grid-template-columns: 18px minmax(0, 1fr);
  column-gap: 10px;
}

.config-form .field.checkbox input[type="checkbox"] {
  margin: 0;
}

.form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

:root[data-theme="light"] .field input,
:root[data-theme="light"] .field textarea,
:root[data-theme="light"] .field select {
  background: rgba(255, 255, 255, 1);
  border-color: rgba(16, 24, 40, 0.25);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

:root[data-theme="light"] .field input:focus,
:root[data-theme="light"] .field textarea:focus,
:root[data-theme="light"] .field select:focus {
  background: #ffffff;
}

/* Light theme button overrides */
:root[data-theme="light"] .btn {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(16, 24, 40, 0.2);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

:root[data-theme="light"] .btn:hover {
  background: rgba(255, 255, 255, 1);
  border-color: rgba(16, 24, 40, 0.3);
}

:root[data-theme="light"] .btn.primary {
  background: rgba(245, 159, 74, 0.15);
}

:root[data-theme="light"] .btn.active {
  background: rgba(245, 159, 74, 0.12);
}

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

.mono {
  font-family: var(--mono);
}

.callout {
  padding: 10px 12px;
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.06), transparent),
    rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}

.callout.danger {
  border-color: rgba(255, 92, 92, 0.4);
  color: var(--danger);
}

.callout.info {
  border-color: rgba(92, 156, 255, 0.4);
  color: var(--accent);
}

.callout.success {
  border-color: rgba(92, 255, 128, 0.4);
  color: var(--positive, #5cff80);
}

.compaction-indicator {
  font-size: 13px;
  padding: 8px 12px;
  margin-bottom: 8px;
  animation: compaction-fade-in 0.2s ease-out;
}

.compaction-indicator--active {
  animation: compaction-pulse 1.5s ease-in-out infinite;
}

.compaction-indicator--complete {
  animation: compaction-fade-in 0.2s ease-out;
}

@keyframes compaction-fade-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes compaction-pulse {
  0%, 100% {
    opacity: 0.7;
  }
  50% {
    opacity: 1;
  }
}

.code-block {
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(0, 0, 0, 0.35);
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  max-height: 360px;
  overflow: auto;
}

:root[data-theme="light"] .code-block,
:root[data-theme="light"] .list-item,
:root[data-theme="light"] .table-row,
:root[data-theme="light"] .chip {
  background: rgba(255, 255, 255, 0.85);
}

.list {
  display: grid;
  gap: 12px;
  container-type: inline-size;
}

.list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 260px);
  gap: 14px;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
}

.list-item-clickable {
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.list-item-clickable:hover {
  border-color: var(--border-strong);
}

.list-item-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--focus);
}

.list-main {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.list-title {
  font-weight: 600;
}

.list-sub {
  color: var(--muted);
  font-size: 12px;
}

.list-meta {
  text-align: right;
  color: var(--muted);
  font-size: 11px;
  display: grid;
  gap: 4px;
  min-width: 220px;
}

.list-meta .btn {
  padding: 6px 10px;
}

.list-meta .field input,
.list-meta .field textarea,
.list-meta .field select {
  width: 100%;
}

@container (max-width: 560px) {
  .list-item {
    grid-template-columns: 1fr;
  }

  .list-meta {
    min-width: 0;
    text-align: left;
  }
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.2);
}

.chip input {
  margin-right: 6px;
}

.chip-ok {
  color: var(--ok);
  border-color: rgba(27, 217, 138, 0.4);
}

.chip-warn {
  color: var(--warn);
  border-color: rgba(242, 201, 76, 0.4);
}

.table {
  display: grid;
  gap: 8px;
}

.table-head,
.table-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 0.8fr 0.7fr 0.8fr 0.8fr 0.8fr 0.8fr 0.6fr;
  gap: 12px;
  align-items: center;
}

.table-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
}

.table-row {
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
}

.session-link {
  text-decoration: none;
  color: var(--accent);
}

.session-link:hover {
  text-decoration: underline;
}

.log-stream {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.2);
  max-height: 520px;
  overflow: auto;
  container-type: inline-size;
}

.log-row {
  display: grid;
  grid-template-columns: 90px 70px minmax(140px, 200px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.log-row:last-child {
  border-bottom: none;
}

.log-time {
  color: var(--muted);
}

.log-level {
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 6px;
  width: fit-content;
}

.log-level.trace,
.log-level.debug {
  color: var(--muted);
}

.log-level.info {
  color: var(--info);
  border-color: rgba(76, 150, 242, 0.4);
}

.log-level.warn {
  color: var(--warn);
  border-color: rgba(242, 201, 76, 0.4);
}

.log-level.error,
.log-level.fatal {
  color: var(--danger);
  border-color: rgba(255, 92, 92, 0.4);
}

.log-chip.trace,
.log-chip.debug {
  color: var(--muted);
}

.log-chip.info {
  color: var(--info);
  border-color: rgba(76, 150, 242, 0.4);
}

.log-chip.warn {
  color: var(--warn);
  border-color: rgba(242, 201, 76, 0.4);
}

.log-chip.error,
.log-chip.fatal {
  color: var(--danger);
  border-color: rgba(255, 92, 92, 0.4);
}

.log-subsystem {
  color: var(--muted);
}

.log-message {
  white-space: pre-wrap;
  word-break: break-word;
}

@container (max-width: 620px) {
  .log-row {
    grid-template-columns: 70px 60px minmax(0, 1fr);
  }

  .log-subsystem {
    display: none;
  }
}

.chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.shell--chat .chat {
  flex: 1;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.chat-header__left {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.chat-header__right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-session {
  min-width: 240px;
}

.chat-thread {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0; /* Allow flex shrinking for scroll behavior */
  overflow-y: auto; /* Enable scrolling */
  overflow-x: hidden;
  padding: 14px 12px;
  min-width: 0;
  border-radius: 0;
  border: none;
  background: transparent;
}

:root[data-theme="light"] .chat-thread {
  background: transparent;
}

.chat-queue {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
  display: grid;
  gap: 8px;
}

:root[data-theme="light"] .chat-queue {
  background: rgba(16, 24, 40, 0.04);
}

.chat-queue__title {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.chat-queue__list {
  display: grid;
  gap: 8px;
}

.chat-queue__item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: rgba(0, 0, 0, 0.2);
}

:root[data-theme="light"] .chat-queue__item {
  background: rgba(16, 24, 40, 0.05);
}

.chat-queue__text {
  color: var(--chat-text);
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.chat-queue__remove {
  align-self: start;
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1;
}

.chat-line {
  display: flex;
}

.chat-line.user {
  justify-content: flex-end;
}

.chat-line.assistant,
.chat-line.other {
  justify-content: flex-start;
}

.chat-msg {
  display: grid;
  gap: 6px;
  max-width: min(720px, 82%);
}

.chat-line.user .chat-msg {
  justify-items: end;
}

.chat-bubble {
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.24);
  border-radius: 16px;
  padding: 10px 12px;
  min-width: 0;
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.24);
}

:root[data-theme="light"] .chat-bubble {
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 12px 26px rgba(16, 24, 40, 0.08);
}

.chat-line.user .chat-bubble {
  border-color: rgba(245, 159, 74, 0.45);
  background: linear-gradient(
    135deg,
    rgba(245, 159, 74, 0.26) 0%,
    rgba(245, 159, 74, 0.12) 100%
  );
}

.chat-line.assistant .chat-bubble {
  border-color: rgba(52, 199, 183, 0.2);
  background: linear-gradient(
    135deg,
    rgba(52, 199, 183, 0.12) 0%,
    rgba(0, 0, 0, 0.24) 100%
  );
}

:root[data-theme="light"] .chat-line.assistant .chat-bubble {
  background: linear-gradient(
    135deg,
    rgba(27, 185, 177, 0.12) 0%,
    rgba(255, 255, 255, 0.85) 100%
  );
}

@keyframes chatStreamPulse {
  0% {
    box-shadow: 0 12px 22px rgba(0, 0, 0, 0.24), 0 0 0 0 rgba(52, 199, 183, 0);
  }
  60% {
    box-shadow: 0 12px 22px rgba(0, 0, 0, 0.24), 0 0 0 6px rgba(52, 199, 183, 0.08);
  }
  100% {
    box-shadow: 0 12px 22px rgba(0, 0, 0, 0.24), 0 0 0 0 rgba(52, 199, 183, 0);
  }
}

.chat-bubble.streaming {
  border-color: rgba(52, 199, 183, 0.4);
  animation: chatStreamPulse 1.6s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .chat-bubble.streaming {
    animation: none;
  }
}

.chat-bubble.chat-reading-indicator {
  width: fit-content;
  padding: 10px 14px;
}

.chat-reading-indicator__dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 10px;
}

.chat-reading-indicator__dots > span {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--chat-text);
  opacity: 0.55;
  transform: translateY(0);
  animation: chatReadingDot 1.1s ease-in-out infinite;
  will-change: transform, opacity;
}

.chat-reading-indicator__dots > span:nth-child(2) {
  animation-delay: 0.12s;
}

.chat-reading-indicator__dots > span:nth-child(3) {
  animation-delay: 0.24s;
}

@keyframes chatReadingDot {
  0%,
  80%,
  100% {
    opacity: 0.38;
    transform: translateY(0) scale(0.92);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px) scale(1.18);
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-reading-indicator__dots > span {
    animation: none;
    opacity: 0.75;
  }
}

.chat-text {
  overflow-wrap: anywhere;
  word-break: break-word;
  color: var(--chat-text);
  line-height: 1.5;
}

.chat-text :where(p, ul, ol, pre, blockquote, table) {
  margin: 0;
}

.chat-text :where(p + p, p + ul, p + ol, p + pre, p + blockquote, p + table) {
  margin-top: 0.75em;
}

.chat-text :where(ul, ol) {
  padding-left: 1.1em;
}

.chat-text :where(li + li) {
  margin-top: 0.25em;
}

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

.chat-text :where(a:hover) {
  text-decoration-thickness: 3px;
}

.chat-text :where(blockquote) {
  border-left: 2px solid rgba(255, 255, 255, 0.14);
  padding-left: 12px;
  color: var(--muted);
}

:root[data-theme="light"] .chat-text :where(blockquote) {
  border-left-color: rgba(16, 24, 40, 0.16);
}

.chat-text :where(hr) {
  border: 0;
  border-top: 1px solid var(--border);
  opacity: 0.6;
  margin: 0.9em 0;
}

.chat-text :where(code) {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

.chat-text :where(:not(pre) > code) {
  padding: 0.15em 0.35em;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

:root[data-theme="light"] .chat-text :where(:not(pre) > code) {
  background: rgba(16, 24, 40, 0.05);
}

.chat-text :where(pre) {
  margin-top: 0.75em;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.22);
  overflow: auto;
}

:root[data-theme="light"] .chat-text :where(pre) {
  background: rgba(16, 24, 40, 0.04);
}

.chat-text :where(pre code) {
  font-size: 12px;
  white-space: pre;
}

.chat-text :where(table) {
  margin-top: 0.75em;
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
}

.chat-text :where(th, td) {
  border: 1px solid var(--border);
  padding: 6px 8px;
  vertical-align: top;
}

.chat-text :where(th) {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--muted);
}

.chat-tool-card {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.22);
  display: grid;
  gap: 4px;
}

:root[data-theme="light"] .chat-tool-card {
  background: rgba(255, 255, 255, 0.7);
}

.chat-tool-card__title {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--chat-text);
}

.chat-tool-card__detail {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

.chat-tool-card__details {
  margin-top: 6px;
}

.chat-tool-card__summary {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chat-tool-card__summary::-webkit-details-marker {
  display: none;
}

.chat-tool-card__summary-meta {
  color: var(--muted);
  opacity: 0.8;
}

.chat-tool-card__details[open] .chat-tool-card__summary {
  color: var(--chat-text);
}

.chat-tool-card__output {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  color: var(--chat-text);
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

:root[data-theme="light"] .chat-tool-card__output {
  background: rgba(16, 24, 40, 0.05);
}

.chat-stamp {
  font-size: 11px;
  color: var(--muted);
}

.chat-line.user .chat-stamp {
  text-align: right;
}

.chat-compose {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.shell--chat .chat-compose {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin-top: 0;
  padding-top: 12px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, var(--panel) 35%);
}

.shell--chat-focus .chat-compose {
  bottom: calc(var(--shell-pad) + 8px);
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 18px;
}

.chat-compose__field {
  gap: 4px;
}

.chat-compose__field textarea {
  min-height: 72px;
  padding: 10px 12px;
  border-radius: 16px;
  resize: vertical;
  white-space: pre-wrap;
  font-family: var(--font-body);
  line-height: 1.45;
}

.chat-compose__field textarea:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.chat-compose__actions {
  justify-content: flex-end;
  align-self: end;
}

@media (max-width: 900px) {
  .chat-session {
    min-width: 200px;
  }

  .chat-compose {
    grid-template-columns: 1fr;
  }
}

.qr-wrap {
  margin-top: 12px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px dashed rgba(255, 255, 255, 0.18);
  padding: 12px;
  display: inline-flex;
}

.qr-wrap img {
  width: 180px;
  height: 180px;
  border-radius: 10px;
  image-rendering: pixelated;
}

.exec-approval-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 18, 0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 200;
}

.exec-approval-card {
  width: min(560px, 100%);
  background: var(--panel-strong);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.35);
  animation: rise 0.25s ease;
}

.exec-approval-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.exec-approval-title {
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.exec-approval-sub {
  color: var(--muted);
  font-size: 12px;
}

.exec-approval-queue {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
}

.exec-approval-command {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 12px;
  word-break: break-word;
  white-space: pre-wrap;
}

.exec-approval-meta {
  margin-top: 12px;
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.exec-approval-meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.exec-approval-meta-row span:last-child {
  color: var(--text);
  font-family: var(--mono);
}

.exec-approval-error {
  margin-top: 10px;
  font-size: 12px;
  color: var(--danger);
}

.exec-approval-actions {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
