:root {
    --bg: #000814;
    --bg-accent: rgba(255, 255, 255, 0.02);
    --surface: rgba(255, 255, 255, 0.03);
    --surface-secondary: rgba(255, 255, 255, 0.05);
    --text: #ffffff;
    --text-dim: rgba(255, 255, 255, 0.5);
    --border: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(255, 255, 255, 0.2);
    --accent: #ffffff;
    --accent-glow: rgba(0, 100, 255, 0.3);
    --header-h: 72px;
    --panel-blur: blur(40px);
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Manrope', -apple-system, sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    background-image:
        radial-gradient(circle at 50% -20%, var(--accent-glow) 0%, transparent 60%),
        linear-gradient(rgba(255, 255, 255, 0.01) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.01) 1px, transparent 1px);
    background-size: 100% 100%, 60px 60px, 60px 60px;
}

h1,
h2,
h3,
h4,
.logo-text {
    font-family: 'Outfit', sans-serif;
    letter-spacing: -0.02em;
}

.silver-text {
    background: linear-gradient(135deg, #fff 0%, rgba(255, 255, 255, 0.7) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* App Layout */
.app-header {
    height: var(--header-h);
    border-bottom: 1px solid var(--border);
    padding: 0 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 8, 20, 0.8);
    backdrop-filter: var(--panel-blur);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.app-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: calc(100vh - var(--header-h));
    overflow: hidden;
}

.app-sidebar {
    border-right: 1px solid var(--border);
    padding: 40px 24px;
    background: rgba(255, 255, 255, 0.01);
    display: flex;
    flex-direction: column;
    gap: 40px;
    overflow-y: auto;
}

.app-content {
    padding: 40px 60px;
    overflow-y: auto;
    background: radial-gradient(circle at center, rgba(0, 100, 255, 0.03) 0%, transparent 70%);
    position: relative;
    padding-bottom: 100px;
    /* Space for status bar */
}

/* Components */
.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: white;
}

.logo img {
    height: 32px;
    width: auto;
}

.logo-text {
    font-weight: 800;
    font-size: 22px;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 24px;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sidebar-label {
    font-size: 10px;
    font-weight: 800;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #fff;
    padding: 14px 16px;
    background: var(--bg-accent);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: 0.2s;
    font-size: 13px;
    font-weight: 700;
}

.sidebar-link:hover,
.sidebar-link.active {
    background: var(--surface-secondary);
    border-color: #fff;
    transform: translateX(4px);
}

/* Glass Card */
.glass-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 32px;
    backdrop-filter: var(--panel-blur);
    transition: 0.3s;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: #fff;
    text-decoration: none;
}

.btn-primary {
    background: #fff;
    color: #000;
    border: none;
}

/* Status Bar */
.status-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: rgba(0, 8, 20, 0.9);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    padding: 0 40px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-dim);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
}

/* Responsive Tool Layout */
/* Global Mobile Nav Hide (Desktop & Tablet) */
.mobile-nav {
    display: none !important;
}

@media (max-width: 768px) {
    :root {
        --header-h: 60px;
    }

    .app-header {
        padding: 0 16px;
    }

    .logo img {
        height: 24px;
    }

    .logo-text {
        font-size: 16px;
    }

    .app-layout {
        display: flex;
        flex-direction: column;
        height: auto;
        overflow: visible;
        padding-bottom: 120px !important;
        /* Increased for fixed nav breathing room */
    }

    .app-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 24px 16px 32px;
        height: auto;
        overflow: visible;
        gap: 24px;
        order: 2;
        /* Controls below content */
    }

    .app-content {
        padding: 16px 16px 40px;
        order: 1;
        /* Result first */
        min-height: auto !important;
    }

    .status-bar {
        display: none !important;
    }

    .status-bar>div:first-child {
        display: none;
        /* Hide 'Service: Active' on very small screens to save space */
    }

    .glass-card {
        padding: 20px;
        border-radius: 20px;
    }

    .mobile-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(0, 8, 20, 0.95);
        backdrop-filter: blur(20px);
        border-top: 1px solid var(--border);
        justify-content: space-around;
        align-items: center;
        padding: 0 4px;
        z-index: 10000 !important;
        padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
        height: calc(84px + env(safe-area-inset-bottom)) !important;
    }

    .mobile-nav .sidebar-link {
        flex-direction: column;
        gap: 4px;
        padding: 10px 4px;
        background: none;
        border: none;
        font-size: 10px;
        flex: 1;
        text-align: center;
        justify-content: center;
        border-radius: 0;
        min-width: 0;
    }

    .mobile-nav .sidebar-link:hover,
    .mobile-nav .sidebar-link.active {
        transform: none;
        background: rgba(255, 255, 255, 0.05);
        color: #fff;
    }

    .mobile-nav .sidebar-link i {
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 480px) {
    .app-header {
        height: 56px;
        padding: 0 12px;
    }

    .logo-text {
        font-size: 14px;
    }

    .app-content {
        padding: 12px 12px 32px;
    }

    .sidebar-label {
        font-size: 8px;
        letter-spacing: 1px;
    }

    .btn {
        font-size: 12px;
        padding: 12px 16px;
    }
}

/* Utils for better mobile fitting */
@media (max-width: 768px) {
    #output-view {
        min-height: 250px !important;
        width: 100% !important;
        max-height: 70vh !important;
        aspect-ratio: auto !important;
        /* Allow content to define height or use separate ratio */
    }

    /* Mobile logout button */
    .mobile-logout {
        background: none;
        border: none;
        color: var(--text);
        cursor: pointer;
        margin-left: auto;
        display: none;
        padding: 8px;
        border-radius: 8px;
        transition: background 0.2s;
    }

    .mobile-logout:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    @media (max-width: 768px) {
        .mobile-logout {
            display: block;
        }
    }
}