:root {
    --bg-dark: #0b0f19;
    --panel-bg: rgba(17, 24, 39, 0.65);
    --panel-border: rgba(255, 255, 255, 0.08);
    --panel-border-hover: rgba(255, 255, 255, 0.16);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-pink: #ec4899;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    --font-main: 'Outfit', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body.dark-theme {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.12) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.12) 0px, transparent 50%),
        radial-gradient(at 50% 50%, rgba(236, 72, 153, 0.05) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: var(--font-main);
    min-height: 100vh;
    padding: 1.5rem;
}

body.light-theme {
    --bg-dark: #f8fafc;
    --panel-bg: rgba(255, 255, 255, 0.85);
    --panel-border: rgba(0, 0, 0, 0.08);
    --panel-border-hover: rgba(0, 0, 0, 0.16);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    background-color: #f1f5f9;
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.08) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.08) 0px, transparent 50%),
        radial-gradient(at 50% 50%, rgba(236, 72, 153, 0.04) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: var(--font-main);
    min-height: 100vh;
    padding: 1.5rem;
}

body.light-theme .glass-panel {
    background: rgba(255, 255, 255, 0.82);
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.08);
}

body.light-theme .agent-panel-box {
    background: rgba(241, 245, 249, 0.6);
    border-color: rgba(0, 0, 0, 0.08);
}

body.light-theme .agent-card-item {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.1);
}

body.light-theme input,
body.light-theme textarea,
body.light-theme select {
    background: rgba(255, 255, 255, 0.95);
    color: #0f172a;
    border-color: rgba(0, 0, 0, 0.15);
}

body.light-theme .btn-secondary {
    background: rgba(0, 0, 0, 0.05);
    color: #1e293b;
    border-color: rgba(0, 0, 0, 0.12);
}

body.light-theme .btn-secondary:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #0f172a;
}

body.light-theme .btn-shuffle-chip {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.12);
    color: #475569;
}

body.light-theme .btn-shuffle-chip:hover {
    background: rgba(59, 130, 246, 0.1);
    color: #1d4ed8;
    border-color: #3b82f6;
}

body.light-theme .chat-msg {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.08);
}

body.light-theme .msg-body {
    color: #1e293b;
}

body.light-theme .modal-card {
    background: #ffffff;
    color: #0f172a;
    border-color: rgba(0, 0, 0, 0.1);
}

.app-container {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Glassmorphism Panel Base */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    position: relative;
    z-index: 100;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    font-size: 2rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem;
    border-radius: 12px;
    border: 1px solid var(--panel-border);
}

.logo-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.version-tag {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border-radius: 6px;
    font-family: var(--font-mono);
    margin-left: 0.5rem;
    -webkit-text-fill-color: initial;
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-running .status-dot {
    background: var(--accent-emerald);
    box-shadow: 0 0 10px var(--accent-emerald);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.8; }
}

/* Workspace Grid */
.workspace-grid {
    display: grid;
    grid-template-columns: 460px 1fr;
    gap: 1.5rem;
}

@media (max-width: 1100px) {
    .workspace-grid {
        grid-template-columns: 1fr;
    }
}

/* Configuration Panel */
.config-section {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.section-header p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.preset-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.chip {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--panel-border);
    color: var(--text-secondary);
    padding: 0.35rem 0.65rem;
    border-radius: 8px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chip:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: var(--panel-border-hover);
}

textarea, input[type="text"], select {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 0.75rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color 0.2s ease;
}

textarea:focus, input[type="text"]:focus, select:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Target Selector Grid */
.target-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.target-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 0.65rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.target-card input[type="radio"] {
    display: none;
}

.target-card.active, .target-card:has(input:checked) {
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.1);
}

.target-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.25rem;
}

.target-icon {
    font-size: 1.25rem;
}

.target-title {
    font-size: 0.8rem;
    font-weight: 600;
}

.target-desc {
    font-size: 0.68rem;
    color: var(--text-muted);
}

/* Slider */
.slider-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
}

/* Language Switcher */
.lang-switcher {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    padding: 0.2rem 0.5rem;
    border-radius: 8px;
}

.lang-switcher select {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
}

.full-width {
    width: 100%;
}

.btn-subtitled {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 0.8rem;
    text-align: center;
}

.btn-main-title {
    font-weight: 600;
    font-size: 0.92rem;
}

.btn-sub-title {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 0.15rem;
}

/* Visually Separated Agent Panel Box */
.agent-panel-box {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 0.75rem 0.85rem;
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* Floating Scroll to Bottom Button */
.scroll-bottom-btn {
    position: absolute;
    bottom: 15px;
    right: 25px;
    z-index: 100;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    animation: fadeIn 0.2s ease-in-out;
}

/* Agent Card Matrix (Streamlined Summary View) */
.agent-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.shuffle-buttons-strip {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.btn-shuffle-chip {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-secondary);
    border-radius: 6px;
    padding: 0.15rem 0.4rem;
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

.btn-shuffle-chip:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
    border-color: var(--accent-blue);
    transform: translateY(-1px);
}

.btn-shuffle-chip:active {
    transform: translateY(0);
}

.agent-cards-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.agent-card-item {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 0.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    position: relative;
    transition: border-color 0.2s ease;
}

.agent-card-item:hover {
    border-color: var(--panel-border-hover);
}

.agent-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.agent-card-identity {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    font-size: 0.88rem;
}

.agent-badges-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    font-size: 0.72rem;
}

.agent-badge-tag {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.btn-remove-agent {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.95rem;
    cursor: pointer;
    padding: 0.1rem 0.3rem;
}

.btn-remove-agent:hover {
    color: var(--accent-rose);
}

/* Buttons */
.btn {
    padding: 0.65rem 1.25rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border: 1px solid var(--panel-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.3);
}

.btn-warning {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.btn-warning:hover:not(:disabled) {
    background: rgba(245, 158, 11, 0.3);
}

.btn-accent {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: #fff;
}

/* Pause Control Bar */
.pause-control-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 12px;
}

.pause-bar-info {
    font-size: 0.88rem;
    font-weight: 500;
    color: #fcd34d;
}

.pause-bar-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-small {
    padding: 0.35rem 0.65rem;
    font-size: 0.78rem;
    border-radius: 6px;
}

.btn-large {
    padding: 0.85rem;
    font-size: 1rem;
    width: 100%;
}

/* Arena Section */
.arena-section {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: calc(100vh - 140px);
}

.arena-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 0.75rem;
}

.arena-title h2 {
    font-size: 1.25rem;
}

.session-id-tag {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

.font-size-controls {
    display: flex;
    gap: 0.25rem;
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.checkbox-container input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-blue);
    cursor: pointer;
}

/* Custom Traits Slider Box */
.custom-traits-box {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    background: rgba(16, 185, 129, 0.08);
    border: 1px dashed rgba(16, 185, 129, 0.3);
    border-radius: 8px;
    padding: 0.65rem;
    margin-top: 0.4rem;
}

.trait-slider-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.trait-slider-item input[type="range"] {
    width: 110px;
}

/* Multi-Room Session Tabs Bar */
.session-tabs-bar {
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--panel-border);
}

.tab-item {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--panel-border);
    color: var(--text-secondary);
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-family: var(--font-mono);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.tab-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.tab-item.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--accent-blue);
    color: #fff;
}

.btn-add-tab {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
    border-style: dashed;
}

/* Chat Feed */
.chat-feed-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-right: 0.5rem;
    font-size: var(--chat-font-size, 0.92rem);
}

.welcome-placeholder {
    margin: auto;
    text-align: center;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-secondary);
}

.placeholder-icon {
    font-size: 3rem;
}

/* Chat Message Cards */
.chat-msg {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 1rem;
    animation: fadeIn 0.3s ease;
}

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

.msg-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.msg-speaker {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.psych-badge {
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-weight: 500;
    color: #fff;
}

.role-badge {
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.msg-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.msg-body {
    font-size: var(--chat-font-size, 0.92rem);
    line-height: 1.55;
    color: var(--text-primary);
    white-space: pre-wrap;
}

/* Streaming Typing Indicator */
.typing-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed var(--panel-border);
    border-radius: 12px;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-blue);
    animation: dotPulse 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes dotPulse {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Human Intervention Bar */
.intervention-bar {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
}

.intervention-bar input {
    flex: 1;
}

/* Resolution Output Panel */
.resolution-panel {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 250px;
    overflow-y: auto;
    border-color: rgba(59, 130, 246, 0.3);
    background: rgba(15, 23, 42, 0.85);
}

.resolution-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.resolution-body {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
}

.modal-card {
    width: 90%;
    max-width: 650px;
    max-height: 80vh;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
}

.history-list {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.history-item {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-item:hover {
    border-color: var(--accent-blue);
}

.hidden {
    display: none !important;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}
