:root {
    --bg-primary: #0d0e15;
    --bg-secondary: #161824;
    --accent-glow: #ff477e;
    --accent-subtle: #ff7096;
    --text-main: #f8f9fa;
    --text-muted: #a0a5c1;
    --border-color: #2a2d44;
    --ok: #2ec4b6;
    --warn: #f4a261;
    --bad: #e63946;
}

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

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-x: hidden;
}

.background-glow {
    position: fixed;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(255, 47, 126, 0.08) 0%, rgba(0, 0, 0, 0) 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 0;
    pointer-events: none;
}

.container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 780px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), 0 0 50px rgba(255, 47, 126, 0.05);
    text-align: center;
}

h1.title {
    font-family: 'Lobster', cursive;
    font-size: 4rem;
    color: var(--accent-glow);
    margin-bottom: 10px;
    letter-spacing: 1px;
    text-shadow: 0 0 20px rgba(255, 47, 126, 0.4);
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 30px;
    font-weight: 300;
}

.config-box {
    background-color: rgba(13, 14, 21, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 22px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
}

.config-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.config-row label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    min-width: 110px;
}

.config-row input,
.config-row select {
    flex: 1;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 9px 12px;
    border-radius: 6px;
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
    min-width: 0;
}

.config-row input {
    font-family: monospace;
}

.config-row input:focus,
.config-row select:focus {
    border-color: var(--accent-glow);
}

.selector-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-bottom: 26px;
}

.selector-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.group-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    text-align: left;
}

.card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    height: 100%;
}

.engine-card,
.transport-card {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 12px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    color: var(--text-main);
    font-family: inherit;
    text-align: center;
}

.engine-card:hover,
.transport-card:hover {
    border-color: rgba(255, 47, 126, 0.5);
    transform: translateY(-2px);
}

.engine-card.active,
.transport-card.active {
    background-color: rgba(255, 47, 126, 0.1);
    border-color: var(--accent-glow);
    box-shadow: 0 0 15px rgba(255, 47, 126, 0.2);
}

.engine-card h3,
.transport-card h3 {
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.engine-card p,
.transport-card p {
    font-size: 0.66rem;
    color: var(--text-muted);
    line-height: 1.35;
}

.search-bar {
    display: flex;
    background-color: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 50px;
    padding: 6px 6px 6px 20px;
    align-items: center;
    transition: all 0.3s;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.search-bar:focus-within {
    border-color: var(--accent-glow);
    box-shadow: 0 0 20px rgba(255, 47, 126, 0.15), inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.search-bar input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-main);
    font-size: 1.05rem;
    font-family: inherit;
    padding-right: 15px;
    min-width: 0;
}

.search-bar input::placeholder {
    color: var(--text-muted);
}

.search-bar button {
    background-color: var(--accent-glow);
    color: white;
    border: none;
    outline: none;
    padding: 12px 30px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    white-space: nowrap;
}

.search-bar button:hover {
    background-color: var(--accent-subtle);
}

.search-bar button:active {
    transform: scale(0.98);
}

.search-bar button:disabled {
    opacity: 0.6;
    cursor: wait;
}

.status-container {
    margin-top: 22px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: var(--ok);
    border-radius: 50%;
    margin-right: 6px;
    box-shadow: 0 0 8px var(--ok);
    vertical-align: middle;
    transition: background-color 0.3s, box-shadow 0.3s;
}

.status-indicator[data-state="working"] {
    background-color: var(--warn);
    box-shadow: 0 0 8px var(--warn);
    animation: pulse 1s infinite;
}

.status-indicator[data-state="error"] {
    background-color: var(--bad);
    box-shadow: 0 0 8px var(--bad);
}

@keyframes pulse {
    50% { opacity: 0.35; }
}

.error-box {
    margin-top: 16px;
    background: rgba(230, 57, 70, 0.08);
    border: 1px solid rgba(230, 57, 70, 0.45);
    border-radius: 10px;
    padding: 12px 14px;
    text-align: left;
    font-size: 0.8rem;
}

.error-box strong {
    color: var(--bad);
    display: block;
    margin-bottom: 6px;
}

.error-box pre {
    color: var(--text-muted);
    white-space: pre-wrap;
    word-break: break-word;
    font-family: monospace;
    font-size: 0.72rem;
}

.mini-footer {
    margin-top: 24px;
    font-size: 0.68rem;
    color: var(--text-muted);
    opacity: 0.7;
}

/* ------------------------------------------------------------------ */
/* Active browsing session                                             */
/* ------------------------------------------------------------------ */

.session {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

.session[hidden] {
    display: none;
}

.session-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex: 0 0 auto;
}

.session-url {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    padding: 8px 16px;
    font-family: monospace;
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-btn {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 50px;
    padding: 8px 16px;
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, opacity 0.2s;
    white-space: nowrap;
}

.session-btn:hover {
    border-color: var(--accent-glow);
    color: var(--accent-glow);
}

.session-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.session-btn:disabled:hover {
    border-color: var(--border-color);
    color: var(--text-main);
}

.nav-group {
    display: flex;
    gap: 6px;
    flex: 0 0 auto;
}

.icon-btn {
    padding: 8px 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

.session-stage {
    flex: 1;
    position: relative;
    background: #fff;
    overflow: hidden;
}

.session-stage iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
}

.session-stage iframe[hidden] {
    display: none;
}

/* ------------------------------------------------------------------ */
/* 404 page                                                            */
/* ------------------------------------------------------------------ */

.nf-card {
    max-width: 460px;
    text-align: center;
}

.nf-code {
    font-family: 'Lobster', cursive;
    font-size: 6rem;
    color: var(--accent-glow);
    text-shadow: 0 0 24px rgba(255, 47, 126, 0.4);
    line-height: 1;
}

.nf-link {
    display: inline-block;
    margin-top: 22px;
    color: var(--accent-glow);
    text-decoration: none;
    border: 1px solid var(--accent-glow);
    border-radius: 50px;
    padding: 10px 26px;
    font-size: 0.9rem;
    transition: background 0.2s, color 0.2s;
}

.nf-link:hover {
    background: var(--accent-glow);
    color: #fff;
}

@media (max-width: 640px) {
    .container {
        padding: 26px 18px;
    }

    h1.title {
        font-size: 2.8rem;
    }

    .selector-grid {
        grid-template-columns: 1fr;
    }

    .config-row {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    .search-bar {
        flex-wrap: wrap;
        border-radius: 16px;
        padding: 10px;
        gap: 8px;
    }

    .search-bar input {
        flex: 1 1 100%;
        padding: 6px 8px;
    }

    .search-bar button {
        flex: 1 1 100%;
    }
}
