:root {
    --bg: #0d0d10;
    --text: #f7f7fb;
    --glass-bg: rgba(255, 255, 255, 0.11);
    --glass-border: rgba(255, 255, 255, 0.15);
    --card-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    --accent: #4da3ff;
    --hint: rgba(247,247,251,0.7);
    --splash-bg: #ff3b3b;
}
body.theme-light {
    --bg: #f4f6fa;
    --text: #0f141d;
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(0, 0, 0, 0.06);
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    --accent: #3b82f6;
    --hint: rgba(15,20,29,0.6);
    --splash-bg: #ff3b3b;
}
body.theme-benito {
    --bg: #0f1f18;
    --text: #e9f7ed;
    --glass-bg: rgba(23, 46, 35, 0.75);
    --glass-border: rgba(0, 255, 170, 0.15);
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --accent: #00e68a;
    --hint: rgba(233,247,237,0.7);
    --splash-bg: #00a86b;
}
body.theme-blue {
    --bg: #0d1b2a;
    --text: #e8f1ff;
    --glass-bg: rgba(26, 48, 78, 0.75);
    --glass-border: rgba(77, 163, 255, 0.2);
    --card-shadow: 0 12px 30px rgba(0, 20, 50, 0.4);
    --accent: #4dabff;
    --hint: rgba(232,241,255,0.7);
    --splash-bg: #1d64c0;
}
body.theme-red {
    --bg: #2b0f13;
    --text: #ffeaea;
    --glass-bg: rgba(64, 20, 28, 0.78);
    --glass-border: rgba(255, 90, 95, 0.18);
    --card-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
    --accent: #ff5a5f;
    --hint: rgba(255,234,234,0.7);
    --splash-bg: #ff3b3b;
}
body.theme-creme {
    --bg: #f6efe7;
    --text: #1b1613;
    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(0, 0, 0, 0.05);
    --card-shadow: 0 12px 28px rgba(0, 0, 0, 0.08);
    --accent: #d17b00;
    --hint: rgba(27,22,19,0.55);
    --splash-bg: #e0a453;
}
body {
    margin: 0;
    padding: 0;
    font-family: system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-width: 100vw;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.glass {
    background: var(--glass-bg);
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    backdrop-filter: blur(8.6px);
    -webkit-backdrop-filter: blur(8.6px);
    border: 1px solid var(--glass-border);
}
body.no-glass .glass {
    background: rgba(20, 20, 24, 0.9);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 1px solid rgba(255,255,255,0.05);
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
body.settings-open .camera-container,
body.settings-open .gallery,
body.settings-open .settings-btn {
    display: none;
}
body.meta-open .camera-container,
body.meta-open .gallery,
body.meta-open .settings-btn {
    display: none;
}
body.theme-light .toast {
    color: #0f141d;
}

.settings-btn {
    position: fixed;
    top: 24px;
    left: 24px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 10;
}

.settings-modal {
    display: none;
    position: fixed;
    top: 60px;
    left: 24px;
    padding: 24px;
    min-width: 220px;
    z-index: 20;
    flex-direction: column;
    gap: 16px;
}
.settings-modal.active {
    display: flex;
}
.settings-modal label {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
    font-size: 1rem;
}
.settings-modal button {
    margin-top: 12px;
    padding: 8px 16px;
    font-size: 1rem;
    cursor: pointer;
}
.settings-modal .toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.settings-modal .toggle-row.switch {
    align-items: center;
}
.switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.switch .slider {
    position: relative;
    width: 52px;
    height: 28px;
    background: rgba(255,255,255,0.18);
    border-radius: 20px;
    box-shadow: inset 0 1px 4px rgba(0,0,0,0.12);
    transition: background 0.2s ease;
    display: inline-block;
}
.switch .slider::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    transition: transform 0.2s ease;
}
.switch input:checked + .slider {
    background: rgba(255,255,255,0.35);
}
.switch input:checked + .slider::after {
    transform: translateX(24px);
}
.settings-modal .version-row {
    margin-top: 8px;
    font-size: 0.9rem;
    text-align: right;
    color: #2f2f2f;
}

/* Full settings page */
.settings-page {
    position: fixed;
    inset: 0;
    background: var(--bg);
    color: var(--text);
    z-index: 2000;
    display: none;
    flex-direction: column;
    overflow-y: auto;
    padding: 16px 20px 32px;
}
.settings-page.active {
    display: flex;
}
.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0 4px;
    position: sticky;
    top: 0;
    background: linear-gradient(180deg, var(--bg) 0%, rgba(0,0,0,0.15) 100%);
    z-index: 1;
}
.settings-title {
    font-size: 1.2rem;
    letter-spacing: 0.02em;
    text-align: center;
    flex: 1;
}
.settings-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.ghost-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--text);
    padding: 8px 12px;
    border-radius: 12px;
    cursor: pointer;
}
.version-chip {
    min-width: 64px;
    text-align: right;
    font-size: 0.9rem;
    color: var(--text);
}
.settings-sections {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}
.accordion {
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 14px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.35);
    overflow: hidden;
}
.accordion-header {
    width: 100%;
    background: none;
    color: inherit;
    border: none;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 1rem;
    cursor: pointer;
}
.accordion-body {
    padding: 0 16px 16px 16px;
    display: block;
}
.control-stack label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
}
.control-stack label:first-of-type {
    margin-top: 0;
}
.control-stack input[type="range"] {
    appearance: none;
    height: 10px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent) 0%, rgba(255,255,255,0.3) 100%);
    outline: none;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
}
.control-stack #saturation {
    background: linear-gradient(
        90deg,
        rgba(255,255,255,0.2) 0%,
        #d13dff 10%,
        #5f5bff 25%,
        #24a6ff 40%,
        #1fd1a5 55%,
        #a4e92d 70%,
        #ffb02e 85%,
        #ff5a5a 100%
    );
}
.control-stack #warmth {
    background: linear-gradient(90deg, #4aa8ff 0%, #ffda6a 100%);
}
.control-stack input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--accent);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.control-stack input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--accent);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.chevron {
    opacity: 0.7;
    font-size: 0.9rem;
}
.row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.space-between {
    justify-content: space-between;
}
.label-col .label {
    font-weight: 600;
}
.label-col .hint {
    font-size: 0.85rem;
    color: var(--hint);
}
.placeholder {
    margin: 8px 0;
    color: var(--hint);
}
.theme-row {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}
.theme-dot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: none;
    border: 2px solid transparent;
    border-radius: 14px;
    padding: 8px 10px;
    cursor: pointer;
    color: var(--text);
    transition: border-color 0.2s ease, transform 0.1s ease;
}
.theme-dot .dot {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.18);
    box-shadow: inset 0 1px 6px rgba(0,0,0,0.2);
}
.theme-dot .theme-label {
    font-size: 0.9rem;
}
.theme-dot.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(77,163,255,0.2);
    transform: translateY(-1px);
}
.about-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    font-size: 0.95rem;
}
.about-row .bullet {
    color: #7cf08a;
    font-size: 1.2rem;
}
.about-text {
    flex: 1;
}
.version-pill {
    padding: 6px 10px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.05);
    font-size: 0.9rem;
}

.splash {
    position: fixed;
    inset: 0;
    background: var(--splash-bg, #ff3b3b);
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 4000;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}
.splash.hide {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.splash-title {
    display: none;
}
.splash-version {
    font-size: 1rem;
    opacity: 0.9;
}
.splash-logo {
    width: 140px;
    height: 140px;
    object-fit: contain;
    margin-bottom: 10px;
    filter: drop-shadow(0 10px 22px rgba(0,0,0,0.25));
}

.camera-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1;
    padding: 0;
    background: none;
    box-shadow: none;
    border: none;
}

video {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    object-fit: cover;
    border-radius: 0;
    background: #222;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    transform-origin: center center;
}

.ring-light {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    background: radial-gradient(circle, rgba(255,255,255,0) 60%, rgba(255,255,255,0.8) 85%, rgba(255,255,255,0.95) 100%);
    mix-blend-mode: screen;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 2;
}
.ring-light.on {
    opacity: 1;
}

.demo-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    object-fit: cover;
    z-index: 1;
    display: none;
}

.grid-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255,255,255,0.25) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.25) 1px, transparent 1px);
    background-size: calc(100vw / 3) calc(100vh / 3);
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 3;
}
.grid-overlay.on {
    opacity: 1;
}

.styl-overlay {
    position: fixed;
    bottom: 18px;
    left: 18px;
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: 0.08em;
    color: #000;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 3;
    background: rgba(255,255,255,0.65);
    padding: 6px 10px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.styl-overlay.on { opacity: 1; }

.capture-btn {
    position: fixed;
    bottom: 48px;
    left: 50%;
    transform: translateX(-50%);
    width: 72px;
    height: 72px;
    border-radius: 24px;
    border: none;
    outline: none;
    background: rgba(255,255,255,0.18);
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}
.capture-btn::after {
    content: '';
    display: block;
    width: 48px;
    height: 48px;
    background: rgba(255,255,255,0.35);
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}

.zoom-slider {
    position: fixed;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 240px;
    accent-color: var(--accent);
    z-index: 10;
}

.flash-btn {
    position: fixed;
    bottom: 54px;
    left: 32px;
    transform: none;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    border: none;
    outline: none;
    background: rgba(255,255,255,0.18);
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}
.flash-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.flash-btn.active {
    box-shadow: 0 0 0 2px var(--accent), 0 4px 12px rgba(0,0,0,0.2);
}
.flip-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    transform: none;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    border: none;
    outline: none;
    background: rgba(255,255,255,0.18);
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.meta-page {
    position: fixed;
    inset: 0;
    background: var(--bg);
    color: var(--text);
    z-index: 2000;
    display: none;
    flex-direction: column;
    overflow-y: auto;
    padding: 16px 20px 32px;
}
.meta-page.active {
    display: flex;
}
.meta-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.drop-zone {
    position: relative;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    border: 1px dashed rgba(255,255,255,0.25);
}
.drop-zone input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.drop-zone.drag {
    border-color: var(--accent);
}
.meta-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}
.meta-panel {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.meta-output {
    min-height: 140px;
    line-height: 1.5;
    white-space: pre-wrap;
    transition: opacity 0.2s ease;
}
.meta-output.loading { opacity: 0.6; font-style: italic; }
.label-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
}
.label-preview {
    padding: 12px;
    margin-top: 6px;
    font-family: 'Menlo', monospace;
    white-space: pre-wrap;
}
.release-list {
    margin: 8px 0 0 16px;
    color: var(--hint);
}

.settings-footer {
    display: flex;
    justify-content: center;
    padding: 12px 0 4px;
}
.settings-footer .footer-logo {
    width: 92px;
    height: 92px;
    object-fit: contain;
    filter: drop-shadow(0 6px 14px rgba(0,0,0,0.25));
}
.gallery {
    position: fixed;
    bottom: 32px;
    right: 32px;
    left: auto;
    transform: none;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0;
    padding: 0;
    justify-content: flex-end;
    max-width: 64px;
    z-index: 30;
    background: none;
    box-shadow: none;
    border: none;
    cursor: pointer;
    width: 64px;
    height: 64px;
}

.gallery img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 16px;
    margin-bottom: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 2px solid rgba(255,255,255,0.25);
}
/* Gallery Overlay */
.gallery-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(30,30,30,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}
.gallery-overlay .overlay-content {
    background: rgba(255,255,255,0.11);
    border-radius: 24px;
    box-shadow: 0 4px 30px rgba(0,0,0,0.1);
    backdrop-filter: blur(8.6px);
    -webkit-backdrop-filter: blur(8.6px);
    border: 1px solid rgba(255,255,255,0.15);
    padding: 32px 24px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.gallery-overlay .overlay-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    justify-content: center;
    margin-bottom: 16px;
}
/* Three-dot menu */
.img-menu-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.18);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    z-index: 2;
    font-size: 1.5rem;
    color: #333;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.img-menu-dropdown {
    position: absolute;
    top: 44px;
    right: 10px;
    min-width: 120px;
    background: rgba(255,255,255,0.95);
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.13);
    display: flex;
    flex-direction: column;
    z-index: 10;
    padding: 8px 0;
}
.img-menu-dropdown button {
    background: none;
    border: none;
    padding: 10px 18px;
    font-size: 1rem;
    text-align: left;
    cursor: pointer;
    color: #222;
    border-radius: 8px;
    transition: background 0.15s;
}
.img-menu-dropdown button:hover {
    background: rgba(0,0,0,0.07);
}
.gallery-overlay img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.gallery-overlay .close-overlay {
    margin-top: 8px;
    padding: 8px 24px;
    font-size: 1.1rem;
    border-radius: 12px;
    border: none;
    background: rgba(255,255,255,0.18);
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
/* Glassmorphism toast */
.toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    min-width: 220px;
    max-width: 90vw;
    padding: 16px 24px;
    z-index: 1000;
    font-size: 1.1rem;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}
.toast.show {
    opacity: 1;
    pointer-events: auto;
}
.toast.success {
    background: rgba(46, 204, 113, 0.18);
    border: 1px solid rgba(46, 204, 113, 0.35);
    color: #0f3f1f;
}
@media (max-width: 600px) {
    .gallery img {
        width: 60px;
        height: 60px;
    }
    .capture-btn {
        width: 56px;
        height: 56px;
        border-radius: 16px;
    }
    .capture-btn::after {
        width: 36px;
        height: 36px;
        border-radius: 10px;
    }
}

.gallery .download-btn {
    display: block;
    margin: 0 auto 8px auto;
    padding: 4px 12px;
    font-size: 0.9rem;
    border-radius: 8px;
    border: none;
    background: rgba(255,255,255,0.18);
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.offline-page {
    background: #e0e0e0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.offline-card {
    padding: 32px 28px;
    max-width: 360px;
    text-align: center;
}
.offline-card .muted {
    color: #555;
}
