header {
    flex-shrink: 0;
    height: calc(var(--header-height) + var(--safe-area-top));
    display: flex;
    align-items: flex-end;
    padding: 0 20px 10px 20px;
    z-index: 2000;
    background: #0f172a;
    border-bottom: 1px solid var(--border-color);
    width: 100%;
    position: relative;
    transition: height 0.2s ease;
}

/* App container: no page-level scroll, only main scrolls */
#app {
    height: var(--app-height, 100vh);
    overflow: hidden;
    min-height: 0;
}

/* Editor mode - taller header for 2 rows */
header.editor-mode {
    height: calc(110px + var(--safe-area-top));
    align-items: flex-start;
    padding-top: 10px;
}

main {
    height: calc(var(--app-height, 100vh) - var(--header-height) - var(--safe-area-top) - 64px - var(--safe-area-bottom));
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    position: relative;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

#app.landing main {
    height: var(--app-height, 100vh);
    padding: 0;
}

main>.view {
    width: 100%;
    min-height: 100%;
    flex-grow: 1;
}

.header-content {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 15px;
    margin-bottom: 5px;
}

.badge-count {
    margin-left: 10px;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    opacity: 0.8;
    display: none;
}

.back-btn-pos {
    display: none;
}

.debug-overlay {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    pointer-events: none;
}

h1 {
    font-size: 1.2rem;
    font-weight: 700;
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(64px + var(--safe-area-bottom));
    background: #0f172a;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 10px var(--safe-area-bottom);
    z-index: 2000;
    width: 100%;
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex: 1;
}

.nav-item.active {
    color: var(--accent-color);
    background: rgba(56, 189, 248, 0.1);
}

/* Footer Actions */
.footer-actions {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    padding: 16px 20px calc(16px + var(--safe-area-bottom));
    background: #0f172a;
    border-top: 1px solid var(--border-color);
    z-index: 1000;
}

/* Desktop Responsiveness & Background */
.bg-blobs {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    background: #020617;
    pointer-events: none;
}

.blob {
    position: absolute;
    width: 600px;
    height: 600px;
    background: rgba(56, 189, 248, 0.05);
    filter: blur(80px);
    border-radius: 50%;
    contain: strict;
}

.blob-1 {
    top: -10%;
    left: -10%;
    animation-delay: 0s;
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    background: rgba(236, 72, 153, 0.05);
}

.blob-3 {
    top: 40%;
    left: 60%;
    animation-delay: -10s;
    width: 400px;
    height: 400px;
}

@keyframes blobFloat {
    0% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(30px, -50px) scale(1.1);
    }

    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }

    100% {
        transform: translate(0, 0) scale(1);
    }
}

@media (min-width: 768px) {
    body {
        display: flex;
        justify-content: center;
        background-color: #020617;
    }

    #app {
        width: 100%;
        max-width: 600px;
        margin: 0 auto;
        height: var(--app-height, 100vh);
        min-height: 0;
        overflow: hidden;
        background-color: transparent;
        position: relative;
        border-left: 1px solid var(--border-color);
        border-right: 1px solid var(--border-color);
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
        transition: max-width 0.3s ease;
    }

    #app.landing {
        max-width: 100%;
        border-left: none;
        border-right: none;
    }

    header {
        width: 100%;
        max-width: 600px;
    }

    .bottom-nav {
        width: 100%;
        max-width: 600px;
        left: 50%;
        transform: translateX(-50%);
    }

    .footer-actions {
        width: 100%;
        max-width: 600px;
        left: 50%;
        transform: translateX(-50%);
    }

    .loader-container {
        left: 50%;
        transform: translate(-50%, -50%);
        max-width: 600px;
    }
}

/* Editor Header Controls */
#editor-header-controls {
    display: none;
    /* Controlled by JS */
    flex-direction: column;
    width: 100%;
    gap: 8px;
}

.editor-header-row {
    display: flex;
    align-items: center;
    width: 100%;
}

.editor-header-title-row {
    gap: 8px;
}

.editor-header-actions-row {
    gap: 10px;
}

.editor-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
    flex-grow: 1;
    margin: 0;
}

.header-search {
    flex-grow: 1;
}

.header-search input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    width: 100%;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s;
}

.header-search input:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent-color);
}

.add-q-sticky-btn {
    padding: 0 12px;
    width: auto;
    font-size: 0.9rem;
    height: 36px;
    white-space: nowrap;
}

.add-q-sticky-btn.compact {
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 1.2rem;
    line-height: 1;
}

/* Mobile optimization for editor header */
@media (max-width: 400px) {
    .editor-title {
        font-size: 1rem;
    }

    .editor-header-actions-row .badge-count {
        display: none;
    }

    #header-add-btn span {
        font-size: 0.85rem;
    }

    .header-search input {
        font-size: 0.85rem;
    }
}
