/* Ferra shop chat (#184). Own file so this PR does not collide with
   grok/expedite-density on app.css. Tokens only. Print-hidden. */

/* Launcher: a fixed bottom-right button, reachable from every screen instead of
   one word in the topbar. Solid fill and a 2px border so it reads under shop
   fluorescents; no pulse, no glow, no amber — amber is the expedite signal and
   this is not an expedite. Raised clearance (bottom 72px) so it sits above the
   Inbox Review/Archive row zone and never covers Archive. B12: the mark is an
   inline stencil-F SVG (currentColor), never an <img>, photograph, or face. */
#ferra-open {
  position: fixed;
  right: 24px;
  bottom: 72px;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  padding: 0;
  background: var(--panel2);
  color: #dfe6f2;
  border: 2px solid rgba(90, 140, 220, .55);
  border-radius: 50%;
  cursor: pointer;
  font-family: inherit;
}
#ferra-open:hover {
  background: rgba(90, 140, 220, .24);
  border-color: var(--accent);
}
#ferra-open:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
/* Open: step left of the 360px drawer so the launcher stays visible and keeps
   the focus it is given when the drawer closes. */
#ferra-open[aria-expanded="true"] {
  right: 384px;
  color: var(--accent);
  border-color: var(--accent);
}
/* Brand stencil F — inline SVG, currentColor so FAB/drawer chrome tint it. */
.ferra-fab-mark,
.ferra-head-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  line-height: 0;
}
.ferra-fab-mark { width: 28px; height: 28px; }
.ferra-head-mark { width: 28px; height: 28px; color: var(--accent); }
.ferra-mark {
  display: block;
  width: 100%;
  height: 100%;
}
.ferra-head-id {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

#ferra-drawer {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 100vw;
  background: var(--panel);
  border-left: 1px solid var(--border);
  z-index: 110;
  flex-direction: column;
  font-size: 13px;
  line-height: 1.4;
}
#ferra-drawer.is-open { display: flex; }

.ferra-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.ferra-name {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: .4px;
}
.ferra-sig { font-size: 11px; color: var(--muted); margin-top: 1px; }
.ferra-head-actions { display: flex; align-items: center; gap: 4px; }
.ferra-head-actions button {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.ferra-head-actions button:hover { border-color: #5a6580; }
#ferra-close {
  font-size: 16px;
  line-height: 1;
  padding: 2px 8px;
  color: var(--muted);
  background: none;
  border-color: transparent;
}

/* 139-lock copy, not decoration: the drawer has to SAY it is a clerk that drafts
   and that a human approves and sends. Muted, but never display:none — if the note
   is ever hidden the lock stops being visible to the person using the screen. */
.ferra-note {
  margin: 0;
  padding: 7px 12px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
  background: var(--panel2);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.ferra-ctx {
  padding: 6px 12px;
  font-size: 11px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  font-family: 'IBM Plex Mono', monospace;
  flex: 0 0 auto;
  min-height: 28px;
}

.ferra-log {
  flex: 1 1 auto;
  overflow: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}
.ferra-empty { color: var(--muted); font-size: 12px; padding: 4px 0; }
.ferra-msg {
  max-width: 100%;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
}
.ferra-msg-user {
  align-self: flex-end;
  background: var(--panel2);
  color: var(--text);
}
.ferra-msg-ferra {
  align-self: flex-start;
  background: var(--bg);
  color: var(--text);
}
.ferra-msg-status {
  align-self: flex-start;
  background: transparent;
  border-style: dashed;
  color: var(--muted);
  font-size: 12px;
}
.ferra-who {
  display: block;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: .3px;
  text-transform: uppercase;
  margin-bottom: 3px;
}

/* Reply rating. Chrome, not a signal — no amber (amber is expedite) and no colour
   fill that would pull the eye off the answer. 32px targets for a shop-floor thumb;
   the pressed thumb is a border + panel fill, so it reads without relying on colour.
   B12: the glyphs are characters, never an image of a person. */
.ferra-rate {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  white-space: normal;
}
.ferra-rate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 28px;
  padding: 0 6px;
  font-size: 13px;
  line-height: 1;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
  opacity: .65;
}
.ferra-rate-btn:hover { opacity: 1; border-color: #5a6580; }
.ferra-rate-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  opacity: 1;
}
.ferra-rate-btn.is-on {
  opacity: 1;
  background: var(--panel2);
  border-color: var(--accent);
  color: var(--text);
}
.ferra-rate-said {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: .2px;
  margin-left: 2px;
}

/* One optional line after a thumbs-down. Text only — there is no file control
   anywhere in this drawer and there must never be one. */
.ferra-note-row {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  white-space: normal;
}
.ferra-note-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 30px;
  padding: 4px 7px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 5px;
}
.ferra-note-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.ferra-note-save {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
}
.ferra-note-save:hover { border-color: #5a6580; }

.ferra-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  white-space: normal;
}
.ferra-chip {
  display: inline-block;
  font-size: 11px;
  line-height: 1.35;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel2);
  color: var(--text);
  font-family: 'IBM Plex Mono', monospace;
}
.ferra-chip-id { font-weight: 600; }
.ferra-chip-exp {
  background: var(--accent-warn);
  color: #0a0603;
  border-color: var(--accent-warn-dim);
  font-weight: 600;
  font-family: inherit;
}

.ferra-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.ferra-form {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex: 0 0 auto;
}

/* C3 verbs. Takes a full row of the wrapped form so it reads as a hint above the
   box, not as a control beside it. These are asks, not buttons — nothing here
   fires a mutation, mints a number, or sends mail. */
.ferra-verbs {
  flex: 1 0 100%;
  margin: 0;
  font-size: 10px;
  line-height: 1.5;
  color: var(--muted);
  letter-spacing: .02em;
}
.ferra-verbs span {
  display: inline-block;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 5px;
  margin: 2px 2px 0 0;
}
#ferra-input {
  flex: 1 1 auto;
  min-height: 44px;
  max-height: 120px;
  resize: vertical;
  font-size: 13px;
  line-height: 1.35;
}
#ferra-send {
  flex: 0 0 auto;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  min-height: 44px;
}
#ferra-send:hover { opacity: .9; }
#ferra-send:disabled { opacity: .45; cursor: not-allowed; }

@media (max-width: 640px) {
  #ferra-drawer { width: 100vw; }
  #ferra-open { width: 48px; height: 48px; right: 16px; bottom: 60px; }
  /* Full-width drawer — nowhere to step aside to; the drawer's own Close is the
     way out, so the launcher just stays put behind it. */
  #ferra-open[aria-expanded="true"] { right: 16px; }
}

@media print {
  #ferra-open, #ferra-drawer { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  #ferra-drawer, #ferra-open { transition: none; }
}
