:root {
    --bg: #000;
    --fg: #fff;
    --muted: rgba(255, 255, 255, 0.5);
    --muted2: rgba(255, 255, 255, 0.1);
    --tile: #0a0a0a;
    --tileBorder: rgba(255, 255, 255, 0.06);
    --gap: 12px;
    --accent: #ffffff;
    --accent-dim: rgba(255, 255, 255, 0.7);
    --danger: #ff6363;
    --success: #22c55e;
    --font-main: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-main);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow: hidden;
}

/* Custom Scrollbar - Minimal White */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.4); }
::-webkit-scrollbar-corner { background: transparent; }

/* ============================================
   AGENT OVERLAY
   ============================================ */

.agent-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.agent-overlay.active {
    opacity: 1;
    visibility: visible;
}

.agent-overlay.fade-out {
    opacity: 0;
    transition: opacity 0.6s ease;
}

.agent-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.agent-overlay-icon {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.agent-pulse-ring {
    position: absolute;
    inset: 0;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    animation: agentPulse 2s ease-in-out infinite;
}

.agent-pulse-ring::before {
    content: '';
    position: absolute;
    inset: -8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    animation: agentPulse 2s ease-in-out infinite 0.3s;
}

.agent-pulse-ring::after {
    content: '';
    position: absolute;
    inset: -16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    animation: agentPulse 2s ease-in-out infinite 0.6s;
}

@keyframes agentPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.5; }
}

/* Agent core icon - matches logo icon */
.agent-core {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255, 255, 255, 0.8);
    border-radius: 5px;
    transform: rotate(45deg);
    animation: agentGlow 2s ease-in-out infinite;
}

@keyframes agentGlow {
    0%, 100% { opacity: 0.9; border-color: rgba(255, 255, 255, 0.8); }
    50% { opacity: 0.5; border-color: rgba(255, 255, 255, 0.4); }
}

.agent-overlay-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.agent-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4);
}

.agent-status {
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    min-width: 200px;
    text-align: center;
}

/* ============================================
   WIDGET ENTRY ANIMATION (Agent Building)
   ============================================ */

.mod.agent-entering {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
}

.mod.agent-enter {
    animation: widgetAgentEntry 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes widgetAgentEntry {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Staggered glow effect on entry */
.mod.agent-enter::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: inherit;
    pointer-events: none;
    animation: widgetGlow 0.8s ease-out forwards;
}

@keyframes widgetGlow {
    from {
        opacity: 1;
        border-color: rgba(255, 255, 255, 0.4);
    }
    to {
        opacity: 0;
        border-color: rgba(255, 255, 255, 0);
    }
}

/* ============================================
   TOPBAR - OutputLayer Branding
   ============================================ */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--tileBorder);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    font-size: 1.1rem;
    font-weight: 400;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
}

.logo b {
    font-weight: 700;
}

/* Logo icon - rotated square */
.logo-icon {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 3px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
    transform: rotate(45deg);
    margin-top: 1px;
}

.tagline {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 400;
    padding-left: 16px;
    border-left: 1px solid var(--tileBorder);
}

.actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ============================================
   AGENT MODE TOGGLE
   ============================================ */

.agent-mode-toggle {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid var(--tileBorder);
    background: transparent;
    transition: all 0.2s ease;
    position: relative;
    user-select: none;
}

.agent-mode-toggle:hover {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.05);
}

.agent-mode-toggle.on {
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.1);
}

.agent-mode-toggle.on .agent-mode-icon {
    opacity: 1;
}

.agent-mode-toggle.off {
    opacity: 0.5;
}

.agent-mode-toggle.off:hover {
    opacity: 0.75;
}

.agent-mode-icon {
    font-size: 1rem;
    opacity: 0.6;
    transition: opacity 0.2s;
}

/* ============================================
   LEGAL LINKS
   ============================================ */

.legal-links {
    position: fixed;
    bottom: 10px;
    right: 14px;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.3);
    display: flex;
    gap: 6px;
    z-index: 50;
}

.legal-links a {
    color: rgba(255, 255, 255, 0.3);
    text-decoration: none;
    transition: color 0.2s;
}

.legal-links a:hover {
    color: rgba(255, 255, 255, 0.6);
}

/* ============================================
   PRESENCE & PULSE TOGGLES
   ============================================ */

.presence-toggle,
.pulse-toggle {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid var(--tileBorder);
    background: transparent;
    transition: all 0.2s ease;
    position: relative;
}

.presence-toggle:hover,
.pulse-toggle:hover {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.05);
}

.presence-toggle.on,
.pulse-toggle.on {
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.1);
}

.presence-toggle.detected {
    border-color: var(--success);
    background: rgba(34, 197, 94, 0.15);
}

.presence-icon,
.pulse-icon {
    font-size: 1rem;
    opacity: 0.7;
}

.presence-toggle.on .presence-icon,
.pulse-toggle.on .pulse-icon {
    opacity: 1;
}

/* Tooltips */
.presence-tooltip,
.pulse-tooltip {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: #111;
    border: 1px solid var(--tileBorder);
    border-radius: 8px;
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
}

.presence-tooltip.show,
.pulse-tooltip.show {
    opacity: 1;
    visibility: visible;
}

/* User Badge */
.presence-user-badge {
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--success);
    color: #000;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
    animation: badgeFadeIn 0.3s ease;
}

@keyframes badgeFadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-5px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}