/* ── Form & Directory Components ── */
/* ── Layout ── */
.layout {
  min-height: 100vh;
}

.main {
  padding: 8px 0;
  overflow-x: hidden;
}

/* ── CWD badge ── */
.cwd-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 500;
  background: var(--accent-glow);
  color: var(--accent);
  margin-left: 8px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.cwd-badge:empty { display: none; }

/* ── Directory Picker ── */
.dir-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dir-picker-display {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-family: var(--font-mono);
  min-height: 38px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--transition);
}

.dir-picker-display:hover {
  border-color: var(--border-light);
  background: var(--surface);
}

.dir-picker-display.has-value {
  color: var(--text);
}

.dir-picker-display .dir-icon {
  flex-shrink: 0;
  color: var(--text-muted);
}

.dir-picker-clear {
  flex-shrink: 0;
  padding: 4px;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  display: none;
}

.dir-picker-clear:hover {
  background: var(--red-dim);
  color: var(--red);
}

.dir-picker-clear.visible { display: inline-flex; }

/* ── Recent Directory Chips ── */
/* ── Project Bar ── */
.project-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.project-bar:empty { display: none; }
.project-chips { display: flex; gap: 5px; flex-wrap: wrap; flex: 1; min-height: 0; }
.project-chips:empty + .project-action-btn { margin-left: 0; }

.project-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--transition);
  max-width: 200px;
}
.project-chip:hover { background: var(--surface-hover); border-color: var(--border-light); }
.project-chip.selected {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}
.project-chip .project-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-chip .project-chip-remove {
  display: inline-flex;
  align-items: center;
  opacity: 0;
  transition: opacity var(--transition);
  color: var(--text-muted);
  flex-shrink: 0;
}
.project-chip:hover .project-chip-remove { opacity: 1; }
.project-chip .project-chip-remove:hover { color: var(--red); }

.project-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px dashed var(--border-light);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.project-action-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }

.recent-dirs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.recent-dirs:empty { display: none; }

.recent-dirs-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  flex-shrink: 0;
  margin-right: 2px;
}

.recent-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all var(--transition);
  max-width: 200px;
}

.recent-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.recent-chip.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
  font-weight: 500;
}

.recent-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-chip-remove {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  padding: 0;
  margin-left: 2px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.recent-chip-remove:hover {
  background: var(--red-dim);
  color: var(--red);
}

/* ── Inline Directory Browser Panel ── */
.dir-browser-panel {
  display: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-top: 8px;
  overflow: hidden;
  animation: panel-slide 0.15s ease-out;
}

.dir-browser-panel.open { display: block; }

@keyframes panel-slide {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.dir-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.dir-modal-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.dir-modal-close {
  padding: 4px;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  border: none;
  cursor: pointer;
}

.dir-modal-close:hover { background: var(--surface-active); color: var(--text); }

.dir-create-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.dir-create-input {
  flex: 1;
  padding: 4px 8px;
  font-size: 0.78rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.dir-create-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.dir-modal-path {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  overflow-x: auto;
  white-space: nowrap;
}

.dir-modal-path .breadcrumb-seg {
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--accent);
  transition: background var(--transition);
}

.dir-modal-path .breadcrumb-seg:hover {
  background: var(--accent-glow);
}

.dir-modal-path .breadcrumb-sep {
  color: var(--text-muted);
}

.dir-modal-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  max-height: 240px;
}

.dir-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text);
  transition: background var(--transition);
}

.dir-item:hover { background: var(--surface-hover); }

.dir-item-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.dir-item-icon.is-dir { color: var(--yellow); }
.dir-item-icon.is-parent { color: var(--accent); }

.dir-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dir-item-name.is-dir { font-weight: 500; }

.dir-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  gap: 8px;
}

.dir-modal-current {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dir-modal-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  color: var(--text-muted);
  font-size: 0.85rem;
  gap: 8px;
}

/* ── Cards / Sections ── */
.section {
  animation: fadeIn 0.3s ease forwards;
  animation-iteration-count: 1;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: none;
  border-right: none;
  border-radius: 0;
  overflow: visible;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 0;
}

.card-title svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--accent); }

.card-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.card-body { padding: 18px; }

/* ── Send Task Form ── */
.form-group { margin-bottom: 14px; }

.form-label {
  display: flex;
  align-items: center;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

textarea, input[type="text"] {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.85rem;
  line-height: 1.6;
  resize: vertical;
  transition: border-color var(--transition);
}

textarea:focus, input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea { min-height: unset; position: relative; }

/* ── Prompt Input + Mirror (color-only highlight, no text replacement) ── */
#promptInput {
  color: transparent;
  caret-color: var(--text);
  padding-right: 44px;
}

#promptInput::selection {
  background: rgba(108, 140, 255, 0.3);
  color: transparent;
}

.prompt-mirror {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 14px;
  padding-right: 44px;
  font-family: var(--font);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: hidden;
  pointer-events: none;
}

.prompt-at-ref {
  color: var(--green);
  font-weight: 500;
}

/* ── Image Attachments ── */
.prompt-wrapper {
  position: relative;
}

.prompt-wrapper.drag-over textarea {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.drop-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(108, 140, 255, 0.08);
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  z-index: 10;
  pointer-events: none;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  gap: 8px;
}

.prompt-wrapper.drag-over .drop-overlay {
  display: flex;
}

.image-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.image-previews:empty { display: none; }

.img-thumb {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 6px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--bg);
  flex-shrink: 0;
  animation: fadeIn 0.2s ease;
}

.img-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
}

.img-thumb .img-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  border: none;
  padding: 0;
  line-height: 1;
}

.img-thumb:hover .img-remove {
  opacity: 1;
}

.img-thumb.uploading {
  opacity: 0.5;
}

.img-thumb.uploading::after {
  content: '';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
}

.img-count-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--accent-glow);
  color: var(--accent);
  margin-left: 8px;
}

.img-count-badge:empty { display: none; }

/* ── File Attachments (non-image) ── */
.file-thumb {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  max-width: 200px;
  animation: fadeIn 0.2s ease;
  flex-shrink: 0;
}
.file-thumb .file-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  background: var(--surface-active);
  color: var(--text-muted);
  flex-shrink: 0;
  font-size: 0.6rem;
  font-weight: 700;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: -0.02em;
}
.file-thumb .file-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
  min-width: 0;
}
.file-thumb .file-name {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-thumb .file-size {
  font-size: 0.65rem;
  color: var(--text-muted);
}
.file-thumb .file-remove {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  border: none;
  padding: 0;
  line-height: 1;
}
.file-thumb:hover .file-remove { opacity: 1; }
.file-thumb.uploading { opacity: 0.5; }

/* ── Attach Button (inside prompt-wrapper) ── */
.attach-float-btn {
  position: absolute;
  bottom: 12px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  z-index: 5;
}
.attach-float-btn:hover {
  background: var(--surface-active);
  color: var(--accent);
  border-color: var(--accent);
}

textarea::placeholder, input::placeholder {
  color: var(--text-muted);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.automation-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg-secondary);
  border-radius: 6px;
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
  flex-shrink: 0;
}
.automation-inline-label {
  font-size: 0.72rem;
  color: var(--primary);
  font-weight: 500;
  white-space: nowrap;
}
.automation-inline-hint {
  font-size: 0.62rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.form-actions-buttons {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
