.app-main {
  padding-top: 1.5rem;
  padding-bottom: 3rem;
}

/* ── Config panel ── */
.config-panel {
  margin-bottom: 1.25rem;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .6rem .9rem;
  margin-bottom: .75rem;
}

.config-grid label {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  font-size: .9rem;
  color: var(--muted);
}

.config-grid input,
.config-grid select {
  padding: .5rem .7rem;
  background: var(--input-bg, #0a1230);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  color: var(--text);
  font-size: .9rem;
  font-family: var(--font-family);
  transition: border-color .15s;
}

.config-grid input:focus,
.config-grid select:focus {
  outline: 2px solid var(--focus-ring, #8bb8ff);
  outline-offset: 2px;
  border-color: var(--accent);
}

.config-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}

.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.status-dot[data-state="ok"]   { background: var(--success, #44d07b); }
.status-dot[data-state="err"]  { background: var(--danger, #ff6b6b); }
.status-dot[data-state="busy"] { background: var(--warning, #ffd166); animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .45; }
}

.status-text {
  font-size: .85rem;
  color: var(--muted);
  min-width: 0;
  word-break: break-word;
}

/* ── Model list ── */
.model-list-panel {
  margin-bottom: 1.25rem;
}

.model-list-panel details > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  color: var(--muted);
  font-size: .9rem;
  padding: .35rem 0;
}
.model-list-panel details > summary::-webkit-details-marker { display: none; }
.model-list-panel details > summary::before {
  content: "▶ ";
  font-size: .7rem;
}
.model-list-panel details[open] > summary::before { content: "▼ "; }

.model-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  padding-top: .5rem;
}

.model-chip {
  padding: .25rem .65rem;
  border-radius: 20px;
  border: 1px solid var(--border-soft);
  background: var(--panel-soft);
  font-size: .8rem;
  color: var(--text);
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.model-chip:hover,
.model-chip[aria-selected="true"] {
  background: var(--accent);
  color: var(--accent-contrast, #07111f);
  border-color: var(--accent);
}

/* ── Chat window ── */
.chat-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.chat-window {
  min-height: 340px;
  max-height: 56vh;
  overflow-y: auto;
  padding: 1rem 1rem .5rem;
  background: var(--input-bg, #0a1230);
  border: 1px solid var(--border-soft);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  scroll-behavior: smooth;
}

/* empty state */
.chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: .9rem;
  text-align: center;
  pointer-events: none;
  padding: 2rem 0;
}

/* messages */
.msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  gap: .2rem;
}
.msg.user  { align-self: flex-end; }
.msg.assistant { align-self: flex-start; }

.msg-bubble {
  padding: .6rem .9rem;
  border-radius: 14px;
  font-size: .93rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user .msg-bubble {
  background: var(--accent);
  color: var(--accent-contrast, #07111f);
  border-bottom-right-radius: 4px;
}
.msg.assistant .msg-bubble {
  background: var(--panel-soft);
  color: var(--text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border-soft);
}

.msg-meta {
  font-size: .75rem;
  color: var(--muted);
  padding: 0 .35rem;
}
.msg.user .msg-meta { text-align: right; }

/* streaming cursor */
.cursor-blink::after {
  content: "▋";
  animation: blink .75s step-end infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── Composer ── */
.composer {
  display: flex;
  gap: .5rem;
  padding: .65rem .75rem;
  background: var(--panel-soft);
  border: 1px solid var(--border-soft);
  border-top: none;
  border-radius: 0 0 12px 12px;
  align-items: flex-end;
}

.composer textarea {
  flex: 1;
  resize: none;
  min-height: 42px;
  max-height: 140px;
  padding: .55rem .75rem;
  background: var(--input-bg, #0a1230);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  color: var(--text);
  font-size: .93rem;
  font-family: var(--font-family);
  line-height: 1.45;
  overflow-y: auto;
  transition: border-color .15s;
}
.composer textarea:focus {
  outline: 2px solid var(--focus-ring, #8bb8ff);
  outline-offset: 2px;
  border-color: var(--accent);
}

.composer-btns {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.btn-send {
  padding: .55rem .9rem;
  background: var(--accent);
  color: var(--accent-contrast, #07111f);
  border: none;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
  white-space: nowrap;
}
.btn-send:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.btn-send:not(:disabled):hover { opacity: .85; }

.btn-clear {
  padding: .45rem .9rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  font-size: .82rem;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.btn-clear:hover {
  background: var(--panel);
  color: var(--text);
}

/* ── System prompt toggle ── */
.system-prompt-wrap {
  margin-top: 1rem;
}
.system-prompt-wrap details > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  color: var(--muted);
  font-size: .85rem;
}
.system-prompt-wrap details > summary::-webkit-details-marker { display: none; }
.system-prompt-wrap details > summary::before { content: "▶ "; font-size: .7rem; }
.system-prompt-wrap details[open] > summary::before { content: "▼ "; }

.system-prompt-wrap textarea {
  width: 100%;
  margin-top: .5rem;
  padding: .55rem .75rem;
  background: var(--input-bg, #0a1230);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  color: var(--text);
  font-size: .87rem;
  font-family: var(--font-family);
  resize: vertical;
}
.system-prompt-wrap textarea:focus {
  outline: 2px solid var(--focus-ring, #8bb8ff);
  outline-offset: 2px;
}

/* ── About note ── */
.about-note {
  margin-top: 1.25rem;
  padding: .8rem 1rem;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: var(--panel-soft);
  font-size: .85rem;
  color: var(--muted);
  line-height: 1.55;
}
.about-note a { color: var(--accent); }
