/* ============================================================================
   The composer — the question box (Oct 2026)
   ----------------------------------------------------------------------------
   One card. The question on top, a quiet toolbar below; the orange Send is the
   only filled control. Three states, each carried by ONE motion or ONE row:

     before  → the card at rest; context mode is a chip, shortcuts sit under it
     during  → a hairline travels the top edge and a ring circles Stop; the box
               stays live (S10 steering) — nothing in it repeats the answer's
               work line (that fact lives once, in the Living Answer)
     after   → the turn's receipt row on top of the card (verdict · time ·
               tokens · cost · trust record) until the next keystroke

   Theme tokens only; reduced motion keeps every state and removes the travel.
   ============================================================================ */

#chat-form.composer {
    --cmp-bg: var(--card-bg, rgba(24, 26, 30, 0.92));
    --cmp-line: var(--border-primary, rgba(255, 255, 255, 0.1));
    --cmp-edge: color-mix(in srgb, var(--text-muted, #94a3b8) 34%, transparent);
    --cmp-chip: var(--hover-bg, rgba(255, 255, 255, 0.05));
    --cmp-hover: var(--hover-bg-strong, rgba(255, 255, 255, 0.08));
    --cmp-ac: var(--teradata-orange, #F15F22);
    --cmp-d: 160ms;
    --cmp-ease: cubic-bezier(.2, .7, .2, 1);

    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 10px 8px 14px;
    background: var(--cmp-bg);
    border: 1px solid var(--cmp-edge);
    border-radius: 18px;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 32px rgba(0, 0, 0, 0.32);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    transition: border-color var(--cmp-d) var(--cmp-ease), box-shadow var(--cmp-d) var(--cmp-ease);
}
#chat-form.composer:focus-within {
    border-color: color-mix(in srgb, var(--cmp-ac) 60%, transparent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cmp-ac) 14%, transparent), 0 12px 32px rgba(0, 0, 0, 0.32);
}
[data-theme="light"] #chat-form.composer {
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 10px 28px rgba(15, 23, 42, 0.08);
}
[data-theme="light"] #chat-form.composer:focus-within {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cmp-ac) 14%, transparent), 0 10px 28px rgba(15, 23, 42, 0.08);
}

/* the input row — the card is the box; the wrapper and the textarea draw nothing */
#chat-form #input-area,
#chat-form #input-area:focus-within {
    display: block;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    border-radius: 0;
    padding: 0;
}
#chat-form textarea#user-input.composer-textarea {
    display: block;
    width: 100%;
    min-height: 30px;
    padding: 6px 4px 4px;
    margin: 0;
    font-size: 15px;
    line-height: 1.55;
    color: var(--text-primary);
    background: transparent;
}
#chat-form textarea#user-input.composer-textarea::placeholder { color: var(--text-muted); opacity: 1; }
#chat-form textarea#user-input.composer-textarea:focus { box-shadow: none !important; }
#chat-form textarea#user-input.composer-textarea:disabled { cursor: not-allowed; }

/* the toolbar */
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; }
.composer-group { display: flex; align-items: center; gap: 6px; min-width: 0; }
.composer-group--context { flex: 1 1 auto; flex-wrap: wrap; }
.composer-group--acts { flex: none; }
#chat-form #active-profile-tag { margin-left: 0; }

.composer-ib {
    width: 36px; height: 36px; border-radius: 10px; border: 0; padding: 0;
    background: transparent; color: var(--text-muted);
    align-items: center; justify-content: center; cursor: pointer;
    transition: background var(--cmp-d) var(--cmp-ease), color var(--cmp-d) var(--cmp-ease);
}
.composer-ib:not(.hidden) { display: inline-flex; }
.composer-ib:hover:not(:disabled) { background: var(--cmp-hover); color: var(--text-primary); }
.composer-ib:disabled { cursor: wait; }
.composer-ib:focus-visible,
.composer-ctx:focus-visible,
.composer-send:focus-visible,
.composer-receipt button:focus-visible { outline: 2px solid var(--cmp-ac); outline-offset: 2px; }
/* a mode that is ON wears the accent (voice held / locked, observations on autoplay) */
#chat-form .composer-ib.is-active,
#chat-form #key-observations-toggle-button.autoplay-on { background: var(--cmp-ac); color: #fff; }
#chat-form #key-observations-toggle-button.off { opacity: 0.55; }

/* the context mode — a chip, not a sentence under the box */
.composer-ctx {
    display: inline-flex; align-items: center; gap: 6px;
    height: 28px; padding: 0 9px; border-radius: 8px;
    border: 1px solid var(--cmp-line); background: var(--cmp-chip);
    color: var(--text-muted); font: 500 12px/1 var(--font-primary, system-ui, sans-serif);
    cursor: pointer; white-space: nowrap;
    transition: color var(--cmp-d) var(--cmp-ease), border-color var(--cmp-d) var(--cmp-ease), background var(--cmp-d) var(--cmp-ease);
}
.composer-ctx:hover { color: var(--text-primary); border-color: var(--cmp-edge); }
.composer-ctx[data-mode="temp"] { color: var(--trust-warn, #f59e0b); border-color: color-mix(in srgb, var(--trust-warn, #f59e0b) 45%, transparent); }
.composer-ctx[data-mode="locked"] { color: var(--cmp-ac); border-color: color-mix(in srgb, var(--cmp-ac) 50%, transparent); background: color-mix(in srgb, var(--cmp-ac) 8%, transparent); }

.composer-steer-tag {
    display: none; align-items: center; gap: 6px; padding-left: 4px;
    font: 400 12px/1 var(--font-primary, system-ui, sans-serif); color: var(--text-muted); white-space: nowrap;
}
#chat-form.is-steering .composer-steer-tag { display: inline-flex; }

/* Send ↔ Stop — one control, a ring around it while the turn runs */
.composer-send-wrap { position: relative; width: 40px; height: 40px; display: grid; place-items: center; }
#chat-form .composer-send {
    position: relative; width: 36px; height: 36px; border-radius: 50%; border: 0; padding: 0;
    display: grid; place-items: center; cursor: pointer;
    background: var(--cmp-ac); color: #fff;
    transition: background var(--cmp-d) var(--cmp-ease), color var(--cmp-d) var(--cmp-ease), transform 120ms var(--cmp-ease);
}
#chat-form .composer-send:hover:not(:disabled) { background: color-mix(in srgb, var(--cmp-ac) 86%, #000); }
#chat-form .composer-send:active:not(:disabled) { transform: scale(0.94); }
#chat-form .composer-send:disabled,
#chat-form.is-empty .composer-send:not(.composer-stop) {
    background: color-mix(in srgb, var(--text-muted) 20%, transparent); color: var(--text-muted);
}
#chat-form .composer-send:disabled { cursor: default; }
/* the send arrow no longer encodes the context mode (the chip does) */
#chat-form #send-icon, #chat-form #send-icon.flipped { transform: none; transition: none; }
#chat-form #submit-button.composer-stop { background: var(--text-primary); color: var(--bg-primary, #0f1115); }
#chat-form #submit-button.composer-stop:hover { background: #dc2626; color: #fff; }
#chat-form #submit-button.is-stopping { opacity: 0.6; cursor: wait; }

.composer-ring { position: absolute; inset: -2px; width: 44px; height: 44px; pointer-events: none; opacity: 0; transition: opacity 220ms var(--cmp-ease); }
.composer-ring-track { fill: none; stroke: var(--cmp-line); stroke-width: 2; }
.composer-ring-arc {
    fill: none; stroke: var(--cmp-ac); stroke-width: 2; stroke-linecap: round; stroke-dasharray: 28 98;
    transform-origin: 22px 22px; animation: cmp-spin 1.4s linear infinite; animation-play-state: paused;
}
#chat-form.is-running .composer-ring { opacity: 1; }
#chat-form.is-running .composer-ring-arc { animation-play-state: running; }

/* the hairline — the box is working (inset from the corners, so nothing clips it) */
.composer-hair { position: absolute; left: 18px; right: 18px; top: -1px; height: 2px; overflow: hidden; border-radius: 2px; pointer-events: none; opacity: 0; transition: opacity 240ms var(--cmp-ease); }
.composer-hair i {
    position: absolute; top: 0; left: -35%; width: 35%; height: 100%;
    background: linear-gradient(90deg, transparent, var(--cmp-ac), transparent);
    animation: cmp-hair 1.6s cubic-bezier(.4, 0, .2, 1) infinite; animation-play-state: paused;
}
#chat-form.is-running .composer-hair { opacity: 1; }
#chat-form.is-running .composer-hair i { animation-play-state: running; }

/* the receipt — what the last turn came to, on the card, until the next keystroke */
.composer-receipt {
    display: flex; align-items: center; gap: 12px;
    margin: -10px -10px 6px -14px; padding: 0 8px 0 14px; min-height: 34px;
    border-bottom: 1px solid var(--cmp-line); border-radius: 17px 17px 0 0;
    background: color-mix(in srgb, var(--text-muted) 7%, transparent);
    font: 500 11.5px/1 var(--font-mono, ui-monospace, monospace); color: var(--text-muted);
    animation: cmp-receipt-in 240ms var(--cmp-ease);
}
.composer-receipt[hidden] { display: none; }
.composer-receipt .cr-verdict { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.composer-receipt .cr-verdict.cr-pass { color: var(--trust-pass, #34d399); }
.composer-receipt .cr-verdict.cr-warn { color: var(--trust-warn, #fbbf24); }
.composer-receipt .cr-verdict.cr-danger { color: var(--trust-danger, #f87171); }
.composer-receipt .cr-verdict.cr-na { color: var(--trust-na, var(--text-muted)); }
.composer-receipt .cr-sep { width: 1px; height: 14px; background: var(--cmp-edge); flex: none; }
.composer-receipt .cr-fig { white-space: nowrap; }
.composer-receipt .cr-fig b { color: var(--text-primary); font-weight: 500; }
.composer-receipt .cr-grow { flex: 1; }
.composer-receipt button {
    display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px; border-radius: 6px;
    border: 0; background: transparent; color: var(--text-primary); font: inherit; cursor: pointer;
}
.composer-receipt button:hover { background: var(--cmp-hover); }
.composer-receipt .cr-dismiss { width: 24px; padding: 0; justify-content: center; color: var(--text-muted); }

/* the shortcuts line under the card */
.composer-hint {
    margin-top: 8px; text-align: center;
    font: 400 11.5px/1.4 var(--font-mono, ui-monospace, monospace); color: var(--text-muted);
}
.composer-hint kbd {
    font: 500 11px var(--font-mono, ui-monospace, monospace); color: var(--text-primary);
    padding: 0 4px; border-radius: 4px; border: 1px solid var(--cmp-line, var(--border-primary)); border-bottom-width: 2px;
    background: var(--card-bg);
}

@keyframes cmp-spin { to { transform: rotate(360deg); } }
@keyframes cmp-hair { from { left: -35%; } to { left: 100%; } }
@keyframes cmp-receipt-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
    #chat-form.composer, .composer-ib, .composer-ctx, #chat-form .composer-send { transition: none; }
    .composer-ring-arc { animation: none; }
    .composer-hair i { animation: none; left: 0; width: 100%; opacity: 0.5; }
    .composer-receipt { animation: none; }
}

@media (max-width: 640px) {
    #chat-form.composer { padding: 8px 8px 6px 12px; border-radius: 16px; }
    .composer-receipt { margin: -8px -8px 6px -12px; border-radius: 15px 15px 0 0; flex-wrap: wrap; row-gap: 4px; padding-top: 6px; padding-bottom: 6px; }
    .composer-hint { display: none; }
}
