/* Oletusvärit — ylikirjoitetaan teemalla */
:root {
    --bg: #0d1117;
    --panel: #161b22;
    --text: #c9d1d9;
    --accent: #58a6ff;
    --green: #3fb950;
    --yellow: #d29922;
    --red: #f85149;
    --purple: #a371f7;
    --border: #30363d;
    --hero-accent: #ff6b00;
    --hero-glow: rgba(255, 107, 0, 0.15);
}

/* Gecko — lämmin kulta/oranssi (kipina.tech) */
[data-theme="gecko"] {
    --bg: #0a0500;
    --panel: #1f1000;
    --text: #fff5e6;
    --accent: #ff7b00;
    --green: #3fb950;
    --yellow: #ffae00;
    --red: #f85149;
    --purple: #ff9d4d;
    --border: rgba(255, 174, 0, 0.2);
    --hero-accent: #ff7b00;
    --hero-glow: rgba(255, 123, 0, 0.15);
}

/* Forge — kyber-sininen/syaani (kipina.tech) */
[data-theme="forge"] {
    --bg: #060b11;
    --panel: #121e2d;
    --text: #e0f2fe;
    --accent: #00e5ff;
    --green: #3fb950;
    --yellow: #ff5e3a;
    --red: #f85149;
    --purple: #7dd3fc;
    --border: rgba(0, 229, 255, 0.15);
    --hero-accent: #00e5ff;
    --hero-glow: rgba(0, 229, 255, 0.15);
}

/* Serpent — neon-turkoosi/teal (kipina.tech) */
[data-theme="serpent"] {
    --bg: #000808;
    --panel: #001e1e;
    --text: #ccffff;
    --accent: #00ffff;
    --green: #00ffaa;
    --yellow: #d29922;
    --red: #f85149;
    --purple: #66cccc;
    --border: rgba(0, 255, 255, 0.15);
    --hero-accent: #00ffff;
    --hero-glow: rgba(0, 255, 255, 0.15);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.container { 
    max-width: 1600px; 
    margin: 0 auto; 
    padding: 20px 40px; 
}

#app.container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#app:not(.active) { display: none; }
#landing.hidden { display: none; }

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; flex-shrink: 0; }
.tab {
    padding: 10px 20px; border-radius: 6px 6px 0 0; cursor: pointer;
    border: 1px solid var(--border); border-bottom: none;
    background: var(--bg); color: #8b949e; font-size: 15px;
}
.tab.active { background: var(--panel); color: var(--accent); border-color: var(--border); }

/* Panels */
.panel { display: none; }
.panel.active { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; }

/* Status bar */
.status-bar {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px; background: var(--bg);
    border: 1px solid var(--border); border-radius: 6px 6px 0 0;
    font-family: 'Courier New', monospace; font-size: 14px;
}
.status-dot {
    width: 8px; height: 8px; border-radius: 50%; display: inline-block;
}
.status-group { display: flex; align-items: center; gap: 6px; }
.status-separator { color: var(--border); }

/* Terminal */
.terminal {
    background: #010409; border: 1px solid var(--border); border-top: none;
    font-family: 'Courier New', monospace; font-size: 16px;
    flex: 1; min-height: 0; max-height: none; overflow-y: auto;
    padding: 12px 16px;
}
.terminal-line { padding: 1px 0; white-space: pre-wrap; word-break: break-word; }
.terminal-prompt { color: var(--yellow); margin-right: 8px; }
.terminal-input-row {
    display: flex; align-items: center; position: relative;
    background: #0d1117; border: 1px solid var(--accent); border-top: none;
    border-radius: 0 0 6px 6px; padding: 10px 14px;
    font-family: 'Courier New', monospace; font-size: 15px;
    box-shadow: 0 2px 8px rgba(88,166,255,0.1);
}
.terminal-input {
    flex: 1; background: transparent; border: none; outline: none;
    color: var(--green); font-family: inherit; font-size: 16px;
}
.terminal-dropdown {
    display: none; position: absolute; bottom: 100%; left: 30px;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 6px; max-height: 200px; overflow-y: auto;
    font-size: 13px; min-width: 200px; z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.dd-item {
    padding: 6px 12px; cursor: pointer; color: var(--text);
    white-space: nowrap; border-bottom: 1px solid #21262d;
}
.dd-item:hover, .dd-item.active { background: var(--border); color: var(--accent); }

#editor-file-list .dd-item {
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.4;
}

/* Pipeline progress */
.pipeline-bar {
    display: none; padding: 8px 14px; background: var(--bg);
    border: 1px solid var(--border); border-top: none;
    font-family: 'Courier New', monospace; font-size: 12px;
    overflow-x: auto; white-space: nowrap;
}

/* Project card */
.project-card {
    margin: 8px 0; border: 1px solid var(--border);
    border-radius: 6px; background: var(--panel); overflow: hidden;
}
.project-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px; background: var(--bg); border-bottom: 1px solid var(--border);
}
.project-tabs { display: flex; gap: 2px; padding: 6px 8px 0; background: var(--bg); }
.project-tab {
    padding: 4px 10px; cursor: pointer; border-radius: 4px 4px 0 0;
    font-size: 12px; color: #8b949e;
    white-space: nowrap; flex-shrink: 0;
}
.project-tab.active { background: var(--panel); color: var(--accent); border: 1px solid var(--border); border-bottom: none; }

/* Buttons */
.btn {
    padding: 2px 10px; border-radius: 4px;
    border: 1px solid var(--border); background: var(--panel);
    font-size: 12px; font-family: inherit; cursor: pointer;
}
.btn-accent { color: var(--accent); }
.btn-green { color: var(--green); border-color: var(--green); }
.btn-red { color: var(--red); border-color: var(--red); }
.btn-muted { color: #8b949e; background: none; }

/* Code display */
.code-block {
    font-family: 'Courier New', monospace; background: #010409;
    border: 1px solid var(--border); border-radius: 6px;
    padding: 14px; font-size: 13px; line-height: 1.6;
    white-space: pre-wrap; overflow-x: auto; max-height: 400px; overflow-y: auto;
}
.code-block .hljs { background: transparent; padding: 0; }

/* Agent avatars */
.agent-avatar {
    background: linear-gradient(145deg, rgba(33,38,45,0.4) 0%, rgba(13,17,23,0.8) 100%);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(240,246,252,0.1);
    border-radius: 14px;
    padding: 8px 8px 6px;
    text-align: center;
    width: 90px;
    opacity: 0.8;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}
.agent-avatar:hover {
    opacity: 0.85;
    transform: translateY(-2px) scale(1.02);
    border-color: rgba(240,246,252,0.3);
    box-shadow: 0 8px 14px rgba(0,0,0,0.4);
}
.agent-avatar img {
    width: 64px; height: 64px; border-radius: 14px;
    margin-bottom: 4px; border: 2px solid rgba(240,246,252,0.1);
    transition: all 0.4s ease; object-fit: cover;
}
.agent-avatar .avatar-name {
    font-size: 11px; color: #8b949e; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.agent-avatar.active {
    opacity: 1;
    transform: translateY(-8px) scale(1.05);
    border-color: var(--accent);
    background: linear-gradient(145deg, rgba(88,166,255,0.15) 0%, rgba(13,17,23,0.9) 100%);
    box-shadow: 0 16px 24px rgba(0,0,0,0.5), 0 0 20px rgba(88,166,255,0.3);
    z-index: 2;
}
.agent-avatar.active img {
    border-color: var(--accent);
    box-shadow: 0 0 25px rgba(88,166,255,0.8);
    animation: agentBlink 1.5s infinite;
}

@keyframes agentBlink {
    0% { opacity: 0.8; box-shadow: 0 0 15px rgba(88,166,255,0.5); }
    50% { opacity: 1.0; box-shadow: 0 0 35px rgba(88,166,255,1.0); }
    100% { opacity: 0.8; box-shadow: 0 0 15px rgba(88,166,255,0.5); }
}

/* Settings */
.settings-section {
    margin-bottom: 24px; padding: 16px; background: var(--panel);
    border: 1px solid var(--border); border-radius: 6px;
}
.settings-title { color: #e6edf3; font-size: 15px; margin-bottom: 4px; }
.settings-desc { color: #8b949e; font-size: 13px; margin-bottom: 12px; }
.settings-label { color: var(--text); font-size: 13px; display: block; margin-bottom: 4px; }
.settings-val { color: var(--accent); font-weight: 600; float: right; }
.settings-hint { color: #8b949e; font-size: 11px; margin-top: 2px; }
.settings-textarea {
    width: 100%; background: var(--bg); color: var(--text);
    border: 1px solid var(--border); border-radius: 4px;
    padding: 8px; font-size: 13px; font-family: 'Courier New', monospace;
    resize: vertical;
}
.settings-select {
    width: 100%; background: var(--bg); color: var(--text);
    border: 1px solid var(--border); border-radius: 4px;
    padding: 8px; font-size: 13px;
}
.settings-slider {
    width: 100%; accent-color: var(--accent);
}
.settings-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}

/* ===== LANDING PAGE ===== */

#landing {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    min-height: 100vh;
    position: relative;
    overflow: hidden;
}

.bg-mesh {
    position: fixed; inset: 0; z-index: -1;
    background:
        radial-gradient(ellipse 80% 60% at 20% 40%, var(--hero-glow) 0%, transparent 70%),
        radial-gradient(ellipse 60% 50% at 80% 20%, rgba(88,166,255,0.06) 0%, transparent 70%),
        var(--bg);
}

.landing-nav {
    padding: 20px 40px;
    display: flex; align-items: center; justify-content: space-between;
}
.landing-logo { text-decoration: none; font-size: 18px; font-weight: 700; }
.logo-accent { color: var(--hero-accent); }
.logo-sub { color: #8b949e; font-weight: 400; }
.theme-cycle-btn {
    background: none; border: 1px solid var(--border); border-radius: 8px;
    width: 38px; height: 38px; font-size: 20px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: border-color 0.2s, transform 0.15s;
}
.theme-cycle-btn:hover {
    border-color: var(--hero-accent); transform: scale(1.1);
}

/* Hero */
.hero {
    padding: 60px 40px 40px;
}
.hero-container {
    max-width: 1200px; margin: 0 auto;
    display: grid; grid-template-columns: 1fr 400px; gap: 60px; align-items: center;
}
.hero-title {
    font-size: clamp(2rem, 4vw, 3rem); font-weight: 800;
    line-height: 1.15; color: #e6edf3; margin-bottom: 16px;
}
.hero-divider {
    width: 60px; height: 3px; background: var(--hero-accent);
    border-radius: 2px; margin-bottom: 20px;
}
.hero-desc {
    font-size: 1.05rem; color: #8b949e; line-height: 1.7; margin-bottom: 12px;
}
.hero-notice {
    font-size: 0.9rem; color: #6e7681; line-height: 1.6;
    border-left: 2px solid var(--border); padding-left: 12px; margin-bottom: 28px;
}

/* Hero input */
.hero-input-group {
    display: flex; gap: 8px; margin-bottom: 20px;
}
.hero-input {
    flex: 1; padding: 14px 18px; font-size: 16px;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    background: var(--panel); color: var(--text);
    border: 1px solid var(--border); border-radius: 8px;
    outline: none; transition: border-color 0.2s;
}
.hero-input:focus {
    border-color: var(--hero-accent); box-shadow: 0 0 0 3px var(--hero-glow);
}
.hero-input::placeholder { color: #484f58; }
.hero-input.shake {
    animation: shake 0.4s ease;
    border-color: #f85149;
    box-shadow: 0 0 0 3px rgba(248,81,73,0.2);
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}
.hero-btn {
    padding: 14px 28px; font-size: 16px; font-weight: 600;
    font-family: 'Inter', sans-serif;
    background: var(--hero-accent); color: #fff; border: none; border-radius: 8px;
    cursor: pointer; transition: background 0.2s, transform 0.1s;
    white-space: nowrap;
}
.hero-btn:hover { filter: brightness(0.85); transform: translateY(-1px); }
.hero-btn:active { transform: translateY(0); }

/* Example buttons */
.hero-examples { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.hero-examples-label { color: #6e7681; font-size: 14px; margin-right: 4px; }
.example-btn {
    padding: 8px 16px; font-size: 13px; font-family: 'Inter', sans-serif;
    background: transparent; color: var(--accent);
    border: 1px solid var(--border); border-radius: 6px;
    cursor: pointer; transition: all 0.2s;
}
.example-btn:hover {
    border-color: var(--accent); background: rgba(88,166,255,0.08);
}

/* Hero orb */
.hero-orb-wrapper {
    display: flex; justify-content: center; align-items: center;
}
.hero-orb {
    width: 340px; height: 340px; border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, var(--hero-glow) 0%, transparent 70%);
    display: flex; align-items: center; justify-content: center;
    animation: orb-float 6s ease-in-out infinite;
}
.hero-orb-img {
    width: 100%; height: 100%; object-fit: contain;
    filter: drop-shadow(0 0 40px var(--hero-glow));
    transition: opacity 0.2s ease;
}
@keyframes orb-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

/* How section */
.how-section {
    padding: 60px 40px;
    background: rgba(22,27,34,0.6);
    border-top: 1px solid var(--border);
}
.how-container { max-width: 900px; margin: 0 auto; }
.how-title {
    text-align: center; font-size: 1.5rem; font-weight: 700;
    color: #e6edf3; margin-bottom: 40px;
}
.how-steps {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px;
}
.how-step {
    text-align: center; padding: 24px;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 12px; transition: border-color 0.3s;
}
.how-step:hover { border-color: var(--hero-accent); }
.how-step-num {
    width: 40px; height: 40px; line-height: 40px;
    border-radius: 50%; background: var(--hero-glow);
    color: var(--hero-accent); font-weight: 700; font-size: 18px;
    margin: 0 auto 14px;
}
.how-step h3 { color: #e6edf3; font-size: 1rem; margin-bottom: 8px; }
.how-step p { color: #8b949e; font-size: 0.9rem; line-height: 1.5; }

/* Landing footer */
.landing-footer {
    text-align: center; padding: 32px 40px;
    color: #484f58; font-size: 13px;
    border-top: 1px solid var(--border);
}
.landing-footer a { color: #8b949e; }

/* Responsive */
@media (max-width: 860px) {
    .hero-container { grid-template-columns: 1fr; gap: 32px; }
    .hero-orb-wrapper { order: -1; }
    .hero-orb { width: 220px; height: 220px; }
    .how-steps { grid-template-columns: 1fr; }
    .hero-input-group { flex-direction: column; }
}

/* ===== OPPIMISPOLKU ===== */
.learn-step {
    margin: 12px 0; border: 1px solid var(--border);
    border-radius: 8px; background: var(--panel); overflow: hidden;
}
.learn-step-header {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; cursor: pointer;
    transition: background 0.15s;
}
.learn-step-header:hover { background: rgba(88,166,255,0.04); }
.learn-step-num {
    width: 28px; height: 28px; line-height: 28px; text-align: center;
    border-radius: 50%; background: var(--hero-glow);
    color: var(--hero-accent); font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.learn-step-agent {
    font-weight: 600; color: #e6edf3; font-size: 14px;
}
.learn-step-label {
    color: #8b949e; font-size: 13px; margin-left: auto;
}
.learn-step-body {
    display: none; padding: 0 16px 16px;
    border-top: 1px solid var(--border);
}
.learn-step-body.open { display: block; }
.learn-section-title {
    color: var(--accent); font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
    margin: 14px 0 6px;
}
.learn-code {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 12px; line-height: 1.6;
    background: #010409; border: 1px solid var(--border);
    border-radius: 6px; padding: 12px; overflow-x: auto;
    max-height: 300px; overflow-y: auto; white-space: pre-wrap;
}

/* Animations */
@keyframes blink { 0%,100% { opacity:1 } 50% { opacity:0 } }
@keyframes spin { to { transform: rotate(360deg) } }
