/* Chat mode overrides the centered-card body layout. */
body.chat-mode {
  display: block;
  min-height: 100vh;
  min-height: 100dvh;
}
.chat-shell { display: flex; height: 100vh; height: 100dvh; }
.sidebar {
  width: 260px;
  flex-shrink: 0;
  border-right: 1px solid #2a2a2a;
  background: #0a0a0a;
  display: flex;
  flex-direction: column;
}
.sidebar-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #2a2a2a;
}
.sidebar-header h1 { font-size: 1rem; }
.new-chat-btn {
  margin: 0.75rem 1.25rem;
  padding: 0.5rem;
  background: transparent;
  border: 1px solid #c8a96e;
  color: #c8a96e;
  font-family: inherit;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  border-radius: 4px;
}
.new-chat-btn:hover { background: #c8a96e; color: #0d0d0d; }
.conv-list { list-style: none; overflow-y: auto; flex: 1; }
.conv-row {
  position: relative;
  padding: 0.6rem 2rem 0.6rem 1.25rem;
  font-size: 0.8rem;
  color: #aaa;
  cursor: pointer;
  border-left: 2px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-row:hover { background: #131313; color: #e8e8e8; }
.conv-row.active {
  border-left-color: #c8a96e;
  background: #131313;
  color: #e8e8e8;
}
.conv-archive {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  color: #555;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 0.4rem;
  opacity: 0;
  font-family: inherit;
}
.conv-row:hover .conv-archive,
.conv-archive:focus { opacity: 1; }
.conv-archive:hover { color: #c46e6e; }

.sidebar-footer {
  border-top: 1px solid #2a2a2a;
  padding: 0.5rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.kbd-help {
  position: relative;
  display: inline-block;
  cursor: help;
  color: #555;
}
.kbd-help:hover, .kbd-help:focus-within {
  color: #c8a96e;
  outline: none;
}
.kbd-icon { font-size: 1rem; }
.kbd-popup {
  position: absolute;
  bottom: calc(100% + 0.4rem);
  left: 0;
  background: #131313;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  padding: 0.5rem 0.7rem;
  white-space: nowrap;
  font-size: 0.75rem;
  color: #aaa;
  display: none;
  z-index: 20;
}
.kbd-help:hover .kbd-popup,
.kbd-help:focus-within .kbd-popup { display: block; }
.kbd-row { padding: 0.15rem 0; }
.kbd-row kbd {
  font-family: inherit;
  font-size: 0.7rem;
  background: #0a0a0a;
  border: 1px solid #2a2a2a;
  border-radius: 3px;
  padding: 0.05rem 0.35rem;
  color: #c8a96e;
}

.pane { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.messages { flex: 1; overflow-y: auto; padding: 2rem 3rem 1rem; }
.empty {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555;
  font-size: 0.9rem;
}
.msg {
  max-width: 60rem;
  margin: 0 auto 1.5rem;
  font-size: 0.9rem;
  line-height: 1.5;
}
.msg.user {
  max-width: 40rem;
  margin-right: 0;
  margin-left: auto;
  background: #1a1512;
  border: 1px solid #2a2118;
  border-radius: 10px;
  padding: 0.6rem 0.85rem;
}
.msg.assistant {
  max-width: 60rem;
  margin-left: 0;
  margin-right: auto;
  background: #10161b;
  border: 1px solid #233742;
  border-radius: 10px;
  padding: 0.6rem 0.85rem;
}
.msg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.msg-role {
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}
.msg-role.user { color: #c8a96e; }
.msg-role.assistant { color: #6ea0c4; }
.msg-content {
  white-space: pre-wrap;
  word-wrap: break-word;
  color: #e8e8e8;
}
.msg.cancelled .msg-content,
.msg.error .msg-content { color: #888; }
.msg-status {
  font-size: 0.65rem;
  margin-top: 0.3rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.msg.cancelled .msg-status { color: #c4a06e; }
.msg.error .msg-status { color: #c46e6e; }

.summary-divider {
  border-top: 1px solid #2a2a2a;
  padding: 0.5rem 0;
  margin: 0.4rem 0;
  font-size: 0.75rem;
  color: #888;
  text-align: center;
}

.tools-btn {
  flex: none;
  padding: 0.15rem 0.55rem;
  background: #0a0a0a;
  color: #6ea0c4;
  border: 1px solid #2a4a5a;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.7rem;
  cursor: pointer;
}
.tools-btn:hover { background: #131313; }
.tools-btn.error { color: #c46e6e; border-color: #5a2a2a; }
.tool-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.tool-list-item {
  text-align: left;
  padding: 0.4rem 0.6rem;
  background: #0a0a0a;
  color: #6ea0c4;
  border: 1px solid #2a4a5a;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  word-break: break-all;
}
.tool-list-item:hover { background: #131313; }
.tool-list-item.error { color: #c46e6e; border-color: #5a2a2a; }
.tool-list-item.active { background: #1a1f15; border-color: #5a6e2a; color: #c8a96e; }
/* Skills (Gitea #201) chips share the tools-btn palette but pick a
   distinct cool-warm tone so users can tell skill chips from tool
   chips at a glance even with screen tinting. */
.tools-btn.skills-btn {
  color: #c8a96e;
  border-color: #5a4a2a;
}
/* AUTH_MISSING credential chips (Gitea #225, #233) — orange,
   deliberately not red (that's reserved for "tool errored"). The
   class lands on both the per-message chip and individual modal rows. */
.tools-btn.skills-btn.skills-auth,
.tool-list-item.skills-auth {
  color: #d4891f;
  border-color: #6a4a1f;
}
.tool-list-item.skills-auth:hover { background: #1a140a; }
.skills-browse-btn {
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #0a0a0a;
  color: #c8a96e;
  border: 1px solid #5a4a2a;
  border-radius: 4px;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
}
.skills-browse-btn:hover { background: #131313; }
.pending-skills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.9rem 0;
  font-size: 0.75rem;
}
.pending-skills-label { opacity: 0.7; }
.pending-skill-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.5rem;
  background: #0a0a0a;
  color: #c8a96e;
  border: 1px solid #5a4a2a;
  border-radius: 4px;
}
.pending-skill-x {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0;
}
.pending-skill-x:hover { color: #c46e6e; }
.tool-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 2rem;
}
.tool-modal {
  background: #131313;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  max-width: 800px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
}
.tool-modal h3 {
  margin: 0 0 0.75rem;
  color: #c8a96e;
  font-size: 0.9rem;
}
.tool-modal h4 {
  margin: 1rem 0 0.3rem;
  color: #6ea0c4;
  font-size: 0.78rem;
}
.tool-modal pre {
  background: #0a0a0a;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  padding: 0.6rem;
  font-size: 0.72rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 30vh;
  overflow-y: auto;
}
.tool-modal-close {
  float: right;
  background: transparent;
  color: #888;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  font-family: inherit;
  cursor: pointer;
  padding: 0.2rem 0.55rem;
}
.tool-modal-close:hover { color: #c46e6e; }

.composer {
  padding: 1rem 3rem 1.5rem;
  /* Keep the composer clear of the iOS home indicator (with
     viewport-fit=cover the bottom edge meets the safe area). */
  padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  border-top: 1px solid #2a2a2a;
  background: #0a0a0a;
}
.composer-inner {
  max-width: 60rem;
  margin: 0 auto;
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}
.composer textarea {
  flex: 1;
  background: #131313;
  color: #e8e8e8;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  padding: 0.6rem 0.8rem;
  font-family: inherit;
  font-size: 0.85rem;
  resize: none;
  line-height: 1.4;
  min-height: 2.4rem;
  max-height: 10rem;
  overflow-y: auto;
}
.composer textarea:focus { outline: none; border-color: #c8a96e; }
.composer textarea:disabled { opacity: 0.5; cursor: not-allowed; }
.send-btn, .stop-btn {
  background: transparent;
  border: 1px solid #c8a96e;
  color: #c8a96e;
  padding: 0.5rem 1.1rem;
  font-family: inherit;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  border-radius: 4px;
  white-space: nowrap;
}
.send-btn:hover { background: #c8a96e; color: #0d0d0d; }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.stop-btn { border-color: #c46e6e; color: #c46e6e; }
.stop-btn:hover { background: #c46e6e; color: #0d0d0d; }
.stream-error {
  max-width: 60rem;
  margin: 0 auto 1rem;
  padding: 0.6rem 0.8rem;
  background: #2a1010;
  border: 1px solid #c46e6e;
  border-radius: 4px;
  font-size: 0.8rem;
  color: #c46e6e;
}

/* Admin-only conversation model picker (Gitea #182). Sits above the message
   list; only rendered when a conversation is active and the user is admin. */
.conv-header {
  border-bottom: 1px solid #2a2a2a;
  background: #0a0a0a;
  padding: 0.5rem 3rem;
}
.model-picker {
  max-width: 60rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.model-picker-label {
  flex: none;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #888;
}
.model-picker-input {
  flex: 1;
  min-width: 0;
  background: #131313;
  color: #e8e8e8;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  padding: 0.35rem 0.6rem;
  font-family: inherit;
  font-size: 0.8rem;
}
.model-picker-input:focus { outline: none; border-color: #c8a96e; }
.model-picker-save {
  flex: none;
  background: transparent;
  border: 1px solid #c8a96e;
  color: #c8a96e;
  padding: 0.35rem 0.9rem;
  font-family: inherit;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  border-radius: 4px;
}
.model-picker-save:hover { background: #c8a96e; color: #0d0d0d; }
.model-picker-save:disabled { opacity: 0.4; cursor: not-allowed; }
.model-picker-error {
  flex: none;
  font-size: 0.75rem;
  color: #c46e6e;
}
