/* Singularity Image AI — Styles */
:root {
    --bg-1: #0a0a0a;
    --bg-2: #161616;
    --bg-3: #1e1e1e;
    --bg-4: #2a2a2a;
    --border: #2a2a2a;
    --border-h: #3a3a3a;
    --t1: #e8e8e8;
    --t2: #a0a0a0;
    --t3: #666;
    --accent-bg: #e0e0e0;
    --accent-text: #0a0a0a;
    --r: 12px;
    --sb-w: 240px
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-1);
    color: var(--t1);
    height: 100vh;
    overflow: hidden
}

.app {
    display: flex;
    height: 100vh
}

/* Sidebar */
.sidebar {
    width: var(--sb-w);
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0
}

.sb-brand {
    padding: 1rem .875rem;
    display: flex;
    align-items: center;
    gap: .625rem;
    border-bottom: 1px solid var(--border)
}

.sb-logo {
    width: 28px;
    height: 28px;
    background: var(--accent-bg);
    color: var(--accent-text);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 700
}

.sb-name {
    font-size: .8125rem;
    font-weight: 600
}

.sb-nav {
    flex: 1;
    padding: .5rem .625rem;
    display: flex;
    flex-direction: column;
    gap: .125rem;
    overflow-y: auto
}

.sb-item {
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: .5rem .75rem;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--t2);
    font-family: inherit;
    font-size: .8125rem;
    cursor: pointer;
    transition: all .15s;
    text-align: left;
    width: 100%
}

.sb-item:hover {
    background: var(--bg-3);
    color: var(--t1)
}

.sb-item.active {
    background: var(--bg-3);
    color: var(--t1)
}

.sb-item svg {
    flex-shrink: 0;
    opacity: .7
}

.sb-item:hover svg,
.sb-item.active svg {
    opacity: 1
}

.sb-divider {
    height: 1px;
    background: var(--border);
    margin: .375rem .75rem;
    opacity: .5
}

.sb-section {
    font-size: .625rem;
    font-weight: 600;
    color: var(--t3);
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: .25rem .75rem .125rem;
    margin-top: .125rem
}

.sb-footer {
    padding: .75rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: .5rem
}

.sb-avatar {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #10b981, #059669);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .6875rem;
    font-weight: 600
}

.sb-user {
    font-size: .75rem;
    flex: 1
}

.sb-logout {
    font-size: .625rem;
    color: var(--t3);
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit
}

.sb-logout:hover {
    color: var(--t1)
}

/* Hamburger */
.hamburger {
    display: none;
    position: fixed;
    top: .75rem;
    left: .75rem;
    z-index: 200;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--t1);
    padding: .375rem;
    cursor: pointer
}

/* Pages */
.page {
    display: none;
    flex: 1;
    position: relative;
    flex-direction: column;
    overflow: hidden
}

.page.active {
    display: flex
}

.page-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: .25rem
}

.page-sub {
    font-size: .8125rem;
    color: var(--t2);
    margin-bottom: 1rem
}

/* Generate center (initial view — like TTS) */
.gen-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: .5rem;
    max-width: 700px;
    margin: 0 auto;
    width: 100%
}

.gen-logo {
    font-size: 2.5rem;
    margin-bottom: .25rem;
    color: var(--t2)
}

.gen-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.25rem
}

.chat-area {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 80px;
    overflow-y: auto;
    padding: 1.5rem
}

.chat-results {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%
}

/* Bottom input (chat mode) */
.gen-input-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: .75rem 1.5rem;
    background: var(--bg-1);
    border-top: 1px solid var(--border)
}

.gen-input-wrap {
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: .75rem
}

.gen-input-wrap:focus-within {
    border-color: var(--border-h)
}

.gen-textarea {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--t1);
    font-family: inherit;
    font-size: .9375rem;
    outline: none;
    resize: none;
    min-height: 48px;
    max-height: 150px;
    line-height: 1.5
}

.gen-textarea::placeholder {
    color: var(--t3)
}

.gen-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem
}

.gen-tools {
    display: flex;
    gap: .25rem;
    align-items: center;
    flex: 1;
    min-width: 0;
    flex-wrap: wrap
}

.tool-select {
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: .25rem .5rem;
    font-size: .6875rem;
    color: var(--t2);
    cursor: pointer;
    font-family: inherit;
    outline: none
}

.tool-select:hover {
    border-color: var(--border-h);
    color: var(--t1)
}

.send-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-bg);
    color: var(--accent-text);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .875rem;
    flex-shrink: 0
}

.send-btn:hover {
    box-shadow: 0 2px 8px rgba(255, 255, 255, .15)
}

.send-btn:disabled {
    opacity: .3;
    cursor: not-allowed
}

/* Suggestions */
.gen-suggestions {
    display: flex;
    flex-direction: column;
    gap: .375rem;
    margin-top: .25rem;
    width: 100%
}

.gen-sug-label {
    font-size: .6875rem;
    color: var(--t3);
    margin-bottom: .125rem
}

.gen-sug {
    text-align: left;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: .625rem .875rem;
    color: var(--t2);
    font-family: inherit;
    font-size: .8125rem;
    cursor: pointer;
    transition: all .15s
}

.gen-sug:hover {
    border-color: var(--border-h);
    color: var(--t1)
}

.gen-sug b {
    color: var(--t1)
}

/* Chat */
.chat-results {
    display: none;
    flex-direction: column;
    gap: 1rem;
    width: 100%
}

.chat-results.active {
    display: flex
}

.msg {
    display: flex;
    gap: .625rem;
    max-width: 700px;
    width: 100%;
    margin: 0 auto;
    animation: fadeIn .25s ease
}

.msg-user {
    flex-direction: row-reverse
}

.msg-ai {
    flex-direction: row
}

.msg-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--bg-3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .625rem;
    flex-shrink: 0
}

.msg-user .msg-avatar {
    background: var(--accent-bg);
    color: var(--accent-text)
}

.msg-bubble {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: .625rem .875rem;
    font-size: .8125rem;
    line-height: 1.6
}

.msg-user .msg-bubble {
    background: var(--bg-3)
}

.msg-time {
    font-size: .5625rem;
    color: var(--t3);
    margin-top: .125rem
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}

/* Image card */
.img-card {
    border-radius: var(--r);
    overflow: hidden;
    margin-top: .375rem;
    position: relative;
    max-width: 512px
}

.img-card img {
    width: 100%;
    display: block;
    border-radius: var(--r);
    background: var(--bg-3)
}

.img-card .img-actions {
    display: flex;
    gap: .375rem;
    margin-top: .375rem
}

.img-action-btn {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    font-size: .625rem;
    color: var(--t2);
    text-decoration: none;
    padding: .2rem .5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: none;
    cursor: pointer;
    font-family: inherit
}

.img-action-btn:hover {
    border-color: var(--border-h);
    color: var(--t1)
}

.img-meta {
    font-size: .625rem;
    color: var(--t3);
    margin-top: .25rem
}

/* Loading skeleton */
.img-skeleton {
    width: 100%;
    max-width: 512px;
    aspect-ratio: 1/1;
    border-radius: var(--r);
    background: linear-gradient(90deg, var(--bg-3) 25%, var(--bg-4) 50%, var(--bg-3) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    margin-top: .375rem
}

@keyframes shimmer {
    0% {
        background-position: -200% 0
    }

    100% {
        background-position: 200% 0
    }
}

/* Thinking dots */
.thinking {
    display: flex;
    gap: 4px;
    padding: .25rem 0
}

.thinking span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--t3);
    animation: dotPulse .8s infinite alternate
}

.thinking span:nth-child(2) {
    animation-delay: .2s
}

.thinking span:nth-child(3) {
    animation-delay: .4s
}

@keyframes dotPulse {
    to {
        opacity: .2;
        transform: scale(.8)
    }
}

/* removed — using gen-input-bottom */

/* Gallery */
.gallery-page {
    padding: 1.5rem;
    overflow-y: auto;
    height: 100%
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: .75rem;
    margin-top: .5rem
}

.gallery-item {
    border-radius: var(--r);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-2);
    cursor: pointer;
    transition: all .15s;
    position: relative
}

.gallery-item:hover {
    border-color: var(--border-h);
    transform: translateY(-2px)
}

.gallery-item img {
    width: 100%;
    display: block;
    aspect-ratio: 1/1;
    object-fit: cover
}

.gallery-item-info {
    padding: .5rem .625rem;
    font-size: .6875rem;
    color: var(--t2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.gallery-item-actions {
    padding: 0 .625rem .5rem;
    display: flex;
    gap: .375rem
}

.gallery-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    font-size: .8125rem;
    color: var(--t3)
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(0, 0, 0, .9);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem
}

.lightbox.open {
    display: flex
}

.lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: var(--r)
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--bg-3);
    border: 1px solid var(--border);
    color: var(--t1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem
}

/* Settings */
.cfg-page {
    padding: 1.5rem;
    overflow-y: auto
}

.cfg-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 1rem;
    margin-bottom: .75rem
}

.cfg-label {
    font-size: .75rem;
    font-weight: 600;
    margin-bottom: .5rem
}

.cfg-row {
    display: flex;
    gap: .5rem
}

.cfg-input {
    flex: 1;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .5rem .75rem;
    color: var(--t1);
    font-family: inherit;
    font-size: .8125rem;
    outline: none
}

.cfg-input:focus {
    border-color: var(--border-h)
}

.cfg-btn {
    background: var(--accent-bg);
    color: var(--accent-text);
    border: none;
    border-radius: 8px;
    padding: .5rem 1rem;
    font-family: inherit;
    font-size: .75rem;
    font-weight: 600;
    cursor: pointer
}

.cfg-btn:hover {
    box-shadow: 0 2px 8px rgba(255, 255, 255, .1)
}

/* Mobile */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        z-index: 150;
        transition: left .2s
    }

    .sidebar.open {
        left: 0
    }

    .hamburger {
        display: flex
    }

    .gen-input-bottom {
        padding: .5rem .75rem
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr))
    }
}