/* ==========================================================================
   Queue panel (Task Queue, Q app msg 6952). Its own file only so the parallel
   rounds editing style.css do not collide here; it adds no new tokens. Every
   color, radius, size and motion value is style.css's, and the rules hold:
   indigo accent for "working", amber only for "needs you", red only for
   failing, the report reuses the chat's .msg-text markdown styles.
   ========================================================================== */

/* The rail dot: the Queue tab carries it while a task waits on Q. */
nav.tabs > button .rail-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 10px rgba(245, 182, 74, 0.7);
  pointer-events: none;
}

.queue-layout {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  animation: rise 0.3s var(--ease) both;
}
/* No task open (never picked, or closed with the X): the detail card goes
   away and the list takes the whole width. */
.queue-layout:not(.detail-open) { grid-template-columns: minmax(0, 1fr); }
.queue-layout:not(.detail-open) #queue-detail { display: none; }
.queue-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

#queue-form { display: flex; flex-direction: column; gap: 8px; padding: 14px; }
#queue-desc, .queue-answer { height: auto; min-height: 76px; padding: 9px 11px; line-height: 1.5; resize: vertical; }
.queue-form-row { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.queue-form-row .muted { margin-right: auto; font-size: var(--fs-xs); color: var(--danger); }
#queue-filters { margin: 2px 0 0; }

#queue-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.queue-row {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  width: 100%;
  padding: 11px 13px;
  text-align: left;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  transition: border-color 0.16s var(--ease), background 0.16s var(--ease);
}
.queue-row:hover { border-color: var(--line-2); }
.queue-row.active { border-color: var(--accent-line); background: var(--surface-2); }
.queue-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; margin-top: 7px; background: var(--text-3); }
.queue-dot.st-working { background: var(--accent); box-shadow: 0 0 8px rgba(139, 142, 255, 0.6); animation: queuePulse 1.8s var(--ease) infinite; }
.queue-dot.st-needs { background: var(--warn); box-shadow: 0 0 10px rgba(245, 182, 74, 0.7); }
.queue-dot.st-done { background: var(--ok); opacity: 0.8; }
.queue-dot.st-failed { background: var(--danger); }
.queue-dot.st-cancelled { background: var(--text-3); opacity: 0.5; }
/* Start now (task queue #121 follow-up 4): queued, and the runner takes it next tick. */
.queue-dot.st-forced { background: var(--teal); box-shadow: 0 0 0 2px rgba(94, 234, 212, 0.25), 0 0 10px rgba(94, 234, 212, 0.55); }
/* Paused by Q (app msg 9168): stopped, and it keeps its slot. */
.queue-dot.st-paused { background: var(--warn); opacity: 0.6; }
@keyframes queuePulse { 50% { opacity: 0.35; } }
.queue-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.queue-row-title { font-size: var(--fs); font-weight: 560; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.queue-row-meta { font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex: none; }
.queue-empty { padding: 14px 2px; font-size: var(--fs-sm); color: var(--text-3); }

/* Status badge: the Reading tab's mono pill, one tint per status. */
.queue-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 10.5px;
  white-space: nowrap;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  flex: none;
}
.queue-badge.st-working { color: var(--accent-2); border-color: var(--accent-line); background: var(--accent-soft); }
.queue-badge.st-needs { color: var(--warn); border-color: rgba(245, 182, 74, 0.35); background: var(--warn-soft); }
.queue-badge.st-forced { color: var(--teal); border-color: rgba(94, 234, 212, 0.4); background: rgba(94, 234, 212, 0.08); }
.queue-forced { display: inline-flex; align-items: center; height: 28px; padding: 0 10px; border-radius: 999px; font-size: var(--fs-xs); color: var(--teal); border: 1px solid rgba(94, 234, 212, 0.35); background: rgba(94, 234, 212, 0.07); }
button.linklike.queue-force { color: var(--teal); }
.queue-badge.st-paused { color: var(--text-2); border-color: rgba(245, 182, 74, 0.3); background: var(--surface-2); }
button.linklike.queue-force:hover { border-color: rgba(94, 234, 212, 0.4); background: rgba(94, 234, 212, 0.08); }
.queue-badge.st-done { color: var(--ok); border-color: rgba(74, 222, 128, 0.28); background: rgba(74, 222, 128, 0.07); }
.queue-badge.st-failed { color: var(--danger); border-color: rgba(255, 107, 107, 0.3); background: var(--danger-soft); }
.queue-badge.st-cancelled { color: var(--text-3); }

#queue-detail { position: relative; min-width: 0; padding: 18px 20px 20px; }
.queue-back { display: none; margin-bottom: 12px; }
.queue-close { position: absolute; top: 12px; right: 12px; }
.queue-detail-eyebrow { font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-3); margin-bottom: 6px; padding-right: 30px; }
.queue-detail-titlerow { display: flex; align-items: flex-start; gap: 12px; }
.queue-detail-title { flex: 1; min-width: 0; font-size: var(--fs-lg); font-weight: 600; letter-spacing: -0.02em; line-height: 1.25; }
.queue-detail-titlerow .queue-badge { margin-top: 3px; }
.queue-detail-actions { display: flex; gap: 6px; margin-top: 10px; }
.queue-detail-actions:empty { display: none; }
button.linklike.queue-cancel:hover { color: var(--danger); border-color: rgba(255, 107, 107, 0.3); background: var(--danger-soft); }

.queue-block { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.queue-block-title { display: flex; align-items: baseline; gap: 8px; font-size: var(--fs-sm); font-weight: 560; color: var(--text-2); margin-bottom: 10px; }
.queue-text { margin: 0; font-size: var(--fs); line-height: 1.62; color: #d6d6dd; white-space: pre-wrap; overflow-wrap: anywhere; }
/* A link in a job's question (task queue #159), styled like a link in a chat bubble. */
.queue-text a { color: var(--accent-2); text-decoration: none; border-bottom: 1px solid var(--accent-line); transition: border-color 0.16s; }
.queue-text a:hover { border-bottom-color: var(--accent-2); }
.queue-question { border-top: 0; margin-top: 16px; padding: 14px 16px; border-radius: 12px; background: var(--warn-soft); border: 1px solid rgba(245, 182, 74, 0.3); }
.queue-question .queue-block-title { color: var(--warn); }
.queue-question .queue-text { color: var(--text); margin-bottom: 12px; }
.queue-question .queue-form-row { margin-top: 8px; }
.queue-report { color: #d6d6dd; }
.queue-qa { display: grid; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.queue-qa:last-child { border-bottom: 0; }
.queue-qa .ops-cat { margin-right: 8px; }
.queue-answer-text { color: var(--text-2); }
.queue-events { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.queue-events li { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 10px; padding: 4px 0; font-size: var(--fs-sm); color: var(--text-2); }
.queue-events li .ops-when { padding-top: 2px; }
.queue-events li.ev-question, .queue-events li.ev-failed, .queue-events li.ev-followup { color: var(--text); }

@media (max-width: 1180px) {
  .queue-layout { grid-template-columns: minmax(260px, 360px) minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .queue-layout { grid-template-columns: minmax(0, 1fr); }
  .queue-layout.detail-open .queue-side { display: none; }
  .queue-back { display: inline-flex; }
  .queue-events li { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

/* Follow-ups (task queue #6): the composer on a finished task, and each
   earlier round's report behind a disclosure so the newest stays on top. */
.queue-followup .queue-form-row, .queue-message .queue-form-row { margin-top: 8px; }
.queue-message .queue-qa .ops-when { margin: 2px 0 0; }
.queue-round details > summary { cursor: pointer; list-style: none; margin-bottom: 0; }
.queue-round details > summary::-webkit-details-marker { display: none; }
.queue-round details > summary::before { content: '▸'; color: var(--text-3); transition: transform 0.15s var(--ease); }
.queue-round details[open] > summary::before { transform: rotate(90deg); }
.queue-round details > summary .queue-badge { margin-left: 2px; }
.queue-round details[open] > summary { margin-bottom: 10px; }

/* Tags, search and filters (task queue #13). Tag chips stay neutral: the
   accent, amber and red above already mean working, needs you and failing.
   The project reads brightest, the type next, a topic tag quietest. */
.queue-find { display: flex; flex-direction: column; gap: 8px; }
.queue-find-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.queue-find select.task-input { text-overflow: ellipsis; }
.queue-find select.task-input.picked { border-color: var(--line-3); color: var(--text); }
/* Full width (no task open): the search and both menus share one row. */
@media (min-width: 761px) {
  .queue-layout:not(.detail-open) .queue-find { flex-direction: row; }
  .queue-layout:not(.detail-open) #queue-search { flex: 1.3; }
  .queue-layout:not(.detail-open) .queue-find-row { flex: 1; }
}
.queue-shown { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 28px; font-size: var(--fs-xs); color: var(--text-3); }

.queue-tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  max-width: 100%;
  padding: 0 7px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-2);
  border: 1px solid var(--line);
  background: transparent;
}
.queue-tag.qt-project { color: var(--text); border-color: var(--line-2); background: var(--surface-2); font-weight: 560; }
/* A project no chat holds yet (task queue #121): the old name, dashed. */
.queue-tag.qt-project.qt-nochat { color: var(--text-2); border-style: dashed; background: none; font-weight: 500; }
.queue-tag.qt-tag { color: var(--text-3); border-color: transparent; padding: 0 3px; }
.queue-tag.qt-tag::before { content: '#'; opacity: 0.7; }
button.queue-tag { cursor: pointer; transition: border-color 0.16s var(--ease), color 0.16s var(--ease); }
button.queue-tag:hover { color: var(--text); border-color: var(--line-3); }
.queue-row-tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 3px 0 1px; min-width: 0; }
.queue-row-match { font-size: var(--fs-xs); line-height: 1.45; color: var(--text-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.queue-row-match .ops-cat { margin-right: 6px; }
#queue-panel mark { background: rgba(255, 255, 255, 0.14); color: var(--text); border-radius: 3px; padding: 0 1px; }

.queue-detail-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.queue-detail-tags .queue-tag { height: 24px; padding: 0 9px; font-size: var(--fs-sm); }
.queue-detail-tags .queue-tag.qt-tag { padding: 0 4px; }
.queue-tagging { font-size: var(--fs-xs); color: var(--text-3); }
.queue-tags-edit { height: 24px; margin-left: 2px; }
.queue-meta-edit { display: grid; gap: 10px; margin-top: 12px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--sunken); }
.queue-meta-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.queue-meta-field { display: grid; gap: 5px; min-width: 0; }
.queue-meta-edit .queue-form-row { flex-wrap: wrap; }

/* Voice notes as tasks (task queue #26). The mic sits beside "Add to queue";
   while it records it turns red and pulses, and the status line beside it
   counts the time. A voice task's row carries a small mic before its title. */
.queue-mic { color: var(--text-3); }
.queue-mic:hover { color: var(--text); }
.queue-mic.recording { color: #fff; background: var(--danger); animation: queuePulse 1.4s var(--ease) infinite; }
.queue-mic.recording:hover { background: var(--danger); color: #fff; }
.queue-mic:disabled { opacity: 0.4; }
.queue-form-row .muted.voice-status { color: var(--text-2); }
.queue-row-mic { width: 13px; height: 13px; margin-right: 5px; vertical-align: -1px; color: var(--text-3); }
.queue-voice-wait { margin: 6px 0 0; font-size: var(--fs-sm); color: var(--text-3); }
.queue-audio { display: block; width: 100%; max-width: 420px; height: 36px; }
.queue-heard { margin-top: 10px; }
.queue-heard > summary { cursor: pointer; font-size: var(--fs-xs); font-weight: 560; color: var(--text-2); }
.queue-heard[open] > summary { margin-bottom: 6px; }
.queue-heard .queue-text { color: var(--text-2); }

/* Draft questions (task queue #58): the job's text in a box Q edits directly. */
.queue-draft-text { width: 100%; min-height: 280px; padding: 10px 12px; line-height: 1.55; font-size: var(--fs); resize: vertical; }
.queue-draft-state { margin: 6px 0 8px; font-size: var(--fs-xs); }
.queue-draft-state .linklike { height: 20px; font-size: var(--fs-xs); }
.queue-draft .queue-form-row { gap: 8px; }
.queue-draft-done { margin-top: 6px; }
.queue-draft-done summary { cursor: pointer; color: var(--text-3); font-size: var(--fs-xs); }
.queue-draft-done pre { white-space: pre-wrap; font-family: var(--font); font-size: var(--fs-sm); color: var(--text-2); background: var(--sunken); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; margin: 6px 0 0; }

/* ---- one task in a window over any panel (task queue #121 follow-up 3) ----
   #queue-detail itself moves in here (queue.js openQueueModal), so every rule
   above still styles it. Above the notification menu (95), below native dialogs. */
#queue-modal { position: fixed; inset: 0; z-index: 110; display: grid; place-items: center; padding: 28px; }
.qm-scrim { position: absolute; inset: 0; background: rgba(4, 4, 7, 0.66); backdrop-filter: blur(3px); animation: fadeIn 0.16s var(--ease) both; }
.qm-window {
  position: relative;
  width: min(880px, 100%);
  max-height: min(88vh, 1100px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: var(--radius-lg, 16px);
  box-shadow: var(--shadow-pop);
  outline: none;
  animation: popIn 0.2s var(--ease) both;
}
.qm-window #queue-detail { padding: 22px 26px 26px; border-radius: inherit; }
.qm-window .queue-close { position: sticky; top: 0; float: right; margin: -8px -12px 0 8px; z-index: 1; background: var(--surface); }
#queue-modal .queue-back { display: none; }
@media (max-width: 760px) {
  #queue-modal { padding: 0; place-items: stretch; }
  .qm-window { width: 100%; max-height: none; height: 100%; border-radius: 0; }
  .qm-window #queue-detail { min-height: 100%; padding: 16px 16px 24px; border-radius: 0; }
}
