/* The question composer (js/composer-editor.js and its pickers): the field, tokens, the graph and template palettes, attachments, the send button and the source picker.
   Moved out of base.css, shared-components.css and features.css in their
   original cascade order; loaded after features.css and before type.css. */

#input-area {
  position: fixed;
  left: var(--rail-width);
  right: 14px;
  bottom: 0;
  z-index: 55;
  padding: 14px var(--main-pad) 16px;
  pointer-events: none;
  transition: right 180ms ease;
}

#input-area form {
  max-width: var(--content-width);
  margin: 0 auto;
  display: flex;
  position: relative;
  gap: 0;
  border-top: none;
  padding-top: 0;
  pointer-events: auto;
}

.question-input {
  width: 100%;
  display: block;
  border: none;
  border-radius: var(--r-2xl);
  padding: 13px 50px;
  font-size: var(--text-base);
  /* A step up from 400, as in the rail: Instrument Sans at its regular
     weight reads thin beside the controls around it. */
  font-weight: 450;
  outline: none;
  min-height: 24px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  overflow-x: hidden;
  overflow-y: hidden;
  line-height: 22px;
  box-sizing: border-box;
}

.question-input:focus { outline: none; }

.question-input::selection,
.question-input *::selection {
  background: rgba(15, 23, 42, 0.14);
  color: inherit;
}

.question-input:empty::before {
  content: attr(data-placeholder);
  pointer-events: none;
}

.source-token,
.graph-token {
  display: inline;
  max-width: min(320px, 70vw);
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-weight: 650;
  line-height: inherit;
  white-space: nowrap;
  vertical-align: baseline;
  user-select: all;
  -webkit-user-select: all;
}

.question-input .source-token,
.question-input .graph-token {
  cursor: default;
}

#send-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--r-pill);
  padding: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
  transition: background 0.16s ease, transform 0.16s ease, opacity 0.16s ease;
}

#send-btn:hover { transform: translateY(-1px); }

#send-btn svg {
  display: block;
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#send-btn .send-icon {
  width: 19px;
  height: 19px;
  fill: currentColor;
  stroke: none;
}

#send-btn.is-voice-entry svg {
  stroke-width: 2.2;
}

#send-btn.is-voice-loading svg { display: none; }

#send-btn.is-voice-loading::before {
  content: "";
  width: 13px;
  height: 13px;
  box-sizing: border-box;
  border: 2px solid color-mix(in srgb, var(--on-accent) 38%, transparent);
  border-top-color: var(--on-accent);
  border-radius: 50%;
  animation: voice-input-spin .72s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  #send-btn.is-voice-loading::before { animation: none; }
}

#send-btn:disabled { opacity: 0.45; cursor: wait; transform: none; }

#send-btn.is-stop::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--surface);
  display: block;
}

#send-btn.is-uploading,
#send-btn.is-uploading:hover {
  background: var(--muted);
  color: var(--surface);
  cursor: default;
  opacity: 1;
  transform: none;
}

#send-btn.is-uploading::before {
  content: "";
  width: 13px;
  height: 13px;
  box-sizing: border-box;
  border: 2px solid color-mix(in srgb, var(--surface) 38%, transparent);
  border-top-color: var(--surface);
  border-radius: 50%;
  animation: voice-input-spin .72s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  #send-btn.is-uploading::before { animation: none; }
}
.input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s, border-radius 0.18s ease;
  min-height: 52px;
}

.input-wrap.composer-resizing { overflow: hidden; }

.composer-text-pane {
  flex: 0 0 auto;
  min-height: 50px;
  max-height: 50px;
  overflow: hidden;
  scrollbar-gutter: stable;
}

.composer-text-pane.is-scrolled {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0 4px, #000 16px, #000 100%);
  mask-image: linear-gradient(to bottom, transparent 0 4px, #000 16px, #000 100%);
}

.composer-footer {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 2;
  padding: 0;
  pointer-events: none;
}

.composer-footer::before {
  content: none;
}

.composer-footer > * {
  pointer-events: auto;
  position: relative;
  z-index: 1;
}

.composer-footer-spacer {
  display: block;
  flex: 1;
  min-width: 12px;
  pointer-events: none;
}

.voice-input-status {
  overflow: hidden;
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.voice-input-status.is-error { color: var(--red); }

/* The one-line composer lays its footer over the field, so a voice message
   lands exactly where the placeholder is drawn; it takes the placeholder's
   place for as long as it shows. */
.input-wrap:has(.voice-input-status:not([hidden]):not(.is-listening)) .question-input:empty::before {
  visibility: hidden;
}

.voice-input-status.is-listening {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Voice mode (js/voice-mode.js): the orb floats above the composer, which
   keeps only the model picker and the mute and end buttons. The orb's state
   is the conversation's -- connecting, listening, hearing the user,
   responding, waiting on the analyst, speaking -- and --voice-level, set
   every frame, is how loud whoever is talking is. */
.voice-orb-stage {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 14px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(560px, calc(100vw - 32px));
  pointer-events: none;
}

.voice-orb-stage[hidden] { display: none; }

.voice-orb {
  display: block;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  transition: opacity .3s ease, filter .3s ease;
}

/* The motion is drawn in js/voice-mode.js; connecting is what the colour
   itself shows. */
.voice-orb-stage[data-voice-state="connecting"] .voice-orb {
  opacity: .6;
  filter: saturate(.4);
}

body.voice-mode-active #chat-suggestions,
body.voice-mode-active .empty-state { display: none; }

body.voice-mode-active #chat-area { padding-bottom: 280px; }

/* A new chat centres its composer as a poster; a conversation by voice puts
   it at the bottom with the orb above, so the view changes the moment the
   call starts. */
body.voice-mode-active.chat-empty #input-area {
  top: auto;
  bottom: 0;
  padding-top: 14px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

@media (prefers-reduced-motion: reduce) {
  .voice-orb { transition: none; }
}

.input-wrap.multiline {
  min-height: 82px;
  border-radius: var(--r-2xl);
}

.input-wrap.multiline .composer-text-pane {
  flex: 0 0 auto;
  min-height: 0;
  max-height: min(42vh, 320px);
  overflow-y: auto;
}

.input-wrap.multiline .question-input {
  padding: 10px 18px;
}

.input-wrap.multiline .composer-footer {
  position: relative;
  left: auto;
  right: auto;
  top: auto;
  bottom: auto;
  transform: none;
  flex: 0 0 44px;
  width: 100%;
  height: 44px;
  padding: 0 8px 8px;
}

.input-wrap.multiline .composer-footer::before {
  content: none;
}

/* ── Source picker (+) button ─── */
.source-picker-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background var(--dur) ease, color var(--dur) ease, transform var(--dur) ease;
  padding: 0;
  line-height: 1;
}

.source-picker-btn svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.source-picker-btn:hover { transform: translateY(-1px); }

/* Anchored to both edges of the composer it belongs to, so the popup is
   always exactly as wide as the input box rather than a fixed 640px. */
.source-picker-popup {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  z-index: 70;
  overflow: hidden;
  box-shadow: var(--shadow-pop);
}

.source-picker-popup.open {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 24px);
}

.source-picker-popup.opens-below {
  top: calc(100% + 8px);
  bottom: auto;
}

.source-picker-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
}

.source-picker-filter {
  width: auto;
  flex: 1 1 auto;
  min-width: 0;
  /* Same field as the Knihovna and Databáze searches: magnifier first,
     then the text. */
  min-height: 38px;
  background-color: var(--surface);
  background-image: var(--search-icon);
  background-repeat: no-repeat;
  background-position: 12px center;
  background-size: 15px 15px;
  border: 1px solid var(--border-input);
  border-radius: var(--r-md);
  color: var(--ink);
  padding: 8px 12px 8px 34px;
  font-size: var(--text-sm);
  outline: none;
  transition: border-color var(--dur);
}

.source-picker-filter::placeholder { color: var(--faint); }

.source-picker-filter:focus {
  border-color: var(--border-focus);
  box-shadow: none;
}

.source-picker-filter::selection {
  background: rgba(15, 23, 42, 0.14);
  color: inherit;
}

/* What a message can carry besides its text, beside the search rather
   than in a footer of its own: one header row, and the list gets the
   height the footer used to take. */
.source-picker-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 2px;
}

.source-picker-actions[hidden] { display: none; }

.source-picker-action {
  flex: 0 0 auto;
  min-width: 0;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur), color var(--dur);
}

.source-picker-action[hidden] { display: none; }

.source-picker-action:hover { background: var(--hover-bg); color: var(--ink); }

.source-picker-action svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 720px) {
  .source-picker-action { padding: 0 9px; }

  .source-picker-action span { display: none; }
}
.source-picker-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 340px;
  overflow-y: auto;
  padding: 6px;
}

.source-picker-item {
  padding: 10px 10px;
  cursor: pointer;
  border: 0;
  border-radius: var(--r-sm);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background var(--dur);
}

.source-picker-item:hover { background: var(--hover-bg); }

.source-picker-source-icon {
  width: 21px;
  height: 21px;
  opacity: .78;
}

.source-picker-source-icon svg {
  width: 18px;
  height: 18px;
}

/* The recent picks and the key sources are set off from the rest by a
   rule alone, with no heading. */
/* Quick access: the recent picks and key sources as a compact grid,
   rows as quiet as the list's, as many columns as the width holds. */
.source-picker-quick {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 2px 6px;
}

.source-picker-quick .source-picker-item { min-width: 0; }

.source-picker-divider {
  height: 1px;
  margin: 6px 10px;
  background: var(--border-soft);
}

.source-picker-more { height: 1px; }

.source-picker-source-icon.is-document svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.source-picker-empty { padding: 16px 14px; font-size: var(--text-sm); text-align: center; }

.source-picker-empty.loading {
  display: grid;
  place-items: center;
  justify-items: center;
  min-height: 92px;
  padding: 18px 14px;
}

.source-picker-empty.loading .quiet-loader {
  margin: 0 auto;
}

/* ── Answer mode (Rychlý / Chytrý) ─────────────────────────────────
   A quiet text button beside the send button -- identical in both modes,
   only its word changes -- and a small popup with the two modes as tiles.
   The popup hangs off the composer's right edge and follows the source
   picker's side: below on a new chat, above in a conversation. */
.model-mode-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.model-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 8px 0 12px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}

.model-mode-btn:hover,
.model-mode-btn.is-open {
  background: var(--hover-bg);
  color: var(--ink);
}

.model-mode-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.model-mode-btn svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.model-mode-chevron {
  width: 14px;
  height: 14px;
  stroke-width: 2;
  transition: transform var(--dur) var(--ease-out);
}

.model-mode-btn.is-open .model-mode-chevron { transform: rotate(180deg); }

/* The single-line composer lays its buttons over the text, so the text
   keeps clear of the mode button as well as the send button -- with a
   gap, so it moves to two lines before it ever touches the button. */
.input-wrap:not(.multiline) .question-input { padding-right: 144px; }

.model-mode-popup {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 70;
  width: 300px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-pop);
}

.model-mode-popup.opens-below {
  top: calc(100% + 8px);
  bottom: auto;
}

/* Two tiles on a shared tray; the chosen one is lifted onto the surface,
   like a pressed segment. */
.model-mode-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: var(--r-lg);
  background: var(--hover-bg);
}

.model-mode-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 11px 8px 10px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--muted);
  font: inherit;
  text-align: center;
  cursor: pointer;
  transition: background var(--dur) var(--ease-out), color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}

.model-mode-option:hover { color: var(--ink); }

.model-mode-option.is-current {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-card);
}

.model-mode-option:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.model-mode-option svg {
  width: 19px;
  height: 19px;
  margin-bottom: 2px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.model-mode-option-name {
  font-size: var(--text-sm);
  font-weight: 600;
}

.model-mode-option-desc {
  color: var(--muted);
  font-size: var(--text-2xs);
  line-height: 1.35;
}

@media (prefers-reduced-motion: reduce) {
  .model-mode-option,
    .model-mode-chevron { transition: none; }
}
.source-picker-item-text { min-width: 0; display: block; }

.source-picker-item-name {
  color: inherit;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.input-wrap,
.question-input {
  /* The colour only: the library search draws its magnifier as a
     background image, which the shorthand would wipe. */
  background-color: var(--surface);
  border-color: var(--border-input);
  color: var(--ink);
}

#input-area form {
  border-top-color: transparent;
}

.question-input:empty::before {
  color: var(--faint);
}

.input-wrap,
.question-input {
  background: var(--surface);
}

/* The pill paints the field; the text inside it stays clear. With its own
   fill and a tighter radius it covered the pill's border at the top-left
   corner, which read as the outline fading out there. */
.input-wrap .question-input {
  background: transparent;
}

.input-wrap {
  border-color: var(--border);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.08);
}

.input-wrap:focus-within {
  border-color: var(--border-input);
  box-shadow: 0 20px 46px rgba(15, 23, 42, 0.11);
}

.input-wrap.multiline .composer-footer::before {
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), var(--surface) 84%);
}

@media (max-width: 720px) {
  #input-area {
      left: 0;
      right: 0;
      padding-inline: 10px;
    }
}
.source-picker-empty {
  color: var(--muted) !important;
}

.source-picker-item {
  color: var(--ink);
}

.source-picker-btn {
  background: var(--surface);
  border-color: var(--border-input);
  color: var(--text);
}

.composer-footer .source-picker-btn {
  background: transparent;
  border-color: transparent;
  color: var(--ink-strong);
  box-shadow: none;
}

.source-picker-btn:hover {
  background: var(--card-hover-bg);
  border-color: var(--green);
  color: var(--ink);
}

.composer-footer .source-picker-btn:hover {
  background: var(--hover-bg);
  border-color: transparent;
  color: var(--accent-hover);
}

#send-btn {
  background: var(--green);
  border-color: var(--green);
  color: var(--on-accent);
}

.composer-footer #send-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  border-radius: var(--r-pill);
  box-shadow: none;
}

#send-btn:hover {
	      background: var(--green-hover);
	      border-color: var(--green-hover);
	    }

.composer-footer #send-btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}


#send-btn:disabled {
  background: var(--border-soft);
  color: var(--faint);
}

.composer-footer #send-btn.is-uploading,
.composer-footer #send-btn.is-uploading:hover {
  background: var(--muted);
  border-color: var(--muted);
  color: var(--surface);
  opacity: 1;
}

.source-picker-header,
.source-picker-item {
  border-color: var(--border);
}

.source-picker-item.active {
  background: var(--active-bg);
}

#send-btn.is-stop {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

#send-btn.is-stop:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* The strip under the composer is the page ground, not a white shelf: the
   gradient exists so messages fade out as they scroll beneath it, which
   only works if it fades to the colour actually behind them. */
#input-area {
  background: linear-gradient(
    to top,
    var(--surface-page) 0%,
    rgb(var(--surface-page-rgb) / .96) 74%,
    rgb(var(--surface-page-rgb) / 0) 100%
  );
}

/* Ad-hoc chat file attachments */
.chat-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 9px 10px 0;
}

.chat-attachments[hidden] { display: none; }

.chat-attachment-chip {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  width: min(290px, calc(100vw - 72px));
  min-height: 50px;
  padding: 6px 36px 6px 7px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  box-sizing: border-box;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .03);
}

/* Same treatment as the export-file icon: the drawing carries the type, so
   it is tinted on transparent rather than reversed out of a filled tile. */
.chat-attachment-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}

.chat-attachment-chip[data-visual-kind="spreadsheet"] .chat-attachment-icon { color: var(--green); }

.chat-attachment-chip[data-visual-kind="document"] .chat-attachment-icon { color: var(--blue); }

.chat-attachment-chip[data-visual-kind="presentation"] .chat-attachment-icon { color: var(--presentation); }

.chat-attachment-chip[data-visual-kind="pdf"] .chat-attachment-icon { color: var(--red); }

/* Uploading takes over the icon slot rather than adding a second marker off
   at the edge of the chip: the slot already says what this row is about, and
   the file's own icon takes it back the moment the upload lands. The 36px
   column stays either way, so nothing shifts when it does.

   One ring serves both readings of an upload. Until the browser reports
   anything it is a quarter-arc that turns; once bytes are counted the same
   arc stops and grows to the fraction that has gone out. --upload-progress
   is the arc's length either way, which is why the animated state simply
   leaves it at its initial 25. */
.chat-attachment-chip.is-uploading .chat-attachment-icon svg { display: none; }

.chat-attachment-chip.is-uploading .chat-attachment-icon::after {
  content: '';
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: conic-gradient(
    var(--upload-ring, var(--muted)) calc(var(--upload-progress, 25) * 1%),
    var(--upload-ring-track, color-mix(in srgb, var(--muted) 24%, transparent)) 0);
  /* Masked to a ring rather than drawn as a border: a border cannot be a
     fraction of a circle, and a conic gradient cannot be a border. */
  -webkit-mask: radial-gradient(farthest-side, transparent 76%, #000 78%);
  mask: radial-gradient(farthest-side, transparent 76%, #000 78%);
  animation: spin .8s linear infinite;
  box-sizing: border-box;
}

/* Counted bytes: the ring holds still and fills. It stays full and still
   once every byte is out -- the server takes seconds more to store a large
   file, and the only thing that happens next is the file's own icon. */
.chat-attachment-chip[data-upload-progress] .chat-attachment-icon::after,
.chat-attachment-chip.is-image[data-upload-progress]::after {
  animation: none;
  transition: --upload-progress .18s linear;
}

.chat-attachment-chip.is-error {
  border-color: color-mix(in srgb, var(--red) 35%, var(--border));
}

.chat-attachment-chip.is-error .chat-attachment-type { color: var(--red); }

.chat-attachment-icon svg {
  width: 27px;
  height: 27px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-attachment-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.chat-attachment-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 17px;
}

.chat-attachment-type {
  color: var(--muted);
  font-size: var(--text-2xs);
  line-height: 15px;
}

/* The remove button appears on hover, so a chip reads as a file at rest
   rather than as something with a control stuck to it. Kept for keyboard
   users via :focus-within, which hover alone would lock them out of. */
.chat-attachment-chip { transition: background var(--dur), border-color var(--dur), box-shadow var(--dur); }

.chat-attachment-chip:hover {
  background: var(--surface-inset);
  border-color: var(--border-card-hover);
  box-shadow: 0 2px 6px rgba(15, 23, 42, .06);
}

.chat-attachment-remove {
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur), background var(--dur);
  position: absolute;
  /* Straddles the corner rather than sitting inside it, so it reads as a
     badge on the file instead of a control crowding the filename. */
  top: -7px;
  right: -7px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  /* A ring in the composer's own colour separates it from whatever it
     overlaps. */
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--ink);
  color: var(--on-accent);
  line-height: 0;
  cursor: pointer;
}

.chat-attachment-chip:hover .chat-attachment-remove,
.chat-attachment-chip:focus-within .chat-attachment-remove {
  opacity: 1;
  pointer-events: auto;
}

.chat-attachment-remove:hover { background: var(--text); }

.chat-attachment-remove:focus-visible { opacity: 1; pointer-events: auto; }

/* An SVG cross centres exactly; the × glyph carries its own side bearings
   and sat a pixel off no matter what line-height it was given. */
.chat-attachment-remove svg {
  width: 10px;
  height: 10px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
}

#ask-form.is-uploading .chat-attachment-chip {
  border-color: var(--border-card-hover);
  background: var(--surface-inset);
}

#ask-form.is-uploading .chat-attachment-remove {
  opacity: 0;
  pointer-events: none;
}

.input-wrap.has-attachments:not(.multiline) {
  min-height: 110px;
  border-radius: var(--r-2xl);
}

.input-wrap.has-attachments:not(.multiline) .composer-text-pane {
  min-height: 50px;
  max-height: 50px;
  margin-top: auto;
}

.input-wrap.has-attachments:not(.multiline) .composer-footer {
  top: auto;
  bottom: 9px;
  transform: none;
}

.chat-drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(247, 246, 240, .78);
  backdrop-filter: blur(4px);
  pointer-events: none; /* purely visual; drag events pass through to the window handlers */
}

.chat-drop-overlay[hidden] { display: none; }

.chat-drop-overlay-card {
  min-width: min(360px, calc(100vw - 48px));
  padding: 30px 42px;
  border: 1px dashed var(--border-focus);
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, .88);
  box-shadow: var(--shadow-pop);
  text-align: center;
  color: var(--ink);
}

.chat-drop-overlay-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--green);
}

.chat-drop-overlay-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-drop-overlay-title { margin-top: 12px; font-size: var(--text-base); font-weight: 600; }

/* Explicit chart command */
#ask-form {
  flex-direction: column;
}

.graph-command-palette,
.command-palette {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 10px);
  z-index: 120;
  padding: 8px;
  border: 1px solid var(--border-input);
  border-radius: var(--r-xl);
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 18px 48px rgba(15, 23, 42, .14);
  backdrop-filter: blur(14px);
}

.graph-command-palette[hidden],
.command-palette[hidden] {
  display: none;
}

.graph-command-options,
.command-palette-options {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

/* A deck thumbnail is a 16:9 slide, not a 96x54 chart glyph, so the
   template palette runs fewer and wider cells. */
.command-palette-options.is-templates {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.command-palette-option .template-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--r-xs);
  border: 1px solid var(--border-soft);
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
}

.command-palette-option .template-preview svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* The thumbnail is the template's own palette at postage-stamp size, so a
   reader picks by recognising the deck rather than by reading its name. */
.tpl-ground { fill: var(--surface-rail); }

.tpl-custom { fill: #fff; }

.tpl-light { fill: #f7f6f0; }

.tpl-kicker {
  font-family: var(--font-sans);
  font-size: 5px;
  font-weight: 700;
  letter-spacing: .7px;
}

.tpl-heading {
  font-family: var(--font-display);
  font-size: 8px;
  font-weight: 650;
}

.tpl-stat {
  font-family: var(--font-sans);
  font-size: var(--text-2xs);
  font-weight: 700;
}

.tpl-source {
  font-family: var(--font-sans);
  font-size: 4px;
}

.tpl-grid,
.tpl-chart {
  fill: none;
  stroke-width: 1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tpl-chart { stroke-width: 2; }

.tpl-neutral { fill: #69706a; }

.tpl-neutral-strong { fill: #242824; }

.tpl-neutral-grid { stroke: #e4e7e4; }

.tpl-neutral-chart { stroke: #69706a; }

.tpl-neutral-dot { fill: #69706a; }

.tpl-green { fill: #41702e; }

.tpl-ink { fill: #1b1e16; }

.tpl-ink-soft-fill { fill: #686b5f; }

.tpl-light-grid { stroke: #ddded5; }

.tpl-green-chart { stroke: #41702e; }

.tpl-mark { fill: #3e9e36; }

.template-option-copy {
  display: block;
  min-width: 0;
  text-align: left;
}

.template-option-copy strong {
  font-size: var(--text-xs);
  font-weight: 650;
  color: var(--text);
}

.graph-command-option,
.command-palette-option {
  min-width: 0;
  height: 96px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 5px;
  padding: 9px 9px 8px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--card-hover-bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.command-palette-options.is-templates .command-palette-option {
  height: auto;
  min-height: 150px;
  grid-template-rows: auto auto;
  align-content: start;
  gap: 7px;
}

.graph-command-option:hover,
.graph-command-option:focus-visible,
.graph-command-option.is-active,
.command-palette-option:hover,
.command-palette-option:focus-visible,
.command-palette-option.is-active {
  border-color: var(--border-card-hover);
  background: var(--active-bg);
  outline: none;
}

.graph-command-option:hover,
.command-palette-option:hover {
  transform: translateY(-1px);
}

.graph-command-option svg,
.command-palette-option svg {
  width: 100%;
  height: 54px;
  overflow: visible;
}

/* The chart palette, not the interface greys. charts.js keeps its own set
   for a reason -- it has to hold up as a set, under CVD and against the
   chart surface -- so a preview that used --muted would be advertising a
   chart the app does not draw. Where a token carries the identical value it
   is used; the two grid greys have drifted from theirs, so those are the
   chart's own. */
.gp-grid {
  fill: none;
  stroke: #e6e3d6;          /* CHART_GRID */
  stroke-width: 1;
}

.gp-axis {
  fill: none;
  stroke: #d8d4c3;          /* CHART_RULE */
  stroke-linecap: round;
  stroke-width: 1.2;
}

/* Vega interpolates the line as `monotone` and strokes it at 2.1 against a
   54-unit-tall plot, which is what the curve and the weight here are. */
.gp-line {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.4;
}

.gp-bar,
.gp-dot { fill: var(--accent); }

/* Slices are parted by a surface-coloured stroke, the way the arc mark is
   configured, so the ring reads as separate wedges and not one disc. */
.gp-slice-0, .gp-slice-1, .gp-slice-2, .gp-slice-3 {
  stroke: var(--surface);
  stroke-width: 1.6;
}

.gp-slice-0 { fill: var(--accent); }

.gp-slice-1 { fill: var(--blue); }

.gp-slice-2 { fill: var(--gold); }

.gp-slice-3 { fill: #8043a6; }

/* A choropleth in the `blues` scheme the map layer asks Vega for, on the
   app's own kraje outlines, hairlined in the chart surface. */
.graph-command-option [class^="gp-map-"] {
  stroke: var(--surface);
  stroke-width: .5;
  stroke-linejoin: round;
}

.gp-map-0 { fill: #deebf7; }

.gp-map-1 { fill: #c6dbef; }

.gp-map-2 { fill: #9ecae1; }

.gp-map-3 { fill: #6baed6; }

.gp-map-4 { fill: #4292c6; }

.gp-map-5 { fill: #2171b5; }

@media (max-width: 680px) {
  .graph-command-palette,
    .command-palette {
      left: 8px;
      right: 8px;
    }

  .graph-command-options,
    .command-palette-options {
      grid-auto-flow: column;
      grid-auto-columns: 126px;
      grid-template-columns: none;
      overflow-x: auto;
      overscroll-behavior-inline: contain;
      scroll-snap-type: inline proximity;
    }

  .graph-command-option {
      scroll-snap-align: start;
    }

  .command-palette-options.is-templates {
      grid-template-columns: none;
      grid-auto-columns: 210px;
    }

  .command-palette-options.is-templates .command-palette-option {
      scroll-snap-align: start;
    }
}
@media (prefers-reduced-motion: reduce) {
  .graph-command-option {
      transition: none;
    }
}
/* An image attachment is a thumbnail, not a chip: the picture identifies it
   far better than its filename, and at chip width it would otherwise be
   stretched across the whole tray. */
.chat-attachment-chip.is-image {
  display: block;
  width: 52px;
  min-width: 52px;
  height: 52px;
  min-height: 52px;
  padding: 0;
  border-radius: var(--r-md);
}

/* A thumbnail is the image's own icon, so the ring takes that slot the same
   way -- over the picture, which dims to let it read. */
.chat-attachment-chip.is-image.is-uploading::after {
  content: '';
  position: absolute;
  inset: 17px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: conic-gradient(
    #fff calc(var(--upload-progress, 25) * 1%),
    rgba(255, 255, 255, .4) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent 76%, #000 78%);
  mask: radial-gradient(farthest-side, transparent 76%, #000 78%);
  animation: spin .8s linear infinite;
  box-sizing: border-box;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .35));
}

.chat-attachment-chip.is-image.is-uploading .chat-attachment-thumb { opacity: .6; }

/* The thumbnail rounds itself, so the chip need not clip -- clipping would
   cut the remove badge off at the corner it straddles. */
.chat-attachment-thumb {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--r-md);
  object-fit: cover;
}

@media (max-width: 720px) {
  body[data-mode="chat"] #input-area {
      padding-left: var(--rail-toggle-slot);
    }
}
