/* ============================================================
   The Loom — always-on GM capture surface.

   Global (non-scoped) styles because the Loom spans multiple components
   (WorldLoomRail, LoomCaptureInput, LoomProposalCard, LoomPendingTray,
   LoomSmartPaste, LoomGhostScan, WorldCommandPalette). Blazor scoped
   CSS wouldn't cross component boundaries, so these live here alongside
   world-dashboard.css, cinema.css, etc. per the app's convention.

   Sections below (separated by the original ============= rules):
     1) WorldLoomRail — frame, thread, header, capture, tray, cards, paste,
        answer pane, responsive drawer
     2) WorldCommandPalette — offset parchment card + ink cursor
     3) LoomGhostScan — stitched-thread chip + moonlit-glass popover
   ============================================================ */

/*
    The Loom — rail, expanded + collapsed + responsive drawer.

    Identity: a warm wood frame strung with a single gold thread; captures tie
    into the thread and become knots (proposals); accepting unweaves a knot
    into the world. Not a todo list — an instrument that listens.

    Typography: MedievalSharp for the Loom wordmark, Alegreya italic for whispered
    UI copy, Alegreya SC for mechanical labels. No generic sans.

    Motion budget: three moments earn animation — capture submitted, proposal
    accepted, world answers. Everything else is still.
*/

.rw-loom {
    position: sticky;
    top: 1rem;
    align-self: flex-start;
    width: 340px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px 18px 18px;
    /* Warm wood frame: two-tone border + inset gold stitching suggests a real
       object, not a div. Subtle ambient grain prevents the dark panel from
       reading as a flat tech surface. */
    background:
        radial-gradient(ellipse at 50% -10%, rgba(236, 208, 106, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 50% 110%, rgba(61, 138, 85, 0.06) 0%, transparent 50%),
        linear-gradient(180deg, rgba(30, 60, 66, 0.45) 0%, rgba(11, 24, 32, 0.96) 100%),
        var(--rw-bg-panel);
    border: 1px solid var(--rw-border-gold);
    border-radius: var(--rw-radius-lg);
    box-shadow:
        inset 0 1px 0 rgba(236, 208, 106, 0.08),
        inset 0 0 0 1px rgba(10, 20, 26, 0.6),
        var(--rw-glow-candle),
        0 2px 22px rgba(0, 0, 0, 0.3);
    max-height: calc(100dvh - 2rem);
    overflow: hidden;
}

/* ── Thread: a single gold filament running down the rail's inner edge.
   Everything pending ties into this thread via a matching 2px source-color
   bar on its left edge. The thread is decorative but intentional — it's the
   visual spine of the metaphor. */
.rw-loom::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 60px;
    bottom: 18px;
    width: 1px;
    background: linear-gradient(
        180deg,
        transparent 0%,
        var(--rw-gold-glow) 8%,
        var(--rw-gold) 50%,
        var(--rw-gold-ember) 92%,
        transparent 100%);
    opacity: 0.45;
    pointer-events: none;
}

/* Ambient grain — 3% opacity, extremely subtle. Breaks the flatness without
   being noticeable. Single tiny SVG inlined as base64. */
.rw-loom::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence baseFrequency='0.9' numOctaves='2'/><feColorMatrix values='0 0 0 0 0.7  0 0 0 0 0.6  0 0 0 0 0.35  0 0 0 0.4 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.4'/></svg>");
    opacity: 0.03;
    mix-blend-mode: overlay;
    pointer-events: none;
    border-radius: inherit;
}

.rw-loom--collapsed {
    width: 54px;
    padding: 14px 6px 14px;
    gap: 14px;
    align-items: center;
}

.rw-loom--collapsed::before { display: none; }

/* ── Header: a ritual mark, not a title.
   MedievalSharp wordmark + a slowly rotating 3-thread braid sigil. The GM's eye
   should drift to this and feel "this is a place," not "this is a toolbar." */

.rw-loom__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--rw-border-narrative);
    position: relative;
}

.rw-loom__sigil {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    color: var(--rw-gold-light);
    opacity: 0.9;
    animation: rw-loom-braid 24s linear infinite;
}

@keyframes rw-loom-braid {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.rw-loom__wordmark {
    font-family: var(--rw-font-display);
    font-size: 18px;
    letter-spacing: 0.08em;
    color: var(--rw-gold-light);
    text-shadow: 0 0 18px rgba(236, 208, 106, 0.15);
    margin: 0;
    line-height: 1;
    flex: 1;
    min-width: 0;
}

.rw-loom__collapse-btn {
    background: transparent;
    color: var(--rw-sage-tan);
    border: 1px solid var(--rw-border-gold);
    border-radius: var(--rw-radius-sm);
    width: 24px;
    height: 24px;
    padding: 0;
    cursor: pointer;
    font-family: var(--rw-font-display);
    font-size: 14px;
    line-height: 1;
    transition: border-color var(--rw-transition), color var(--rw-transition), background var(--rw-transition);
    flex-shrink: 0;
}

.rw-loom__collapse-btn:hover {
    border-color: var(--rw-border-strong);
    color: var(--rw-gold-light);
    background: var(--rw-gold-ember);
}

/* Collapsed-mode header: the sigil stays visible as the rail's identity mark. */
.rw-loom--collapsed .rw-loom__header {
    flex-direction: column;
    gap: 10px;
    padding-bottom: 0;
    border-bottom: none;
}

.rw-loom--collapsed .rw-loom__wordmark,
.rw-loom--collapsed .rw-loom__tagline { display: none; }

/* Collapsed badge rail — pending count + source glyphs stacked vertically so
   the GM can tell at a glance "something from last session is waiting" without
   reopening the full rail. */
.rw-loom__collapsed-badges {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    position: relative;
    z-index: 1;
}

.rw-loom--collapsed .rw-loom__collapsed-badges { display: flex; }

.rw-loom__collapsed-count {
    min-width: 22px;
    padding: 2px 6px;
    font-family: var(--rw-font-display);
    font-size: 11px;
    color: var(--rw-gold-light);
    background: var(--rw-gold-ember);
    border: 1px solid var(--rw-border-strong);
    border-radius: var(--rw-radius-pill);
    text-align: center;
    box-shadow: 0 0 12px rgba(236, 208, 106, 0.25);
}

.rw-loom__collapsed-glyphs {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
}

.rw-loom__collapsed-glyphs span {
    font-size: 11px;
    line-height: 1;
    opacity: 0.8;
}

.rw-loom__collapsed-wordmark {
    display: none;
    font-family: var(--rw-font-display);
    font-size: 10px;
    letter-spacing: 0.28em;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    color: var(--rw-sage-tan);
    margin-top: 8px;
    opacity: 0.6;
}

.rw-loom--collapsed .rw-loom__collapsed-wordmark { display: inline-block; }

/* Tagline no longer in header by default (wordmark stands alone); kept for future A/B. */
.rw-loom__tagline { display: none; }

/* ── Capture input: sigil row + hero Ask/Shape ── */

.rw-loom__capture {
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    z-index: 1;
}

.rw-loom__capture-input-row {
    display: flex;
    align-items: stretch;
    gap: 6px;
    position: relative;
}

.rw-loom__capture-input {
    flex: 1;
    min-width: 0;
    resize: vertical;
    min-height: 80px;
    padding: 11px 12px 11px 14px;
    font-family: var(--rw-font-body);
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--rw-sage-cream);
    background: rgba(7, 14, 20, 0.65);
    border: 1px solid var(--rw-border-gold);
    border-radius: var(--rw-radius-md);
    outline: none;
    transition: border-color var(--rw-transition), box-shadow var(--rw-transition);
    /* A subtle inset gold hairline on the left mirrors the rail's thread so the
       capture input visually "ties in" to the loom. */
    box-shadow: inset 2px 0 0 var(--rw-gold-ember);
}

.rw-loom__capture-input::placeholder {
    color: var(--rw-text-faint);
    font-style: italic;
    font-family: var(--rw-font-body);
}

.rw-loom__capture-input:focus {
    border-color: var(--rw-border-strong);
    box-shadow: inset 2px 0 0 var(--rw-gold), 0 0 0 1px rgba(196, 160, 64, 0.12);
}

.rw-loom__capture-input:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* Dispatch shimmer: active during AI round-trip. A gold sheen sweeps top-to-bottom
   on the textarea border so the GM sees "something magical is happening" rather
   than a plain disabled state. */
.rw-loom__capture-input--weaving {
    position: relative;
}
.rw-loom__capture-input--weaving::after {
    content: '';
    position: absolute; inset: -1px;
    border-radius: var(--rw-radius-md);
    pointer-events: none;
    background: linear-gradient(
        180deg,
        transparent 0%,
        rgba(236, 208, 106, 0.28) 48%,
        rgba(72, 176, 192, 0.22) 52%,
        transparent 100%);
    animation: rw-loom-shimmer 1.6s linear infinite;
    mix-blend-mode: screen;
}
@keyframes rw-loom-shimmer {
    0%   { transform: translateY(-100%); }
    100% { transform: translateY(100%); }
}

/* Voice button — tucked alongside the textarea; when listening it pulses ember
   (not just the button, the whole textarea border acquires an ember ring). */

.rw-loom__voice-btn {
    width: 36px;
    flex-shrink: 0;
    background: rgba(7, 14, 20, 0.65);
    border: 1px solid var(--rw-border-gold);
    border-radius: var(--rw-radius-md);
    color: var(--rw-sage-tan);
    cursor: pointer;
    transition: border-color var(--rw-transition), color var(--rw-transition), background var(--rw-transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.rw-loom__voice-btn:hover:not(:disabled) {
    border-color: var(--rw-border-strong);
    color: var(--rw-gold-light);
}

.rw-loom__voice-glyph {
    font-size: 14px;
    line-height: 1;
}

.rw-loom__voice-btn--live {
    color: var(--rw-blood-bright);
    border-color: var(--rw-blood-bright);
    background: rgba(184, 58, 26, 0.08);
    animation: rw-loom-ember 1.4s ease-in-out infinite;
}

@keyframes rw-loom-ember {
    0%, 100% { box-shadow: 0 0 0 0 rgba(184, 58, 26, 0.5); }
    50%      { box-shadow: 0 0 0 6px rgba(184, 58, 26, 0); }
}

/* Extend the ember ring to the whole textarea while listening — dictation as
   stage moment, not corner utility. */
.rw-loom__capture--listening .rw-loom__capture-input {
    border-color: var(--rw-blood-bright);
    box-shadow: inset 2px 0 0 var(--rw-blood-bright), 0 0 0 1px rgba(184, 58, 26, 0.25);
}

/* Primary button — "Ask / Shape". Dual-layer gradient (gold + arcane-blue) +
   inner shimmer. Full-width, single action. Calls the GM to trust the loom. */

.rw-loom__capture-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 9px 14px;
    font-family: var(--rw-font-sc);
    font-size: 11px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--rw-gold-glow);
    background: linear-gradient(
        135deg,
        rgba(196, 160, 64, 0.22) 0%,
        rgba(58, 128, 168, 0.18) 100%);
    border: 1px solid var(--rw-border-strong);
    border-radius: var(--rw-radius-md);
    cursor: pointer;
    transition: border-color var(--rw-transition), background var(--rw-transition), color var(--rw-transition), box-shadow var(--rw-transition);
    box-shadow: inset 0 1px 0 rgba(236, 208, 106, 0.14);
    position: relative;
    overflow: hidden;
}

.rw-loom__capture-primary:hover:not(:disabled) {
    border-color: var(--rw-gold-light);
    color: var(--rw-gold-glow);
    background: linear-gradient(
        135deg,
        rgba(196, 160, 64, 0.35) 0%,
        rgba(58, 128, 168, 0.28) 100%);
    box-shadow: inset 0 1px 0 rgba(236, 208, 106, 0.25), 0 0 24px rgba(196, 160, 64, 0.14);
}

.rw-loom__capture-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.rw-loom__capture-primary-glyph {
    font-size: 14px;
    color: var(--rw-gold-glow);
}

/* Sigil-tile row — six kinds as icon-first tiles. No labels by default; label
   appears on hover. Feels like choosing a card, not flipping a toggle. */

.rw-loom__sigil-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.rw-loom__sigil-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 2px 6px;
    background: rgba(7, 14, 20, 0.45);
    border: 1px solid var(--rw-border-narrative);
    border-radius: var(--rw-radius-sm);
    cursor: pointer;
    transition: border-color var(--rw-transition), background var(--rw-transition), transform var(--rw-transition);
    color: var(--rw-sage-tan);
    position: relative;
}

.rw-loom__sigil-tile:hover:not(:disabled) {
    border-color: var(--rw-border-strong);
    background: var(--rw-gold-ember);
    color: var(--rw-gold-light);
    transform: translateY(-1px);
}

.rw-loom__sigil-tile:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.rw-loom__sigil-glyph {
    font-size: 18px;
    line-height: 1;
    color: var(--rw-gold);
    text-shadow: 0 0 8px rgba(196, 160, 64, 0.25);
}

.rw-loom__sigil-tile:hover:not(:disabled) .rw-loom__sigil-glyph {
    color: var(--rw-gold-glow);
    text-shadow: 0 0 10px rgba(236, 208, 106, 0.45);
}

.rw-loom__sigil-label {
    font-family: var(--rw-font-sc);
    font-size: 8px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--rw-text-faint);
    line-height: 1;
}

.rw-loom__sigil-tile:hover:not(:disabled) .rw-loom__sigil-label {
    color: var(--rw-sage-cream);
}

.rw-loom__capture-hint {
    margin: 0;
    font-family: var(--rw-font-body);
    font-size: 10.5px;
    font-style: italic;
    color: var(--rw-text-faint);
    line-height: 1.3;
    text-align: center;
}

.rw-loom__capture-error {
    margin: 0;
    font-family: var(--rw-font-sc);
    font-size: 10px;
    letter-spacing: 0.12em;
    color: var(--rw-blood-bright);
}

/* ── Answer pane — The Loom's Voice ──
   Moonlit glass. Arcane-blue wash, Cinzel/MedievalSharp letter-spaced heading,
   single gold hairline inscribing beneath it on entrance. Ephemeral: dismisses
   to fold away, not a standing panel. */

.rw-loom__answer {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 14px 12px 18px;
    position: relative;
    background: var(--rw-glass-bg);
    backdrop-filter: var(--rw-glass-blur);
    -webkit-backdrop-filter: var(--rw-glass-blur);
    border: 1px solid var(--rw-glass-border-cyan);
    border-left: 2px solid var(--rw-arcane-blue);
    border-radius: var(--rw-radius-md);
    box-shadow: 0 0 24px rgba(72, 176, 192, 0.08);
    animation: rw-loom-answer-rise 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes rw-loom-answer-rise {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.rw-loom__answer-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 6px;
    position: relative;
}

/* The gold hairline being inscribed beneath the heading — the "this answer is
   being written for you" beat. 600ms once, then static. */
.rw-loom__answer-head::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0;
    height: 1px;
    width: 0;
    background: linear-gradient(90deg, transparent, var(--rw-gold-glow), transparent);
    animation: rw-loom-inscribe 600ms cubic-bezier(0.2, 0.8, 0.2, 1) 180ms forwards;
}

@keyframes rw-loom-inscribe {
    from { width: 0; }
    to   { width: 100%; }
}

.rw-loom__answer-glyph {
    color: var(--rw-arcane-cyan);
    font-size: 13px;
    text-shadow: 0 0 10px rgba(72, 176, 192, 0.4);
}

.rw-loom__answer-title {
    flex: 1;
    font-family: var(--rw-font-display);
    font-size: 12px;
    letter-spacing: 0.20em;
    color: var(--rw-arcane-cyan);
}

.rw-loom__answer-close {
    background: transparent;
    border: none;
    color: var(--rw-sage-tan);
    cursor: pointer;
    font-size: 14px;
    padding: 0 2px;
    line-height: 1;
    transition: color var(--rw-transition);
}
.rw-loom__answer-close:hover { color: var(--rw-sage-cream); }

.rw-loom__answer-body {
    margin: 0;
    font-family: var(--rw-font-body);
    font-size: 13px;
    line-height: 1.55;
    color: var(--rw-sage-cream);
    white-space: pre-wrap;
    font-style: italic;
}

/* ── Pending tray ── */

.rw-loom__toolbelt {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    z-index: 1;
}

.rw-loom__toolbelt-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 4px 0;
    background: transparent;
    border: none;
    color: var(--rw-sage-tan);
    font-family: var(--rw-font-sc);
    font-size: 10px;
    letter-spacing: 0.16em;
    text-align: left;
    text-transform: uppercase;
    cursor: pointer;
    transition: color var(--rw-transition);
}

.rw-loom__toolbelt-toggle:hover {
    color: var(--rw-gold-light);
}

.rw-loom__toolbelt-toggle-glyph {
    color: var(--rw-gold);
    font-size: 11px;
}

.rw-loom__toolbelt-toggle strong {
    margin-left: auto;
    min-width: 18px;
    padding: 1px 7px;
    border: 1px solid rgba(72, 176, 192, 0.35);
    border-radius: var(--rw-radius-pill);
    background: rgba(72, 176, 192, 0.08);
    color: var(--rw-arcane-cyan);
    font-family: var(--rw-font-display);
    font-size: 10px;
    letter-spacing: 0;
    line-height: 1.5;
    text-align: center;
}

.rw-loom__toolbelt-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 9px 10px 10px 12px;
    border: 1px solid rgba(72, 176, 192, 0.18);
    border-left: 2px solid var(--rw-arcane-blue);
    border-radius: var(--rw-radius-md);
    background:
        linear-gradient(135deg, rgba(72, 176, 192, 0.08), rgba(196, 160, 64, 0.05)),
        rgba(7, 14, 20, 0.38);
    box-shadow: 0 0 18px rgba(72, 176, 192, 0.06);
}

.rw-loom__toolbelt-status,
.rw-loom__toolbelt-intent,
.rw-loom__toolbelt-message {
    margin: 0;
    font-family: var(--rw-font-body);
    font-size: 11px;
    font-style: italic;
    line-height: 1.4;
}

.rw-loom__toolbelt-status,
.rw-loom__toolbelt-intent {
    color: var(--rw-text-dim);
}

.rw-loom__toolbelt-command {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
}

.rw-loom__toolbelt-command input {
    min-width: 0;
    padding: 7px 8px;
    font-family: var(--rw-font-body);
    font-size: 12px;
    line-height: 1.3;
    color: var(--rw-sage-cream);
    background: rgba(7, 14, 20, 0.62);
    border: 1px solid var(--rw-border-gold);
    border-radius: var(--rw-radius-sm);
    outline: none;
    transition: border-color var(--rw-transition), box-shadow var(--rw-transition);
}

.rw-loom__toolbelt-command input:focus {
    border-color: var(--rw-glass-border-cyan);
    box-shadow: inset 0 0 0 1px rgba(72, 176, 192, 0.12);
}

.rw-loom__toolbelt-command input::placeholder {
    color: var(--rw-text-faint);
    font-style: italic;
}

.rw-loom__toolbelt-command button {
    padding: 0 9px;
    font-family: var(--rw-font-sc);
    font-size: 9px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--rw-arcane-cyan);
    background: rgba(72, 176, 192, 0.08);
    border: 1px solid rgba(72, 176, 192, 0.32);
    border-radius: var(--rw-radius-sm);
    cursor: pointer;
    transition: border-color var(--rw-transition), color var(--rw-transition), background var(--rw-transition);
}

.rw-loom__toolbelt-command button:hover:not(:disabled) {
    color: var(--rw-gold-light);
    border-color: var(--rw-border-strong);
    background: var(--rw-gold-ember);
}

.rw-loom__toolbelt-command button:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.rw-loom__toolbelt-actions {
    display: grid;
    gap: 6px;
}

.rw-loom__toolbelt-action {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    min-width: 0;
    padding: 8px;
    border: 1px solid var(--rw-border-narrative);
    border-radius: var(--rw-radius-sm);
    background: rgba(7, 14, 20, 0.45);
    color: var(--rw-sage-cream);
    cursor: pointer;
    text-align: left;
    transition: border-color var(--rw-transition), background var(--rw-transition), transform var(--rw-transition);
}

.rw-loom__toolbelt-action:hover:not(:disabled) {
    border-color: var(--rw-glass-border-cyan);
    background: rgba(72, 176, 192, 0.08);
    transform: translateY(-1px);
}

.rw-loom__toolbelt-action--disabled {
    cursor: not-allowed;
    opacity: 0.52;
}

.rw-loom__toolbelt-action > span {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border: 1px solid rgba(72, 176, 192, 0.24);
    border-radius: 999px;
    color: var(--rw-arcane-cyan);
    font-family: var(--rw-font-display);
}

.rw-loom__toolbelt-action strong,
.rw-loom__toolbelt-action small {
    display: block;
    min-width: 0;
}

.rw-loom__toolbelt-action strong {
    overflow: hidden;
    color: var(--rw-sage-cream);
    font-family: var(--rw-font-sc);
    font-size: 10px;
    letter-spacing: 0.12em;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.rw-loom__toolbelt-action small {
    margin-top: 2px;
    color: var(--rw-text-faint);
    font-family: var(--rw-font-body);
    font-size: 10.5px;
    line-height: 1.25;
}

.rw-loom__toolbelt-preview {
    display: grid;
    gap: 8px;
    padding: 9px;
    border: 1px solid rgba(196, 160, 64, 0.26);
    border-radius: var(--rw-radius-sm);
    background: rgba(196, 160, 64, 0.06);
}

.rw-loom__toolbelt-preview-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rw-loom__toolbelt-preview-head strong {
    flex: 1;
    color: var(--rw-gold-light);
    font-family: var(--rw-font-display);
    font-size: 13px;
    letter-spacing: 0.04em;
}

.rw-loom__toolbelt-preview-head button {
    border: none;
    background: transparent;
    color: var(--rw-sage-tan);
    cursor: pointer;
}

.rw-loom__toolbelt-preview p {
    margin: 0;
    color: var(--rw-text-dim);
    font-family: var(--rw-font-body);
    font-size: 11.5px;
    line-height: 1.35;
}

.rw-loom__toolbelt-preview ul {
    display: grid;
    gap: 5px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.rw-loom__toolbelt-preview li {
    display: grid;
    gap: 2px;
    padding: 6px 7px;
    border: 1px solid rgba(177, 162, 132, 0.14);
    border-radius: var(--rw-radius-sm);
    background: rgba(7, 14, 20, 0.35);
}

.rw-loom__toolbelt-preview li span {
    color: var(--rw-arcane-cyan);
    font-family: var(--rw-font-sc);
    font-size: 8.5px;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.rw-loom__toolbelt-preview li strong {
    color: var(--rw-sage-cream);
    font-family: var(--rw-font-body);
    font-size: 12px;
    font-weight: 700;
}

.rw-loom__toolbelt-preview li small {
    color: var(--rw-text-faint);
    font-family: var(--rw-font-body);
    font-size: 10.5px;
    line-height: 1.35;
}

.rw-loom__toolbelt-plan {
    display: grid;
    gap: 8px;
    padding: 9px;
    border: 1px solid rgba(72, 176, 192, 0.28);
    border-radius: var(--rw-radius-sm);
    background:
        linear-gradient(135deg, rgba(72, 176, 192, 0.08), rgba(196, 160, 64, 0.05)),
        rgba(7, 14, 20, 0.38);
}

.rw-loom__toolbelt-evidence {
    display: grid;
    gap: 7px;
    padding: 8px;
    border: 1px solid rgba(196, 160, 64, 0.18);
    border-radius: var(--rw-radius-sm);
    background: rgba(196, 160, 64, 0.04);
}

.rw-loom__toolbelt-evidence-head {
    display: grid;
    gap: 2px;
}

.rw-loom__toolbelt-evidence-head strong,
.rw-loom__toolbelt-evidence-row strong {
    overflow: hidden;
    color: var(--rw-sage-cream);
    font-family: var(--rw-font-sc);
    font-size: 9.5px;
    letter-spacing: 0.12em;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.rw-loom__toolbelt-evidence-head small,
.rw-loom__toolbelt-evidence-row small {
    color: var(--rw-text-faint);
    font-family: var(--rw-font-body);
    font-size: 10.5px;
    line-height: 1.35;
}

.rw-loom__toolbelt-evidence-list {
    display: grid;
    gap: 6px;
}

.rw-loom__toolbelt-evidence-row {
    display: grid;
    grid-template-columns: minmax(112px, 0.8fr) minmax(0, 1fr);
    gap: 8px;
    align-items: start;
    padding: 6px 0;
    border-top: 1px solid rgba(177, 162, 132, 0.12);
}

.rw-loom__toolbelt-evidence-row:first-child {
    border-top: 0;
}

.rw-loom__toolbelt-evidence-row > div {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.rw-loom__toolbelt-evidence-row ul {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: flex-end;
    min-width: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.rw-loom__toolbelt-evidence-row li {
    max-width: 100%;
    padding: 2px 6px;
    border: 1px solid rgba(72, 176, 192, 0.18);
    border-radius: var(--rw-radius-pill);
    color: var(--rw-text-dim);
    background: rgba(7, 14, 20, 0.34);
    font-family: var(--rw-font-body);
    font-size: 10px;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.rw-loom__toolbelt-plan-steps {
    display: grid;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.rw-loom__toolbelt-plan-steps li {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 8px;
    padding: 7px;
    border: 1px solid rgba(177, 162, 132, 0.14);
    border-radius: var(--rw-radius-sm);
    background: rgba(7, 14, 20, 0.42);
}

.rw-loom__toolbelt-plan-steps li > span {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border: 1px solid rgba(72, 176, 192, 0.3);
    border-radius: var(--rw-radius-pill);
    color: var(--rw-arcane-cyan);
    font-family: var(--rw-font-display);
    font-size: 11px;
}

.rw-loom__toolbelt-plan-steps strong {
    display: block;
    overflow: hidden;
    color: var(--rw-sage-cream);
    font-family: var(--rw-font-sc);
    font-size: 10px;
    letter-spacing: 0.12em;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.rw-loom__toolbelt-plan-steps p,
.rw-loom__toolbelt-plan-steps small {
    display: block;
    margin: 2px 0 0;
    color: var(--rw-text-dim);
    font-family: var(--rw-font-body);
    font-size: 11px;
    line-height: 1.35;
}

.rw-loom__toolbelt-plan-steps small {
    color: var(--rw-gold-light);
    font-style: italic;
}

.rw-loom__toolbelt-plan-step--blocked {
    opacity: 0.72;
}

.rw-loom__toolbelt-plan-step--blocked > span {
    color: var(--rw-blood-bright);
    border-color: rgba(184, 58, 26, 0.32);
}

.rw-loom__toolbelt-plan-step--blocked small {
    color: var(--rw-blood-bright);
}

.rw-loom__toolbelt-plan-safety {
    display: grid;
    gap: 3px;
    margin: 0;
    padding: 7px 8px 7px 20px;
    border: 1px solid rgba(72, 176, 192, 0.16);
    border-radius: var(--rw-radius-sm);
    color: var(--rw-text-faint);
    background: rgba(72, 176, 192, 0.04);
    font-family: var(--rw-font-body);
    font-size: 10.5px;
    font-style: italic;
    line-height: 1.35;
}

.rw-loom__toolbelt-preview-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

.rw-loom__toolbelt-preview-actions button {
    padding: 4px 9px;
    border: 1px solid var(--rw-border-gold);
    border-radius: var(--rw-radius-sm);
    background: transparent;
    color: var(--rw-sage-tan);
    cursor: pointer;
    font-family: var(--rw-font-sc);
    font-size: 9.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.rw-loom__toolbelt-preview-actions button:hover:not(:disabled) {
    color: var(--rw-gold-light);
    border-color: var(--rw-border-strong);
}

.rw-loom__toolbelt-preview-actions .rw-loom__toolbelt-confirm {
    color: var(--rw-verdant-bright);
    border-color: rgba(80, 176, 104, 0.35);
}

.rw-loom__toolbelt-message {
    color: var(--rw-verdant-bright);
}

.rw-loom__toolbelt-message--error {
    color: var(--rw-blood-bright);
}

.rw-loom__tray {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    position: relative;
    z-index: 1;
}

.rw-loom__tray-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0 6px;
    border-top: 1px solid var(--rw-border-narrative);
}

.rw-loom__tray-title {
    margin: 0;
    font-family: var(--rw-font-sc);
    font-size: 10px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--rw-sage-tan);
}

.rw-loom__tray-count {
    display: inline-block;
    min-width: 18px;
    padding: 1px 7px;
    font-family: var(--rw-font-display);
    font-size: 10px;
    color: var(--rw-gold-light);
    background: var(--rw-gold-ember);
    border: 1px solid var(--rw-border-strong);
    border-radius: var(--rw-radius-pill);
    text-align: center;
    line-height: 1.6;
}

.rw-loom__tray-spacer { flex: 1; }

.rw-loom__tray-action {
    background: transparent;
    border: none;
    color: var(--rw-sage-tan);
    cursor: pointer;
    font-family: var(--rw-font-sc);
    font-size: 9.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    padding: 2px 4px;
    transition: color var(--rw-transition);
}
.rw-loom__tray-action:hover { color: var(--rw-gold-light); }
.rw-loom__tray-action--accept { color: var(--rw-verdant-bright); }
.rw-loom__tray-action--accept:hover { color: var(--rw-verdant-bright); text-shadow: 0 0 8px rgba(80, 176, 104, 0.4); }
.rw-loom__tray-action--reject { color: var(--rw-blood-bright); }
.rw-loom__tray-action--reject:hover { color: var(--rw-blood-bright); text-shadow: 0 0 8px rgba(184, 58, 26, 0.4); }
.rw-loom__tray-action--disabled { opacity: 0.3; cursor: not-allowed; }

.rw-loom__tray-empty {
    margin: 0;
    padding: 14px 2px 6px;
    font-family: var(--rw-font-body);
    font-size: 11.5px;
    font-style: italic;
    color: var(--rw-text-faint);
    text-align: center;
    line-height: 1.5;
}

.rw-loom__tray-list {
    list-style: none;
    margin: 0;
    padding: 0 0 2px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    overscroll-behavior: contain;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(196, 160, 64, 0.25) transparent;
}

.rw-loom__tray-row { margin: 0; }

/* ── Proposal card ──
   Left chromatic bar carries the source color. Kind sigil + summary + optional
   source snippet. Rune pill on AI-generated. Accept/reject at the right edge in
   collapsed state; full actions in expanded. */

.rw-loom__card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 8px 10px 8px 14px;
    background: rgba(7, 14, 20, 0.55);
    border: 1px solid var(--rw-border-narrative);
    border-radius: var(--rw-radius-sm);
    transition: border-color var(--rw-transition), background var(--rw-transition), box-shadow var(--rw-transition), transform 250ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 250ms ease;
}

.rw-loom__card:hover {
    border-color: var(--rw-border-strong);
    background: rgba(14, 30, 38, 0.7);
}

/* Chromatic source bar — 2px inset on the left, colored by source. Anchors the
   card to the rail's gold thread metaphor while telegraphing origin. */
.rw-loom__card::before {
    content: '';
    position: absolute;
    left: 0; top: 6px; bottom: 6px;
    width: 2px;
    background: var(--rw-loom-source-color, var(--rw-gold));
    border-radius: 2px;
    box-shadow: 0 0 8px var(--rw-loom-source-glow, rgba(196, 160, 64, 0.35));
    transition: box-shadow var(--rw-transition);
}

.rw-loom__card:hover::before {
    box-shadow: 0 0 14px var(--rw-loom-source-glow, rgba(196, 160, 64, 0.6));
}

/* Source theming via CSS custom properties set inline from the component's source. */
.rw-loom__card--source-capture     { --rw-loom-source-color: var(--rw-gold);            --rw-loom-source-glow: rgba(196, 160, 64, 0.45); }
.rw-loom__card--source-palette     { --rw-loom-source-color: var(--rw-gold-light);      --rw-loom-source-glow: rgba(218, 184, 85, 0.45); }
.rw-loom__card--source-paste       { --rw-loom-source-color: var(--rw-arcane-purple);   --rw-loom-source-glow: rgba(106, 74, 138, 0.45); }
.rw-loom__card--source-scan        { --rw-loom-source-color: var(--rw-arcane-blue);     --rw-loom-source-glow: rgba(58, 128, 168, 0.45); }
.rw-loom__card--source-backflow    { --rw-loom-source-color: var(--rw-verdant-bright);  --rw-loom-source-glow: rgba(80, 176, 104, 0.45); }

/* Selected-for-batch: gold glow around the whole card. */
.rw-loom__card--selected {
    border-color: var(--rw-gold);
    background: var(--rw-gold-ember);
    box-shadow: 0 0 16px rgba(196, 160, 64, 0.15);
}

/* Accepted: 400ms weave-out — card glows gold, its chromatic bar widens to
   envelope the card, then fades. */
.rw-loom__card--accepting {
    animation: rw-loom-accept 420ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
.rw-loom__card--accepting::before {
    animation: rw-loom-weave-out 420ms ease-out forwards;
}
@keyframes rw-loom-accept {
    0%   { box-shadow: 0 0 0 0 rgba(80, 176, 104, 0); }
    40%  { box-shadow: 0 0 24px rgba(236, 208, 106, 0.45); transform: translateX(4px); }
    100% { opacity: 0; transform: translateX(36px); box-shadow: 0 0 0 0 transparent; }
}
@keyframes rw-loom-weave-out {
    0%   { width: 2px; }
    40%  { width: 100%; background: var(--rw-verdant-bright); opacity: 0.2; }
    100% { width: 100%; background: var(--rw-verdant-bright); opacity: 0; }
}

/* Rejected: sinks to ember + fades. */
.rw-loom__card--rejecting {
    animation: rw-loom-reject 320ms ease-in forwards;
}
@keyframes rw-loom-reject {
    0%   { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(8px); background: rgba(184, 58, 26, 0.08); }
}

.rw-loom__card-head {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
}

.rw-loom__card-select {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    margin-top: 3px;
    accent-color: var(--rw-gold);
    cursor: pointer;
}

.rw-loom__card-kind {
    flex-shrink: 0;
    font-size: 14px;
    line-height: 1.1;
    color: var(--rw-gold-light);
    text-shadow: 0 0 6px rgba(196, 160, 64, 0.25);
    width: 16px;
    text-align: center;
}

.rw-loom__card-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.rw-loom__card-summary-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
}

.rw-loom__card-source-glyph {
    font-size: 10px;
    color: var(--rw-loom-source-color, var(--rw-gold));
    opacity: 0.85;
    flex-shrink: 0;
    line-height: 1;
}

.rw-loom__card-summary {
    flex: 1;
    font-family: var(--rw-font-body);
    font-size: 12.5px;
    color: var(--rw-sage-cream);
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.rw-loom__card-source {
    font-family: var(--rw-font-body);
    font-size: 10.5px;
    font-style: italic;
    color: var(--rw-text-faint);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.rw-loom__card-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
}

/* Rune pill — only when RuneCostSpent > 0. Gold capsule, Alegreya SC, small. */
.rw-loom__card-runes {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 7px 2px;
    font-family: var(--rw-font-sc);
    font-size: 9px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--rw-gold-glow);
    background: var(--rw-gold-ember);
    border: 1px solid var(--rw-border-strong);
    border-radius: var(--rw-radius-pill);
    line-height: 1;
}

.rw-loom__card-runes::before {
    content: '⧍';
    font-size: 9px;
    color: var(--rw-gold-glow);
}

.rw-loom__card-source-chip {
    font-family: var(--rw-font-sc);
    font-size: 9px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--rw-loom-source-color, var(--rw-gold));
    opacity: 0.75;
}

.rw-loom__card-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    align-self: center;
}

.rw-loom__card-btn {
    width: 26px;
    height: 26px;
    padding: 0;
    background: transparent;
    color: var(--rw-sage-tan);
    border: 1px solid var(--rw-border-gold);
    border-radius: var(--rw-radius-sm);
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    transition: border-color var(--rw-transition), color var(--rw-transition), background var(--rw-transition);
}

.rw-loom__card-btn--accept:hover {
    border-color: var(--rw-verdant-bright);
    color: var(--rw-verdant-bright);
    background: var(--rw-verdant-glow);
}

.rw-loom__card-btn--reject:hover {
    border-color: var(--rw-blood-bright);
    color: var(--rw-blood-bright);
    background: rgba(184, 58, 26, 0.08);
}

/* Expanded region — reveals full draft content. Animates open via max-height. */

.rw-loom__card-expand {
    overflow: hidden;
    max-height: 0;
    transition: max-height 260ms cubic-bezier(0.2, 0.8, 0.2, 1), margin-top 260ms ease;
}

.rw-loom__card--expanded .rw-loom__card-expand {
    max-height: 720px; /* generous cap; real content rarely exceeds */
    margin-top: 8px;
}

.rw-loom__card-expand-inner {
    padding-top: 8px;
    border-top: 1px dashed var(--rw-border-narrative);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rw-loom__card-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.rw-loom__card-field-label {
    font-family: var(--rw-font-sc);
    font-size: 9px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--rw-sage-tan);
}

.rw-loom__card-field-value {
    font-family: var(--rw-font-body);
    font-size: 12px;
    line-height: 1.5;
    color: var(--rw-sage-cream);
    white-space: pre-wrap;
    word-break: break-word;
}

.rw-loom__card-field-value--muted {
    color: var(--rw-text-dim);
    font-style: italic;
}

.rw-loom__card-link {
    font-family: var(--rw-font-sc);
    font-size: 10px;
    letter-spacing: 0.12em;
    color: var(--rw-arcane-cyan);
    text-decoration: none;
    margin-top: 2px;
}
.rw-loom__card-link:hover { text-decoration: underline; }

.rw-loom__card-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 6px;
    border-top: 1px dashed var(--rw-border-narrative);
}

.rw-loom__card-footer-spacer { flex: 1; }

.rw-loom__card-footer-btn {
    padding: 4px 10px;
    font-family: var(--rw-font-sc);
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--rw-sage-cream);
    background: transparent;
    border: 1px solid var(--rw-border-gold);
    border-radius: var(--rw-radius-sm);
    cursor: pointer;
    transition: border-color var(--rw-transition), color var(--rw-transition), background var(--rw-transition);
}

.rw-loom__card-footer-btn--accept {
    color: var(--rw-verdant-bright);
    border-color: rgba(80, 176, 104, 0.35);
}
.rw-loom__card-footer-btn--accept:hover {
    background: var(--rw-verdant-glow);
    border-color: var(--rw-verdant-bright);
}

.rw-loom__card-footer-btn--reject {
    color: var(--rw-blood-bright);
    border-color: rgba(184, 58, 26, 0.3);
}
.rw-loom__card-footer-btn--reject:hover {
    background: rgba(184, 58, 26, 0.08);
    border-color: var(--rw-blood-bright);
}

/* ── Smart paste ── */

.rw-loom__paste {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    z-index: 1;
}

.rw-loom__paste-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: fit-content;
    padding: 2px 0;
    background: transparent;
    border: none;
    color: var(--rw-sage-tan);
    font-family: var(--rw-font-sc);
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    cursor: pointer;
    transition: color var(--rw-transition);
}

.rw-loom__paste-toggle:hover { color: var(--rw-gold-light); }

.rw-loom__paste-toggle-glyph {
    font-size: 11px;
    transition: transform var(--rw-transition);
    color: var(--rw-gold);
}

.rw-loom__paste--open .rw-loom__paste-toggle-glyph { transform: rotate(90deg); }

/* Unroll animation: grid-template-rows 0fr→1fr trick keeps auto-height + animatable. */
.rw-loom__paste-body-wrap {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.rw-loom__paste--open .rw-loom__paste-body-wrap {
    grid-template-rows: 1fr;
}

.rw-loom__paste-body {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 4px 2px 12px;
    border-left: 2px solid var(--rw-arcane-purple);
    box-shadow: 0 0 12px rgba(106, 74, 138, 0.08);
}

.rw-loom__paste-input {
    width: 100%;
    padding: 8px 10px;
    font-family: var(--rw-font-body);
    font-size: 12px;
    line-height: 1.45;
    color: var(--rw-sage-cream);
    background: rgba(7, 14, 20, 0.55);
    border: 1px solid var(--rw-border-gold);
    border-radius: var(--rw-radius-sm);
    resize: vertical;
    outline: none;
    transition: border-color var(--rw-transition);
}

.rw-loom__paste-input:focus {
    border-color: var(--rw-arcane-purple);
}

.rw-loom__paste-input::placeholder {
    color: var(--rw-text-faint);
    font-style: italic;
}

.rw-loom__paste-actions {
    display: flex;
    gap: 6px;
}

.rw-loom__paste-btn {
    padding: 4px 10px;
    font-family: var(--rw-font-sc);
    font-size: 9px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--rw-sage-cream);
    background: rgba(30, 60, 66, 0.45);
    border: 1px solid var(--rw-border-gold);
    border-radius: var(--rw-radius-sm);
    cursor: pointer;
    transition: border-color var(--rw-transition), color var(--rw-transition);
}

.rw-loom__paste-btn:hover:not(:disabled) {
    border-color: var(--rw-border-strong);
    color: var(--rw-gold-light);
}

.rw-loom__paste-btn--quiet {
    background: transparent;
    color: var(--rw-text-dim);
}

.rw-loom__paste-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.rw-loom__paste-status {
    margin: 0;
    font-family: var(--rw-font-body);
    font-size: 11px;
    font-style: italic;
    color: var(--rw-text-dim);
    line-height: 1.4;
}

.rw-loom__paste-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(196, 160, 64, 0.25) transparent;
}

.rw-loom__paste-row {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 6px 8px;
    background: rgba(7, 14, 20, 0.45);
    border: 1px solid var(--rw-border-narrative);
    border-left: 2px solid var(--rw-arcane-purple);
    border-radius: var(--rw-radius-sm);
}

.rw-loom__paste-row-head {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.rw-loom__paste-name {
    flex: 1;
    font-family: var(--rw-font-body);
    font-size: 12.5px;
    color: var(--rw-sage-cream);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rw-loom__paste-count {
    font-family: var(--rw-font-sc);
    font-size: 9px;
    color: var(--rw-text-dim);
}

.rw-loom__paste-kinds {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.rw-loom__paste-kind {
    padding: 2px 6px;
    font-family: var(--rw-font-sc);
    font-size: 8.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--rw-sage-tan);
    background: transparent;
    border: 1px solid var(--rw-border-gold);
    border-radius: 2px;
    cursor: pointer;
    transition: border-color var(--rw-transition), color var(--rw-transition), background var(--rw-transition);
}

.rw-loom__paste-kind:hover {
    border-color: var(--rw-border-strong);
    color: var(--rw-gold-light);
    background: var(--rw-gold-ember);
}

.rw-loom__paste-kind--skip {
    color: var(--rw-text-faint);
    border-color: var(--rw-border);
}

.rw-loom__paste-kind--skip:hover {
    color: var(--rw-blood-bright);
    border-color: rgba(184, 58, 26, 0.4);
    background: rgba(184, 58, 26, 0.06);
}

/* ── Drawer (responsive, <1100px) ──
   Below the split-column breakpoint, the rail transforms into a bottom-edge
   drawer so it doesn't hijack horizontal real estate. Handle shows pending
   count + source glyphs; tap/click to expand to a 75dvh sheet. */

@media (max-width: 1100px) {
    .rw-loom {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        width: auto;
        max-height: 75dvh;
        max-width: none;
        padding: 10px 14px 14px;
        border-radius: var(--rw-radius-lg) var(--rw-radius-lg) 0 0;
        border-bottom: none;
        z-index: 1200;
        transform: translateY(calc(100% - 56px));
        transition: transform 320ms cubic-bezier(0.2, 0.8, 0.2, 1);
        box-shadow:
            inset 0 1px 0 rgba(236, 208, 106, 0.08),
            0 -8px 24px rgba(0, 0, 0, 0.4);
    }

    .rw-loom::before { display: none; }

    .rw-loom--drawer-open {
        transform: translateY(0);
    }

    .rw-loom--collapsed {
        /* Keep drawer-bottom position even when the desktop "collapsed" toggled. */
        transform: translateY(calc(100% - 56px));
        width: auto;
        padding: 10px 14px 14px;
    }

    .rw-loom--collapsed .rw-loom__collapsed-badges,
    .rw-loom--collapsed .rw-loom__collapsed-wordmark { display: none; }

    .rw-loom__header {
        cursor: grab;
        padding-bottom: 8px;
    }

    /* Drawer handle — a grip line above the header so the affordance reads. */
    .rw-loom__header::before {
        content: '';
        position: absolute;
        top: -6px; left: 50%;
        transform: translateX(-50%);
        width: 44px;
        height: 3px;
        background: var(--rw-border-strong);
        border-radius: var(--rw-radius-pill);
    }
}

/* Respect user motion preferences — kill non-essential animation. */
@media (prefers-reduced-motion: reduce) {
    .rw-loom__sigil,
    .rw-loom__voice-btn--live,
    .rw-loom__capture-input--weaving::after,
    .rw-loom__answer-head::after,
    .rw-loom__card--accepting,
    .rw-loom__card--accepting::before,
    .rw-loom__card--rejecting {
        animation: none !important;
    }
}
/*
    Command palette — the GM's whispered utterance.

    An off-center parchment card (not a centered modal) floats onto the GM's
    screen when Ctrl+K fires. Warm gold + arcane-blue borders, ink-quill cursor,
    sigil-tile kind row matching the Loom rail so muscle memory transfers. The
    veil behind is a soft arcane wash — dismiss by clicking outside or Esc.
*/

.rw-cmd-palette__veil {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(58, 128, 168, 0.18) 0%, transparent 55%),
        rgba(4, 12, 16, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    /* Offset from top-left so it reads like something placed there, not summoned center-stage. */
    padding: 14vh 0 0 14vw;
    z-index: 1400;
    animation: rw-cmd-veil 140ms ease;
}

@keyframes rw-cmd-veil {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.rw-cmd-palette {
    width: min(560px, calc(100vw - 32px));
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 22px 18px;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(236, 208, 106, 0.12) 0%, transparent 60%),
        linear-gradient(180deg, rgba(30, 60, 66, 0.55) 0%, rgba(8, 18, 24, 0.96) 100%),
        var(--rw-bg-panel);
    border: 1px solid var(--rw-border-strong);
    border-radius: var(--rw-radius-lg);
    box-shadow:
        inset 0 1px 0 rgba(236, 208, 106, 0.12),
        0 28px 70px rgba(0, 0, 0, 0.6);
    animation: rw-cmd-drop 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
    position: relative;
}

/* A very thin gold hairline traces the inner top edge — reads as a warm halo
   from the enchanted canopy above. */
.rw-cmd-palette::before {
    content: '';
    position: absolute;
    top: 0; left: 18%; right: 18%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--rw-gold-glow), transparent);
    opacity: 0.5;
}

@keyframes rw-cmd-drop {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.rw-cmd-palette__header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rw-cmd-palette__sigil {
    width: 20px;
    height: 20px;
    color: var(--rw-gold-light);
    opacity: 0.9;
    flex-shrink: 0;
}

.rw-cmd-palette__title {
    flex: 1;
    font-family: var(--rw-font-display);
    font-size: 15px;
    letter-spacing: 0.08em;
    color: var(--rw-gold-light);
    text-shadow: 0 0 16px rgba(236, 208, 106, 0.12);
}

.rw-cmd-palette__hint {
    font-family: var(--rw-font-sc);
    font-size: 9px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    padding: 2px 7px;
    color: var(--rw-sage-tan);
    background: var(--rw-gold-ember);
    border: 1px solid var(--rw-border-gold);
    border-radius: var(--rw-radius-sm);
}

.rw-cmd-palette__input {
    width: 100%;
    padding: 13px 16px;
    font-family: var(--rw-font-body);
    font-size: 16px;
    line-height: 1.4;
    color: var(--rw-sage-cream);
    background: rgba(7, 14, 20, 0.75);
    border: 1px solid var(--rw-border-gold);
    border-radius: var(--rw-radius-md);
    outline: none;
    transition: border-color var(--rw-transition), box-shadow var(--rw-transition);
    /* Ink-quill caret — warm amber instead of the browser default. */
    caret-color: var(--rw-gold-glow);
}

.rw-cmd-palette__input:focus {
    border-color: var(--rw-border-strong);
    box-shadow: inset 0 0 0 1px rgba(196, 160, 64, 0.2);
}

.rw-cmd-palette__input::placeholder {
    color: var(--rw-text-faint);
    font-style: italic;
}

/* Sigil-tile row — mirrors the Loom rail's sigil tiles so the palette looks
   like part of the same instrument. Six tiles (NPC/Place/Faction/Lore/Deity/Region). */

.rw-cmd-palette__sigils {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    padding-top: 2px;
}

.rw-cmd-palette__sigil-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 4px 8px;
    background: rgba(7, 14, 20, 0.55);
    border: 1px solid var(--rw-border-narrative);
    border-radius: var(--rw-radius-sm);
    cursor: pointer;
    transition: border-color var(--rw-transition), background var(--rw-transition), transform var(--rw-transition);
    color: var(--rw-sage-tan);
}

.rw-cmd-palette__sigil-tile:hover:not(:disabled) {
    border-color: var(--rw-border-strong);
    background: var(--rw-gold-ember);
    color: var(--rw-gold-light);
    transform: translateY(-1px);
}

.rw-cmd-palette__sigil-tile:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.rw-cmd-palette__sigil-glyph {
    font-size: 22px;
    line-height: 1;
    color: var(--rw-gold);
    text-shadow: 0 0 10px rgba(196, 160, 64, 0.25);
}

.rw-cmd-palette__sigil-tile:hover:not(:disabled) .rw-cmd-palette__sigil-glyph {
    color: var(--rw-gold-glow);
    text-shadow: 0 0 14px rgba(236, 208, 106, 0.45);
}

.rw-cmd-palette__sigil-label {
    font-family: var(--rw-font-sc);
    font-size: 9px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--rw-text-faint);
}

.rw-cmd-palette__sigil-tile:hover:not(:disabled) .rw-cmd-palette__sigil-label {
    color: var(--rw-sage-cream);
}

.rw-cmd-palette__status {
    margin: 0;
    font-family: var(--rw-font-body);
    font-size: 12px;
    font-style: italic;
    color: var(--rw-verdant-bright);
    text-align: center;
    padding-top: 2px;
}

@media (max-width: 768px) {
    .rw-cmd-palette__veil {
        padding: 10vh 16px 0 16px;
        justify-content: center;
    }
    .rw-cmd-palette {
        width: 100%;
    }
    .rw-cmd-palette__sigils {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (prefers-reduced-motion: reduce) {
    .rw-cmd-palette__veil,
    .rw-cmd-palette { animation: none !important; }
}
/* LoomGhostScan — chip + moonlit-glass popover beside a MarkdownEditor's label.

   Quiet sage-on-dark by default, pulses gold when unknowns are waiting — a
   subtle "something here needs you" beat the GM can notice peripherally.
   The popover matches the Loom rail's answer-pane glass so the three
   non-tray surfaces (command palette, answer, ghost scan) feel like a family.
*/

.rw-ghost-scan {
    position: relative;
    display: inline-block;
}

.rw-ghost-scan__chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px 3px 8px;
    font-family: var(--rw-font-sc);
    font-size: 9px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--rw-sage-tan);
    background: rgba(7, 14, 20, 0.45);
    border: 1px solid var(--rw-border-gold);
    border-radius: var(--rw-radius-pill);
    cursor: pointer;
    transition: border-color var(--rw-transition), color var(--rw-transition), background var(--rw-transition), box-shadow var(--rw-transition);
}

.rw-ghost-scan__chip:hover:not(:disabled) {
    border-color: var(--rw-border-strong);
    color: var(--rw-gold-light);
    background: var(--rw-gold-ember);
}

.rw-ghost-scan__chip:disabled {
    opacity: 0.55;
    cursor: wait;
}

/* Live state — pulsing gold when unknowns exist. The pulse is slow and small so it
   never distracts from the editor, only telegraphs peripheral-vision presence. */
.rw-ghost-scan__chip--live {
    color: var(--rw-gold-glow);
    border-color: var(--rw-gold);
    background: var(--rw-gold-ember);
    animation: rw-ghost-pulse 2.4s ease-in-out infinite;
}

@keyframes rw-ghost-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(196, 160, 64, 0.35); }
    50%      { box-shadow: 0 0 0 5px rgba(196, 160, 64, 0); }
}

.rw-ghost-scan__glyph {
    font-size: 11px;
    line-height: 1;
}

.rw-ghost-scan__chip strong {
    color: var(--rw-gold-glow);
    font-family: var(--rw-font-display);
    font-weight: normal;
    font-size: 12px;
    letter-spacing: 0;
    margin-right: 2px;
}

/* Popover — moonlit glass. Arcane-blue top accent + tinted gold stitching on edges. */
.rw-ghost-scan__panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 60;
    width: 340px;
    max-width: 82vw;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 14px 12px;
    background: var(--rw-glass-bg-dense);
    backdrop-filter: var(--rw-glass-blur-strong);
    -webkit-backdrop-filter: var(--rw-glass-blur-strong);
    border: 1px solid var(--rw-border-gold);
    border-top: 1px solid var(--rw-glass-border-cyan);
    border-radius: var(--rw-radius-md);
    box-shadow:
        inset 0 1px 0 rgba(236, 208, 106, 0.08),
        0 12px 32px rgba(0, 0, 0, 0.45);
    animation: rw-ghost-drop 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.rw-ghost-scan__panel--quiet {
    width: auto;
    min-width: 220px;
}

@keyframes rw-ghost-drop {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.rw-ghost-scan__hint {
    margin: 0;
    font-family: var(--rw-font-body);
    font-size: 11px;
    font-style: italic;
    color: var(--rw-text-dim);
    line-height: 1.4;
}

.rw-ghost-scan__status {
    margin: 0;
    font-family: var(--rw-font-body);
    font-size: 12px;
    font-style: italic;
    color: var(--rw-sage-cream);
    text-align: center;
}

.rw-ghost-scan__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 260px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(196, 160, 64, 0.25) transparent;
}

.rw-ghost-scan__row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 7px 9px;
    background: rgba(7, 14, 20, 0.5);
    border: 1px solid var(--rw-border-narrative);
    border-left: 2px solid var(--rw-arcane-blue);
    border-radius: var(--rw-radius-sm);
}

.rw-ghost-scan__row-head {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.rw-ghost-scan__name {
    flex: 1;
    font-family: var(--rw-font-body);
    font-size: 12.5px;
    color: var(--rw-sage-cream);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rw-ghost-scan__count {
    font-family: var(--rw-font-sc);
    font-size: 9px;
    color: var(--rw-text-dim);
}

.rw-ghost-scan__kinds {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.rw-ghost-scan__kind {
    padding: 2px 7px;
    font-family: var(--rw-font-sc);
    font-size: 8.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--rw-sage-tan);
    background: transparent;
    border: 1px solid var(--rw-border-gold);
    border-radius: 2px;
    cursor: pointer;
    transition: border-color var(--rw-transition), color var(--rw-transition), background var(--rw-transition);
}

.rw-ghost-scan__kind:hover {
    border-color: var(--rw-border-strong);
    color: var(--rw-gold-light);
    background: var(--rw-gold-ember);
}

.rw-ghost-scan__kind--skip {
    color: var(--rw-text-faint);
    border-color: var(--rw-border);
}

.rw-ghost-scan__kind--skip:hover {
    color: var(--rw-blood-bright);
    border-color: rgba(184, 58, 26, 0.4);
    background: rgba(184, 58, 26, 0.06);
}

@media (prefers-reduced-motion: reduce) {
    .rw-ghost-scan__chip--live { animation: none !important; }
    .rw-ghost-scan__panel { animation: none !important; }
}
