/*
 * Fred's terminal (lane t22-fredterm, 8 Oct 2026; js/v21_fredterm.js 1.0.0): the leaders' button in the top bar and
 * the side panel (status, then the messages). The desk's own tokens, so every theme follows, light and dark and High
 * contrast. No inline styles.
 */
.ft-btn {
  position: relative; display: inline-flex; align-items: center; gap: 6px; height: 40px; margin-right: 6px; padding: 0 12px;
  border: 1px solid var(--glass-rim); border-radius: 999px; background: var(--solid); color: var(--ink-2); cursor: pointer;
  box-shadow: var(--shadow-1); font: inherit; font-size: .875rem; font-weight: 700;
}
.ft-btn:hover, .ft-btn.has-new { color: var(--ink); }
.ft-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.ft-dot {
  position: absolute; top: -3px; right: -3px; width: 12px; height: 12px; border-radius: 50%; background: var(--info);
  border: 2px solid var(--solid);
}

.sheet.ft-sheet { width: min(640px, 100%); }
.ft-sheet .sheet-b { gap: 22px; }
.ft-h { margin: 0 0 8px; font-size: 1.0625rem; }
.ft-sub { margin: 14px 0 6px; font-size: .875rem; color: var(--ink-2); text-transform: none; }

.ft-summary {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 0; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--glass-rim); font-weight: 700; font-size: .9375rem;
}
.ft-summary .meta { font-weight: 400; margin-left: auto; font-size: .75rem; }
.ft-summary.is-ok { background: color-mix(in srgb, var(--ok, #2e7d32) 10%, var(--solid)); }
.ft-summary.is-bad { background: color-mix(in srgb, var(--danger) 10%, var(--solid)); }
.ft-ldot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--ink-3, var(--ink-2)); }
.ft-summary.is-ok .ft-ldot, .ft-loop.is-running .ft-ldot { background: var(--ok, #2e7d32); }
.ft-summary.is-bad .ft-ldot, .ft-loop.is-stopped .ft-ldot, .ft-loop.is-missing .ft-ldot { background: var(--danger); }
.ft-loop.is-late .ft-ldot { background: var(--warn); }

.ft-fred { padding: 2px 0 0; }
.ft-dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; margin: 0 0 4px; font-size: .875rem; }
.ft-dl dt { color: var(--ink-2); font-weight: 700; }
.ft-dl dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.ft-dl dd.is-wait { color: var(--warn); font-weight: 700; }
.ft-fred .meta, .ft-status > .meta { margin: 0; font-size: .75rem; }

.ft-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px; margin-top: 12px; }
.ft-tile {
  display: grid; gap: 2px; align-content: start; padding: 10px 12px; border: 1px solid var(--glass-rim); border-radius: 12px;
  background: var(--solid);
}
.ft-tile-h { font-size: .75rem; color: var(--ink-2); font-weight: 700; }
.ft-tile-n { font-size: 1.125rem; font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ft-tile-l { font-size: .75rem; line-height: 1.1rem; }
.ft-tile.is-bad { border-color: var(--danger); }
.ft-tile.is-bad .ft-tile-n { color: var(--danger); }
.ft-tile.is-warn { border-color: var(--warn); }
.ft-fails { margin: 8px 0 0; padding-left: 18px; font-size: .8125rem; color: var(--ink-2); }

.ft-loops { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.ft-loop {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 2px 10px; padding: 6px 8px;
  border-radius: 8px; font-size: .875rem;
}
.ft-loop:nth-child(odd) { background: var(--glass-hover); }
.ft-lname { font-weight: 700; overflow-wrap: anywhere; }
.ft-lstate { font-weight: 700; font-size: .8125rem; }
.ft-loop.is-late .ft-lstate { color: var(--warn); }
.ft-loop.is-stopped .ft-lstate, .ft-loop.is-missing .ft-lstate { color: var(--danger); }
.ft-lwhen { grid-column: 2 / 4; font-size: .75rem; }

.ft-thread { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.ft-empty { padding: 8px 0; font-size: .875rem; }
.ft-msg { padding: 10px 12px; border: 1px solid var(--glass-rim); border-radius: 12px; background: var(--solid); }
.ft-msg.is-mine { background: color-mix(in srgb, var(--info) 6%, var(--solid)); }
.ft-mhead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; font-size: .8125rem; }
.ft-who { font-weight: 800; }
.ft-chip {
  margin-left: auto; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 700; color: var(--ink-2);
  border: 1px solid var(--glass-rim);
}
.ft-chip.is-read { color: var(--info); border-color: var(--info); }
.ft-chip.is-on_it { color: var(--warn); border-color: var(--warn); }
.ft-chip.is-done { color: var(--ok, #2e7d32); border-color: var(--ok, #2e7d32); }
.ft-text { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .9375rem; line-height: 1.4rem; }
.ft-replies { list-style: none; margin: 10px 0 0; padding: 0 0 0 14px; display: grid; gap: 8px; border-left: 3px solid var(--info); }
.ft-reply .ft-text { font-size: .875rem; }

.ft-compose { display: grid; gap: 8px; position: sticky; bottom: -32px; padding: 10px 0 4px; background: var(--solid); }
.ft-label { font-weight: 700; font-size: .875rem; }
.ft-box {
  width: 100%; min-height: 72px; resize: vertical; padding: 10px 12px; border: 1px solid var(--glass-rim); border-radius: 10px;
  background: var(--solid); color: var(--ink); font: inherit; font-size: .9375rem; line-height: 1.35rem; box-sizing: border-box;
}
.ft-box:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.ft-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.ft-hint { margin: 0; flex: 1 1 200px; font-size: .75rem; }
.ft-count { font-size: .75rem; font-variant-numeric: tabular-nums; }
.ft-count.is-over { color: var(--danger); font-weight: 700; }
.ft-note { margin: 0; font-size: .8125rem; min-height: 1.1rem; }

/* 1.1.0 (8 Oct 19:3x): the connected line, Details, quick asks, the box beside Send, the moving dots */
.ft-conn {
  display: flex; align-items: center; gap: 10px; margin: 0 0 8px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--glass-rim); font-weight: 700; font-size: .9375rem;
}
.ft-conn.is-ok { background: color-mix(in srgb, var(--ok, #2e7d32) 8%, var(--solid)); }
.ft-conn.is-bad { background: color-mix(in srgb, var(--danger) 12%, var(--solid)); border-color: var(--danger); }
.ft-conn.is-ok .ft-ldot { background: var(--ok, #2e7d32); }
.ft-conn.is-bad .ft-ldot { background: var(--danger); }
.ft-ldot.is-live { animation: ft-pulse 2s ease-in-out infinite; }
@keyframes ft-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok, #2e7d32) 55%, transparent); }
  50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--ok, #2e7d32) 0%, transparent); }
}
.ft-status .ft-summary { margin-bottom: 4px; }
.ft-more { margin-top: 10px; border: 1px solid var(--glass-rim); border-radius: 12px; padding: 0 12px; background: var(--solid); }
.ft-more[open] { padding-bottom: 10px; }
.ft-more-h { cursor: pointer; padding: 10px 0; font-weight: 700; font-size: .8125rem; color: var(--ink-2); }
.ft-more-h:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.ft-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.ft-qbtn {
  min-height: 34px; padding: 4px 12px; border: 1px solid var(--glass-rim); border-radius: 999px; background: var(--solid);
  color: var(--ink); font: inherit; font-size: .8125rem; font-weight: 700; cursor: pointer;
}
.ft-qbtn:hover { background: var(--glass-hover); }
.ft-qbtn:active { transform: scale(.97); }
.ft-qbtn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.ft-inrow { display: flex; align-items: flex-end; gap: 8px; }
.ft-inrow .ft-box { flex: 1 1 auto; min-height: 48px; }
.ft-inrow .btn { flex: none; min-height: 48px; padding: 0 20px; }
.ft-chip { display: inline-flex; align-items: center; gap: 6px; }
.ft-chip.is-sent { color: var(--info); border-color: var(--info); }
.ft-busy {
  display: inline-block; width: 18px; height: 6px; flex: none;
  background: radial-gradient(circle, currentColor 2.4px, transparent 2.8px) 0 50% / 6px 6px repeat-x;
  animation: ft-wait 1.2s steps(4, end) infinite;
}
@keyframes ft-wait { 0% { width: 0; } 100% { width: 24px; } }
.ft-msg.is-mine.is-sent, .ft-msg.is-mine.is-on_it { border-color: color-mix(in srgb, var(--info) 45%, var(--glass-rim)); }

@media (prefers-reduced-motion: reduce) {
  .ft-ldot.is-live, .ft-busy { animation: none; }
  .ft-busy { width: 18px; }
  .ft-qbtn:active { transform: none; }
}

/* 1.2.0 (t22-fredterm2): Open wide, the control room beside the messages; the side panel keeps the feed short */
.ft-headx { display: inline-flex; align-items: center; gap: 6px; }
.ft-widebtn { border-radius: 999px; font-weight: 800; }
.ft-widebtn[aria-pressed="false"] { background: linear-gradient(90deg, color-mix(in srgb, var(--info) 18%, var(--solid)), var(--solid)); border-color: color-mix(in srgb, var(--info) 45%, var(--glass-rim)); }
.sheet.ft-sheet.ft-wide { width: min(1480px, 100%); transition: width .35s cubic-bezier(.2, .8, .2, 1); }
.sheet.ft-sheet { transition: width .35s cubic-bezier(.2, .8, .2, 1); }
.ft-sheet:not(.ft-wide) .ftl-stage { display: none; }
.ft-sheet:not(.ft-wide) .ftl-feed { max-height: 168px; }
.ft-left { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.ft-left > .ft-status { order: 1; }
.ft-left > .ft-live { order: 2; }
.ft-sheet.ft-wide .ft-left > .ft-live { order: 1; }
.ft-sheet.ft-wide .ft-left > .ft-status { order: 2; }
@media (min-width: 900px) {
  .ft-sheet.ft-wide .sheet-b {
    grid-template-columns: minmax(0, 1.45fr) minmax(360px, 1fr); grid-template-rows: minmax(0, 1fr);
    overflow: hidden; align-content: stretch; gap: 22px; padding-bottom: 14px;
  }
  .ft-sheet.ft-wide .ft-left { min-height: 0; overflow: auto; padding-right: 6px; overscroll-behavior: contain; }
  .ft-sheet.ft-wide .ft-msgs { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
  .ft-sheet.ft-wide .ft-thread { flex: 1 1 auto; min-height: 0; overflow: auto; padding-right: 4px; overscroll-behavior: contain; align-content: start; }
  .ft-sheet.ft-wide .ft-compose { position: static; padding-bottom: 0; }
  .ft-sheet.ft-wide .ft-status { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: stretch; }
  .ft-sheet.ft-wide .ft-status .ft-h { display: none; }
  .ft-sheet.ft-wide .ft-status .ft-conn, .ft-sheet.ft-wide .ft-status .ft-summary { margin: 0; }
  .ft-sheet.ft-wide .ft-status .ft-fred, .ft-sheet.ft-wide .ft-status .ft-more { grid-column: 1 / -1; margin-top: 0; }
}
@media (prefers-reduced-motion: reduce) { .sheet.ft-sheet, .sheet.ft-sheet.ft-wide { transition: none; } }

@media (max-width: 760px) {
  .ft-btn { height: 36px; padding: 0 9px; margin-right: 4px; }
  .ft-btn-t { display: none; }
  .ft-inrow .btn { padding: 0 14px; }
  .ft-hint { flex-basis: 100%; }
}
@media (forced-colors: active) {
  .ft-ldot, .ft-dot { forced-color-adjust: none; border: 1px solid CanvasText; }
  .ft-chip, .ft-msg, .ft-tile { border: 1px solid CanvasText; }
}
