/* Chat-specific styles — extends style.css dark theme variables */

/* Widen app container for chat (login/picker still look fine centered) */
#app { max-width: 900px; }

/* ===== Chat View ===== */
#chat-view {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  position: relative;
}

/* --- Header --- */
#chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

#chat-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: #4aff7a;
  transition: background 0.2s;
}

#chat-header.provider-openai::after {
  background: #ff4a6a;
}

#chat-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #555;
  transition: background 0.3s;
}
#chat-status-dot.connected { background: #4aff7a; }
#chat-status-dot.error { background: var(--danger); }

#chat-agent-label {
  font-size: 15px;
  font-weight: 600;
}

/* --- Activity state label --- */
#chat-activity-label {
  font-size: 12px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.2s;
}
#chat-activity-label.visible { opacity: 1; }
#chat-activity-label.state-processing { color: var(--text-dim); animation: think-pulse 1.2s ease-in-out infinite; }
#chat-activity-label.state-thinking { color: var(--accent); animation: think-pulse 1s ease-in-out infinite; }
#chat-activity-label.state-responding { color: #4aff7a; }
#chat-activity-label.state-speaking { color: #b78aff; animation: think-pulse 1.2s ease-in-out infinite; }

/* Status dot active states */
#chat-status-dot.active {
  animation: dot-pulse 1.5s ease-in-out infinite;
}
@keyframes dot-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 255, 122, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(74, 255, 122, 0); }
}

.notif-btn {
  position: relative;
}

.notif-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #ff5a6b;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.chat-header-spacer { flex: 1; }

/* --- Messages area --- */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* --- Message containers --- */
.msg {
  display: flex;
  flex-direction: column;
  max-width: 90%;
}
.msg.user { align-self: flex-end; }
.msg.agent { align-self: flex-start; }

.msg-content {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.msg.user .msg-content {
  background: var(--user-bg);
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}
.msg.user { cursor: default; -webkit-user-select: none; user-select: none; }

/* Copy toast (overrides style.css position for chat layout) */
#copy-toast {
  bottom: 80px;
}

.msg.agent .msg-content {
  background: var(--agent-bg);
  border-bottom-left-radius: 4px;
  user-select: text;
  -webkit-user-select: text;
}

.approval-card {
  border: 1px solid rgba(255, 201, 90, 0.45);
  background: rgba(255, 201, 90, 0.07);
  border-radius: 10px;
  padding: 10px;
  margin: 8px 0;
}

.approval-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 6px;
  color: #ffd474;
}

.approval-prompt {
  font-size: 14px;
  margin-bottom: 8px;
}

.approval-actions {
  display: flex;
  gap: 8px;
}

.approval-actions button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.approval-actions button:hover {
  border-color: var(--accent);
}

#notif-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 90;
}

#notif-panel {
  position: absolute;
  top: 54px;
  right: 14px;
  width: min(420px, calc(100vw - 24px));
  max-height: min(70vh, 560px);
  overflow-y: auto;
  border: 1px solid var(--border);
  background: #101018;
  border-radius: 12px;
  padding: 10px;
}

.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.notif-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.notif-clear-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.notif-clear-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}
.notif-clear-btn.hidden { display: none; }

.notif-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.notif-item:last-child {
  margin-bottom: 0;
}

.notif-item h4 {
  margin: 0 0 4px 0;
  font-size: 13px;
}

.notif-item p {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
}

/* --- Markdown rendering --- */
.msg.agent .msg-content .response-text p { margin: 0 0 8px 0; }
.msg.agent .msg-content .response-text p:last-child { margin-bottom: 0; }

.msg.agent .msg-content .response-text code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  font-size: 13px;
}

.msg.agent .msg-content .response-text pre {
  background: #161622;
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  margin: 8px 0;
  position: relative;
}

.msg.agent .msg-content .response-text pre code {
  background: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.5;
}

.code-copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--border);
  border: none;
  color: var(--text-dim);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
pre:hover .code-copy-btn { opacity: 1; }
.code-copy-btn:active { background: var(--accent); color: white; }

/* Tables */
.msg.agent .msg-content table {
  border-collapse: collapse;
  margin: 8px 0;
  width: 100%;
}
.msg.agent .msg-content th,
.msg.agent .msg-content td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
  font-size: 13px;
}
.msg.agent .msg-content th { background: rgba(255, 255, 255, 0.05); }

/* Lists */
.msg.agent .msg-content ul,
.msg.agent .msg-content ol {
  padding-left: 20px;
  margin: 4px 0;
}

/* Links */
.msg.agent .msg-content a { color: var(--accent); text-decoration: none; }
.msg.agent .msg-content a:hover { text-decoration: underline; }

/* --- Thinking panel --- */
.thinking-panel {
  background: rgba(74, 158, 255, 0.06);
  border: 1px solid rgba(74, 158, 255, 0.15);
  border-radius: 10px;
  margin-bottom: 8px;
  overflow: hidden;
}

.thinking-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--accent);
  user-select: none;
  -webkit-user-select: none;
}

.thinking-header .arrow {
  transition: transform 0.15s;
  font-size: 10px;
}
.thinking-panel.open .thinking-header .arrow {
  transform: rotate(90deg);
}

.thinking-body {
  display: none;
  padding: 0 12px 10px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
}
.thinking-panel.open .thinking-body { display: block; }

.thinking-spinner {
  display: inline-block;
  animation: think-pulse 1s ease-in-out infinite;
}
@keyframes think-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.thinking-expand-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.thinking-expand-btn:hover { opacity: 1; }

/* --- Thinking modal --- */
#thinking-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
}

#thinking-modal {
  width: min(640px, calc(100vw - 32px));
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: #101018;
  border: 1px solid rgba(74, 158, 255, 0.25);
  border-radius: 12px;
  overflow: hidden;
}

.thinking-modal-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.thinking-modal-status {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

.thinking-modal-tokens {
  font-size: 12px;
  color: var(--text-dim);
}

.thinking-modal-close {
  margin-left: auto;
  background: none;
  border: 1px solid var(--danger);
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 12px;
  border-radius: 6px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.thinking-modal-close:hover {
  background: var(--danger);
  color: #fff;
}

.thinking-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
  white-space: pre-wrap;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
}

/* --- Tool panel --- */
.tool-panel {
  border-radius: 8px;
  margin: 6px 0;
  overflow: hidden;
  border: 1px solid var(--border);
}

.tool-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  user-select: none;
  -webkit-user-select: none;
}

.tool-header .arrow {
  transition: transform 0.15s;
  font-size: 10px;
}
.tool-panel.open .tool-header .arrow {
  transform: rotate(90deg);
}

.tool-panel.running .tool-header {
  color: var(--accent);
  background: rgba(74, 158, 255, 0.06);
}
.tool-panel.success .tool-header {
  color: #4aff7a;
  background: rgba(74, 255, 122, 0.06);
}
.tool-panel.error .tool-header {
  color: var(--danger);
  background: rgba(255, 74, 106, 0.06);
}

.tool-body {
  display: none;
  padding: 8px 10px;
  font-size: 12px;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  color: var(--text-dim);
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
  background: #161622;
}
.tool-panel.open .tool-body { display: block; }

.tool-input-summary {
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 300px;
}

.tool-duration {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: auto;
  flex-shrink: 0;
}

/* --- Input bar --- */
#input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  resize: none;
  outline: none;
  max-height: 150px;
  min-height: 42px;
}
#chat-input:focus { border-color: var(--accent); }
#chat-input::placeholder { color: var(--text-dim); }

#send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
#send-btn:disabled {
  background: var(--border);
  color: var(--text-dim);
  cursor: not-allowed;
}
#send-btn:not(:disabled):active { transform: scale(0.92); }

/* --- Processing indicator (animated dots) --- */
.processing-indicator {
  padding: 4px 0;
}

.processing-dots {
  display: flex;
  gap: 6px;
  align-items: center;
  height: 24px;
}
.processing-dots.clickable {
  cursor: pointer;
}

.processing-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: dot-bounce 1.2s ease-in-out infinite;
}

.processing-dots .dot:nth-child(2) { animation-delay: 0.15s; }
.processing-dots .dot:nth-child(3) { animation-delay: 0.3s; }

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

/* --- Streaming cursor --- */
.streaming-cursor {
  display: inline-block;
  width: 6px;
  height: 15px;
  background: var(--accent);
  border-radius: 1px;
  animation: cursor-blink 0.8s ease-in-out infinite;
  vertical-align: text-bottom;
  margin-left: 2px;
}
@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* --- Sessions sidebar --- */
#sessions-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: none;
}
#sessions-overlay.open { display: block; }

#sessions-panel {
  position: fixed;
  top: 0;
  right: -320px;
  width: 300px;
  max-width: 85vw;
  height: 100dvh;
  background: var(--bg);
  border-left: 1px solid var(--border);
  z-index: 101;
  transition: right 0.2s ease;
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow-y: auto;
}
#sessions-overlay.open #sessions-panel { right: 0; }

.sessions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.sessions-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.sessions-new-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}
.sessions-new-btn:active { opacity: 0.7; }

.session-item {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
  transition: all 0.15s;
}
.session-item.active {
  border-color: var(--accent);
  background: rgba(74, 158, 255, 0.1);
}

.session-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-item-text {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.session-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-time {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.session-delete-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: none;
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.session-delete-btn:hover {
  color: var(--danger);
  border-color: var(--danger);
}
.session-delete-btn.confirming {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(255, 74, 106, 0.1);
  font-weight: 700;
}

/* --- Attach button --- */
#attach-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
#attach-btn:hover { color: var(--text); }

/* --- Voice toggle buttons (mic / speaker) --- */
.voice-toggle-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  border-radius: 50%;
}
.voice-toggle-btn:hover { color: var(--text); }
.voice-toggle-btn.active {
  color: var(--accent);
  background: rgba(74, 158, 255, 0.12);
}
#mic-btn.recording {
  color: #ff4a6a;
  background: rgba(255, 74, 106, 0.12);
  animation: mic-pulse 1.5s ease-in-out infinite;
}
#tts-btn.speaking {
  color: #b78aff;
  background: rgba(183, 138, 255, 0.12);
  animation: tts-pulse 1.5s ease-in-out infinite;
}
@keyframes tts-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(183, 138, 255, 0.3); }
  50% { box-shadow: 0 0 0 6px rgba(183, 138, 255, 0); }
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 74, 106, 0.3); }
  50% { box-shadow: 0 0 0 6px rgba(255, 74, 106, 0); }
}

/* --- STT listening bar --- */
#stt-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: rgba(255, 74, 106, 0.06);
  flex-shrink: 0;
}
#stt-bar.hidden { display: none; }
#stt-indicator {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 14px;
}
.stt-pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff4a6a;
  animation: stt-blink 1s ease-in-out infinite;
}
@keyframes stt-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.stt-stop-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 4px 14px;
  font-size: 13px;
  cursor: pointer;
}
.stt-stop-btn:active { transform: scale(0.95); }

/* --- Warming indicator --- */
.warming-indicator {
  padding: 4px 0;
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
}

/* --- Image preview strip --- */
#image-preview-strip {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
}
#image-preview-strip.hidden { display: none; }

.preview-thumb {
  position: relative;
  flex-shrink: 0;
}
.preview-thumb img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.preview-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--danger);
  color: white;
  border: none;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- User message images --- */
.msg-images {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.msg-image-thumb {
  max-width: 200px;
  max-height: 200px;
  border-radius: 8px;
  object-fit: contain;
}

/* --- File chips (text/markdown attachments) --- */
.preview-file-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 28px 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--fg);
  white-space: nowrap;
  flex-shrink: 0;
}
.preview-file-chip .file-icon { font-size: 16px; }
.msg-files {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.msg-file-chip {
  display: inline-block;
  padding: 3px 8px;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--fg-dim, var(--fg));
}

/* --- Drag-drop overlay --- */
#chat-view.drag-over::after {
  content: "Drop file here";
  position: absolute;
  inset: 0;
  background: rgba(74, 158, 255, 0.08);
  border: 2px dashed var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--accent);
  z-index: 10;
  pointer-events: none;
}

/* --- Briefing card (pinned) --- */
.briefing-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border: 1px solid rgba(74, 255, 122, 0.35);
  background: rgba(74, 255, 122, 0.06);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.briefing-card-content {
  flex: 1;
  min-width: 0;
}

.briefing-card-title {
  font-weight: 700;
  font-size: 13px;
  color: #4aff7a;
  margin-bottom: 4px;
}

.briefing-card-body {
  font-size: 13px;
  color: var(--text-dim);
  max-height: 400px;
  overflow-y: auto;
}
.briefing-card-body h1,
.briefing-card-body h2,
.briefing-card-body h3 { font-size: 14px; font-weight: 600; margin: 10px 0 4px; color: var(--text); }
.briefing-card-body h1 { font-size: 15px; }
.briefing-card-body p { margin: 4px 0; }
.briefing-card-body ul, .briefing-card-body ol { padding-left: 20px; margin: 4px 0; }
.briefing-card-body li { margin: 2px 0; }
.briefing-card-body a { color: #4fc3f7; }
.briefing-card-body code { background: rgba(255,255,255,0.08); padding: 1px 4px; border-radius: 3px; font-size: 12px; }
.briefing-card-body pre { background: #161622; border-radius: 6px; padding: 8px; overflow-x: auto; margin: 6px 0; position: relative; }
.briefing-card-body pre code { background: none; padding: 0; font-size: 12px; }
.briefing-card-body strong { color: var(--text); }

.briefing-card-dismiss,
.card-dismiss {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
}

.briefing-card-dismiss:hover,
.card-dismiss:hover {
  color: var(--text);
}

/* Position dismiss button in inline cards (task, bookmark, approval, tweet) */
.task-card,
.bookmark-card,
.approval-card,
.tweet-card {
  position: relative;
}

.task-card > .card-dismiss,
.bookmark-card > .card-dismiss,
.approval-card > .card-dismiss,
.tweet-card > .card-dismiss {
  position: absolute;
  top: 4px;
  right: 4px;
  opacity: 0.4;
  transition: opacity 0.15s;
}

.task-card:hover > .card-dismiss,
.bookmark-card:hover > .card-dismiss,
.approval-card:hover > .card-dismiss,
.tweet-card:hover > .card-dismiss {
  opacity: 1;
}

/* --- Tasks button --- */
.tasks-btn {
  position: relative;
  margin-left: 4px;
}

.tasks-btn svg {
  display: block;
}

/* --- Task cards (inline in chat) --- */
.task-card {
  border-radius: 10px;
  padding: 10px;
  margin: 8px 0;
}

.task-card.task-created,
.task-card.task-updated {
  border: 1px solid rgba(74, 158, 255, 0.4);
  background: rgba(74, 158, 255, 0.06);
}

.task-card.task-completed {
  border: 1px solid rgba(74, 255, 122, 0.4);
  background: rgba(74, 255, 122, 0.06);
}

.task-card.task-deleted {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.task-card.task-due-soon {
  border: 1px solid rgba(255, 201, 90, 0.45);
  background: rgba(255, 201, 90, 0.07);
}

.task-card.task-overdue {
  border: 1px solid rgba(255, 74, 106, 0.45);
  background: rgba(255, 74, 106, 0.07);
}

.task-card-label {
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}

.task-created .task-card-label,
.task-updated .task-card-label { color: var(--accent); }
.task-completed .task-card-label { color: #4aff7a; }
.task-deleted .task-card-label { color: var(--text-dim); }
.task-due-soon .task-card-label { color: #ffd474; }
.task-overdue .task-card-label { color: #ff5a6b; }

.task-card-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
}

.task-card-meta {
  display: flex;
  gap: 10px;
  font-size: 12px;
  color: var(--text-dim);
}

.task-priority-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.task-priority-badge.high {
  background: rgba(255, 74, 106, 0.15);
  color: #ff5a6b;
}

.task-priority-badge.low {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
}

/* --- Bookmark cards --- */
.bookmark-card {
  border-radius: 10px;
  padding: 10px;
  margin: 8px 0;
}
.bookmark-card.bookmark-created {
  border: 1px solid rgba(138, 92, 246, 0.4);
  background: rgba(138, 92, 246, 0.06);
}
.bookmark-card.bookmark-updated {
  border: 1px solid rgba(74, 158, 255, 0.4);
  background: rgba(74, 158, 255, 0.06);
}
.bookmark-card.bookmark-deleted {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}
.bookmark-card-label {
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
  color: #8a5cf6;
}
.bookmark-deleted .bookmark-card-label { color: var(--text-dim); }
.bookmark-card-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
}
.bookmark-card-url {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.bookmark-card-url a {
  color: var(--accent);
  text-decoration: none;
}
.bookmark-card-url a:hover { text-decoration: underline; }
.bookmark-card-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.bookmark-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(138, 92, 246, 0.15);
  color: #a78bfa;
}

/* --- Bookmarks panel overlay --- */
#bookmarks-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
}
#bookmarks-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(90vw, 460px);
  max-height: 60vh;
  overflow-y: auto;
  padding: 16px;
}
#bookmarks-panel h3 {
  font-size: 16px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.bookmarks-panel-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.bookmarks-panel-item:last-child { border-bottom: none; }
.bookmarks-panel-title {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
}
.bookmarks-panel-title:hover { color: var(--accent); }
.bookmarks-panel-host {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}
.bookmarks-panel-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.bookmarks-panel-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 20px 0;
}

/* --- Tweet draft cards --- */
.tweet-card {
  border: 1px solid rgba(29, 161, 242, 0.4);
  background: rgba(29, 161, 242, 0.07);
  border-radius: 10px;
  padding: 10px;
  margin: 8px 0;
}
.tweet-card-posted {
  border-color: rgba(74, 255, 122, 0.4);
  background: rgba(74, 255, 122, 0.07);
}
.tweet-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.tweet-card-label {
  font-weight: 700;
  font-size: 13px;
  color: #1da1f2;
}
.tweet-card-posted .tweet-card-label { color: #4aff7a; }
.tweet-card-chars {
  font-size: 11px;
  color: var(--text-dim);
}
.tweet-card-text {
  font-size: 14px;
  white-space: pre-wrap;
  margin-bottom: 8px;
  line-height: 1.4;
}
.tweet-card-edit {
  width: 100%;
  min-height: 80px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 8px;
  line-height: 1.4;
  box-sizing: border-box;
}
.tweet-card-actions {
  display: flex;
  gap: 8px;
}
.tweet-card-actions button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.tweet-card-actions button:hover { background: var(--hover); }
.tweet-btn-publish {
  background: rgba(29, 161, 242, 0.2) !important;
  border-color: rgba(29, 161, 242, 0.5) !important;
}
.tweet-btn-publish:hover { background: rgba(29, 161, 242, 0.35) !important; }
.tweet-card-actions button:disabled { opacity: 0.5; cursor: not-allowed; }
.tweet-card-status {
  font-size: 12px;
  margin-top: 6px;
  font-weight: 600;
}
.tweet-status-pending { color: var(--text-dim); }
.tweet-status-posted { color: #4aff7a; }
.tweet-status-error { color: #ff5a6b; }

/* --- Task panel (overlay) --- */
#tasks-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 90;
}

#tasks-panel {
  position: absolute;
  top: 54px;
  right: 14px;
  width: min(420px, calc(100vw - 24px));
  max-height: min(70vh, 560px);
  overflow-y: auto;
  border: 1px solid var(--border);
  background: #101018;
  border-radius: 12px;
  padding: 10px;
}

#tasks-panel h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 10px 4px;
  color: var(--text);
}

.tasks-panel-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.tasks-panel-item:last-child {
  margin-bottom: 0;
}

.tasks-panel-item.overdue {
  border-color: rgba(255, 74, 106, 0.4);
  background: rgba(255, 74, 106, 0.04);
}

.tasks-panel-title {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
}

.tasks-panel-due {
  font-size: 12px;
  color: var(--text-dim);
}

.tasks-panel-due.overdue {
  color: #ff5a6b;
}

.tasks-panel-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 20px 0;
}

/* --- Replay banner --- */
.replay-banner {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 8px 0;
  animation: think-pulse 1s ease-in-out infinite;
}

/* --- Responsive --- */
@media (max-width: 600px) {
  .msg { max-width: 95%; }
  .tool-input-summary { max-width: 150px; }
}
