/**
 * "How it works" — one agent run as a product mock (js/agent-tour.js).
 *
 * Modelled on the app's dark theme (solid-ui tokens, copied as --at-*),
 * the docked Agent column (AgentDockPanel, PlanCard, ReviewCard,
 * ApprovalCard) and the board's ReComp tool node + output container.
 *
 * The mock sits in .agent-tour__window[data-step]. Elements carry
 * data-s="2" or data-s="2-5" (the steps they show in); the script adds
 * .is-off to the rest. The board is drawn at 760×500 and scaled to fit.
 */

.agent-tour {
    /* solid-ui dark theme */
    --at-bg: #1b1c1d;
    --at-surface: #232526;
    --at-raised: #2b2e2f;
    --at-hover: #343739;
    --at-board: #151617;
    --at-border: rgba(255, 255, 255, 0.10);
    --at-border-soft: rgba(255, 255, 255, 0.06);
    --at-text: #dde0e2;
    --at-muted: #989ea1;
    --at-faint: #5e6366;
    --at-accent: #05c7bb;
    --at-on-accent: #0b1215;
    --at-ok: #43c283;
    --at-warn: #fbbf24;
    --at-edit: #5f9c7c;
    --at-edit-2: #4d8467;
    --at-ai: linear-gradient(135deg, #296cfd 0%, #1c91ff 25%, #05c7bb 63%, #38ffc7 100%);
    --at-ai-sweep: linear-gradient(90deg, #296cfd, #1c91ff, #05c7bb, #38ffc7, #296cfd);
    --at-temp-line: rgba(245, 180, 80, 0.75);
    --at-temp-bg:
        repeating-linear-gradient(135deg, rgba(245, 180, 80, 0.16) 0 6px, rgba(245, 180, 80, 0.05) 6px 12px),
        #1d1a14;
    --at-chat-w: 340px;
    --at-h: 600px;
    --at-ease: cubic-bezier(0.16, 1, 0.3, 1);

    position: relative;
    width: 100%;
    max-width: 68rem;
    margin: 0 auto;
}

/* ── Step tabs ─────────────────────────────────────────────────────────── */

.agent-tour__tabs {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.5rem;
    max-width: 46rem;
    margin: 0 auto 1.5rem;
}

.agent-tour__tab {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-width: 0;
    padding: 0.7rem 0.75rem 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    color: rgba(255, 255, 255, 0.6);
    font: 600 0.9375rem/1.2 'Inter', system-ui, sans-serif;
    cursor: pointer;
    overflow: hidden;
    transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.agent-tour__tab:hover { color: #fff; border-color: rgba(255, 255, 255, 0.16); }

.agent-tour__tab:focus-visible {
    outline: 2px solid #05c7bb;
    outline-offset: 2px;
}

.agent-tour__tab[aria-selected="true"] {
    color: #fff;
    border-color: rgba(5, 199, 187, 0.45);
    background: rgba(5, 199, 187, 0.08);
}

.agent-tour__tab-num {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    color: rgba(5, 199, 187, 0.7);
}

.agent-tour__tab-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-tour__tab-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: #05c7bb;
    transform: scaleX(0);
    transform-origin: left center;
}

.agent-tour__tab[aria-selected="true"] .agent-tour__tab-bar { transform: scaleX(var(--p, 0)); }
.agent-tour.is-static .agent-tour__tab-bar { display: none; }

/* ── Captions ──────────────────────────────────────────────────────────── */

.agent-tour__captions {
    display: grid;
    max-width: 40rem;
    margin: 1.5rem auto 0;
    text-align: center;
}

.agent-tour__caption {
    grid-area: 1 / 1;
    margin: 0;
    font-size: 1rem;
    line-height: 1.65;
    color: rgba(156, 163, 175, 0.95);
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.35s ease, transform 0.35s var(--at-ease), visibility 0s linear 0.35s;
}

.agent-tour__caption.is-active,
.agent-tour:not(.is-ready) .agent-tour__caption[data-caption="1"] {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity 0.35s ease, transform 0.35s var(--at-ease), visibility 0s;
}

/* ── Staging ───────────────────────────────────────────────────────────── */

.agent-tour [data-s].is-off,
.agent-tour:not(.is-ready) [data-s]:not([data-s^="1"]) { display: none !important; }

.agent-tour.is-ready .agent-tour__window [data-s]:not([data-at]) { animation: atIn 0.45s var(--at-ease) both; }

/* ── Beats (data-at, see the script) ───────────────────────────────────── */

/* Board pieces and cards: rise in when their beat comes. */
.agent-tour.is-ready :is(.at-row, .at-plan, .at-plan__note, .at-tag, .at-delivery, .at-people li, .at-ct__tag, .at-delivery__foot)[data-at] {
    transition: opacity 0.45s ease, transform 0.55s var(--at-ease);
}

.agent-tour.is-ready :is(.at-row, .at-plan, .at-plan__note, .at-tag, .at-delivery, .at-people li, .at-ct__tag, .at-delivery__foot)[data-at]:not(.is-on) {
    opacity: 0;
    transform: translateY(8px);
}

.agent-tour.is-ready .at-delivery__foot[data-at]:not(.is-on) { display: none; }

/* Chat messages: added to the thread, so the thread grows from the bottom. */
.agent-tour.is-ready .at-chat[data-at]:not(.is-on) { display: none; }
.agent-tour.is-ready .at-chat[data-at].is-on { animation: atIn 0.45s var(--at-ease) both; }

/* Wires draw from the source to the node, then on to the container. */
.agent-tour.is-ready .at-wire[data-at] {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    transition: stroke-dashoffset 0.6s cubic-bezier(0.65, 0, 0.35, 1);
}

.agent-tour.is-ready .at-wire[data-at].is-on { stroke-dashoffset: 0; }

/* Files drop into the delivery one by one. */
.agent-tour.is-ready .at-file[data-at] { transition: opacity 0.3s ease, transform 0.45s var(--at-ease); }
.agent-tour.is-ready .at-file[data-at]:not(.is-on) { opacity: 0; transform: translateY(-10px) scale(0.85); }

/* Agent status and "busy" marks swap in place. */
.agent-tour.is-ready .at-agent__status > [data-at]:not(.is-on) { display: none; }
.at-status--ok { background: rgba(67, 194, 131, 0.14); color: var(--at-ok); }

.agent-tour.is-ready .at-mark[data-at].is-on {
    border-color: rgba(28, 145, 255, 0.45);
    animation: atBreathe 2.2s ease-in-out infinite;
}

.agent-tour.is-ready .at-mark[data-at].is-on img { filter: none; opacity: 1; }

/* A button lights up when it is clickable, and dips when the pointer clicks it. */
.at-btn,
.at-seg > span,
.at-composer__send { transition: transform 0.15s ease, background-color 0.2s ease, color 0.2s ease, opacity 0.2s ease; }
.agent-tour .is-pressed { transform: scale(0.94); filter: brightness(1.15); }
.agent-tour.is-ready .at-review__send[data-at]:not(.is-on) { opacity: 0.4; }

/* Typing: a caret while the words come in. */
.agent-tour .is-typing::after {
    content: '';
    display: inline-block;
    width: 1.5px;
    height: 1.05em;
    margin-left: 1px;
    vertical-align: -0.15em;
    background: var(--at-accent);
    animation: atCaret 0.8s steps(1) infinite;
}

@keyframes atCaret { 50% { opacity: 0; } }

/* The pointer */
.at-cursor {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 5;
    width: 18px;
    height: 22px;
    margin: -3px 0 0 -3px;
    pointer-events: none;
    opacity: 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 22'%3E%3Cpath d='M2 1.5v16.2l4.3-4.1 2.9 6.6 2.8-1.2-2.9-6.5H15z' fill='%23fff' stroke='%23111' stroke-width='1.3' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
    transition: transform 0.75s cubic-bezier(0.45, 0, 0.2, 1), opacity 0.25s ease;
}

.at-cursor.is-on { opacity: 1; }
.at-cursor.is-jump { transition: opacity 0.25s ease; }

.at-cursor::after {
    content: '';
    position: absolute;
    left: -9px;
    top: -9px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--at-accent);
    opacity: 0;
    transform: scale(0.4);
}

.at-cursor.is-click::after { animation: atClick 0.38s ease-out; }

@keyframes atClick {
    0% { opacity: 0.9; transform: scale(0.4); }
    100% { opacity: 0; transform: scale(1.4); }
}

@keyframes atIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

@keyframes atFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes atSpin { to { transform: rotate(360deg); } }
@keyframes atSweep { to { background-position: 0 0, -200% 0; } }
@keyframes atShimmer { to { background-position: -200% 0; } }
@keyframes atDash { to { stroke-dashoffset: -24; } }
@keyframes atBreathe { 50% { box-shadow: 0 0 0 3px rgba(28, 145, 255, 0.18); } }

/* ── The app window ────────────────────────────────────────────────────── */

.agent-tour__window {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 1.1rem;
    background: var(--at-bg);
    box-shadow: 0 40px 90px -40px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(0, 0, 0, 0.35);
    color: var(--at-text);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 13px;
    line-height: 1.45;
    text-align: left;
    -webkit-font-smoothing: antialiased;
}

.agent-tour__window p { margin: 0; }
.agent-tour__window ul,
.agent-tour__window ol { margin: 0; padding: 0; list-style: none; }

.at-chrome {
    display: flex;
    align-items: center;
    gap: 14px;
    height: 44px;
    padding: 0 10px 0 16px;
    border-bottom: 1px solid var(--at-border);
    background: var(--at-surface);
}

.at-chrome__dots { display: inline-flex; gap: 6px; flex: none; }
.at-chrome__dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--at-hover); }

.at-chrome__crumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
    font-size: 12.5px;
    white-space: nowrap;
}

.at-chrome__project { color: var(--at-muted); }
.at-chrome__sep { color: var(--at-faint); }
.at-chrome__board { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--at-text); font-weight: 600; }

.at-askai {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: none;
    height: 28px;
    padding: 0 10px;
    border: 1px solid var(--at-border);
    border-radius: 8px;
    background: var(--at-raised);
    font-size: 12px;
    font-weight: 600;
    color: var(--at-text);
}

.at-askai img { width: 14px; height: auto; }

.at-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--at-chat-w);
    height: calc(var(--at-h) - 44px);
}

/* ── Board ─────────────────────────────────────────────────────────────── */

.at-main {
    position: relative;
    min-width: 0;
    overflow: hidden;
    background: var(--at-board);
}

.at-board {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1.2px);
    background-size: 20px 20px;
    transition: opacity 0.4s ease, filter 0.4s ease;
}

.at-stage {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 760px;
    height: 500px;
    transform: translate(-50%, -50%) scale(var(--at-scale, 0.9));
    transform-origin: center center;
}

.at-wires { position: absolute; inset: 0; overflow: visible; }

.at-wire {
    fill: none;
    stroke: rgba(255, 255, 255, 0.28);
    stroke-width: 1.5;
}

.at-asset { position: absolute; left: 16px; top: 185px; width: 168px; }

.at-asset__name {
    display: block;
    height: 18px;
    font-size: 11px;
    color: var(--at-muted);
}

.at-asset img {
    display: block;
    width: 168px;
    height: 94.5px;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.6);
}

/* Steps 1–2: the photo attached to the chat is selected on the board */
.agent-tour__window[data-step="1"] .at-asset img,
.agent-tour__window[data-step="2"] .at-asset img {
    outline: 2px solid var(--at-accent);
    outline-offset: 3px;
}

.at-port {
    position: absolute;
    width: 10px;
    height: 10px;
    border: 2px solid var(--at-board);
    border-radius: 50%;
    background: var(--at-muted);
}

.at-port--out { right: -5px; top: 60px; }

.at-row { position: absolute; left: 236px; width: 508px; height: 140px; }

/* The plan's rows, before they run */
.at-ghost {
    position: absolute;
    left: 236px;
    width: 508px;
    height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 1.5px dashed rgba(255, 255, 255, 0.14);
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--at-muted);
}

.at-ghost small { font-size: 10px; font-weight: 500; color: var(--at-faint); }
.agent-tour.is-ready .at-ghost[data-at] { transition: opacity 0.45s ease, transform 0.55s var(--at-ease); }
.agent-tour.is-ready .at-ghost[data-at]:not(.is-on) { opacity: 0; transform: translateX(-10px); }

/* The tool node (ReComp, "edit" category) */
.at-gn {
    position: absolute;
    left: 0;
    top: 0;
    width: 220px;
    height: 140px;
    border: 1.5px solid var(--at-border);
    border-radius: 16px;
    background: var(--at-surface);
    box-shadow: 0 12px 28px -14px rgba(0, 0, 0, 0.7);
}

.at-gn__head {
    display: flex;
    align-items: center;
    gap: 7px;
    height: 32px;
    padding: 0 10px;
    border-radius: 14px 14px 0 0;
    background: linear-gradient(180deg, var(--at-edit), var(--at-edit-2));
}

.at-gn__icon {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    background-color: rgba(255, 255, 255, 0.22);
    -webkit-mask: none;
    position: relative;
}

.at-gn__icon::after {
    content: '';
    position: absolute;
    inset: 3px;
    background: #fff;
    -webkit-mask: var(--at-i-wand) center / contain no-repeat;
    mask: var(--at-i-wand) center / contain no-repeat;
}

.at-gn__label {
    flex: 1;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #fff;
}

.at-gn__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--at-ok); }

.at-gn__prompt {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 36px 12px 0 !important;
    font-size: 10px;
    line-height: 1.4;
    color: var(--at-muted);
}

.at-gn__props {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 9px;
    display: flex;
    gap: 6px;
}

.at-gn__props span {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 3px 7px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    font-size: 10px;
    color: var(--at-text);
}

.at-gn__props b {
    font-size: 7.5px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--at-faint);
}

.at-pill {
    position: absolute;
    top: 46px;
    height: 18px;
    padding: 0 7px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 9px;
    line-height: 16px;
    color: rgba(255, 255, 255, 0.72);
}

.at-pill::before {
    content: '';
    position: absolute;
    top: 50%;
    width: 9px;
    height: 9px;
    margin-top: -4.5px;
    border: 2px solid var(--at-surface);
    border-radius: 50%;
    background: var(--at-muted);
}

.at-pill--in { left: 10px; }
.at-pill--in::before { left: -17px; }
.at-pill--out { right: 10px; }
.at-pill--out::before { right: -17px; }

/* Running: drawn in the Light whatever its category */
.at-gn[data-status="running"] {
    border-color: transparent;
    background:
        linear-gradient(var(--at-surface), var(--at-surface)) padding-box,
        var(--at-ai-sweep) border-box;
    background-size: 100% 100%, 200% 100%;
    animation: atSweep 2.4s linear infinite;
}

.at-gn[data-status="running"] .at-gn__dot { background: #eab308; }
.at-gn__dot { transition: background-color 0.3s ease; }

/* The output container */
.at-ct {
    position: absolute;
    left: 272px;
    top: 0;
    width: 236px;
    height: 140px;
    border: 1px solid var(--at-border);
    border-radius: 16px;
    background: var(--at-surface);
    box-shadow: 0 12px 28px -14px rgba(0, 0, 0, 0.7);
}

.at-ct::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 51px;
    width: 10px;
    height: 10px;
    border: 2px solid var(--at-board);
    border-radius: 50%;
    background: var(--at-muted);
}

.at-ct__head {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 34px;
    padding: 0 12px;
    border-radius: 15px 15px 0 0;
    background: rgba(95, 156, 124, 0.14);
}

.at-ct__title { font-size: 11.5px; font-weight: 600; color: var(--at-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.at-ct__sub { font-size: 9.5px; color: var(--at-muted); }

.at-ct__body {
    position: relative;
    display: flex;
    gap: 6px;
    padding: 8px 12px 0;
}

/* Results: a shimmer while the node runs, then the image develops. */
.at-ct__body > .at-tile,
.at-v2 > .at-tile { transition: opacity 0.6s ease, filter 0.9s ease; }

.agent-tour.is-ready .at-ct__body[data-at]:not(.is-on) > .at-tile,
.agent-tour.is-ready .at-ct__body[data-at]:not(.is-on) > .at-v2 { opacity: 0; filter: blur(8px); }

.agent-tour.is-ready .at-ct__body[data-at]:not(.is-on)::after {
    content: '';
    position: absolute;
    left: 12px;
    top: 8px;
    width: 206px;
    height: 72px;
    border-radius: 6px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.12) 50%, rgba(255, 255, 255, 0.04) 100%);
    background-size: 200% 100%;
    animation: atShimmer 1.4s linear infinite;
}

.at-tile {
    display: block;
    flex: none;
    height: 72px;
    border-radius: 6px;
    background: #222 var(--img) var(--x, 50%) 50% / cover no-repeat;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.at-tile--wide { width: 128px; }
.at-tile--square { width: 72px; }

/* The redo, closer on the car: laid over the first version */
.at-v2 { position: absolute; left: 12px; top: 8px; display: flex; gap: 6px; }
.agent-tour.is-ready .at-v2[data-at]:not(.is-on) { opacity: 0; filter: blur(8px); }
.at-v2 { transition: opacity 0.6s ease, filter 0.9s ease; }
.at-tile--closer { background-size: 165%; background-position: var(--x, 42%) 62%; }

.at-ct__body::before {
    content: '1920×1080 · 1080×1080';
    position: absolute;
    left: 12px;
    top: 86px;
    font-size: 8.5px;
    color: var(--at-faint);
    white-space: nowrap;
}

.at-ct__tag {
    position: absolute;
    top: 9px;
    right: 10px;
    height: 16px;
    padding: 0 6px;
    border-radius: 5px;
    background: rgba(67, 194, 131, 0.16);
    font-size: 9px;
    font-weight: 600;
    line-height: 16px;
    color: var(--at-ok);
}

.at-ct__tag--v2 { background: rgba(5, 199, 187, 0.16); color: var(--at-accent); font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* ── Delivery (step 5) ─────────────────────────────────────────────────── */

.agent-tour__window[data-step="5"] .at-board { opacity: 0.35; filter: saturate(0.5); }

.at-delivery {
    position: absolute;
    top: 16px;
    right: 16px;
    width: min(300px, calc(100% - 32px));
    max-height: calc(100% - 32px);
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    overflow: hidden;
    border: 1px solid var(--at-border);
    border-radius: 14px;
    background: var(--at-surface);
    box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.8);
}

.at-delivery__head { display: flex; flex-direction: column; gap: 3px; }

.at-delivery__kicker {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--at-accent);
}

.at-delivery__title { font-size: 14px; font-weight: 600; color: #fff; }
.at-delivery__meta { font-size: 11px; color: var(--at-muted); }

.at-delivery__files { display: flex; gap: 6px; align-items: flex-end; }
.at-file {
    display: block;
    flex: none;
    width: 48px;
    height: 27px;
    border-radius: 4px;
    background: #222 var(--img) var(--x, 50%) 50% / cover no-repeat;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.at-file--sq { width: 27px; }
.at-file.at-file--closer { background-size: 165%; background-position: var(--x, 42%) 62%; }

.at-delivery__label {
    margin-top: 2px;
    font-size: 11px;
    font-weight: 600;
    color: var(--at-muted);
}

.at-people { display: flex; flex-direction: column; gap: 9px; }
.at-people li { display: flex; align-items: center; gap: 10px; min-width: 0; }

.at-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #3b4f5c;
    font-size: 10.5px;
    font-weight: 700;
    color: #fff;
}

.at-people li:nth-child(2) .at-avatar { background: #5b4a6e; }
.at-avatar--mail { background: var(--at-raised) !important; color: var(--at-muted); }

.at-people__who { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.at-people__name { font-size: 12.5px; font-weight: 600; color: var(--at-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.at-people__role { font-size: 11px; color: var(--at-muted); }

.at-delivery__foot {
    margin-top: 4px;
    padding-top: 10px;
    border-top: 1px solid var(--at-border-soft);
    font-size: 11px;
    color: var(--at-muted);
}

/* ── Agent column ──────────────────────────────────────────────────────── */

.at-agent {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    border-left: 1px solid var(--at-border);
    background: var(--at-bg);
}

.at-agent__head {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: none;
    height: 54px;
    padding: 0 8px 0 14px;
    border-bottom: 1px solid var(--at-border);
}

.at-agent__titles { display: flex; flex-direction: column; flex: 1; min-width: 0; margin-left: 6px; gap: 1px; }
.at-agent__title { font-size: 13px; font-weight: 600; color: var(--at-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.at-agent__status { display: flex; font-size: 11px; color: var(--at-muted); }

.at-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 17px;
    padding: 0 7px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 600;
}

.at-status::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.at-status--ai { background: rgba(28, 145, 255, 0.14); color: #6cb8ff; }
.at-status--warn { background: rgba(251, 191, 36, 0.13); color: var(--at-warn); }

.at-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 24px;
    height: 24px;
    border: 1px solid var(--at-border);
    border-radius: 50%;
    background: var(--at-surface);
}

.at-mark img { width: 12px; height: auto; filter: grayscale(1) brightness(1.4); opacity: 0.85; }
.at-mark--sm { width: 20px; height: 20px; }
.at-mark--sm img { width: 10px; }

.at-mark.is-working {
    border-color: rgba(28, 145, 255, 0.45);
    animation: atBreathe 2.2s ease-in-out infinite;
}

.at-mark.is-working img { filter: none; opacity: 1; }

.at-iconbtn {
    position: relative;
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 7px;
}

.at-iconbtn::after {
    content: '';
    position: absolute;
    inset: 7px;
    background: var(--at-muted);
    -webkit-mask: var(--at-icon) center / contain no-repeat;
    mask: var(--at-icon) center / contain no-repeat;
}

.at-iconbtn--new { --at-icon: var(--at-i-pencil); }
.at-iconbtn--expand { --at-icon: var(--at-i-expand); }
.at-iconbtn--close { --at-icon: var(--at-i-x); }

/* Plan strip */
.at-plan {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: none;
    margin: 10px 10px 0;
    padding: 10px 12px;
    border: 1px solid var(--at-border);
    border-radius: 12px;
    background: var(--at-surface);
}

.at-plan__head { display: flex; align-items: center; gap: 7px; min-width: 0; }

.at-plan__title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12.5px;
    font-weight: 600;
}

.at-tag {
    display: inline-flex;
    align-items: center;
    flex: none;
    height: 18px;
    padding: 0 6px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.07);
    font-size: 10px;
    font-weight: 600;
    color: var(--at-muted);
    white-space: nowrap;
}

.at-tag--ok { background: rgba(67, 194, 131, 0.14); color: var(--at-ok); }
.at-tag--strong { background: var(--at-text); color: var(--at-bg); }
.at-tag--mail { background: rgba(5, 199, 187, 0.12); color: var(--at-accent); }

.at-count {
    flex: none;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px;
    line-height: 18px;
    color: var(--at-muted);
}

.at-caret {
    flex: none;
    width: 12px;
    height: 12px;
    background: var(--at-muted);
    -webkit-mask: var(--at-i-caret) center / contain no-repeat;
    mask: var(--at-i-caret) center / contain no-repeat;
}

.agent-tour__window[data-step="2"] .at-caret { transform: rotate(180deg); }

.at-progress {
    display: block;
    height: 4px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
}

.at-progress span {
    display: block;
    width: 40%;
    height: 100%;
    border-radius: inherit;
    background: var(--at-accent);
    transition: width 0.6s var(--at-ease);
}

.agent-tour__window[data-step="3"] .at-progress span { width: 60%; }
.agent-tour__window[data-step="4"] .at-progress span { width: 80%; }
.agent-tour__window[data-step="5"] .at-progress span { width: 100%; background: var(--at-ok); }

.at-plan__now { display: flex; align-items: baseline; gap: 8px; min-width: 0; font-size: 11.5px; }

.at-plan__now-label {
    flex: none;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 9.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--at-faint);
}

.at-plan__now-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--at-text); }

.at-plan__steps { display: flex; flex-direction: column; gap: 2px; }

.at-plan__steps li {
    display: grid;
    grid-template-columns: 16px minmax(0, 1fr);
    gap: 9px;
    padding: 5px 6px;
    border-radius: 7px;
}

.at-plan__steps li[data-current] { background: rgba(255, 255, 255, 0.05); }
.at-plan__step { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.at-plan__step-row { display: flex; align-items: center; gap: 7px; }
.at-plan__step-title { font-size: 12px; color: var(--at-text); }
.at-plan__steps li[data-status="pending"] .at-plan__step-title { color: var(--at-muted); }
.at-plan__note { font-size: 10.5px; color: var(--at-muted); }

/* Step markers: done, running, waiting, pending */
.at-marker {
    position: relative;
    display: inline-block;
    flex: none;
    width: 14px;
    height: 14px;
    margin-top: 2px;
    border: 1.5px solid var(--at-faint);
    border-radius: 50%;
}

[data-status="done"] > .at-marker { border-color: var(--at-ok); background: var(--at-ok); }

[data-status="done"] > .at-marker::after {
    content: '';
    position: absolute;
    inset: 1.5px;
    background: var(--at-bg);
    -webkit-mask: var(--at-i-check) center / contain no-repeat;
    mask: var(--at-i-check) center / contain no-repeat;
}

[data-status="waiting"] > .at-marker { border-color: var(--at-warn); }

[data-status="waiting"] > .at-marker::after {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: var(--at-warn);
}

[data-status="running"] > .at-marker,
[data-status="live"] > .at-marker {
    border-color: rgba(28, 145, 255, 0.25);
    border-top-color: #1c91ff;
    animation: atSpin 0.9s linear infinite;
}

/* Thread */
.at-thread {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 32px);
    mask-image: linear-gradient(to bottom, transparent 0, #000 32px);
}

.at-thread__inner {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 14px 10px;
}

.at-msg { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }

.at-msg__asset {
    width: 72px;
    height: 72px;
    overflow: hidden;
    border: 1px solid var(--at-border);
    border-radius: 10px;
}

.at-msg__asset img { width: 100%; height: 100%; object-fit: cover; display: block; }

.at-msg__bubble {
    max-width: 88%;
    padding: 8px 12px;
    border-radius: 16px 16px 4px 16px;
    background: var(--at-raised);
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--at-text);
}

.at-turn { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.at-turn__head { display: flex; align-items: center; gap: 7px; }
.at-turn__name { font-size: 12px; font-weight: 600; color: var(--at-text); }
.at-turn__text { font-size: 12.5px; line-height: 1.55; color: var(--at-text); }

.at-steps { display: flex; flex-direction: column; gap: 6px; }

.at-steps li {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    font-size: 11.5px;
    color: var(--at-text);
    white-space: nowrap;
}

.at-steps .at-marker { margin-top: 0; }
.at-steps li[data-status="live"] { color: var(--at-muted); }
.at-steps__arg { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--at-muted); }

.at-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.at-btn--primary { background: var(--at-accent); color: var(--at-on-accent); }
.at-btn--ghost { border-color: var(--at-border); color: var(--at-text); }

.at-question {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--at-border);
    border-radius: 12px;
    background: var(--at-surface);
}

.at-question__q { font-size: 12.5px; font-weight: 600; }
.at-question__options { display: flex; flex-wrap: wrap; gap: 6px; }

/* Review card */
.at-review {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--at-border);
    border-radius: 12px;
    background: var(--at-surface);
}

.at-review__list { display: flex; flex-direction: column; gap: 8px; width: 100%; }

.at-review__list li {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
}

.at-review__frame {
    display: block;
    width: 56px;
    height: 32px;
    margin-top: 2px;
    border-radius: 5px;
    background: #222 var(--img) center / cover no-repeat;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.at-review__main { display: flex; flex-direction: column; gap: 5px; min-width: 0; padding-top: 1px; }
.at-review__head { display: flex; align-items: center; gap: 6px; min-width: 0; }
.at-review__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; font-weight: 600; }

.at-seg {
    display: flex;
    width: 100%;
    padding: 2px;
    border: 1px solid var(--at-border);
    border-radius: 7px;
    background: var(--at-bg);
}

.at-seg > span {
    flex: 1;
    min-width: 0;
    padding: 2px 4px;
    border-radius: 5px;
    font-size: 10.5px;
    text-align: center;
    color: var(--at-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.at-seg > span.is-on { background: var(--at-hover); color: #fff; font-weight: 600; }

.at-note {
    padding: 5px 8px;
    border: 1px solid var(--at-border);
    border-radius: 7px;
    background: var(--at-bg);
    font-size: 11px;
    line-height: 1.4;
    color: var(--at-text);
}

/* Approval card (create_delivery) */
.at-approval {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    border: 1px solid rgba(251, 191, 36, 0.45);
    border-radius: 12px;
    background: rgba(251, 191, 36, 0.05);
}

.at-approval__head { display: flex; align-items: center; gap: 10px; }

.at-approval__icon {
    position: relative;
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(251, 191, 36, 0.14);
}

.at-approval__icon::after {
    content: '';
    position: absolute;
    inset: 7px;
    background: var(--at-warn);
    -webkit-mask: var(--at-i-send) center / contain no-repeat;
    mask: var(--at-i-send) center / contain no-repeat;
}

.at-approval__titles { display: flex; flex-direction: column; min-width: 0; }
.at-approval__tool { font-size: 10.5px; color: var(--at-muted); }
.at-approval__title { font-size: 13px; font-weight: 600; color: #fff; }
.at-approval__body { font-size: 11.5px; color: var(--at-muted); }

.at-approval__fields {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 4px 10px;
    margin: 0;
    font-size: 11px;
}

.at-approval__fields dt { color: var(--at-muted); }
.at-approval__fields dd { margin: 0; color: var(--at-text); min-width: 0; overflow-wrap: anywhere; }
.at-approval__actions { display: flex; justify-content: flex-end; gap: 6px; }

/* Composer */
.at-composer {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: none;
    min-height: 46px;
    margin: 0 10px 10px;
    padding: 8px 8px 8px 12px;
    border: 1px solid var(--at-border);
    border-radius: 10px;
    background: var(--at-surface);
}

.at-composer__ph { flex: 1; min-width: 0; font-size: 12.5px; color: var(--at-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.at-composer__send {
    position: relative;
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--at-raised);
}

/* Typing a message: the photo attaches, the words come in, send lights up. */
.at-composer__chip {
    flex: none;
    width: 28px;
    height: 28px;
    overflow: hidden;
    border: 1px solid var(--at-border);
    border-radius: 6px;
}

.at-composer__chip img { display: block; width: 100%; height: 100%; object-fit: cover; }

.at-composer__text {
    flex: 1;
    min-width: 0;
    font-size: 12.5px;
    line-height: 1.4;
    color: var(--at-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.agent-tour.is-ready :is(.at-composer__chip, .at-composer__text)[data-at]:not(.is-on),
.agent-tour.is-ready .at-composer__ph[data-at].is-on,
.agent-tour.is-ready .at-approval__actions[data-at]:not(.is-on),
.agent-tour.is-ready .at-approval__sent[data-at]:not(.is-on) { display: none; }

.agent-tour.is-ready .at-composer__chip[data-at].is-on { animation: atIn 0.35s var(--at-ease) both; }
.at-composer__send.is-on { background: var(--at-accent); }
.at-composer__send.is-on::after { background: var(--at-on-accent); }
.at-approval__sent { align-self: flex-end; }

.at-composer__send::after {
    content: '';
    position: absolute;
    inset: 8px;
    background: var(--at-muted);
    -webkit-mask: var(--at-i-up) center / contain no-repeat;
    mask: var(--at-i-up) center / contain no-repeat;
}

/* Icons (masks) */
.agent-tour {
    --at-i-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3.2 3L13 4.5' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --at-i-caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 6l4.5 4.5L12.5 6' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --at-i-x: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 3.5l9 9M12.5 3.5l-9 9' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
    --at-i-pencil: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M10.5 2.5l3 3-7.5 7.5H3v-3z M8.5 4.5l3 3' fill='none' stroke='%23000' stroke-width='1.5' stroke-linejoin='round'/%3E%3C/svg%3E");
    --at-i-expand: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M9.5 2.5h4v4M13.5 2.5L9 7M6.5 13.5h-4v-4M2.5 13.5L7 9' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --at-i-send: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M14 2L2 7l5 2 2 5z M7 9l7-7' fill='none' stroke='%23000' stroke-width='1.5' stroke-linejoin='round'/%3E%3C/svg%3E");
    --at-i-up: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 13V3M3.5 7.5L8 3l4.5 4.5' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --at-i-wand: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M21.64 3.64l-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72z M14 7l3 3 M5 6v4 M19 14v4 M10 2v2 M7 8H3 M21 16h-4 M11 3H9' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* ── Tablet ────────────────────────────────────────────────────────────── */

@media (max-width: 1023px) {
    .agent-tour { --at-chat-w: 300px; --at-h: 560px; }
}

/* ── Phone: the chat above, the board below ────────────────────────────── */

@media (max-width: 767px) {
    .agent-tour__tabs { gap: 0.3rem; margin-bottom: 1rem; }

    .agent-tour__tab {
        flex-direction: column;
        gap: 0.15rem;
        padding: 0.5rem 0.2rem 0.6rem;
        border-radius: 0.6rem;
        font-size: 0.75rem;
    }

    .agent-tour__tab-num { font-size: 0.625rem; }
    .agent-tour__window { border-radius: 0.9rem; }
    .at-chrome { gap: 10px; height: 40px; padding-left: 12px; }
    .at-chrome__dots { display: none; }
    .at-chrome__project,
    .at-chrome__sep { display: none; }
    .at-askai { height: 26px; }

    .at-body { display: flex; flex-direction: column; height: auto; }

    .at-agent {
        order: -1;
        height: 470px;
        border-left: 0;
        border-bottom: 1px solid var(--at-border);
    }

    .at-main { aspect-ratio: 760 / 500; }

    /* The open plan leaves room for the Confirm card below it */
    .at-plan__note,
    .agent-tour__window[data-step="2"] .at-plan__now { display: none; }
    .at-plan__steps li { padding: 3px 6px; }

    .agent-tour__window[data-step="5"] .at-main { aspect-ratio: auto; }
    .agent-tour__window[data-step="5"] .at-board { display: none; }

    .at-delivery {
        position: static;
        width: auto;
        margin: 12px;
        box-shadow: none;
    }

    .at-delivery__foot { margin-top: 2px; }
    .agent-tour__captions { margin-top: 1.1rem; }
    .agent-tour__caption { font-size: 0.9375rem; }
}

/* ── Reduced motion: no autoplay (see the script), nothing moves ───────── */

@media (prefers-reduced-motion: reduce) {
    .agent-tour *,
    .agent-tour *::before,
    .agent-tour *::after {
        animation: none !important;
        transition: none !important;
    }
}
