/* ═══════════════════════════════════════════════════════════════
   Agent Town — Pixel Village
   BizOps 9-Agent Pipeline Visualization
   Pixel art characters in a cozy village setting
   ═══════════════════════════════════════════════════════════════ */

/* ── Design Tokens ── */
:root {
    --at-floor: #E8F5E0;
    --at-floor-grid: #C4D9B8;
    --at-floor-accent: #A8C698;
    --at-conveyor: #A08060;
    --at-conveyor-active: #D4A04A;
    --at-conveyor-glow: rgba(212, 160, 74, 0.45);
    --at-bubble-bg: #FFFEF5;
    --at-bubble-shadow: 0 4px 16px rgba(60,40,10,0.12);
    --at-station-bg: #FFF8EC;
    --at-station-shadow: 0 3px 10px rgba(60,40,10,0.10);
    --at-station-border: #D4C4A0;
    --at-desk-surface: #FAECD4;
    --at-desk-front: #D4BFA0;
    --at-desk-side: #C4AA88;
    --at-text: #3B2E1A;
    --at-text-muted: #6B5C48;
    --at-text-subtle: #6B5C48;
    --at-success: #4CAF50;
    --at-danger: #E05050;
    --at-warning: #E8A020;
    --at-info: #5090D0;
    /* Text-safe variants (WCAG AA ≥ 4.5:1 on #FFFFFF / light cream) */
    --at-success-text: #2E7D32;
    --at-danger-text: #B71C1C;
    --at-warning-text: #8B5A00;
    --at-info-text: #1E5A9C;
    --at-font-display: 'Fira Code', 'Malgun Gothic', monospace;
    --at-font-body: 'Fira Sans', 'Malgun Gothic', -apple-system, sans-serif;
    --at-iso-skew: -30deg;
    --at-transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Village palette per agent */
    --at-roof-scout: #7BAED8;
    --at-wall-scout: #D6EAF8;
    --at-roof-drafter: #A982C4;
    --at-wall-drafter: #E8D8F4;
    --at-roof-inspector: #D4A840;
    --at-wall-inspector: #FFF0C8;
    --at-roof-sentinel: #D06050;
    --at-wall-sentinel: #FADCD8;
    --at-roof-tester: #D880A8;
    --at-wall-tester: #FDE4EE;
    --at-roof-fixer: #5EAA68;
    --at-wall-fixer: #D4F0D8;
    --at-roof-guardian: #707888;
    --at-wall-guardian: #E0E4EA;
    --at-roof-herald: #6068C0;
    --at-wall-herald: #DDE0F8;
    --at-roof-sage: #C8960C;
    --at-wall-sage: #FFF4D0;
}

/* ── Master Layout ── */
.at-layout {
    display: grid;
    grid-template-rows: auto 1fr;
    height: calc(100vh - 52px);
    overflow: hidden;
    background: var(--at-floor);
}

/* 2-column: village (left) + side panel (right) */
.at-main {
    display: grid;
    grid-template-columns: 1fr 320px;
    overflow: hidden;
    min-height: 0;
}

/* ── Right Side Panel ── */
.at-side-panel {
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
    border-left: 1px solid var(--at-station-border);
    overflow: hidden;
}

.at-side-tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--at-station-border);
    background: #FFF;
    flex-shrink: 0;
}

.at-side-tab {
    flex: 1;
    padding: 8px 4px;
    border: none;
    background: transparent;
    font-family: var(--at-font-body);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--at-text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
}

.at-side-tab:hover {
    background: rgba(0,0,0,0.02);
    color: var(--at-text);
}

.at-side-tab.active {
    color: var(--color-cta-text);
    border-bottom-color: var(--color-cta-hover);
    font-weight: 600;
}

.at-side-content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.at-side-pane {
    display: none;
    position: absolute;
    inset: 0;
    overflow-y: auto;
    padding: 12px;
}

.at-side-pane.active {
    display: block;
}

/* ── Pipeline Progress Bar (Top) ── */
.at-pipeline-bar {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 10px 20px;
    background: #FFF8EC;
    border-bottom: 2px solid #D4C4A0;
    overflow-x: auto;
    scrollbar-width: none;
    image-rendering: pixelated;
}
.at-pipeline-bar::-webkit-scrollbar { display: none; }

.at-pip-step {
    display: flex;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
}

.at-pip-node {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 4px;
    font-family: var(--at-font-body);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--at-text-muted);
    background: transparent;
    transition: all var(--at-transition);
    cursor: default;
    white-space: nowrap;
    border: 1px solid transparent;
}

.at-pip-node .at-pip-emoji {
    font-size: 1rem;
    line-height: 1;
}

.at-pip-node .at-pip-led {
    width: 6px;
    height: 6px;
    border-radius: 1px;
    background: #C4B898;
    flex-shrink: 0;
    transition: background var(--at-transition);
}

.at-pip-node.idle { }
.at-pip-node.running {
    background: rgba(80, 144, 208, 0.10);
    border-color: rgba(80, 144, 208, 0.25);
    color: var(--at-text);
    font-weight: 600;
}
.at-pip-node.running .at-pip-led {
    background: var(--at-info);
    animation: at-led-pulse 1.4s ease-in-out infinite;
}
.at-pip-node.done {
    color: var(--at-success-text);
}
.at-pip-node.done .at-pip-led {
    background: var(--at-success);
}
.at-pip-node.error {
    color: var(--at-danger-text);
}
.at-pip-node.error .at-pip-led {
    background: var(--at-danger);
    animation: at-led-pulse 0.6s ease-in-out infinite;
}

.at-pip-connector {
    width: 28px;
    height: 3px;
    background: #D4C4A0;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    border-radius: 1px;
}
.at-pip-connector.active {
    background: rgba(212, 160, 74, 0.3);
}
.at-pip-connector.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--at-conveyor-active);
    animation: at-flow-pip 1s linear infinite;
}
.at-pip-connector.done {
    background: var(--at-success);
}

@keyframes at-flow-pip {
    to { left: 100%; }
}

/* Pipeline stats inline */
.at-pip-stats {
    margin-left: auto;
    display: flex;
    gap: 14px;
    align-items: center;
    padding-left: 16px;
    border-left: 1px solid var(--at-floor-grid);
    flex-shrink: 0;
}
.at-pip-stat {
    font-family: var(--at-font-body);
    font-size: 0.75rem;
    color: var(--at-text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.at-pip-stat-val {
    font-family: var(--at-font-display);
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--at-text);
}

/* ── Pixel Village Floor (Center) ── */
.at-floor-viewport {
    position: relative;
    overflow: hidden;
    flex: 1;
    /* Alternating grass tile pattern */
    background:
        repeating-conic-gradient(#C4E6A0 0% 25%, #B8DD94 0% 50%) 0 0 / 32px 32px;
    image-rendering: pixelated;
}

/* Decorative pixel trees, well, fence */
.at-floor-viewport::before {
    content: '';
    position: absolute;
    z-index: 0;
    pointer-events: none;
    inset: 0;
    /* Pixel trees using box-shadow technique - each "shadow" is a pixel block */
    /* Tree 1 top-left, Tree 2 top-right, Tree 3 bottom-left */
    background: none;
    box-shadow:
        /* ── Tree 1 (top-left area) ── */
        /* trunk */
        40px 60px 0 0 #8B6944,
        44px 60px 0 0 #8B6944,
        40px 64px 0 0 #8B6944,
        44px 64px 0 0 #8B6944,
        /* canopy */
        32px 44px 0 0 #3A8C3A,
        36px 44px 0 0 #3A8C3A,
        40px 44px 0 0 #3A8C3A,
        44px 44px 0 0 #3A8C3A,
        48px 44px 0 0 #3A8C3A,
        52px 44px 0 0 #3A8C3A,
        28px 48px 0 0 #4AA84A,
        32px 48px 0 0 #4AA84A,
        36px 48px 0 0 #2E7A2E,
        40px 48px 0 0 #4AA84A,
        44px 48px 0 0 #2E7A2E,
        48px 48px 0 0 #4AA84A,
        52px 48px 0 0 #4AA84A,
        56px 48px 0 0 #4AA84A,
        32px 52px 0 0 #3A8C3A,
        36px 52px 0 0 #4AA84A,
        40px 52px 0 0 #3A8C3A,
        44px 52px 0 0 #4AA84A,
        48px 52px 0 0 #3A8C3A,
        52px 52px 0 0 #3A8C3A,
        36px 56px 0 0 #2E7A2E,
        40px 56px 0 0 #4AA84A,
        44px 56px 0 0 #2E7A2E,
        48px 56px 0 0 #4AA84A,

        /* ── Tree 2 (top-right offset) ── */
        calc(100% - 60px) 50px 0 0 #8B6944,
        calc(100% - 56px) 50px 0 0 #8B6944,
        calc(100% - 60px) 54px 0 0 #8B6944,
        calc(100% - 56px) 54px 0 0 #8B6944,
        calc(100% - 72px) 34px 0 0 #3A8C3A,
        calc(100% - 68px) 34px 0 0 #3A8C3A,
        calc(100% - 64px) 34px 0 0 #3A8C3A,
        calc(100% - 60px) 34px 0 0 #3A8C3A,
        calc(100% - 56px) 34px 0 0 #3A8C3A,
        calc(100% - 52px) 34px 0 0 #3A8C3A,
        calc(100% - 48px) 34px 0 0 #3A8C3A,
        calc(100% - 72px) 38px 0 0 #4AA84A,
        calc(100% - 68px) 38px 0 0 #2E7A2E,
        calc(100% - 64px) 38px 0 0 #4AA84A,
        calc(100% - 60px) 38px 0 0 #2E7A2E,
        calc(100% - 56px) 38px 0 0 #4AA84A,
        calc(100% - 52px) 38px 0 0 #2E7A2E,
        calc(100% - 48px) 38px 0 0 #4AA84A,
        calc(100% - 68px) 42px 0 0 #3A8C3A,
        calc(100% - 64px) 42px 0 0 #4AA84A,
        calc(100% - 60px) 42px 0 0 #3A8C3A,
        calc(100% - 56px) 42px 0 0 #4AA84A,
        calc(100% - 52px) 42px 0 0 #3A8C3A,
        calc(100% - 64px) 46px 0 0 #2E7A2E,
        calc(100% - 60px) 46px 0 0 #4AA84A,
        calc(100% - 56px) 46px 0 0 #2E7A2E,

        /* ── Small bush bottom-right ── */
        calc(100% - 80px) calc(100% - 80px) 0 1px #4AA84A,
        calc(100% - 76px) calc(100% - 80px) 0 1px #3A8C3A,
        calc(100% - 72px) calc(100% - 80px) 0 1px #4AA84A,
        calc(100% - 84px) calc(100% - 76px) 0 1px #3A8C3A,
        calc(100% - 80px) calc(100% - 76px) 0 1px #4AA84A,
        calc(100% - 76px) calc(100% - 76px) 0 1px #2E7A2E,
        calc(100% - 72px) calc(100% - 76px) 0 1px #4AA84A,
        calc(100% - 68px) calc(100% - 76px) 0 1px #3A8C3A;
}

/* Central fountain/well decoration */
.at-floor-viewport::after {
    content: '';
    position: absolute;
    z-index: 0;
    pointer-events: none;
    /* Well in center */
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    background: none;
    box-shadow:
        /* Well base (stone ring) */
        -12px 4px 0 0 #8C8478,
        -8px 4px 0 0 #9C948A,
        -4px 4px 0 0 #8C8478,
        0px 4px 0 0 #9C948A,
        4px 4px 0 0 #8C8478,
        8px 4px 0 0 #9C948A,
        12px 4px 0 0 #8C8478,
        -12px 8px 0 0 #9C948A,
        -8px 8px 0 0 #6090C0,
        -4px 8px 0 0 #70A0D0,
        0px 8px 0 0 #6090C0,
        4px 8px 0 0 #70A0D0,
        8px 8px 0 0 #6090C0,
        12px 8px 0 0 #9C948A,
        -12px 12px 0 0 #8C8478,
        -8px 12px 0 0 #70A0D0,
        -4px 12px 0 0 #80B0E0,
        0px 12px 0 0 #70A0D0,
        4px 12px 0 0 #80B0E0,
        8px 12px 0 0 #70A0D0,
        12px 12px 0 0 #8C8478,
        -12px 16px 0 0 #9C948A,
        -8px 16px 0 0 #6090C0,
        -4px 16px 0 0 #70A0D0,
        0px 16px 0 0 #6090C0,
        4px 16px 0 0 #70A0D0,
        8px 16px 0 0 #6090C0,
        12px 16px 0 0 #9C948A,
        -12px 20px 0 0 #8C8478,
        -8px 20px 0 0 #9C948A,
        -4px 20px 0 0 #8C8478,
        0px 20px 0 0 #9C948A,
        4px 20px 0 0 #8C8478,
        8px 20px 0 0 #9C948A,
        12px 20px 0 0 #8C8478,
        /* Well roof post left */
        -8px 0px 0 0 #8B6944,
        -8px -4px 0 0 #8B6944,
        -8px -8px 0 0 #8B6944,
        /* Well roof post right */
        8px 0px 0 0 #8B6944,
        8px -4px 0 0 #8B6944,
        8px -8px 0 0 #8B6944,
        /* Well roof */
        -12px -12px 0 0 #C06030,
        -8px -12px 0 0 #C06030,
        -4px -12px 0 0 #C06030,
        0px -12px 0 0 #C06030,
        4px -12px 0 0 #C06030,
        8px -12px 0 0 #C06030,
        12px -12px 0 0 #C06030,
        -8px -16px 0 0 #D07040,
        -4px -16px 0 0 #D07040,
        0px -16px 0 0 #D07040,
        4px -16px 0 0 #D07040,
        8px -16px 0 0 #D07040,
        -4px -20px 0 0 #C06030,
        0px -20px 0 0 #C06030,
        4px -20px 0 0 #C06030,
        0px -24px 0 0 #D07040;
}

.at-floor-scene {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Auto-height: let content dictate vertical centering */
    min-height: 0;
}

/* Conveyor SVG Layer */
.at-conveyor-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}
.at-conveyor-layer svg {
    width: 100%;
    height: 100%;
}

/* Cobblestone path style conveyors */
.at-conveyor-line {
    fill: none;
    stroke: var(--at-conveyor);
    stroke-width: 3;
    stroke-dasharray: 4 6;
    stroke-linecap: round;
    opacity: 0.45;
    transition: opacity var(--at-transition), stroke var(--at-transition);
}
.at-conveyor-line.active {
    stroke: var(--at-conveyor-active);
    opacity: 0.9;
    stroke-width: 3.5;
    filter: drop-shadow(0 0 3px var(--at-conveyor-glow));
}
.at-conveyor-line.done {
    stroke: var(--at-success);
    opacity: 0.65;
    stroke-dasharray: none;
}

/* Animated data packet on conveyor */
.at-packet {
    r: 5;
    fill: var(--at-conveyor-active);
    filter: drop-shadow(0 0 4px var(--at-conveyor-glow));
    opacity: 0;
}
.at-packet.moving {
    opacity: 1;
}

/* ── Agent Village Building (Station) ── */
.at-stations-grid {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(4, 160px);
    grid-template-rows: repeat(3, auto);
    gap: 20px 32px;
    padding: 24px;
}

.at-station {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    cursor: pointer;
    transition: transform var(--at-transition);
}
.at-station:hover {
    transform: translateY(-4px);
}
.at-station:hover .at-desk {
    box-shadow: 0 6px 20px rgba(60,40,10,0.14);
}

/* Building (was "desk") — pixel house shape */
.at-desk {
    width: 110px;
    height: 52px;
    position: relative;
    border-radius: 2px;
    background: var(--at-station-bg);
    border: 2px solid var(--at-station-border);
    box-shadow: var(--at-station-shadow);
    transition: box-shadow var(--at-transition), border-color var(--at-transition);
    image-rendering: pixelated;
}

/* Building front step / foundation */
.at-desk::before {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 2px;
    right: 2px;
    height: 8px;
    background: #C4AA88;
    border-radius: 0 0 2px 2px;
    border: 2px solid var(--at-station-border);
    border-top: none;
}

/* Triangular roof using clip-path */
.at-desk::after {
    content: '';
    position: absolute;
    top: -22px;
    left: -6px;
    right: -6px;
    height: 24px;
    background: #C06030;
    clip-path: polygon(0% 100%, 50% 0%, 100% 100%);
    z-index: 1;
}

/* Per-agent roof and wall colors */
.at-station[data-agent="scout"] .at-desk { background: var(--at-wall-scout); }
.at-station[data-agent="scout"] .at-desk::after { background: var(--at-roof-scout); }
.at-station[data-agent="drafter"] .at-desk { background: var(--at-wall-drafter); }
.at-station[data-agent="drafter"] .at-desk::after { background: var(--at-roof-drafter); }
.at-station[data-agent="inspector"] .at-desk { background: var(--at-wall-inspector); }
.at-station[data-agent="inspector"] .at-desk::after { background: var(--at-roof-inspector); }
.at-station[data-agent="sentinel"] .at-desk { background: var(--at-wall-sentinel); }
.at-station[data-agent="sentinel"] .at-desk::after { background: var(--at-roof-sentinel); }
.at-station[data-agent="tester"] .at-desk { background: var(--at-wall-tester); }
.at-station[data-agent="tester"] .at-desk::after { background: var(--at-roof-tester); }
.at-station[data-agent="fixer"] .at-desk { background: var(--at-wall-fixer); }
.at-station[data-agent="fixer"] .at-desk::after { background: var(--at-roof-fixer); }
.at-station[data-agent="guardian"] .at-desk { background: var(--at-wall-guardian); }
.at-station[data-agent="guardian"] .at-desk::after { background: var(--at-roof-guardian); }
.at-station[data-agent="herald"] .at-desk { background: var(--at-wall-herald); }
.at-station[data-agent="herald"] .at-desk::after { background: var(--at-roof-herald); }
.at-station[data-agent="sage"] .at-desk { background: var(--at-wall-sage); }
.at-station[data-agent="sage"] .at-desk::after { background: var(--at-roof-sage); }

/* Door (was desk-screen) — small window/door on building */
.at-desk-screen {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 30px;
    border-radius: 2px 2px 0 0;
    background: #5C4830;
    border: 2px solid #4A3820;
    overflow: hidden;
    transition: all var(--at-transition);
    z-index: 2;
}

/* Door knob */
.at-desk-screen::before {
    content: '';
    position: absolute;
    top: 14px;
    right: 3px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #D4A04A;
}

/* Window panes on building sides */
.at-station .at-desk .at-desk-status {
    position: absolute;
    bottom: auto;
    top: 10px;
    left: 8px;
    right: auto;
    width: 16px;
    height: 16px;
    border-radius: 1px;
    background: #88C8E8;
    border: 2px solid #4A3820;
    transition: background var(--at-transition);
}

/* Second window (right side) — added via box-shadow trick */
.at-station .at-desk .at-desk-status::after {
    content: '';
    position: absolute;
    top: 0;
    left: 60px;
    width: 16px;
    height: 16px;
    border-radius: 1px;
    background: #88C8E8;
    border: 2px solid #4A3820;
}

/* Chimney on roof */
.at-station .at-desk .at-desk-status::before {
    content: '';
    position: absolute;
    top: -44px;
    left: 52px;
    width: 10px;
    height: 14px;
    background: #A08070;
    border: 2px solid #806050;
    border-bottom: none;
    z-index: 3;
    border-radius: 1px 1px 0 0;
}

/* Status-based building glow */
.at-station.running .at-desk-screen {
    background: rgba(80, 144, 208, 0.25);
    border-color: rgba(80, 144, 208, 0.5);
    box-shadow: 0 0 8px rgba(80, 144, 208, 0.3);
}
.at-station.running .at-desk-screen::after {
    content: '';
    position: absolute;
    inset: 2px;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 3px,
        rgba(80, 144, 208, 0.15) 3px,
        rgba(80, 144, 208, 0.15) 4px
    );
    animation: at-screen-scroll 2s linear infinite;
}
.at-station.done .at-desk-screen {
    background: rgba(76, 175, 80, 0.2);
    border-color: rgba(76, 175, 80, 0.4);
}
.at-station.error .at-desk-screen {
    background: rgba(224, 80, 80, 0.2);
    border-color: rgba(224, 80, 80, 0.4);
    animation: at-screen-flicker 0.3s ease-in-out 3;
}

/* Monitor data display */
.at-desk-screen.has-data {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--at-font-display);
    font-size: 0.55rem;
    font-weight: 700;
    color: #FFE880;
    text-shadow: 0 0 4px rgba(255, 232, 128, 0.6);
    letter-spacing: -0.02em;
    line-height: 1;
    text-align: center;
    padding: 2px;
    word-break: break-all;
}
.at-station.done .at-desk-screen.has-data { color: #A5D6A7; text-shadow: 0 0 4px rgba(76, 175, 80, 0.5); }
.at-station.error .at-desk-screen.has-data { color: #EF9A9A; text-shadow: 0 0 4px rgba(224, 80, 80, 0.5); }

/* Running windows glow warm */
.at-station.running .at-desk .at-desk-status {
    background: #FFE880;
    box-shadow: 0 0 6px rgba(255, 232, 128, 0.5);
}
.at-station.running .at-desk .at-desk-status::after {
    background: #FFE880;
    box-shadow: 0 0 6px rgba(255, 232, 128, 0.5);
}
.at-station.done .at-desk .at-desk-status {
    background: #A0E8A0;
}
.at-station.done .at-desk .at-desk-status::after {
    background: #A0E8A0;
}
.at-station.error .at-desk .at-desk-status {
    background: #F0A0A0;
}
.at-station.error .at-desk .at-desk-status::after {
    background: #F0A0A0;
}

@keyframes at-screen-scroll {
    to { transform: translateY(-8px); }
}
@keyframes at-screen-flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Agent Character — now a canvas for pixel art */
.at-character {
    position: relative;
    width: 56px;
    height: 56px;
    margin-bottom: 2px;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--at-transition);
}

.at-char-body {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: transparent;
    border: none;
    box-shadow: none;
    transition: all var(--at-transition);
    position: relative;
    image-rendering: pixelated;
}

/* Canvas inside character body */
.at-char-body canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    width: 48px;
    height: 48px;
}

/* Idle floating (gentle bob) — CSS-driven subtle float */
.at-station.idle .at-char-body {
    animation: at-idle-float 2s ease-in-out infinite;
    opacity: 0.85;
}
/* Stagger each agent's animation start for organic feel */
.at-station:nth-child(1).idle .at-char-body { animation-delay: 0s; }
.at-station:nth-child(2).idle .at-char-body { animation-delay: 0.25s; }
.at-station:nth-child(3).idle .at-char-body { animation-delay: 0.5s; }
.at-station:nth-child(4).idle .at-char-body { animation-delay: 0.75s; }
.at-station:nth-child(5).idle .at-char-body { animation-delay: 0.33s; }
.at-station:nth-child(6).idle .at-char-body { animation-delay: 0.58s; }
.at-station:nth-child(7).idle .at-char-body { animation-delay: 0.17s; }
.at-station:nth-child(8).idle .at-char-body { animation-delay: 0.42s; }
.at-station:nth-child(9).idle .at-char-body { animation-delay: 0.67s; }

/* Working bounce + pulsing glow */
.at-station.running .at-char-body {
    animation: at-village-work 0.6s steps(3) infinite;
    opacity: 1;
    filter: drop-shadow(0 0 6px var(--station-color, rgba(80,144,208,0.5)));
}
.at-station.running .at-character {
    animation: at-work-glow 1.2s ease-in-out infinite;
}

/* Done — settled */
.at-station.done .at-char-body {
    opacity: 1;
    animation: none;
    transform: translateY(2px);
}
.at-station.done .at-char-body::after {
    content: '\2713';
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    border-radius: 2px;
    background: var(--at-success);
    color: white;
    font-size: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    image-rendering: auto;
}

/* Error flash red */
.at-station.error .at-char-body {
    animation: at-village-error 0.5s steps(2) infinite;
    opacity: 1;
}
.at-station.error .at-char-body::after {
    content: '!';
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    border-radius: 2px;
    background: var(--at-danger);
    color: white;
    font-size: 0.65rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    image-rendering: auto;
}

@keyframes at-idle-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

@keyframes at-village-idle {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-1px); }
}

@keyframes at-work-glow {
    0%, 100% { filter: drop-shadow(0 0 4px var(--station-color, rgba(80,144,208,0.3))); }
    50% { filter: drop-shadow(0 0 10px var(--station-color, rgba(80,144,208,0.6))); }
}

@keyframes at-village-work {
    0% { transform: translateY(0) translateX(0); }
    33% { transform: translateY(-2px) translateX(1px); }
    66% { transform: translateY(0) translateX(-1px); }
    100% { transform: translateY(-1px) translateX(0); }
}

@keyframes at-village-error {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.4) saturate(2) hue-rotate(-10deg); }
}

@keyframes at-led-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

/* Agent name label under building */
.at-station-label {
    margin-top: 12px;
    text-align: center;
}
.at-station-name {
    font-family: var(--at-font-display);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--at-text);
    letter-spacing: 0.02em;
}
.at-station-role {
    font-family: var(--at-font-body);
    font-size: 0.65rem;
    color: var(--at-text-muted);
    margin-top: 1px;
}

/* ── Chat Bubbles (floating on village floor) ── */
.at-bubble {
    position: absolute;
    z-index: 10;
    max-width: 220px;
    padding: 8px 12px;
    background: var(--at-bubble-bg);
    border-radius: 8px 8px 8px 2px;
    box-shadow: var(--at-bubble-shadow);
    font-family: var(--at-font-body);
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--at-text);
    pointer-events: none;
    opacity: 0;
    transform: translateY(8px) scale(0.95);
    animation: at-bubble-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    border: 2px solid var(--at-station-border);
}
.at-bubble.exit {
    animation: at-bubble-out 0.25s ease-in forwards;
}

.at-bubble::before {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 12px;
    width: 12px;
    height: 12px;
    background: var(--at-bubble-bg);
    border: 2px solid var(--at-station-border);
    border-top: none;
    border-right: none;
    transform: rotate(-45deg);
}

.at-bubble-name {
    font-weight: 700;
    font-size: 0.68rem;
    margin-bottom: 2px;
    color: var(--station-text-color, var(--at-info-text));
}

.at-bubble-text {
    /* I18N-02: preserve Korean word integrity; wrap only when unavoidable */
    word-break: keep-all;
    overflow-wrap: break-word;
}

/* Badge inside bubble */
.at-bubble-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 2px;
    font-size: 0.68rem;
    font-weight: 600;
    margin-top: 4px;
}
.at-bubble-badge.good { background: var(--color-success-light); color: #065F46; }
.at-bubble-badge.warn { background: var(--color-warning-light); color: var(--color-cta-text); }
.at-bubble-badge.bad  { background: var(--color-danger-light); color: #991B1B; }
.at-bubble-badge.info { background: #DBEAFE; color: #1E40AF; }

@keyframes at-bubble-in {
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
@keyframes at-bubble-out {
    to {
        opacity: 0;
        transform: translateY(-6px) scale(0.92);
    }
}

/* ── Bottom Drawer ── */
.at-drawer {
    background: #FFF8EC;
    border-top: 2px solid #D4C4A0;
    display: flex;
    flex-direction: column;
    max-height: 40vh;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.at-drawer.collapsed {
    max-height: 36px;
}

.at-drawer-handle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 16px;
    cursor: pointer;
    border-bottom: 1px solid #D4C4A0;
    flex-shrink: 0;
    user-select: none;
    background: #FFF4E0;
    transition: background var(--at-transition);
}
.at-drawer-handle:hover {
    background: var(--color-warning-light);
}

.at-drawer-handle-title {
    font-family: var(--at-font-display);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--at-text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.at-drawer-toggle {
    font-size: 0.8rem;
    color: var(--at-text-subtle);
    transition: transform 0.3s ease;
}
.at-drawer.collapsed .at-drawer-toggle {
    transform: rotate(180deg);
}

/* Drawer content: two panes side by side */
.at-drawer-body {
    display: grid;
    grid-template-columns: 1fr 280px;
    overflow: hidden;
    flex: 1;
    min-height: 0;
}
.at-drawer.collapsed .at-drawer-body {
    display: none;
}

/* Chat log inside drawer */
.at-drawer-chat {
    overflow-y: auto;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scroll-behavior: smooth;
    border-right: 1px solid #D4C4A0;
    background: #FFFDF5;
}

/* Message in drawer (compact) */
.at-msg {
    display: flex;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 4px;
    animation: at-msg-enter 0.25s ease;
    max-width: 100%;
    font-family: var(--at-font-body);
    align-items: flex-start;
}

@keyframes at-msg-enter {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.at-msg .at-msg-avatar {
    width: 24px;
    height: 24px;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.at-msg-body {
    flex: 1;
    min-width: 0;
}

.at-msg-header {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 1px;
}

.at-msg-name {
    font-weight: 600;
    font-size: 0.72rem;
    font-family: var(--at-font-display);
}
.at-msg-user {
    font-size: 0.65rem;
    font-weight: 500;
    color: #374151;
    background: rgba(0,0,0,0.05);
    padding: 1px 6px;
    border-radius: 3px;
    white-space: nowrap;
}

.at-msg-target {
    font-size: 0.68rem;
    color: var(--at-text-subtle);
}

.at-msg-time {
    font-size: 0.65rem;
    color: var(--at-text-subtle);
    margin-left: auto;
    font-family: var(--at-font-display);
}

.at-msg-text {
    font-size: 0.78rem;
    line-height: 1.4;
    /* I18N-02: Korean-safe wrapping */
    word-break: keep-all;
    overflow-wrap: break-word;
    color: var(--at-text-muted);
}

/* Event type indicators */
.at-msg.type-start {
    background: rgba(80, 144, 208, 0.06);
    border-left: 3px solid var(--at-info);
}
.at-msg.type-complete {
    background: rgba(76, 175, 80, 0.06);
    border-left: 3px solid var(--at-success);
}
.at-msg.type-error {
    background: rgba(224, 80, 80, 0.06);
    border-left: 3px solid var(--at-danger);
}
.at-msg.type-chat {
    background: rgba(169, 130, 196, 0.06);
    border-left: 3px solid #A982C4;
}
.at-msg.type-progress {
    background: transparent;
    border-left: 3px solid #C4B898;
    opacity: 0.75;
}

/* Inter-agent arrow */
.at-msg-arrow {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.68rem;
    color: var(--at-text-subtle);
    background: rgba(60,40,10,0.04);
    padding: 1px 6px;
    border-radius: 4px;
}

/* Data badges */
.at-data-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 2px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-top: 2px;
    margin-right: 3px;
}
.at-data-badge.good { background: var(--color-success-light); color: #065F46; }
.at-data-badge.warn { background: var(--color-warning-light); color: var(--color-cta-text); }
.at-data-badge.bad  { background: var(--color-danger-light); color: #991B1B; }
.at-data-badge.info { background: #DBEAFE; color: #1E40AF; }

/* Memory/insights pane (right of drawer) */
.at-drawer-insights {
    overflow-y: auto;
    padding: 8px 12px;
    background: #FFFDF5;
}
.at-drawer-insights-title {
    font-family: var(--at-font-display);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--at-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #D4C4A0;
}

.at-reflection-card {
    padding: 6px 8px;
    margin-bottom: 6px;
    border-radius: 4px;
    background: #FFF8EC;
    border: 1px solid #D4C4A0;
    font-size: 0.75rem;
}
.at-reflection-title {
    font-weight: 600;
    font-family: var(--at-font-display);
    font-size: 0.7rem;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.at-reflection-content {
    color: var(--at-text-muted);
    line-height: 1.35;
    font-size: 0.72rem;
}
.at-reflection-meta {
    font-size: 0.65rem;
    color: var(--at-text-subtle);
    margin-top: 3px;
    font-family: var(--at-font-display);
}
.at-importance {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 1px;
    background: var(--at-warning);
}
.at-importance.high { background: var(--at-danger); }
.at-importance.low { background: var(--at-success); }

/* ── Empty state ── */
.at-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    color: var(--at-text-subtle);
    gap: 8px;
}
.at-empty-icon {
    font-size: 2rem;
    opacity: 0.4;
}

/* ── Notification counter on drawer handle ── */
.at-drawer-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 2px;
    background: var(--at-conveyor-active);
    color: #FFFFFF;
    font-size: 0.65rem;
    font-weight: 700;
    font-family: var(--at-font-display);
}
.at-drawer-count:empty { display: none; }

/* ── View toggle (floor vs timeline) ── */
.at-view-toggle {
    display: flex;
    gap: 2px;
    background: #FAECD4;
    border-radius: 4px;
    padding: 2px;
}
.at-view-btn {
    padding: 3px 10px;
    border: none;
    background: transparent;
    border-radius: 2px;
    font-family: var(--at-font-body);
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--at-text-muted);
    cursor: pointer;
    transition: all var(--at-transition);
}
.at-view-btn.active {
    background: #FFFFFF;
    color: var(--at-text);
    box-shadow: 0 1px 3px rgba(60,40,10,0.10);
}

/* ── Connection highlight ring on targeted agent ── */
.at-station.receiving .at-char-body {
    animation: at-receive-ping 0.6s ease-out;
}
@keyframes at-receive-ping {
    0% { box-shadow: 0 0 0 0 rgba(212,160,74,0.4); }
    100% { box-shadow: 0 0 0 14px transparent; }
}

/* ── Responsive ── */
@media (max-width: 1200px) {
    .at-stations-grid {
        grid-template-columns: repeat(3, 140px);
        gap: 16px 24px;
    }
}

@media (max-width: 900px) {
    .at-stations-grid {
        grid-template-columns: repeat(3, 120px);
        gap: 12px 16px;
    }
    .at-desk { width: 100px; }
    .at-char-body { width: 40px; height: 40px; font-size: 1.2rem; }
    .at-char-body canvas { width: 40px; height: 40px; }
    .at-drawer-body {
        grid-template-columns: 1fr;
    }
    .at-drawer-insights {
        display: none;
    }
    .at-pip-stats {
        display: none;
    }
    .at-bubble {
        max-width: 160px;
        font-size: 0.7rem;
    }
}

@media (max-width: 900px) {
    .at-main {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 280px;
    }
    .at-side-panel {
        border-left: none;
        border-top: 1px solid var(--at-station-border);
    }
}

@media (max-width: 640px) {
    .at-main {
        grid-template-rows: 1fr 240px;
    }
    .at-stations-grid {
        grid-template-columns: repeat(2, minmax(100px, 1fr));
        gap: 10px 12px;
        padding: 12px;
    }
    .at-floor-scene { justify-content: flex-start; }
    .at-desk { width: 90px; }
    .at-station-label .at-station-name { font-size: 0.7rem; }
    .at-char-body canvas { width: 36px !important; height: 36px !important; }
    .at-bubble { max-width: 140px; font-size: 0.7rem; }
    .at-pipeline-bar {
        padding: 6px 12px;
    }
    .at-pip-node {
        font-size: 0.7rem;
        padding: 3px 6px;
    }
    .at-pip-connector { width: 16px; }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .at-conveyor-line.active {
        filter: none;
    }
    .at-station.running .at-desk-screen::after {
        animation: none;
    }
}

/* ── Sage Insight Bubbles ── */
.at-sage-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px dashed #C8A870;
}
.at-sage-avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}
.at-sage-avatar canvas {
    width: 40px !important;
    height: 40px !important;
    image-rendering: pixelated;
}
.at-sage-intro {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.78rem;
}
.at-sage-intro strong {
    color: var(--color-cta-text);
    font-size: 0.85rem;
}
.at-sage-intro span {
    color: var(--at-text-muted);
    font-size: 0.72rem;
}
.at-sage-refresh {
    margin-left: auto;
    width: 26px;
    height: 26px;
    border: 1px solid #C8A870;
    border-radius: 50%;
    background: transparent;
    color: var(--color-cta-text);
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, background 0.2s ease;
}
.at-sage-refresh:hover {
    background: rgba(217, 119, 6, 0.08);
    transform: rotate(180deg);
}
.at-sage-refresh:active {
    transform: rotate(360deg);
}

.at-sage-bubble {
    position: relative;
    margin-left: 20px;
    margin-bottom: 10px;
    padding: 10px 12px;
    background: linear-gradient(135deg, #FFFBEB 0%, var(--color-warning-light) 100%);
    border: 1px solid #FDE68A;
    border-radius: 2px 12px 12px 12px;
    font-size: 0.78rem;
    animation: at-sage-fade 0.4s ease;
    box-shadow: 0 2px 6px rgba(217, 119, 6, 0.08);
}

.at-sage-bubble-arrow {
    position: absolute;
    left: -8px;
    top: 10px;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 8px solid #FDE68A;
}
.at-sage-bubble-arrow::after {
    content: '';
    position: absolute;
    left: 2px;
    top: -5px;
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-right: 7px solid #FFFBEB;
}

.at-sage-bubble-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.at-sage-ticket {
    font-family: var(--at-font-display);
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--color-cta-text);
    background: rgba(217, 119, 6, 0.12);
    padding: 1px 6px;
    border-radius: 3px;
}

.at-sage-scenario {
    font-size: 0.72rem;
    color: var(--color-warning-text);
    font-weight: 600;
}

.at-sage-bubble-text {
    color: #78350F;
    line-height: 1.45;
    font-size: 0.73rem;
    /* I18N-02: Korean-safe wrapping */
    word-break: keep-all;
    overflow-wrap: break-word;
}

.at-sage-bubble-meta {
    font-size: 0.65rem;
    color: var(--color-cta-text);
    margin-top: 6px;
    text-align: right;
    opacity: 0.7;
}

@keyframes at-sage-fade {
    from { opacity: 0; transform: translateX(-8px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ── Daily Retro Panel ── */

/* KPI summary row — 3 mini cards */
.at-retro-kpi-row {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}
.at-retro-kpi-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px;
    background: #FFFFFF;
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(60,40,10,0.06);
    transition: box-shadow 0.2s;
}
.at-retro-kpi-card:hover {
    box-shadow: 0 2px 8px rgba(60,40,10,0.10);
}
.at-retro-kpi-icon {
    font-size: 1rem;
    line-height: 1;
}
.at-retro-kpi-value {
    font-family: var(--at-font-display);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--at-text);
    line-height: 1.1;
}
.at-retro-kpi-label {
    font-size: 0.6rem;
    font-weight: 500;
    color: var(--at-text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.at-retro-kpi-danger {
    background: linear-gradient(135deg, #FEF2F2 0%, #FECACA 100%);
    border-color: rgba(239,68,68,0.2);
}
.at-retro-kpi-danger .at-retro-kpi-value {
    color: var(--color-danger-text);
}

/* Empty state */
.at-retro-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 32px 8px;
    color: var(--at-text-subtle);
    font-size: 0.75rem;
}
.at-retro-empty-icon {
    font-size: 1.8rem;
    opacity: 0.5;
}

/* User mini-cards */
.at-retro-user-card {
    margin-bottom: 8px;
    padding: 8px 10px;
    background: #FFFFFF;
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(60,40,10,0.05);
}
.at-retro-user-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 3px;
}
.at-retro-user-name {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--at-text);
}
.at-retro-user-badge {
    font-family: var(--at-font-display);
    font-size: 0.62rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    background: rgba(139, 92, 246, 0.10);
    color: #6D28D9;
    flex-shrink: 0;
}
.at-retro-user-period {
    font-size: 0.65rem;
    color: var(--at-text-subtle);
    font-family: var(--at-font-display);
    margin-bottom: 4px;
}
.at-retro-user-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}
.at-retro-user-tag {
    font-size: 0.6rem;
    font-weight: 500;
    padding: 1px 6px;
    border-radius: 3px;
    background: rgba(0,0,0,0.04);
    color: var(--at-text-muted);
    white-space: nowrap;
}
.at-retro-tag-more {
    background: rgba(217,119,6,0.08);
    color: var(--color-cta-text);
    font-weight: 600;
}

/* Improvement alert cards */
.at-retro-alert {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 8px 10px;
    margin-bottom: 6px;
    border-radius: 6px;
    font-size: 0.73rem;
    line-height: 1.4;
}
.at-retro-alert-icon {
    font-size: 0.8rem;
    flex-shrink: 0;
    line-height: 1.4;
}
.at-retro-alert-text {
    flex: 1;
    /* I18N-02: Korean-safe wrapping */
    word-break: keep-all;
    overflow-wrap: break-word;
}
.at-retro-alert-warning {
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    color: #78350F;
}
.at-retro-alert-danger {
    background: #FEF2F2;
    border: 1px solid #FECACA;
    color: #7F1D1D;
}

/* Bar row idle state */
.at-retro-bar-idle {
    opacity: 0.45;
}
.at-retro-bar-count {
    font-size: 0.65rem;
    font-family: var(--at-font-display);
    font-weight: 600;
    color: var(--at-text-muted);
    min-width: 28px;
    text-align: right;
}

/* ── User Visitor Characters ── */
.at-user-visitor {
    position: absolute;
    bottom: -8px;
    right: -12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 10;
    animation: at-user-arrive 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.at-user-visitor canvas {
    image-rendering: pixelated;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

.at-user-nametag {
    margin-top: 2px;
    padding: 1px 6px;
    background: rgba(255,255,255,0.9);
    border: 1px solid var(--at-path);
    border-radius: 4px;
    font-family: var(--at-font-body);
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--at-text);
    white-space: nowrap;
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.at-user-leaving {
    animation: at-user-leave 0.5s ease-in forwards;
}

@keyframes at-user-arrive {
    0% { opacity: 0; transform: translateY(10px) scale(0.5); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes at-user-leave {
    0% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: translateY(-10px) scale(0.5); }
}

/* Multiple users at same station offset */
.at-user-visitor:nth-child(5) { right: -12px; }
.at-user-visitor:nth-child(6) { right: 24px; }
.at-user-visitor:nth-child(7) { right: 60px; }

/* ── Agent Profile Popover ── */
.at-station-bounce {
    animation: at-station-bounce 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes at-station-bounce {
    0% { transform: scale(1); }
    40% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.at-popover {
    position: absolute;
    z-index: 50;
    width: 320px;
    max-width: 320px;
    background: #FFFFFF;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(60, 40, 10, 0.18), 0 2px 8px rgba(60, 40, 10, 0.08);
    border: 1px solid var(--at-station-border);
    font-family: var(--at-font-body);
    opacity: 0;
    transform: translateY(10px);
    animation: at-popover-in 0.2s ease-out forwards;
    pointer-events: auto;
}

.at-popover-exit {
    animation: at-popover-out 0.2s ease-in forwards;
}

/* Triangle pointer at the bottom */
.at-popover::after {
    content: '';
    position: absolute;
    bottom: -7px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 14px;
    height: 14px;
    background: #FFFFFF;
    border-right: 1px solid var(--at-station-border);
    border-bottom: 1px solid var(--at-station-border);
}

@keyframes at-popover-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes at-popover-out {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(10px); }
}

.at-popover-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 14px 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.at-popover-emoji {
    font-size: 1.6rem;
    line-height: 1;
    flex-shrink: 0;
}

.at-popover-header > div {
    flex: 1;
    min-width: 0;
}

.at-popover-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--at-text);
    font-family: var(--at-font-display);
}

.at-popover-role {
    font-size: 0.72rem;
    color: var(--at-text-muted);
    margin-top: 1px;
}

.at-popover-close {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 1.1rem;
    color: var(--at-text-subtle);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
    line-height: 1;
}

.at-popover-close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--at-text);
}

/* Speech bubble inside popover */
.at-popover-speech {
    margin: 10px 14px;
    padding: 8px 12px;
    background: linear-gradient(135deg, #FFFBEB 0%, var(--color-warning-light) 100%);
    border: 1px solid #FDE68A;
    border-radius: 8px;
    font-size: 0.78rem;
    color: #78350F;
    line-height: 1.4;
}

/* Stats row */
.at-popover-stats {
    display: flex;
    padding: 10px 14px;
    gap: 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.at-popover-stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    position: relative;
}

.at-popover-stat + .at-popover-stat::before {
    content: '';
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 1px;
    background: rgba(0, 0, 0, 0.08);
}

.at-popover-stat-val {
    font-family: var(--at-font-display);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--at-text);
    line-height: 1.2;
}

.at-popover-stat-label {
    font-size: 0.62rem;
    font-weight: 500;
    color: var(--at-text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Activity section */
.at-popover-activity {
    padding: 10px 14px;
    max-height: 140px;
    overflow-y: auto;
}

.at-popover-activity-title {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--at-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.at-popover-event {
    font-family: var(--at-font-display);
    font-size: 0.68rem;
    color: var(--at-text-muted);
    padding: 3px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.at-popover-event:last-child {
    border-bottom: none;
}

.at-popover-event-empty {
    color: var(--at-text-subtle);
    font-style: italic;
    font-family: var(--at-font-body);
}

/* Filter button */
.at-popover-filter-btn {
    display: block;
    width: calc(100% - 28px);
    margin: 6px 14px 14px;
    padding: 8px 12px;
    border: 1px solid var(--at-station-border);
    border-radius: 8px;
    background: #FFF8EC;
    font-family: var(--at-font-body);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--at-text-muted);
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}

.at-popover-filter-btn:hover {
    background: #FFF0D4;
    border-color: #C8A870;
    color: var(--at-text);
}

/* ── Log Filter Bar ── */
.at-log-filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: linear-gradient(135deg, #FFFBEB 0%, var(--color-warning-light) 100%);
    border-bottom: 1px solid #FDE68A;
    font-family: var(--at-font-body);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--color-cta-text);
    flex-shrink: 0;
}

.at-log-filter-clear {
    border: 1px solid #FDE68A;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--color-cta-text);
    cursor: pointer;
    font-family: var(--at-font-body);
    transition: all 0.15s;
}

.at-log-filter-clear:hover {
    background: #FFFFFF;
    border-color: var(--color-cta-hover);
}

/* ── Popover Mobile ── */
@media (max-width: 900px) {
    .at-popover {
        width: calc(100% - 16px);
        max-width: none;
        left: 8px !important;
        right: 8px;
    }
}

@media (max-width: 640px) {
    .at-popover {
        width: calc(100% - 16px);
        max-width: none;
        left: 8px !important;
        right: 8px;
    }
}

/* ── Agent Level Badge ── */
.at-level-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: 0.7rem;
    line-height: 1;
    z-index: 5;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
    animation: at-badge-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes at-badge-pop {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

/* ── Time of Day ── */
.at-floor-viewport[data-time-of-day="morning"] {
    background:
        linear-gradient(180deg, rgba(255, 200, 120, 0.15) 0%, transparent 40%),
        repeating-conic-gradient(#C9E8A4 0% 25%, #BDE098 0% 50%) 0 0 / 32px 32px;
}
.at-floor-viewport[data-time-of-day="evening"] {
    background:
        linear-gradient(180deg, rgba(255, 140, 50, 0.2) 0%, rgba(100, 50, 20, 0.1) 100%),
        repeating-conic-gradient(#B8D490 0% 25%, #ACCA84 0% 50%) 0 0 / 32px 32px;
}
.at-floor-viewport[data-time-of-day="evening"] .at-desk-screen { background: #3A2818; border-color: #FFD080; }
.at-floor-viewport[data-time-of-day="evening"] .at-station-name { color: #5C3D1E; }

.at-floor-viewport[data-time-of-day="night"] {
    background:
        linear-gradient(180deg, rgba(20, 20, 60, 0.3) 0%, rgba(10, 10, 40, 0.2) 100%),
        repeating-conic-gradient(#6B8F5A 0% 25%, #5F8350 0% 50%) 0 0 / 32px 32px;
}
.at-floor-viewport[data-time-of-day="night"] .at-desk { opacity: 0.8; }
.at-floor-viewport[data-time-of-day="night"] .at-desk-screen { background: #1A1A3A; border-color: #4A4A8A; }
.at-floor-viewport[data-time-of-day="night"] .at-desk-screen.has-data { color: #8080FF; }
.at-floor-viewport[data-time-of-day="night"] .at-station-name { color: #B0C4DE; }
.at-floor-viewport[data-time-of-day="night"] .at-station-role { color: #8899AA; }

/* ── Agent Status Badge (on building) ── */
.at-status-badge {
    position: absolute;
    top: -28px;
    right: -8px;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    border-radius: 8px;
    font-family: var(--at-font-display);
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    pointer-events: none;
    animation: at-badge-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.at-status-badge .at-badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.at-status-badge .at-badge-count {
    font-size: 0.6rem;
}

/* Badge states */
.at-status-badge.badge-idle {
    background: rgba(156, 163, 175, 0.15);
    color: #374151;
    border: 1px solid rgba(156, 163, 175, 0.3);
}
.at-status-badge.badge-idle .at-badge-dot {
    background: #9CA3AF;
}

.at-status-badge.badge-working {
    background: rgba(76, 175, 80, 0.12);
    color: #065F46;
    border: 1px solid rgba(76, 175, 80, 0.3);
}
.at-status-badge.badge-working .at-badge-dot {
    background: var(--at-success);
    animation: at-badge-pulse 1.2s ease-in-out infinite;
}

.at-status-badge.badge-error {
    background: rgba(224, 80, 80, 0.12);
    color: #991B1B;
    border: 1px solid rgba(224, 80, 80, 0.3);
}
.at-status-badge.badge-error .at-badge-dot {
    background: var(--at-danger);
}

@keyframes at-badge-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}

/* ── Insight Cards (improved) ── */
.at-insight-card {
    position: relative;
    margin-bottom: 10px;
    padding: 10px 12px 10px 16px;
    background: #FFFFFF;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(60,40,10,0.08), 0 0 0 1px rgba(0,0,0,0.04);
    font-size: 0.78rem;
    border-left: 4px solid var(--at-info);
    transition: box-shadow 0.2s, transform 0.2s;
    animation: at-insight-slide 0.3s ease;
}
@keyframes at-insight-slide {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.at-insight-card:hover {
    box-shadow: 0 3px 10px rgba(60,40,10,0.12), 0 0 0 1px rgba(0,0,0,0.06);
    transform: translateY(-1px);
}

/* Severity left border colors + subtle background tints */
.at-insight-card.severity-mismatch {
    border-left-color: var(--at-danger);
    background: linear-gradient(135deg, #FFFFFF 0%, #FEF2F2 100%);
}
.at-insight-card.severity-warning {
    border-left-color: var(--at-warning);
    background: linear-gradient(135deg, #FFFFFF 0%, #FFFBEB 100%);
}
.at-insight-card.severity-info { border-left-color: var(--at-info); }

.at-insight-card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.at-insight-type-icon {
    font-size: 0.9rem;
    line-height: 1;
    flex-shrink: 0;
}

.at-insight-ticket {
    font-family: var(--at-font-display);
    font-weight: 700;
    font-size: 0.73rem;
    color: #1E40AF;
    background: rgba(59, 130, 246, 0.08);
    padding: 1px 7px;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.at-insight-ticket:hover {
    background: rgba(59, 130, 246, 0.18);
    text-decoration: underline;
}

.at-insight-scenario {
    font-size: 0.72rem;
    color: var(--color-warning-text);
    font-weight: 600;
}

.at-insight-title-text {
    font-size: 0.73rem;
    font-weight: 500;
    color: var(--at-text);
}

/* Importance badge */
.at-insight-imp {
    margin-left: auto;
    font-family: var(--at-font-display);
    font-size: 0.62rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}
.at-insight-imp.imp-high {
    background: rgba(239, 68, 68, 0.12);
    color: var(--color-danger-text);
}
.at-insight-imp.imp-mid {
    background: rgba(245, 158, 11, 0.12);
    color: var(--color-cta-text);
}
.at-insight-imp.imp-low {
    background: rgba(16, 185, 129, 0.10);
    color: #065F46;
}

.at-insight-body {
    color: var(--at-text-muted);
    line-height: 1.45;
    font-size: 0.73rem;
    /* I18N-02: Korean-safe wrapping */
    word-break: keep-all;
    overflow-wrap: break-word;
}

/* Truncated body — max 3 lines */
.at-insight-body.at-truncated {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.at-insight-expand {
    display: inline;
    background: none;
    border: none;
    color: var(--color-cta-text);
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0 0 0 4px;
    font-family: var(--at-font-body);
}
.at-insight-expand:hover {
    text-decoration: underline;
}

.at-insight-meta {
    font-size: 0.63rem;
    color: var(--at-text-subtle);
    margin-top: 6px;
    text-align: right;
    font-family: var(--at-font-display);
}

/* ── Retro Bar Chart ── */
.at-retro-chart {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.at-retro-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
    font-family: var(--at-font-body);
}

.at-retro-bar-label {
    width: 56px;
    flex-shrink: 0;
    text-align: right;
    font-weight: 500;
    color: var(--at-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.68rem;
}

.at-retro-bar-track {
    flex: 1;
    height: 16px;
    background: rgba(0,0,0,0.04);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.at-retro-bar-fill {
    height: 100%;
    border-radius: 3px;
    min-width: 2px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    padding-left: 4px;
}

.at-retro-bar-pct {
    font-size: 0.58rem;
    font-weight: 700;
    color: rgba(255,255,255,0.9);
    font-family: var(--at-font-display);
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* Bar colors per agent role */
.at-retro-bar-fill[data-agent="scout"]     { background: var(--color-secondary); }
.at-retro-bar-fill[data-agent="drafter"]   { background: #8B5CF6; }
.at-retro-bar-fill[data-agent="inspector"] { background: var(--color-cta); }
.at-retro-bar-fill[data-agent="sentinel"]  { background: var(--color-danger); }
.at-retro-bar-fill[data-agent="tester"]    { background: #EC4899; }
.at-retro-bar-fill[data-agent="fixer"]     { background: var(--color-success); }
.at-retro-bar-fill[data-agent="guardian"]  { background: #64748B; }
.at-retro-bar-fill[data-agent="herald"]    { background: #6366F1; }
.at-retro-bar-fill[data-agent="sage"]      { background: var(--color-cta-hover); }

.at-retro-chart-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--at-text-muted);
    margin: 10px 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Dialogue target in bubble */
.at-bubble-target {
    font-size: 0.65rem;
    color: var(--at-text-subtle);
    margin-bottom: 2px;
    font-style: italic;
}

/* ── Print ── */
@media print {
    .at-layout { display: block; height: auto; }
    .at-floor-viewport { display: none; }
    .at-drawer { max-height: none; }
    .at-drawer.collapsed .at-drawer-body { display: grid; }
    .at-bubble { display: none; }
}

/* ── SSE Connection Status Indicator ── */
.at-sse-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    transition: background 0.3s, color 0.3s;
    border: 1px solid transparent;
}

.at-sse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background 0.3s;
}

/* Connected — green (opaque so label stays AA on dark header) */
.at-sse-status.at-sse-connected {
    background: #D1FAE5;
    color: #065F46;
    border-color: #A7F3D0;
}
.at-sse-status.at-sse-connected .at-sse-dot {
    background: var(--color-success);
    animation: at-sse-pulse 2s ease-in-out infinite;
}

/* Connecting — amber (opaque for AA contrast on dark header) */
.at-sse-status.at-sse-connecting {
    background: #FEF3C7;
    color: var(--color-cta-text);
    border-color: #FDE68A;
}
.at-sse-status.at-sse-connecting .at-sse-dot {
    background: var(--color-cta);
    animation: at-sse-blink 1s ease-in-out infinite;
}

/* Disconnected — red (opaque for AA contrast on dark header) */
.at-sse-status.at-sse-disconnected {
    background: #FEE2E2;
    color: #991B1B;
    border-color: #FECACA;
}
.at-sse-status.at-sse-disconnected .at-sse-dot {
    background: var(--color-danger);
}

@keyframes at-sse-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.25); }
}

@keyframes at-sse-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ── MISMATCH Detail Cards ──────────────────────────────── */
.at-mismatch-detail-card {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-left: 4px solid var(--color-danger);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.at-mismatch-detail-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.at-mismatch-ticket {
  font-weight: 700;
  color: #DC2626;
  text-decoration: none;
  font-size: 13px;
}
.at-mismatch-ticket:hover { text-decoration: underline; }
.at-mismatch-scenario {
  background: var(--color-danger-light);
  color: #991B1B;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}
.at-mismatch-detail-type {
  font-size: 11px;
  color: var(--color-cta-text);
  margin-top: 2px;
}
.at-mismatch-detail-ts {
  font-size: 10px;
  color: var(--color-text-muted);
  margin-top: 2px;
}
