@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800&family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

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

:root {
    --font-main: 'Cairo', 'Inter', ui-sans-serif, system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;
    --hamiz-primary: #006837;
    --hamiz-secondary: #008542;
    --hamiz-header-height: 70px;
}

[data-theme="dark"] {
    --bg: #0b0e14;
    --card-bg: rgba(17, 21, 28, 0.6);
    --card-bg-solid: #11151c;
    --input-bg: #090b0f;
    --border: rgba(255,255,255,0.05);
    --border-hover: rgba(255,255,255,0.1);
    --text-primary: #f1f5f9;
    --text-secondary: #e2e8f0;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --accent-blue: #60a5fa;
    --accent-violet: #a78bfa;
    --accent-emerald: #34d399;
    --accent-amber: #fbbf24;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.3);
}

[data-theme="light"] {
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --card-bg-solid: #ffffff;
    --input-bg: #f1f5f9;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --text-dim: #94a3b8;
    --accent-blue: #0369a1;
    --accent-violet: #6d28d9;
    --accent-emerald: #047857;
    --accent-amber: #d97706;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

body {
    font-family: var(--font-main);
    background-color: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    padding-top: var(--hamiz-header-height);
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

::selection {
    background: #059669;
    color: #fff;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148,163,184,0.2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(148,163,184,0.4); }

/* Header */
.hamiz-header {
    background-color: var(--hamiz-primary);
    padding: 0.5rem 0;
    box-shadow: var(--shadow);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    height: var(--hamiz-header-height);
}

.hamiz-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    max-width: 1200px;
    margin: 0 auto;
    height: 100%;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.hamiz-header-title {
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'Cairo', sans-serif;
}

.hamiz-menu-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

.header-badge {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    background: rgba(6,78,59,0.4);
    color: #6ee7b7;
    border: 1px solid rgba(52,211,153,0.3);
}

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #34d399;
    animation: ping 1.5s infinite;
}

@keyframes ping {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.5); }
    100% { opacity: 1; transform: scale(1); }
}

@media (min-width: 1024px) {
    .header-badge { display: inline-flex; }
}

.header-btn {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    color: white;
    border: 1px solid rgba(255,255,255,0.1);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-main);
    font-weight: 500;
}

.header-btn:hover { background: rgba(255,255,255,0.2); }
.header-btn.active { background: white; color: var(--hamiz-primary); font-weight: 700; border-color: white; }

.hamiz-logo img {
    max-height: 44px;
    width: auto;
    max-width: 120px;
    transition: transform 0.2s;
}

.hamiz-logo img:hover { transform: scale(1.05); }

/* Side Menu */
.hamiz-side-menu {
    position: fixed;
    right: -320px;
    top: 0;
    width: 300px;
    height: 100vh;
    background-color: var(--card-bg-solid);
    box-shadow: var(--shadow);
    transition: right 0.3s ease;
    z-index: 999;
    overflow-y: auto;
    padding: calc(var(--hamiz-header-height) + 1rem) 1rem 1rem;
    border-left: 1px solid var(--border);
}

.hamiz-side-menu.active { right: 0; }

.hamiz-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.hamiz-menu-header h3 { font-size: 1rem; color: var(--text-primary); }

.hamiz-menu-close {
    background: var(--hamiz-primary);
    border: none;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.hamiz-menu-close:hover { background: var(--hamiz-secondary); transform: scale(1.1); }

.hamiz-menu-items { list-style: none; }
.hamiz-menu-item { margin-bottom: 0.75rem; }

.hamiz-menu-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.75rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s;
    border-radius: 0.5rem;
    font-size: 14px;
    font-weight: 500;
}

.hamiz-menu-link:hover { background: var(--input-bg); }
.submenu-arrow { margin-right: auto; font-size: 10px; transition: transform 0.2s; }
.hamiz-submenu { list-style: none; margin-right: 2rem; margin-top: 0.5rem; display: none; }
.hamiz-submenu.active { display: block; }

/* Notification */
.hamiz-notification {
    position: fixed;
    top: calc(var(--hamiz-header-height) + 20px);
    right: 20px;
    padding: 1rem 1.5rem;
    background: var(--hamiz-primary);
    color: white;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    transform: translateX(120%);
    transition: transform 0.3s ease;
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 14px;
    font-weight: 600;
}

.hamiz-notification.show { transform: translateX(0); }

/* Main Layout */
.main-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

.grid-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (min-width: 1024px) {
    .grid-layout.with-panel {
        grid-template-columns: 5fr 7fr;
    }
}

.config-panel { display: flex; flex-direction: column; gap: 1.5rem; }
.arena-section { display: flex; flex-direction: column; gap: 1.5rem; }

/* Cards */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
    transition: border-color 0.2s;
}

.card-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.card-sublabel {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* Dialect Grid */
.dialect-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
}

.dialect-btn {
    padding: 12px;
    font-size: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-family: var(--font-main);
    font-weight: 500;
}

.dialect-btn:hover { color: var(--text-primary); border-color: var(--border-hover); }
.dialect-btn.active {
    background: rgba(16,185,129,0.08);
    border-color: rgba(16,185,129,0.3);
    color: var(--text-primary);
    font-weight: 700;
    box-shadow: 0 0 12px rgba(16,185,129,0.05);
}

.custom-dialect-form {
    margin-top: 12px;
    padding: 12px;
    background: var(--input-bg);
    border: 1px solid var(--border-hover);
    border-radius: 12px;
}

.custom-dialect-form label { font-size: 10px; color: var(--text-muted); font-weight: 600; display: block; margin-bottom: 8px; }

.custom-dialect-row { display: flex; gap: 8px; }
.custom-dialect-row input {
    flex: 1;
    padding: 6px 12px;
    background: var(--card-bg-solid);
    border: 1px solid var(--border-hover);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-primary);
    outline: none;
    font-family: var(--font-main);
}
.custom-dialect-row input:focus { border-color: #3b82f6; }
.custom-dialect-row button {
    padding: 6px 12px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font-main);
    transition: background 0.2s;
}
.custom-dialect-row button:hover { background: #1d4ed8; }

.active-dialect-bar {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
}

.active-dialect-bar span:first-child { color: var(--text-dim); }
.dialect-value {
    font-weight: 700;
    color: var(--accent-amber);
    padding: 2px 8px;
    background: rgba(251,191,36,0.05);
    border: 1px solid rgba(251,191,36,0.1);
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 10px;
}

/* Config Panel Toggle */
.card-header-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.card-header-toggle i { color: var(--text-muted); transition: transform 0.2s; font-size: 12px; }
.card-header-toggle i.collapsed { transform: rotate(180deg); }

/* API Section */
.api-section { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.api-section textarea {
    width: 100%;
    height: 80px;
    padding: 10px;
    background: var(--input-bg);
    border: 1px solid var(--border-hover);
    border-radius: 8px;
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--text-primary);
    resize: vertical;
    outline: none;
    margin-top: 8px;
}
.api-section textarea:focus { border-color: #3b82f6; }

.api-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; }

.btn-primary-sm {
    padding: 6px 12px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font-main);
    transition: all 0.2s;
}
.btn-primary-sm:hover { background: #1d4ed8; transform: scale(1.02); }

.btn-danger-sm {
    padding: 4px 8px;
    background: none;
    color: #f87171;
    border: none;
    font-size: 10px;
    cursor: pointer;
    text-decoration: underline;
    font-family: var(--font-main);
}
.btn-danger-sm:hover { color: #fca5a5; }

.auto-rotate-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    margin-top: 12px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: background 0.2s;
}
.auto-rotate-row:hover { background: var(--card-bg-solid); }
.rotate-title { display: block; font-size: 10px; font-weight: 600; color: var(--text-secondary); }
.rotate-sub { display: block; font-size: 8px; color: var(--text-dim); }
.auto-rotate-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: #2563eb; cursor: pointer; }

.keys-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.running-key-label {
    font-size: 9px;
    color: var(--accent-amber);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.keys-list {
    margin-top: 8px;
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid var(--border);
    background: var(--input-bg);
    border-radius: 12px;
    padding: 6px;
}

.empty-keys {
    text-align: center;
    padding: 12px;
    font-size: 10px;
    color: var(--text-dim);
    border: 1px dashed var(--border);
    border-radius: 8px;
}

.key-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    border-radius: 8px;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}
.key-item:hover { background: rgba(255,255,255,0.05); }
.key-item.active { background: rgba(37,99,235,0.1); color: white; border-color: rgba(37,99,235,0.2); }
.key-item .key-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-dim);
}
.key-item.active .key-dot { background: #60a5fa; animation: pulse 1.5s infinite; }
.key-item .key-remove {
    color: #f87171;
    background: none;
    border: none;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 4px;
    transition: background 0.2s;
}
.key-item .key-remove:hover { background: rgba(248,113,113,0.1); }

/* Topic */
.topic-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.char-count { font-size: 10px; font-family: var(--font-mono); color: var(--text-muted); background: var(--input-bg); padding: 2px 8px; border-radius: 4px; border: 1px solid var(--border); }

#topicInput {
    width: 100%;
    height: 80px;
    padding: 12px;
    background: var(--input-bg);
    border: 1px solid var(--border-hover);
    border-radius: 12px;
    font-size: 13px;
    color: var(--text-primary);
    outline: none;
    resize: vertical;
    font-family: var(--font-main);
    line-height: 1.7;
    transition: border-color 0.2s;
}
#topicInput:focus { border-color: #3b82f6; }

/* Marketing Lab */
.marketing-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.marketing-title-group { display: flex; align-items: center; gap: 8px; }
.marketing-title-group h3 { font-size: 12px; font-weight: 700; color: var(--text-primary); text-transform: uppercase; letter-spacing: 0.03em; }
.marketing-title-group p { font-size: 10px; color: var(--text-muted); }

.btn-marketing-mode {
    padding: 6px 10px;
    font-size: 10px;
    font-weight: 600;
    border: 1px solid var(--border-hover);
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font-main);
    transition: all 0.2s;
}
.btn-marketing-mode:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }
.btn-marketing-mode.active { background: rgba(99,102,241,0.1); border-color: rgba(99,102,241,0.3); color: #a5b4fc; pointer-events: none; }

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border-hover);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
    background: var(--input-bg);
}
.upload-area:hover, .upload-area.dragover { border-color: #6366f1; background: rgba(99,102,241,0.03); }
.file-input-hidden { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.upload-content { display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.upload-icon { padding: 12px; background: rgba(99,102,241,0.1); border-radius: 12px; color: #818cf8; font-size: 1.5rem; }
.upload-content span { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.upload-content p { font-size: 10px; color: var(--text-dim); }

/* Media Previews */
.media-previews { margin-top: 16px; }
.media-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 12px; padding: 12px; background: var(--input-bg); border-radius: 12px; border: 1px solid var(--border); }
.media-item { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--border-hover); background: var(--card-bg-solid); }
.media-item img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.media-item-info { position: absolute; bottom: 0; left: 0; right: 0; padding: 4px 8px; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); display: flex; justify-content: space-between; font-size: 9px; color: #e2e8f0; }
.media-item .remove-media { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; background: rgba(220,38,38,0.9); color: white; border: none; border-radius: 6px; cursor: pointer; font-size: 10px; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.media-item .remove-media:hover { background: #dc2626; transform: scale(1.1); }
.media-info { margin-top: 8px; padding: 10px; background: rgba(49,46,129,0.1); border: 1px solid rgba(99,102,241,0.1); border-radius: 8px; }
.media-info p { font-size: 10px; color: #a5b4fc; text-align: center; line-height: 1.6; }

/* Presets Grid */
.presets-grid-section { margin-top: 16px; }

/* Featured Preset Buttons */
.featured-presets { display: flex; flex-direction: column; gap: 10px; margin: 12px 0 16px; }
.featured-preset-btn {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 18px; border-radius: 14px;
    cursor: pointer; transition: all 0.25s;
    font-family: var(--font-main); text-align: right;
    border: 1px solid transparent; position: relative; overflow: hidden;
}
.featured-preset-btn.ugc {
    background: linear-gradient(135deg, rgba(239,68,68,0.1), rgba(239,68,68,0.03));
    border-color: rgba(239,68,68,0.15);
}
.featured-preset-btn.ugc:hover { border-color: rgba(239,68,68,0.35); background: linear-gradient(135deg, rgba(239,68,68,0.15), rgba(239,68,68,0.05)); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(239,68,68,0.1); }
.featured-preset-btn.landing {
    background: linear-gradient(135deg, rgba(234,179,8,0.1), rgba(234,179,8,0.03));
    border-color: rgba(234,179,8,0.15);
}
.featured-preset-btn.landing:hover { border-color: rgba(234,179,8,0.35); background: linear-gradient(135deg, rgba(234,179,8,0.15), rgba(234,179,8,0.05)); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(234,179,8,0.1); }
.featured-icon {
    width: 44px; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; flex-shrink: 0;
}
.featured-preset-btn.ugc .featured-icon { background: rgba(239,68,68,0.15); color: #ef4444; }
.featured-preset-btn.landing .featured-icon { background: rgba(234,179,8,0.15); color: #eab308; }
.featured-text { flex: 1; }
.featured-text strong { display: block; font-size: 12px; font-weight: 700; color: var(--text-primary); margin-bottom: 3px; }
.featured-text span { display: block; font-size: 10px; color: var(--text-muted); line-height: 1.5; }
.featured-arrow { color: var(--text-dim); font-size: 12px; transition: transform 0.2s; }
.featured-preset-btn:hover .featured-arrow { transform: translateX(-4px); }
.presets-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 8px;
}
@media (min-width: 640px) { .presets-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1024px) { .presets-grid { grid-template-columns: 1fr 1fr 1fr; } }

.preset-btn {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: linear-gradient(to left, var(--card-bg-solid), var(--input-bg));
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: right;
    font-family: var(--font-main);
}
.preset-btn:hover { border-color: rgba(99,102,241,0.2); background: rgba(27,33,50,0.8); }
.preset-icon { padding: 8px; border-radius: 8px; flex-shrink: 0; font-size: 1rem; transition: background 0.2s; }
.preset-btn:hover .preset-icon { opacity: 0.9; }
.preset-text { flex: 1; }
.preset-text strong { display: block; font-size: 10px; font-weight: 700; color: var(--text-primary); margin-bottom: 2px; }
.preset-text span { display: block; font-size: 9px; color: var(--text-muted); line-height: 1.4; }

/* Custom Presets Import/Export */
.custom-presets-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.custom-presets-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.btn-preset-action {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: 8px;
    font-size: 11px; font-weight: 600; font-family: var(--font-main);
    cursor: pointer; transition: all 0.2s;
    border: 1px solid var(--border);
    background: linear-gradient(135deg, rgba(16,185,129,0.08), rgba(16,185,129,0.02));
    color: #34d399;
}
.btn-preset-action:hover { border-color: rgba(16,185,129,0.3); background: rgba(16,185,129,0.12); transform: translateY(-1px); }
.btn-preset-action.export {
    background: linear-gradient(135deg, rgba(59,130,246,0.08), rgba(59,130,246,0.02));
    color: #60a5fa;
}
.btn-preset-action.export:hover { border-color: rgba(59,130,246,0.3); background: rgba(59,130,246,0.12); }
.btn-preset-action.import {
    background: linear-gradient(135deg, rgba(251,146,60,0.08), rgba(251,146,60,0.02));
    color: #fb923c;
}
.btn-preset-action.import:hover { border-color: rgba(251,146,60,0.3); background: rgba(251,146,60,0.12); }

.custom-presets-list { margin-top: 14px; }
.custom-presets-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.custom-presets-header span { font-size: 11px; font-weight: 600; color: var(--text-secondary); }
.custom-presets-grid { display: grid; grid-template-columns: 1fr; gap: 6px; }
@media (min-width: 640px) { .custom-presets-grid { grid-template-columns: 1fr 1fr; } }

.custom-preset-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 10px;
    background: linear-gradient(to left, var(--card-bg-solid), var(--input-bg));
    border: 1px solid var(--border);
    transition: all 0.2s;
}
.custom-preset-item:hover { border-color: rgba(16,185,129,0.2); }
.custom-preset-item .preset-name { flex: 1; font-size: 11px; font-weight: 600; color: var(--text-primary); cursor: pointer; }
.custom-preset-item .preset-date { font-size: 9px; color: var(--text-dim); }
.custom-preset-item .preset-actions { display: flex; gap: 4px; }
.custom-preset-item .preset-actions button {
    width: 24px; height: 24px; border-radius: 6px;
    border: 1px solid var(--border); background: transparent;
    color: var(--text-muted); cursor: pointer; font-size: 10px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.custom-preset-item .preset-actions button:hover { background: rgba(239,68,68,0.1); color: #ef4444; border-color: rgba(239,68,68,0.2); }
.custom-preset-item .preset-actions button.load-btn:hover { background: rgba(16,185,129,0.1); color: #34d399; border-color: rgba(16,185,129,0.2); }

/* Arena */
.arena-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.arena-title-group { display: flex; align-items: center; gap: 8px; }
.arena-title-group h2 { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-primary); }
.btn-show-panel { font-size: 9px; padding: 2px 8px; background: rgba(59,130,246,0.1); color: #93c5fd; border: 1px solid rgba(59,130,246,0.2); border-radius: 4px; cursor: pointer; font-family: var(--font-main); transition: all 0.2s; display: flex; align-items: center; gap: 4px; }
.btn-show-panel:hover { background: rgba(59,130,246,0.2); }

.status-badge { display: flex; align-items: center; gap: 6px; font-size: 10px; font-weight: 600; color: var(--text-secondary); padding: 4px 8px; background: var(--input-bg); border: 1px solid var(--border); border-radius: 4px; text-transform: uppercase; letter-spacing: 0.03em; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-dot.paused { background: var(--accent-amber); animation: pulse 2s infinite; }
.status-dot.active { background: var(--accent-emerald); animation: ping 1.5s infinite; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; margin-bottom: 16px; }
.stat-card { background: var(--input-bg); padding: 14px; border-radius: 12px; border: 1px solid var(--border); text-align: center; box-shadow: 0 4px 8px rgba(0,0,0,0.05); }
.stat-card span:first-child { display: block; font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; margin-bottom: 4px; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--accent-blue); font-family: var(--font-mono); }
.stat-speaker { font-size: 12px; font-weight: 600; color: var(--text-secondary); }

/* Speed Panel */
.speed-panel { background: rgba(22,27,36,0.4); border: 1px solid var(--border); padding: 14px; border-radius: 12px; margin-bottom: 16px; }
.speed-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 10px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.speed-value { font-family: var(--font-mono); color: var(--accent-blue); font-weight: 700; padding: 2px 8px; background: rgba(37,99,235,0.08); border: 1px solid rgba(37,99,235,0.15); border-radius: 4px; }
#speedSlider { width: 100%; accent-color: #2563eb; height: 4px; background: var(--input-bg); border-radius: 8px; cursor: pointer; }

/* Control Buttons */
.controls-row { display: flex; flex-wrap: wrap; gap: 12px; padding-top: 16px; border-top: 1px solid var(--border); }
.controls-row-sub { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: center; }

.btn-primary {
    flex: 1;
    min-width: 140px;
    padding: 10px 16px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font-main);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(37,99,235,0.2);
}
.btn-primary:hover { background: #1d4ed8; }
.btn-primary.stop { background: #d97706; box-shadow: 0 4px 12px rgba(217,119,6,0.2); }
.btn-primary.stop:hover { background: #b45309; }

.btn-secondary {
    flex: 1;
    min-width: 140px;
    padding: 10px 16px;
    background: var(--card-bg-solid);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font-main);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}
.btn-secondary:hover { background: rgba(31,38,51,1); }
.btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-ghost {
    padding: 6px 12px;
    background: var(--card-bg);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
    font-family: var(--font-main);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--border-hover); }

.btn-export-html {
    padding: 6px 12px;
    background: rgba(49,46,129,0.2);
    color: #a5b4fc;
    border: 1px solid rgba(99,102,241,0.2);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font-main);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}
.btn-export-html:hover { background: rgba(49,46,129,0.3); border-color: rgba(99,102,241,0.4); }

.export-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-right: auto; }

/* Agents Config */
.agents-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.agents-title-group { display: flex; align-items: center; gap: 8px; }
.agents-title-group h3 { font-size: 14px; font-weight: 700; color: var(--text-primary); text-transform: uppercase; letter-spacing: 0.03em; }
.agents-badge { font-size: 10px; color: #a5b4fc; padding: 2px 8px; background: rgba(99,102,241,0.1); border: 1px solid rgba(99,102,241,0.2); border-radius: 6px; font-weight: 600; }

.agents-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 768px) { .agents-grid { grid-template-columns: 1fr 1fr; } }

.agent-card {
    padding: 16px;
    background: var(--input-bg);
    border-radius: 12px;
    border: 1px solid rgba(59,130,246,0.1);
    transition: border-color 0.2s;
}
.agent-card.agent-a:hover { border-color: rgba(59,130,246,0.2); }
.agent-card.agent-b { border-color: rgba(139,92,246,0.1); }
.agent-card.agent-b:hover { border-color: rgba(139,92,246,0.2); }

.agent-card-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.agent-card-header h4 { font-size: 12px; font-weight: 700; color: var(--accent-blue); display: flex; align-items: center; gap: 6px; }
.agent-card.agent-b .agent-card-header h4 { color: var(--accent-violet); }
.model-badge { font-size: 9px; background: rgba(30,58,138,0.3); color: #93c5fd; border: 1px solid rgba(30,64,175,0.3); padding: 2px 8px; border-radius: 4px; text-transform: uppercase; font-weight: 600; font-family: var(--font-mono); }
.model-badge.model-b { background: rgba(76,29,149,0.3); color: #c4b5fd; border-color: rgba(91,33,182,0.3); }

.agent-fields { display: flex; flex-direction: column; gap: 10px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 640px) { .field-row { grid-template-columns: 1fr; } }
.field label { display: block; font-size: 10px; color: var(--text-dim); font-weight: 600; margin-bottom: 4px; }
.field input, .field select {
    width: 100%;
    padding: 8px 10px;
    background: var(--card-bg-solid);
    border: 1px solid var(--border-hover);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-primary);
    outline: none;
    font-family: var(--font-main);
    transition: border-color 0.2s;
}
.field input:focus, .field select:focus { border-color: #3b82f6; }
.field textarea {
    width: 100%;
    height: 72px;
    padding: 8px 10px;
    background: var(--card-bg-solid);
    border: 1px solid var(--border-hover);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-primary);
    outline: none;
    resize: none;
    font-family: var(--font-main);
    line-height: 1.6;
    transition: border-color 0.2s;
}
.field textarea:focus { border-color: #3b82f6; }

/* Error Banner */
.error-banner {
    background: rgba(127,29,29,0.2);
    border: 1px solid rgba(239,68,68,0.2);
    color: #fca5a5;
    padding: 16px;
    border-radius: 12px;
    font-size: 12px;
}
.error-title { font-weight: 700; color: #f87171; display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.error-banner p { line-height: 1.6; white-space: pre-line; }

/* Debate Feed */
.debate-feed-card { min-height: 460px; max-height: 800px; display: flex; flex-direction: column; }
.feed-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--border); margin-bottom: 16px; font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.feed-badge { font-size: 9px; background: var(--input-bg); color: var(--text-muted); border: 1px solid var(--border); padding: 2px 8px; border-radius: 4px; font-family: var(--font-mono); text-transform: uppercase; }

.feed-scroll { flex: 1; overflow-y: auto; padding-left: 4px; }
.feed-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 4rem 2rem; color: var(--text-dim); gap: 14px; }
.feed-empty p { font-size: 12px; max-width: 360px; line-height: 1.7; }

/* Messages */
.message-bubble {
    max-width: 88%;
    margin-bottom: 16px;
    animation: fadeInUp 0.3s ease;
}

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

.message-bubble.agent-a { margin-left: auto; margin-right: 0; }
.message-bubble.agent-b { margin-right: auto; margin-left: 0; }

.bubble-inner {
    padding: 16px;
    border-radius: 16px;
    border: 1px solid;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.message-bubble.agent-a .bubble-inner {
    background: rgba(37,99,235,0.08);
    border-color: rgba(59,130,246,0.2);
    border-top-right-radius: 4px;
}
.message-bubble.agent-b .bubble-inner {
    background: rgba(139,92,246,0.08);
    border-color: rgba(139,92,246,0.2);
    border-top-left-radius: 4px;
}

.bubble-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 12px; }
.bubble-author { font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.message-bubble.agent-a .bubble-author { color: var(--accent-blue); }
.message-bubble.agent-b .bubble-author { color: var(--accent-violet); }
.bubble-author .author-dot { width: 6px; height: 6px; border-radius: 50%; }
.message-bubble.agent-a .author-dot { background: var(--accent-blue); }
.message-bubble.agent-b .author-dot { background: var(--accent-violet); }
.bubble-agent-label { font-size: 10px; font-weight: 400; color: var(--text-dim); }
.bubble-time { font-size: 9px; color: var(--text-dim); font-family: var(--font-mono); }

.bubble-text { font-size: 13px; line-height: 1.8; white-space: pre-line; color: var(--text-secondary); }
.bubble-index { font-size: 10px; font-family: var(--font-mono); color: var(--text-dim); padding: 4px 8px; }
.message-bubble.agent-a .bubble-index { text-align: left; }
.message-bubble.agent-b .bubble-index { text-align: right; }

/* Loading Indicator */
.loading-indicator {
    max-width: 88%;
    padding: 16px;
    border-radius: 16px;
    border: 1px solid rgba(59,130,246,0.1);
    background: rgba(30,58,138,0.1);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    animation: fadeInUp 0.3s ease;
}
.loading-indicator.agent-b { margin-left: 0; border-color: rgba(139,92,246,0.1); background: rgba(76,29,149,0.1); }
.loading-indicator.agent-a { margin-left: auto; }

.thinking-dots { display: flex; gap: 4px; align-items: center; }
.thinking-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: bounce 1s infinite;
}
.thinking-dots span:nth-child(1) { background: #60a5fa; animation-delay: 0ms; }
.thinking-dots span:nth-child(2) { background: #a78bfa; animation-delay: 150ms; }
.thinking-dots span:nth-child(3) { background: #60a5fa; animation-delay: 300ms; }

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

#loadingText { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.running-key-indicator { font-size: 9px; background: rgba(251,191,36,0.1); border: 1px solid rgba(251,191,36,0.2); color: var(--accent-amber); padding: 2px 8px; border-radius: 6px; font-weight: 700; font-family: var(--font-mono); animation: pulse 2s infinite; }

/* Participation */
.participation-title { font-size: 10px; font-weight: 700; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px; }
.participation-labels { display: flex; justify-content: space-between; font-size: 12px; font-family: var(--font-mono); margin-bottom: 8px; }
.label-a { color: var(--accent-blue); font-weight: 600; }
.label-b { color: var(--accent-violet); font-weight: 600; }
.participation-bar { width: 100%; height: 10px; background: var(--input-bg); border-radius: 999px; overflow: hidden; display: flex; border: 1px solid var(--border); }
.bar-a { background: linear-gradient(to left, #2563eb, #06b6d4); transition: width 0.5s; }
.bar-b { background: linear-gradient(to left, #7c3aed, #a855f7); transition: width 0.5s; }
.participation-percents { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); margin-top: 4px; }

/* Footer */
.hamiz-footer {
    margin-top: 3rem;
    max-width: 1280px;
    margin-left: auto;
    margin-right: auto;
    padding: 2rem 1rem;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
}
.footer-logo { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 1.25rem; font-weight: 700; color: var(--accent-emerald); text-decoration: none; margin-bottom: 12px; transition: color 0.2s; }
.footer-logo:hover { color: #10b981; }
.footer-logo img { height: 40px; width: auto; transition: transform 0.2s; }
.footer-logo img:hover { transform: scale(1.05); }
.hamiz-footer > p { font-size: 12px; max-width: 600px; margin: 0 auto 12px; line-height: 1.7; font-weight: 500; }
.footer-links { display: flex; justify-content: center; gap: 16px; font-size: 11px; font-weight: 600; margin-bottom: 16px; }
.footer-links a { color: var(--text-muted); text-decoration: none; transition: color 0.2s; }
.footer-links a:hover { color: var(--accent-emerald); text-decoration: underline; }
.footer-links span { opacity: 0.35; }
.footer-copy { font-size: 10px; opacity: 0.5; font-family: var(--font-mono); }

/* Responsive */
@media (max-width: 768px) {
    :root { --hamiz-header-height: 60px; }
    .hamiz-header-title { font-size: 0.9rem; }
    .hamiz-side-menu { width: 85%; max-width: 300px; }
    .stats-grid { grid-template-columns: 1fr; }
    .stat-card.wide { grid-column: auto; }
    .header-right .header-btn span { display: none; }
    .controls-row { flex-direction: column; }
    .btn-primary, .btn-secondary { min-width: auto; }
}
