:root {
  color-scheme: light dark;
  --bg: #0f172a;
  --bg-alt: #1e293b;
  --panel: #111827;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --border: rgba(148, 163, 184, 0.2);
  --danger: #f87171;
  --success: #22c55e;
  font-family: "Inter", "Dubai", "Noto Sans Arabic", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(145deg, #0f172a 0%, #1e293b 45%, #0f172a 100%);
  color: var(--text);
  display: flex;
  justify-content: center;
  padding: 16px;
}

body.editor-open {
  overflow: hidden;
}
body.ssh-open {
  overflow: hidden;
}

.app-shell {
  width: min(1080px, 100%);
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--border);
  border-radius: 24px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  backdrop-filter: blur(12px);
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.45);
  overflow: hidden;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.95);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ssh-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.65);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.ssh-indicator.connected {
  border-color: rgba(34, 197, 94, 0.4);
  color: var(--text);
}

.ssh-indicator .dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--danger);
  display: inline-block;
}

.ssh-indicator .dot.online {
  background: var(--success);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-mark {
  font-size: 2rem;
}

.brand h1 {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: 0.02em;
}

.tagline {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.ghost-button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, border 0.2s ease;
}

.ghost-button:hover {
  background: rgba(148, 163, 184, 0.12);
  border-color: rgba(148, 163, 184, 0.4);
}

.chat-area {
  overflow-y: auto;
  padding: 24px;
  scrollbar-width: thin;
}

.chat-area::-webkit-scrollbar {
  width: 8px;
}

.chat-area::-webkit-scrollbar-thumb {
  background-color: rgba(148, 163, 184, 0.35);
  border-radius: 10px;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.status-tracker {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 18px;
  padding: 16px;
  background: rgba(15, 23, 42, 0.7);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.08);
}

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

.status-header h2 {
  margin: 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.status-header p {
  margin: 4px 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.virtual-desktop-panel {
  position: fixed;
  z-index: 9000;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 14px;
  padding: 0;
  background: rgba(15, 23, 42, 0.96);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(148, 163, 184, 0.1);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 320px;
  min-height: 220px;
  transition: box-shadow 0.2s ease;
}
.virtual-desktop-panel:hover {
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(56, 189, 248, 0.2);
}
.virtual-desktop-panel[data-maximized="true"] {
  border-radius: 0;
  width: auto !important;
  height: auto !important;
}
.virtual-desktop-panel[hidden] {
  display: none;
}

.virtual-desktop-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(30, 41, 59, 0.9);
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  cursor: default;
  user-select: none;
}
.virtual-desktop-drag-handle {
  cursor: grab;
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  transition: background 0.15s;
}
.virtual-desktop-drag-handle:hover {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text);
}
.virtual-desktop-drag-handle:active {
  cursor: grabbing;
}
.virtual-desktop-window-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.window-control-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.window-control-btn:hover {
  background: rgba(148, 163, 184, 0.2);
  color: var(--text);
}
.window-control-btn.close-btn:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #f87171;
}
.virtual-desktop-resize-handle {
  position: absolute;
  bottom: 2px;
  right: 6px;
  cursor: nwse-resize;
  font-size: 1rem;
  color: var(--text-muted);
  opacity: 0.5;
  transition: opacity 0.15s;
  user-select: none;
  line-height: 1;
}
.virtual-desktop-resize-handle:hover {
  opacity: 1;
  color: var(--accent);
}
.virtual-desktop-dock-btn {
  position: fixed;
  bottom: 90px;
  right: 24px;
  z-index: 8999;
  padding: 14px 24px;
  border: 2px solid rgba(56, 189, 248, 0.6);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.97), rgba(30, 58, 95, 0.95));
  color: #38bdf8;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(56, 189, 248, 0.25), 0 0 12px rgba(56, 189, 248, 0.15);
  backdrop-filter: blur(12px);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  animation: vd-dock-pulse 2.5s ease-in-out infinite;
}
@keyframes vd-dock-pulse {
  0%, 100% { box-shadow: 0 8px 32px rgba(56, 189, 248, 0.25), 0 0 12px rgba(56, 189, 248, 0.15); }
  50% { box-shadow: 0 8px 40px rgba(56, 189, 248, 0.4), 0 0 20px rgba(56, 189, 248, 0.3); }
}
.virtual-desktop-dock-btn:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 12px 40px rgba(56, 189, 248, 0.4), 0 0 24px rgba(56, 189, 248, 0.3);
  border-color: rgba(56, 189, 248, 0.8);
  animation: none;
}
.virtual-desktop-dock-btn[hidden] {
  display: none;
}

.virtual-desktop-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.virtual-desktop-icon {
  font-size: 1.3rem;
}

.virtual-desktop-title h2 {
  margin: 0;
  font-size: 1rem;
}

.virtual-desktop-title p {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.virtual-desktop-indicator {
  border-radius: 999px;
  padding: 6px 14px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  font-size: 0.85rem;
  color: var(--text-muted);
  background: rgba(15, 23, 42, 0.6);
}

.virtual-desktop-indicator[data-state="connected"] {
  border-color: rgba(34, 197, 94, 0.4);
  color: var(--text);
}

.virtual-desktop-indicator[data-state="error"] {
  border-color: rgba(248, 113, 113, 0.5);
  color: var(--danger);
}

.virtual-desktop-toolbar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}

.virtual-desktop-toolbar .ghost-button {
  padding: 5px 12px;
  font-size: 0.82rem;
}

.virtual-desktop-viewport {
  position: relative;
  flex: 1;
  overflow: hidden;
  min-height: 120px;
  background: rgba(15, 23, 42, 0.6);
}

.virtual-desktop-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.virtual-desktop-placeholder[hidden] {
  display: none;
}

.virtual-desktop-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #000;
}

.virtual-desktop-iframe[hidden] {
  display: none;
}

.status-current {
  display: flex;
  align-items: center;
  gap: 14px;
}

.status-icon {
  font-size: 1.5rem;
}

.status-copy {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-message {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.status-progress {
  position: relative;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
  overflow: hidden;
}

.status-progress-bar {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 0.25s ease;
}

.status-timeline {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-timeline li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.status-timeline li span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.2);
}

.status-entry-text {
  flex: 1;
  color: var(--text-muted);
}

.message {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: flex-start;
}

.message.user {
  flex-direction: row-reverse;
}

.message.user .message-body {
  background: rgba(56, 189, 248, 0.12);
  border-radius: 16px 16px 4px 16px;
}

.message.assistant .message-body {
  background: rgba(30, 41, 59, 0.95);
  border-radius: 16px 16px 16px 4px;
}

.message .avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.2);
  display: grid;
  place-items: center;
  font-size: 1.4rem;
}

.message.user .avatar {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent);
}

.message.assistant .avatar {
  background: rgba(16, 185, 129, 0.18);
}

.message-body {
  padding: 16px 18px;
  border: 1px solid rgba(148, 163, 184, 0.1);
  width: 100%;
}

.message-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.stage-badge {
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-muted);
}

.message[data-stage="plan"] .stage-badge {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.4);
  color: var(--accent);
}

.message[data-stage="result"] .stage-badge {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.35);
  color: var(--success);
}

.message[data-stage="plan"] .message-body {
  border-color: rgba(56, 189, 248, 0.35);
}

.message[data-stage="result"] .message-body {
  border-color: rgba(34, 197, 94, 0.35);
}

.message-content {
  color: var(--text);
  line-height: 1.6;
  font-size: 0.97rem;
}

.message-content pre {
  background: #0f172a;
  border-radius: 12px;
  padding: 14px;
  overflow: auto;
  border: 1px solid rgba(148, 163, 184, 0.15);
}

.message-content code {
  font-family: "JetBrains Mono", "Fira Code", "Courier New", monospace;
  font-size: 0.9em;
}

.message-files {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.message-files li {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(148, 163, 184, 0.12);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8rem;
}

.message-files a {
  color: var(--accent);
  text-decoration: none;
}

.message-attachments {
  margin-top: 12px;
}

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

.attachment-card {
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.7);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.attachment-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.attachment-size {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.attachment-preview {
  border: 1px solid rgba(148, 163, 184, 0.15);
  background: rgba(15, 23, 42, 0.55);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 120px;
  max-height: 320px;
  overflow: hidden;
}

.attachment-preview img {
  width: 100%;
  height: auto;
  border-radius: 10px;
  object-fit: contain;
  max-height: 296px;
}

.attachment-preview pre {
  margin: 0;
  width: 100%;
  max-height: 284px;
  overflow: auto;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: "JetBrains Mono", "Fira Code", "Courier New", monospace;
  font-size: 0.85rem;
  white-space: pre-wrap;
}

.attachment-placeholder {
  color: var(--text-muted);
  font-size: 0.85rem;
}

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

.attachment-button {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(148, 163, 184, 0.12);
  color: var(--text);
  cursor: pointer;
  font-size: 0.75rem;
  line-height: 1.2;
  transition: background 0.2s ease, border 0.2s ease, transform 0.2s ease;
}

.attachment-button:hover {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.35);
  transform: translateY(-1px);
}

.attachment-button:disabled {
  opacity: 0.55;
  cursor: progress;
  transform: none;
}

.message-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.message-action {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(15, 23, 42, 0.6);
  color: var(--text);
  cursor: pointer;
  font-size: 0.75rem;
  transition: background 0.2s ease, border 0.2s ease;
}

.message-action:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.32);
}

.attachments-panel {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(15, 23, 42, 0.85);
}

.attachments-panel h2 {
  margin: 0;
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.pending-files {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.pending-files li {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.24);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.remove-file {
  border: none;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font-size: 1rem;
}

.composer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: flex-end;
  gap: 12px;
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.95);
}

.composer textarea {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 16px;
  padding: 12px 16px;
  color: var(--text);
  resize: none;
  font-size: 1rem;
  line-height: 1.4;
  max-height: 220px;
  min-height: 48px;
  transition: border 0.2s ease, background 0.2s ease;
}

.composer textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(14, 116, 144, 0.2);
}

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.7);
  color: var(--text);
  cursor: pointer;
  font-size: 1.2rem;
  display: grid;
  place-items: center;
  transition: background 0.2s ease, border 0.2s ease;
}

.icon-button:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.4);
}

.icon-button.subtle {
  width: 36px;
  height: 36px;
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.4rem;
}

.icon-button.subtle:hover {
  background: rgba(148, 163, 184, 0.12);
  border-color: rgba(148, 163, 184, 0.12);
  color: var(--text);
}

.primary-button {
  padding: 12px 20px;
  border-radius: 16px;
  border: none;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: var(--bg);
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.primary-button:disabled {
  opacity: 0.6;
  cursor: progress;
  box-shadow: none;
}

.primary-button:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(56, 189, 248, 0.35);
}

.composer-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.task-stop-button {
  min-width: 48px;
  min-height: 48px;
  padding: 10px 14px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.task-stop-button[hidden] {
  display: none !important;
}

.task-stop-button:disabled {
  opacity: 0.65;
  cursor: progress;
}

.message.user[data-delivery-status] .timestamp::after {
  content: " · " attr(data-delivery-label);
  color: var(--text-muted);
  font-size: 0.78rem;
}

.message.user[data-delivery-status="sending"] .timestamp::after {
  color: var(--accent);
  animation: rosh-delivery-pulse 1s ease-in-out infinite;
}

.message.user[data-delivery-status="failed"] .timestamp::after {
  color: #f87171;
}

@keyframes rosh-delivery-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

.editor-panel {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.78);
  display: grid;
  place-items: center;
  z-index: 2000;
  padding: 24px;
}

.editor-dialog {
  width: min(760px, 100%);
  max-height: 90vh;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.65);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 16px;
  padding: 22px;
}

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

.editor-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.editor-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.editor-filename {
  font-weight: 600;
  color: var(--text);
}

.editor-size {
  opacity: 0.8;
}

#editorTextarea {
  width: 100%;
  min-height: 320px;
  max-height: calc(80vh - 200px);
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.7);
  color: var(--text);
  font-family: "JetBrains Mono", "Fira Code", "Courier New", monospace;
  font-size: 0.95rem;
  line-height: 1.5;
  padding: 16px;
  resize: vertical;
}

.editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.editor-actions .ghost-button {
  min-width: 120px;
}

.editor-actions .primary-button {
  min-width: 200px;
}

.ssh-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.8);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 2100;
}

.ssh-dialog {
  width: min(480px, 100%);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.65);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
}

.ssh-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.ssh-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.ssh-subtitle {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.ssh-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ssh-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.ssh-form input,
.ssh-form select,
.ssh-form textarea {
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.7);
  color: var(--text);
  padding: 10px 12px;
  font-size: 1rem;
}

.ssh-form input:focus,
.ssh-form select:focus,
.ssh-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.ssh-status {
  min-height: 20px;
  margin: 0;
  font-size: 0.85rem;
  color: var(--danger);
}

.ssh-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

@media (max-width: 768px) {
  body {
    padding: 8px;
  }

  .app-shell {
    border-radius: 18px;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .composer {
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .virtual-desktop-panel {
    border-radius: 14px;
    padding: 12px;
  }

  .virtual-desktop-toolbar {
    flex-direction: column;
  }

  .composer textarea {
    grid-column: 1 / -1;
  }

  .composer-actions {
    grid-column: 1 / -1;
    width: 100%;
  }

  .composer-actions > button {
    flex: 1 1 0;
  }

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

  .editor-dialog {
    width: 100%;
    padding: 18px;
    gap: 14px;
  }

  #editorTextarea {
    min-height: 240px;
  }
}

[dir="rtl"] .message {
  grid-template-columns: 1fr auto;
}

[dir="rtl"] .message.assistant .message-body {
  border-radius: 16px 16px 4px 16px;
}

[dir="rtl"] .message.user .message-body {
  border-radius: 16px 16px 16px 4px;
}

/* Fix: respect hidden attribute on ssh-modal */
.ssh-modal[hidden] { display: none !important; }

/* Fix: respect hidden attribute on editor-panel */
.editor-panel[hidden] { display: none !important; }

/* ============================================================
   RoSH Agent AI - Manus-Style Stage Blocks & Enhanced Chat UI
   ============================================================ */

/* Agent Stage Blocks - Manus-style collapsible steps */
.agent-stage-block {
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.5);
  overflow: hidden;
  transition: border-color 0.3s ease, background 0.3s ease;
  margin: 4px 0;
}

.agent-stage-block:hover {
  border-color: rgba(148, 163, 184, 0.22);
}

.agent-stage-block .stage-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  text-align: left;
  transition: background 0.2s ease;
}

.agent-stage-block .stage-header:hover {
  background: rgba(148, 163, 184, 0.06);
}

.agent-stage-block .stage-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.agent-stage-block .stage-title {
  flex: 1;
  color: var(--text);
  line-height: 1.4;
}

.agent-stage-block .stage-toggle-icon {
  color: var(--text-muted);
  font-size: 0.85rem;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.agent-stage-block .stage-body {
  padding: 0 16px 14px;
  transition: max-height 0.3s ease, opacity 0.3s ease;
}

.agent-stage-block.collapsed .stage-body {
  display: none;
}

.agent-stage-block .stage-content {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-muted);
  word-break: break-word;
}

.agent-stage-block .stage-content pre {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 10px;
  padding: 12px;
  overflow-x: auto;
  font-size: 0.82rem;
  margin: 8px 0;
}

.agent-stage-block .stage-content code {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 0.85em;
}

/* Thinking blocks - blue accent */
.thinking-block {
  border-left: 3px solid rgba(56, 189, 248, 0.5);
}

.thinking-block .stage-icon {
  color: var(--accent);
}

.thinking-block .stage-title {
  color: var(--accent);
}

/* Tool call blocks - amber accent */
.tool-call-block {
  border-left: 3px solid rgba(251, 191, 36, 0.5);
}

.tool-call-block .stage-icon {
  color: #fbbf24;
}

/* Tool result blocks - compact and collapsible */
.tool-result-block {
  border-left: 3px solid rgba(34, 197, 94, 0.4);
}

.tool-result-block[data-status="failed"] {
  border-left-color: rgba(248, 113, 113, 0.5);
}

.tool-result-block .stage-content {
  font-size: 0.82rem;
}

/* Compact stage (tool results auto-collapse) */
.compact-stage .stage-header {
  padding: 8px 14px;
  font-size: 0.82rem;
}

.compact-stage .stage-body {
  padding: 0 14px 10px;
}

/* Observation blocks */
.observation-block {
  border-left: 3px solid rgba(168, 85, 247, 0.4);
}

/* Completed stages get a subtle checkmark feel */
.agent-stage-block.completed .stage-header {
  opacity: 0.85;
}

.agent-stage-block.completed .stage-title {
  color: var(--text-muted);
}

/* Status tracker improvements */
.status-tracker {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.8), rgba(30, 41, 59, 0.6));
  border: 1px solid rgba(56, 189, 248, 0.15);
}

.status-tracker[data-state="succeeded"] {
  border-color: rgba(34, 197, 94, 0.25);
}

.status-tracker[data-state="failed"] {
  border-color: rgba(248, 113, 113, 0.25);
}

/* Improved progress bar animation */
.status-progress-bar {
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Smooth typing indicator */
@keyframes typing-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

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

.typing-indicator .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: typing-pulse 1.4s ease-in-out infinite;
}

.typing-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator .dot:nth-child(3) { animation-delay: 0.4s; }

/* Improved message content markdown rendering */
.message-content h1,
.message-content h2,
.message-content h3 {
  margin: 16px 0 8px;
  color: var(--text);
}

.message-content h1 { font-size: 1.3rem; }
.message-content h2 { font-size: 1.15rem; }
.message-content h3 { font-size: 1.05rem; }

.message-content ul,
.message-content ol {
  padding-left: 20px;
  margin: 8px 0;
}

.message-content li {
  margin: 4px 0;
  line-height: 1.5;
}

.message-content blockquote {
  border-left: 3px solid var(--accent);
  margin: 12px 0;
  padding: 8px 16px;
  background: rgba(56, 189, 248, 0.06);
  border-radius: 0 10px 10px 0;
  color: var(--text-muted);
}

.message-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.88rem;
}

.message-content th,
.message-content td {
  padding: 8px 12px;
  border: 1px solid rgba(148, 163, 184, 0.15);
  text-align: left;
}

.message-content th {
  background: rgba(56, 189, 248, 0.08);
  font-weight: 600;
}

.message-content a {
  color: var(--accent);
  text-decoration: none;
}

.message-content a:hover {
  text-decoration: underline;
}

.message-content img {
  max-width: 100%;
  border-radius: 10px;
  margin: 8px 0;
}

/* Improved chat area scrollbar */
.chat-area {
  scroll-behavior: smooth;
}

/* RTL improvements for stage blocks */
[dir="rtl"] .agent-stage-block .stage-header {
  text-align: right;
}

[dir="rtl"] .thinking-block {
  border-left: none;
  border-right: 3px solid rgba(56, 189, 248, 0.5);
}

[dir="rtl"] .tool-call-block {
  border-left: none;
  border-right: 3px solid rgba(251, 191, 36, 0.5);
}

[dir="rtl"] .tool-result-block {
  border-left: none;
  border-right: 3px solid rgba(34, 197, 94, 0.4);
}

[dir="rtl"] .tool-result-block[data-status="failed"] {
  border-left: none;
  border-right-color: rgba(248, 113, 113, 0.5);
}

[dir="rtl"] .observation-block {
  border-left: none;
  border-right: 3px solid rgba(168, 85, 247, 0.4);
}

[dir="rtl"] .message-content blockquote {
  border-left: none;
  border-right: 3px solid var(--accent);
  border-radius: 10px 0 0 10px;
}

/* Mobile improvements */
@media (max-width: 768px) {
  .agent-stage-block .stage-header {
    padding: 10px 12px;
    font-size: 0.82rem;
  }

  .agent-stage-block .stage-body {
    padding: 0 12px 10px;
  }

  .agent-stage-block .stage-content {
    font-size: 0.8rem;
  }
}

/* ═══════════════════════════════════════════════════════════
   TASK PIPELINE UI - Manus-style execution visualization
   Added: 2026-05-12 - Frontend only patch
   ═══════════════════════════════════════════════════════════ */

/* Pipeline container */
.task-pipeline {
  position: relative;
  margin: 12px 0;
  padding: 0;
}

/* Pipeline phase (main stage) */
.pipeline-phase {
  position: relative;
  margin: 0;
  padding: 0 0 0 32px;
}

/* Vertical connecting line */
.pipeline-phase::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 28px;
  bottom: 0;
  width: 2px;
  background: rgba(148, 163, 184, 0.15);
  transition: background 0.4s ease;
}

.pipeline-phase:last-child::before {
  display: none;
}

.pipeline-phase.phase-active::before {
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.6), rgba(56, 189, 248, 0.1));
}

.pipeline-phase.phase-completed::before {
  background: rgba(34, 197, 94, 0.3);
}

/* Phase node (circle indicator) */
.pipeline-phase-node {
  position: absolute;
  left: 4px;
  top: 8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(30, 41, 59, 0.8);
  border: 2px solid rgba(148, 163, 184, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: all 0.3s ease;
}

.pipeline-phase.phase-active .pipeline-phase-node {
  border-color: rgba(56, 189, 248, 0.8);
  background: rgba(56, 189, 248, 0.15);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.3);
}

.pipeline-phase.phase-completed .pipeline-phase-node {
  border-color: rgba(34, 197, 94, 0.8);
  background: rgba(34, 197, 94, 0.15);
}

.pipeline-phase.phase-failed .pipeline-phase-node {
  border-color: rgba(248, 113, 113, 0.8);
  background: rgba(248, 113, 113, 0.15);
}

/* Spinner animation for active phase */
.pipeline-phase.phase-active .pipeline-phase-node::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: rgba(56, 189, 248, 0.8);
  animation: pipeline-spin 1s linear infinite;
}

@keyframes pipeline-spin {
  to { transform: rotate(360deg); }
}

/* Checkmark for completed */
.pipeline-phase.phase-completed .pipeline-phase-node::after {
  content: "\2713";
  font-size: 9px;
  color: rgba(34, 197, 94, 0.9);
  font-weight: bold;
  animation: none;
}

/* X for failed */
.pipeline-phase.phase-failed .pipeline-phase-node::after {
  content: "\2715";
  font-size: 9px;
  color: rgba(248, 113, 113, 0.9);
  font-weight: bold;
  animation: none;
}

/* Phase header */
.pipeline-phase-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  cursor: pointer;
  user-select: none;
}

.pipeline-phase-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  transition: color 0.3s ease;
}

.pipeline-phase.phase-active .pipeline-phase-title {
  color: rgba(56, 189, 248, 0.95);
}

.pipeline-phase.phase-completed .pipeline-phase-title {
  color: rgba(148, 163, 184, 0.7);
}

.pipeline-phase-toggle {
  font-size: 0.7rem;
  color: var(--text-muted, #94a3b8);
  transition: transform 0.2s ease;
  margin-left: auto;
}

.pipeline-phase.phase-collapsed .pipeline-phase-toggle {
  transform: rotate(-90deg);
}

/* Phase status badge */
.pipeline-phase-status {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.pipeline-phase.phase-active .pipeline-phase-status {
  background: rgba(56, 189, 248, 0.12);
  color: rgba(56, 189, 248, 0.9);
}

.pipeline-phase.phase-completed .pipeline-phase-status {
  background: rgba(34, 197, 94, 0.1);
  color: rgba(34, 197, 94, 0.8);
}

/* Phase body (sub-steps) */
.pipeline-phase-body {
  padding: 4px 0 12px 0;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  max-height: 2000px;
  opacity: 1;
}

.pipeline-phase.phase-collapsed .pipeline-phase-body {
  max-height: 0;
  opacity: 0;
  padding: 0;
  overflow: hidden;
}

/* Phase description text */
.pipeline-phase-desc {
  font-size: 0.8rem;
  color: var(--text-muted, #94a3b8);
  padding: 2px 0 6px 0;
  line-height: 1.4;
  display: none;
}

/* Sub-step items - rounded chips */
.pipeline-step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  margin: 3px 4px;
  border-radius: 16px;
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.1);
  transition: all 0.2s ease;
  font-size: 0.8rem;
}

.pipeline-step:hover {
  background: rgba(148, 163, 184, 0.12);
}

.pipeline-step-icon {
  font-size: 0.75rem;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  font-family: monospace;
}

.pipeline-step-text {
  font-size: 0.8rem;
  color: var(--text-muted, #94a3b8);
  line-height: 1.4;
}

.pipeline-step.step-active {
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.2);
}

.pipeline-step.step-active .pipeline-step-text {
  color: var(--text, #e2e8f0);
}

.pipeline-step.step-active .pipeline-step-icon {
  animation: pulse-icon 1.5s ease-in-out infinite;
}

.pipeline-step.step-done {
  border-color: rgba(34, 197, 94, 0.15);
}

.pipeline-step.step-done .pipeline-step-icon {
  color: rgba(34, 197, 94, 0.8);
}

.pipeline-step.step-failed {
  border-color: rgba(248, 113, 113, 0.2);
}

.pipeline-step.step-failed .pipeline-step-icon {
  color: rgba(248, 113, 113, 0.8);
}

/* Completion banner */
.pipeline-completion {
  margin: 16px 0 8px 0;
  padding: 14px 18px;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.08), rgba(56, 189, 248, 0.05));
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slide-in-completion 0.4s ease;
}

@keyframes slide-in-completion {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.pipeline-completion-icon {
  font-size: 1.4rem;
}

.pipeline-completion-text {
  font-size: 0.88rem;
  font-weight: 500;
  color: rgba(34, 197, 94, 0.9);
}

.pipeline-completion-detail {
  font-size: 0.78rem;
  color: var(--text-muted, #94a3b8);
  margin-top: 2px;
}

/* RTL support */
[dir="rtl"] .pipeline-phase {
  padding: 0 32px 0 0;
}

[dir="rtl"] .pipeline-phase::before {
  left: auto;
  right: 11px;
}

[dir="rtl"] .pipeline-phase-node {
  left: auto;
  right: 4px;
}

[dir="rtl"] .pipeline-phase-toggle {
  margin-left: 0;
  margin-right: auto;
}

/* Hide old stage blocks when pipeline is active */
.task-pipeline ~ .agent-stage-block {
  display: none;
}

/* Mobile improvements */
@media (max-width: 768px) {
  .pipeline-phase {
    padding: 0 0 0 24px;
  }
  .pipeline-phase-node {
    left: 2px;
    width: 14px;
    height: 14px;
  }
  .pipeline-step {
    font-size: 0.75rem;
    padding: 3px 10px;
  }
}


/* ═══════════════════════════════════════════════════════════
   TASK PIPELINE UI - Manus-style execution visualization
   Added: 2026-05-12 - Frontend only patch
   ═══════════════════════════════════════════════════════════ */

/* Pipeline container */
.task-pipeline {
  position: relative;
  margin: 12px 0;
  padding: 0;
}

/* Pipeline phase (main stage) */
.pipeline-phase {
  position: relative;
  margin: 0;
  padding: 0 0 0 32px;
}

/* Vertical connecting line */
.pipeline-phase::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 28px;
  bottom: 0;
  width: 2px;
  background: rgba(148, 163, 184, 0.15);
  transition: background 0.4s ease;
}

.pipeline-phase:last-child::before {
  display: none;
}

.pipeline-phase.phase-active::before {
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.6), rgba(56, 189, 248, 0.1));
}

.pipeline-phase.phase-completed::before {
  background: rgba(34, 197, 94, 0.3);
}

/* Phase node (circle indicator) */
.pipeline-phase-node {
  position: absolute;
  left: 4px;
  top: 8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(30, 41, 59, 0.8);
  border: 2px solid rgba(148, 163, 184, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: all 0.3s ease;
}

.pipeline-phase.phase-active .pipeline-phase-node {
  border-color: rgba(56, 189, 248, 0.8);
  background: rgba(56, 189, 248, 0.15);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.3);
}

.pipeline-phase.phase-completed .pipeline-phase-node {
  border-color: rgba(34, 197, 94, 0.8);
  background: rgba(34, 197, 94, 0.15);
}

.pipeline-phase.phase-failed .pipeline-phase-node {
  border-color: rgba(248, 113, 113, 0.8);
  background: rgba(248, 113, 113, 0.15);
}

/* Spinner animation for active phase */
.pipeline-phase.phase-active .pipeline-phase-node::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: rgba(56, 189, 248, 0.8);
  animation: pipeline-spin 1s linear infinite;
}

@keyframes pipeline-spin {
  to { transform: rotate(360deg); }
}

/* Checkmark for completed */
.pipeline-phase.phase-completed .pipeline-phase-node::after {
  content: "\2713";
  font-size: 9px;
  color: rgba(34, 197, 94, 0.9);
  font-weight: bold;
  animation: none;
}

/* X for failed */
.pipeline-phase.phase-failed .pipeline-phase-node::after {
  content: "\2715";
  font-size: 9px;
  color: rgba(248, 113, 113, 0.9);
  font-weight: bold;
  animation: none;
}

/* Phase header */
.pipeline-phase-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  cursor: pointer;
  user-select: none;
}

.pipeline-phase-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  transition: color 0.3s ease;
}

.pipeline-phase.phase-active .pipeline-phase-title {
  color: rgba(56, 189, 248, 0.95);
}

.pipeline-phase.phase-completed .pipeline-phase-title {
  color: rgba(148, 163, 184, 0.7);
}

.pipeline-phase-toggle {
  font-size: 0.7rem;
  color: var(--text-muted, #94a3b8);
  transition: transform 0.2s ease;
  margin-left: auto;
}

.pipeline-phase.phase-collapsed .pipeline-phase-toggle {
  transform: rotate(-90deg);
}

/* Phase status badge */
.pipeline-phase-status {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.pipeline-phase.phase-active .pipeline-phase-status {
  background: rgba(56, 189, 248, 0.12);
  color: rgba(56, 189, 248, 0.9);
}

.pipeline-phase.phase-completed .pipeline-phase-status {
  background: rgba(34, 197, 94, 0.1);
  color: rgba(34, 197, 94, 0.8);
}

/* Phase body (sub-steps) */
.pipeline-phase-body {
  padding: 4px 0 12px 0;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  max-height: 2000px;
  opacity: 1;
}

.pipeline-phase.phase-collapsed .pipeline-phase-body {
  max-height: 0;
  opacity: 0;
  padding: 0;
  overflow: hidden;
}

/* Phase description text */
.pipeline-phase-desc {
  font-size: 0.8rem;
  color: var(--text-muted, #94a3b8);
  padding: 2px 0 6px 0;
  line-height: 1.4;
  display: none;
}

/* Sub-step items - rounded chips */
.pipeline-step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  margin: 3px 4px;
  border-radius: 16px;
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.1);
  transition: all 0.2s ease;
  font-size: 0.8rem;
}

.pipeline-step:hover {
  background: rgba(148, 163, 184, 0.12);
}

.pipeline-step-icon {
  font-size: 0.75rem;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  font-family: monospace;
}

.pipeline-step-text {
  font-size: 0.8rem;
  color: var(--text-muted, #94a3b8);
  line-height: 1.4;
}

.pipeline-step.step-active {
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.2);
}

.pipeline-step.step-active .pipeline-step-text {
  color: var(--text, #e2e8f0);
}

.pipeline-step.step-active .pipeline-step-icon {
  animation: pulse-icon 1.5s ease-in-out infinite;
}

.pipeline-step.step-done {
  border-color: rgba(34, 197, 94, 0.15);
}

.pipeline-step.step-done .pipeline-step-icon {
  color: rgba(34, 197, 94, 0.8);
}

.pipeline-step.step-failed {
  border-color: rgba(248, 113, 113, 0.2);
}

.pipeline-step.step-failed .pipeline-step-icon {
  color: rgba(248, 113, 113, 0.8);
}

/* Completion banner */
.pipeline-completion {
  margin: 16px 0 8px 0;
  padding: 14px 18px;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.08), rgba(56, 189, 248, 0.05));
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slide-in-completion 0.4s ease;
}

@keyframes slide-in-completion {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.pipeline-completion-icon {
  font-size: 1.4rem;
}

.pipeline-completion-text {
  font-size: 0.88rem;
  font-weight: 500;
  color: rgba(34, 197, 94, 0.9);
}

.pipeline-completion-detail {
  font-size: 0.78rem;
  color: var(--text-muted, #94a3b8);
  margin-top: 2px;
}

/* RTL support */
[dir="rtl"] .pipeline-phase {
  padding: 0 32px 0 0;
}

[dir="rtl"] .pipeline-phase::before {
  left: auto;
  right: 11px;
}

[dir="rtl"] .pipeline-phase-node {
  left: auto;
  right: 4px;
}

[dir="rtl"] .pipeline-phase-toggle {
  margin-left: 0;
  margin-right: auto;
}

/* Hide old stage blocks when pipeline is active */
.task-pipeline ~ .agent-stage-block {
  display: none;
}

/* Mobile improvements */
@media (max-width: 768px) {
  .pipeline-phase {
    padding: 0 0 0 24px;
  }
  .pipeline-phase-node {
    left: 2px;
    width: 14px;
    height: 14px;
  }
  .pipeline-step {
    font-size: 0.75rem;
    padding: 3px 10px;
  }
}


/* ═══════════════════════════════════════════════════════════ */
/* SSH Indicator Button Fix - Clickable styling                */
/* ═══════════════════════════════════════════════════════════ */

.ssh-indicator {
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  user-select: none;
}

.ssh-indicator:hover {
  border-color: rgba(99, 179, 237, 0.6) !important;
  background: rgba(30, 41, 59, 0.85) !important;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 200, 255, 0.15);
}

.ssh-indicator:active {
  transform: translateY(0);
  box-shadow: none;
}

.ssh-indicator.connected:hover {
  border-color: rgba(34, 197, 94, 0.6) !important;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.15);
}


/* ═══════════════════════════════════════════════════════════ */
/* SSH Indicator Button Fix - Clickable styling                */
/* ═══════════════════════════════════════════════════════════ */

.ssh-indicator {
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  user-select: none;
}

.ssh-indicator:hover {
  border-color: rgba(99, 179, 237, 0.6) !important;
  background: rgba(30, 41, 59, 0.85) !important;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 200, 255, 0.15);
}

.ssh-indicator:active {
  transform: translateY(0);
  box-shadow: none;
}

.ssh-indicator.connected:hover {
  border-color: rgba(34, 197, 94, 0.6) !important;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.15);
}


/* ═══════════════════════════════════════════════════════════ */
/* Pipeline Header with Live Timer                             */
/* ═══════════════════════════════════════════════════════════ */

.pipeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 10px;
}

.pipeline-header-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(56, 189, 248, 0.9);
  display: flex;
  align-items: center;
  gap: 6px;
}

.pipeline-header-title::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.8);
  animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 0.4; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

.pipeline-timer {
  font-size: 0.82rem;
  font-weight: 500;
  color: rgba(148, 163, 184, 0.8);
  font-variant-numeric: tabular-nums;
  direction: ltr;
  min-width: 40px;
  text-align: center;
  padding: 2px 8px;
  background: rgba(148, 163, 184, 0.08);
  border-radius: 6px;
}

.pipeline-timer.timer-done {
  color: rgba(34, 197, 94, 0.9);
  background: rgba(34, 197, 94, 0.08);
}

/* When work is complete, stop the pulse animation */
.pipeline-header:has(.timer-done) .pipeline-header-title::before {
  background: rgba(34, 197, 94, 0.8);
  animation: none;
}

/* ===== Mode Selector Styles ===== */
.mode-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-select {
  appearance: none;
  -webkit-appearance: none;
  background: rgba(15, 23, 42, 0.75);
  color: #e2e8f0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 32px 8px 12px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%2712%27 height=%2712%27 viewBox=%270 0 12 12%27%3E%3Cpath fill=%27%2394a3b8%27 d=%27M6 8L1 3h10z%27/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  min-width: 180px;
}

.mode-select:hover {
  border-color: var(--accent);
  background-color: rgba(15, 23, 42, 0.9);
}

.mode-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.mode-select option {
  background: #1e293b;
  color: #e2e8f0;
  padding: 8px;
}

/* Responsive: stack on small screens */
@media (max-width: 640px) {
  .mode-select {
    min-width: 140px;
    font-size: 0.78rem;
    padding: 6px 28px 6px 8px;
  }
}
/* ===== End Mode Selector Styles ===== */

/* ═══════════════════════════════════════════════════════════ */
/* STEP COMMENTS - Live typewriter text under each step       */
/* ═══════════════════════════════════════════════════════════ */

/* Make pipeline-step a block element to allow comment below */
.pipeline-step {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center;
}

.pipeline-step-comment {
  display: none;
  width: 100%;
  margin-top: 4px;
  padding: 4px 8px 4px 24px;
  font-size: 0.75rem;
  color: rgba(148, 163, 184, 0.7);
  line-height: 1.5;
  direction: auto;
  unicode-bidi: plaintext;
  min-height: 0;
  overflow: hidden;
  border-top: 1px solid rgba(148, 163, 184, 0.06);
  font-family: inherit;
}

/* RTL support for Arabic text */
.pipeline-step-comment[dir="rtl"],
.pipeline-step-comment:lang(ar) {
  text-align: right;
  padding: 4px 24px 4px 8px;
}

/* Show comment when it has content */
.pipeline-step-comment:not(:empty) {
  display: block;
}

/* Active step comment styling - brighter */
.pipeline-step.step-active .pipeline-step-comment {
  color: rgba(56, 189, 248, 0.6);
}

/* Typewriter cursor effect */
.pipeline-step.step-active .pipeline-step-comment::after {
  content: "▊";
  animation: blink-cursor 0.8s step-end infinite;
  color: rgba(56, 189, 248, 0.5);
  font-size: 0.7rem;
  margin-inline-start: 2px;
}

/* Done step comment - dimmer */
.pipeline-step.step-done .pipeline-step-comment {
  color: rgba(148, 163, 184, 0.4);
}

.pipeline-step.step-done .pipeline-step-comment::after {
  content: none;
}

/* Failed step comment */
.pipeline-step.step-failed .pipeline-step-comment {
  color: rgba(248, 113, 113, 0.5);
}

.pipeline-step.step-failed .pipeline-step-comment::after {
  content: none;
}

@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Status tracker must stay visible while the pipeline runs so users can see
   complete live execution messages. Hide only when the element is explicitly hidden. */
.status-tracker[hidden] {
  display: none !important;
}

.status-message {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.45;
}


/* Background task controls: send stays available; stop targets this conversation's task only. */
.agent-task-running #sendButton {
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.18);
}

.agent-task-running .status-icon::after,
.conversation-running-spinner {
  content: "";
  width: 12px;
  height: 12px;
  border: 2px solid rgba(99, 102, 241, 0.25);
  border-top-color: #818cf8;
  border-radius: 50%;
  display: inline-block;
  animation: rosh-task-spin 0.85s linear infinite;
}

.agent-task-running .status-icon::after {
  margin-inline-start: 8px;
  vertical-align: middle;
}

@keyframes rosh-task-spin {
  to { transform: rotate(360deg); }
}

/* notify_user truth/display fix: show the complete user-visible sentence. */
.status-current {
  align-items: flex-start;
  min-width: 0;
}

.status-copy {
  min-width: 0;
}

.status-message,
.status-entry-text,
.agent-stage-block .stage-content,
.pipeline-step-text {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.55;
  max-width: 100%;
}

[dir="rtl"] .status-message,
[dir="rtl"] .status-entry-text,
[dir="rtl"] .agent-stage-block .stage-content,
[dir="rtl"] .pipeline-step-text {
  text-align: right;
  unicode-bidi: plaintext;
}



.remote-assist-button {
  border: 1px solid rgba(56, 189, 248, 0.48);
  color: #e0f2fe;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.22), rgba(37, 99, 235, 0.28));
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.18);
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  white-space: nowrap;
}

.remote-assist-button:hover {
  transform: translateY(-1px);
  border-color: rgba(125, 211, 252, 0.86);
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.34), rgba(37, 99, 235, 0.4));
}

@media (max-width: 720px) {
  .remote-assist-button {
    padding: 7px 12px;
    font-size: 0.82rem;
  }
}


/* ===== Auto-reconnect live notice (replaces static "network error") ===== */
.reconnect-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px auto;
  padding: 10px 16px;
  max-width: 640px;
  border-radius: 12px;
  background: rgba(255, 173, 51, 0.12);
  border: 1px solid rgba(255, 173, 51, 0.45);
  color: #ffb84d;
  font-size: 0.9rem;
  line-height: 1.5;
  direction: rtl;
  animation: reconnectPulse 2s ease-in-out infinite;
}

.reconnect-notice.reconnect-success {
  background: rgba(46, 204, 113, 0.12);
  border-color: rgba(46, 204, 113, 0.45);
  color: #2ecc71;
  animation: none;
}

.reconnect-spinner {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 184, 77, 0.3);
  border-top-color: #ffb84d;
  animation: reconnectSpin 0.9s linear infinite;
}

@keyframes reconnectSpin {
  to { transform: rotate(360deg); }
}

@keyframes reconnectPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}


/* PIPELINE ARABIC/RTL TEXT CUTOFF FIX 20260903 */
/* The step chip must wrap so the live comment drops to its own full-width line
   instead of being clipped at the container edge (worst in RTL/Arabic). */
.pipeline-step {
  flex-wrap: wrap;
}

.pipeline-step-text {
  white-space: normal;
  overflow-wrap: anywhere;
  min-width: 0;
  flex: 1 1 auto;
}

.pipeline-step-comment:not(:empty) {
  display: block;
  flex-basis: 100%;
  width: 100%;
  min-width: 0;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  word-break: normal;
  unicode-bidi: plaintext;
  text-align: start;
  line-height: 1.6;
}

[dir="rtl"] .pipeline-step-comment:not(:empty),
.pipeline-step-comment:lang(ar) {
  text-align: right;
}


/* ===== Unified Header Toolbar 2026-12 ===== */
.header-actions { position: relative; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.header-actions .mode-select { height: 36px; box-sizing: border-box; }
#roshTokenBadge {
  height: 36px !important; padding: 0 16px !important; margin: 0 !important;
  border-radius: 10px !important; font-size: 13px !important; font-weight: 700 !important;
  box-shadow: 0 2px 8px rgba(245,158,11,.3) !important;
}
#tbBalanceChip { box-sizing: border-box; }
.hdr-tools-wrap { position: relative; display: inline-flex; }
.hdr-tools-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 16px;
  border-radius: 10px; border: 1px solid rgba(148,163,184,0.28);
  background: rgba(30,41,59,0.85); color: #e2e8f0; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .18s ease, border-color .18s ease;
}
.hdr-tools-btn:hover { background: rgba(51,65,85,0.95); border-color: rgba(148,163,184,0.5); }
.hdr-tools-menu {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0;
  min-width: 250px; z-index: 1200;
  background: #0f172a; border: 1px solid rgba(148,163,184,0.22);
  border-radius: 14px; padding: 8px;
  box-shadow: 0 16px 40px rgba(2,6,23,0.65);
  display: flex; flex-direction: column; gap: 4px;
}
.hdr-tools-menu[hidden] { display: none; }
.hdr-tools-menu button {
  display: flex !important; align-items: center !important; justify-content: flex-start !important;
  gap: 10px !important; width: 100% !important; height: 40px !important; padding: 0 14px !important;
  border-radius: 10px !important; border: none !important;
  background: transparent !important; color: #e2e8f0 !important;
  font-size: 13px !important; font-weight: 600 !important;
  text-align: start !important; cursor: pointer;
  box-shadow: none !important; letter-spacing: normal !important;
  white-space: nowrap; transition: background .15s ease;
  margin: 0 !important;
}
.hdr-tools-menu button:hover:not([disabled]) { background: rgba(59,130,246,0.16) !important; }
.hdr-tools-menu .hdr-menu-sep { height: 1px; margin: 4px 8px; background: rgba(148,163,184,0.18); }
.hdr-tools-menu .ssh-indicator .dot { width: 8px; height: 8px; flex: 0 0 auto; }
.hdr-tools-menu #sshDisconnectBtn[disabled] { opacity: .45 !important; cursor: not-allowed !important; }
@media (max-width: 760px) {
  .hdr-tools-menu { min-width: 215px; }
  .header-actions { gap: 8px; }
}

/* Restored execution steps (conversation history) - convfix 20260909 */
.restored-steps-group { margin: 6px 48px 10px; }
.restored-steps-group details {
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 10px;
  padding: 8px 12px;
}
.restored-steps-group summary {
  cursor: pointer; font-size: 0.85rem; color: #94a3b8; user-select: none;
}
.restored-steps-list { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.restored-step-row {
  font-size: 0.8rem; color: #cbd5e1; padding: 3px 8px;
  border-inline-start: 2px solid rgba(56, 189, 248, 0.35);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ===== Thinking Indicator 2026 - elegant agent-thinking bubble ===== */
.thinking-indicator {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  align-self: flex-start;
  max-width: max-content;
  margin: 10px 0 6px;
  padding: 10px 16px;
  border-radius: 18px 18px 18px 6px;
  background: linear-gradient(135deg, rgba(99,102,241,.10), rgba(168,85,247,.10));
  border: 1px solid rgba(129,140,248,.28);
  box-shadow: 0 4px 18px rgba(99,102,241,.12);
  color: #c7d2fe;
  font-size: 14px;
  font-weight: 500;
  backdrop-filter: blur(6px);
  animation: thinking-in .28s cubic-bezier(.22,1,.36,1);
  direction: ltr;
}
@keyframes thinking-in {
  from { opacity: 0; transform: translateY(8px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.thinking-indicator-exit {
  opacity: 0;
  transform: translateY(-4px) scale(.97);
  transition: opacity .22s ease, transform .22s ease;
}
.thinking-spinner {
  width: 16px; height: 16px; flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid rgba(129,140,248,.25);
  border-top-color: #818cf8;
  animation: thinking-spin .8s linear infinite;
}
@keyframes thinking-spin { to { transform: rotate(360deg); } }
.thinking-text { letter-spacing: .2px; white-space: nowrap; }
.thinking-dots { display: inline-flex; }
.thinking-dots span {
  animation: thinking-blink 1.4s infinite both;
  opacity: .25; font-weight: 700;
}
.thinking-dots span:nth-child(2) { animation-delay: .18s; }
.thinking-dots span:nth-child(3) { animation-delay: .36s; }
@keyframes thinking-blink { 0%,100% { opacity: .25; } 40% { opacity: 1; } }
.thinking-timer {
  margin-inline-start: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(99,102,241,.16);
  border: 1px solid rgba(129,140,248,.22);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: #a5b4fc;
  min-width: 34px;
  text-align: center;
}
