/* ---------- Ask tab (v2.3 C5) ----------
   index.html is frozen: #screen-ask ships with #ask-model-row (empty),
   #ask-history (a plain .screen-body), and #ask-input-bar/#ask-input/
   #ask-send. ask.js reparents #ask-input into a runtime shell (same
   reparent-at-runtime pattern queue.js uses for #process-now) so the
   iOS-zoom-guard trick below can apply without touching that markup. */

:root {
  --ask-input-bar-h: 64px;
}

/* ---------- Model chip row ----------
   ask.js adds the existing .chip-row utility class to #ask-model-row at
   runtime, and each chip is class="chip ask-model-chip" (+ "active" when
   selected) — reusing styles.css's .chip/.chip.active look, no redefinition
   needed here beyond the row's own spacing under the header divider. */

.ask-model-row.chip-row {
  padding: 0 14px 12px;
}

/* ---------- History / chat area ---------- */

#ask-history {
  padding: 10px 10px calc(var(--bottom-chrome-h) + var(--ask-input-bar-h));
}

.ask-empty {
  padding: 70px 24px;
  text-align: center;
  color: var(--text-faint);
  font-size: var(--fs-sub);
}

.ask-entry {
  margin-bottom: 16px;
}

.ask-row {
  display: flex;
}

.ask-row-q {
  justify-content: flex-end;
  margin-bottom: 6px;
}

.ask-row-a {
  justify-content: flex-start;
}

.ask-bubble {
  max-width: 82%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 9px 13px;
  font-size: var(--fs-body);
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.ask-card {
  max-width: 88%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 13px;
}

.ask-answer-text {
  font-size: var(--fs-body);
  color: var(--text);
  line-height: 1.45;
}

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

.ask-card-pending {
  font-size: var(--fs-sub);
  color: var(--text-dim);
  animation: ask-pulse 1.6s ease-in-out infinite;
}

.ask-card-failed {
  color: var(--text-dim);
}

.ask-error-text {
  font-size: var(--fs-sub);
  color: var(--danger);
  margin-bottom: 8px;
}

.ask-retry-chip {
  font-size: var(--fs-micro);
  padding: 5px 12px;
}

.ask-clips {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.ask-clip-card {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.ask-clip-card:active {
  opacity: 0.8;
}

/* Clip thumb: reuses LV.rowThumbHtml()'s .row-thumb-wrap markup (same
   img + data-fallback + LV.wireTileImg wiring as Home/Queue rows) but at
   the 40px size C5 calls for, scoped to this screen only. */
.ask-clip-card .row-thumb-wrap {
  width: 40px;
  height: 40px;
  border-radius: 6px;
}

.ask-clip-title {
  min-width: 0;
  flex: 1;
  font-size: var(--fs-sub);
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Input bar ----------
   Fixed above the floating tab bar, safe-area aware. Only ever visible
   while #screen-ask carries .active (an ancestor display:none hides a
   fixed-position descendant too), so no extra tab-guard is needed here.
   ask.js docks it above the keyboard via LV.ui.beginKeyboardDock/
   endKeyboardDock (visualViewport ownership stays in core.js per the seam
   contract) — that just sets this element's `bottom` inline style. */

#ask-input-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--bottom-chrome-h);
  z-index: 140;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
  background: rgba(12, 12, 14, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
}

/* Search-input trick (copied from #search in styles.css): the shell keeps
   normal chrome; the input inside computes at 16px (iOS zoom-on-focus
   guard) then is visually scaled down to match the app's --fs-sub scale,
   with its width compensated so it still fills the shell. */
.ask-input-shell {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 9px 14px;
  overflow: hidden;
}

.ask-input-shell:focus-within {
  border-color: var(--accent);
}

#ask-input {
  flex: none;
  width: calc(100% / 0.8125);
  background: transparent;
  border: none;
  padding: 0;
  font-size: 16px; /* iOS-zoom-guard exception, same family as #search's 16px in styles.css — A15 whitelisted */
  color: var(--text);
  transform: scale(0.8125);
  transform-origin: left center;
}

#ask-input:focus {
  outline: none;
}

#ask-send {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 100px;
  background: var(--accent);
  border: none;
  color: var(--on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

#ask-send:disabled {
  opacity: 0.4;
  cursor: default;
}

#ask-send:active:not(:disabled) {
  opacity: 0.85;
}

/* ---------- Queue-screen run-progress card (v2.3 C6) ----------
   queue.css is out of scope for this stream, so queue.js builds the card
   from inline styles referencing design tokens instead — nothing to add
   here; this note only exists so a future reader isn't surprised the card
   has no ask.css rule despite ask.css shipping alongside it. */
