:root {
    --bg: #0a0a0f;
    --surface: #111118;
    --text: #e2e8f0;
    --text-muted: #777777;
    --scrollbar: #190a35;
    --accent: #7c3aed;
    --accent-glow: rgba(99, 102, 241, 0.18);
    --border: #1e293b;
    --glow: 0 0 40px rgba(99, 102, 241, 0.12);
    --card-bg: #111118;
}

[data-theme="light"] {
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --accent: #4f46e5;
    --accent-glow: rgba(79, 70, 229, 0.15);
    --border: #e2e8f0;
    --card-bg: #f1f5f9;
}

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

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 1rem;
    line-height: 1.5;
}

.header {
    padding: 2rem 1rem;
    text-align: center;
    top: 0;
    z-index: 1000;
}

h1 {
    font-size: clamp(2rem, 7vw, 3.5rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    margin: 0;
    background: linear-gradient(90deg, #c084fc, #6366f1, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.subtitle {
    font-size: 1.18rem;
    color: var(--text-muted);
    max-width: 540px;
    margin: 0 auto;
}

.form-container {
    width: 100%;
    max-width: 720px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1.2rem;
    padding: 2.5rem 2rem;
    box-shadow: var(--glow);
    transition: all 0.35s ease;
    margin-bottom: 2rem;
}

.form-container:focus-within {
    box-shadow: 0 0 60px var(--accent-glow);
    border-color: var(--accent);
}

label {
    display: block;
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 1rem;
    color: var(--text);
}

textarea {
    width: 100%;
    min-height: 140px;
    padding: 1.1rem 1.3rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.8rem;
    color: var(--text);
    font-size: 1.05rem;
    line-height: 1.6;
    resize: vertical;
    transition: all 0.2s ease;
    overflow-y: hidden;
}

textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.controls {
    margin-top: 1.6rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
}

button {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.95rem 2.2rem;
    font-size: 1.05rem;
    font-weight: 600;
    border-radius: 0.8rem;
    cursor: pointer;
    transition: all 0.25s ease;
}

.delete-agent-btn {
    margin-top: 1rem;
    font-size: .75rem;
    padding: 0.25rem .5rem;
    background: #ef4444;
    font-weight: normal;
}

button:hover {
    background: #9f7aea;
    transform: translateY(-1px);
    box-shadow: 0 10px 25px rgba(79, 70, 229, 0.3);
}

.delete-agent-btn:hover {
    background: #ef6161;
    transform: translateY(-1px);
    box-shadow: 0 10px 25px rgba(79, 70, 229, 0.3);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.status {
    font-size: 0.95rem;
    color: var(--text-muted);
}

.loading {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.25);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── My Agents section ── */
.agents-section {
    display: none;
    width: 100%;
    max-width: 720px;
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1.2rem;
    box-shadow: var(--glow);
}

.agents-section h3 {
    color: var(--accent);
    margin-bottom: 1.2rem;
    font-size: 1.4rem;
}

.agents-section:empty,
.agents-section:has(ul:empty) {
    display: none;
}

.agent-list {
    list-style: none;
}

.agent-item {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.2rem;
    margin-bottom: 1rem;
    transition: all 0.2s ease;
    position: relative;
}

.agent-item:hover {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.15);
}

.agent-item strong {
    color: #60a5fa;
    display: block;
    font-size: 1.1rem;
    margin-bottom: 0.4rem;
}

.agent-item .idea-preview {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 0.4rem;
    display: block;
}

.agent-item .date-launched {
    color: var(--text-muted);
    font-size: 0.85rem;
    position: absolute;
    bottom: 1.2rem;
    right: 1.2rem;
}

.agent-link {
    position: absolute;
    top: 1.2rem;
    right: 1.2rem;
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
}

.agent-link:hover {
    font-weight: bolder;
}

.status-check {
    display: block;
    margin-top: 0.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

textarea:focus::placeholder,
textarea:not(:placeholder-shown)::placeholder {
    opacity: 0;
}

@media (max-width: 480px) {
    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    button {
        width: 100%;
    }

    .agent-item .date-launched,
    .agent-link {
        position: static;
        display: block;
        margin-top: 0.5rem;
    }
}

/* ── Fixed top-right wallet corner ────────────────────────────────────── */
.wallet-corner {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1100;
    /* above header */
}

.wallet-icon-btn {
    background: rgba(153, 69, 255, 0.12);
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.22s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    position: relative;
    padding: 0;
}

.wallet-icon-btn:hover {
    background: rgba(153, 69, 255, 0.22);
    transform: scale(1.08);
}

.wallet-icon-btn.connected {
    background: rgba(16, 185, 129, 0.18);
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.35);
}

.wallet-icon-btn.connected::after {
    content: '';
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: 12px;
    height: 12px;
    background: #10b981;
    border-radius: 50%;
    border: 2px solid #111118;
}

.wallet-icon {
    width: 32px;
    height: 32px;
    color: #9945FF;
}

/* Make sure the icon inherits color properly in all states */
.wallet-icon path,
.wallet-icon rect {
    stroke: currentColor;
}

/* ── Mobile adjustments ────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .wallet-corner {
        top: 0.8rem;
        right: 0.8rem;
    }

    .wallet-icon-btn {
        width: 44px;
        height: 44px;
    }

    .wallet-icon {
        width: 28px;
        height: 28px;
    }

    .wallet-icon-btn.connected::after {
        width: 10px;
        height: 10px;
        bottom: 4px;
        right: 4px;
    }
}

/* ── Touch feedback ────────────────────────────────────────────────────── */
.wallet-icon-btn:active {
    transform: scale(0.92);
}

/* ── Custom Scrollbar Styling ──────────────────────────────────────────── */

/* Firefox + modern standard browsers */
:root {
    scrollbar-width: thin;
    /* thin | auto | none */
    scrollbar-color: var(--text-muted) var(--surface);
    /* thumb color first, then track color */
}

/* For light theme override if needed */
[data-theme="light"] {
    scrollbar-color: #94a3b8 #e2e8f0;
    /* or keep using variables: var(--text-muted) var(--surface) works fine too */
}

/* WebKit browsers (Chrome, Edge, Safari, etc.) */
::-webkit-scrollbar {
    width: 10px;
    /* vertical scrollbar width */
    height: 10px;
    /* horizontal scrollbar height */
}

::-webkit-scrollbar-track {
    background: var(--surface);
    border-radius: 10px;
    /* optional: subtle border or shadow */
    /* border: 1px solid var(--border); */
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 10px;
    border: 3px solid var(--surface);
    /* creates nice "padded" look */
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
    /* or a lighter/darker variant: color-mix(in srgb, var(--accent) 70%, white) */
}

::-webkit-scrollbar-corner {
    background: var(--surface);
}

/* Optional: make scrollbar slightly glow on hover/active (WebKit only) */
::-webkit-scrollbar-thumb:active {
    background: color-mix(in srgb, var(--accent) 90%, white);
}

/* Optional: hide scrollbar completely when not needed (but still scrollable) */
/* html { scrollbar-width: none; } */
/* ::-webkit-scrollbar { display: none; } */