:root {
    --primary-color: #007aff;
    --primary-hover: #005bb5;
    --bg-color: #f2f2f7;
    --card-bg: #ffffff;
    --text-main: #1c1c1e;
    --text-muted: #8e8e93;
    --border-color: #e5e5ea;
    --danger-color: #ff3b30;
    --danger-hover: #d32f2f;
    --success-color: #34c759;
    --share-color: #5856d6;
    --share-hover: #4a47bc;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    --radius: 16px;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
    --primary-color: #0a84ff;
    --primary-hover: #409cff;
    --bg-color: #000000;
    --card-bg: #1c1c1e;
    --text-main: #f2f2f7;
    --text-muted: #aeaeb2;
    --border-color: #38383a;
    --share-color: #5e5ce6;
    --share-hover: #7b79f7;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    /* Verhindert den Bounce-Effekt am gesamten Dokument */
    overscroll-behavior: none;
    height: 100%;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overscroll-behavior-y: none;
    overflow-x: hidden;
}

*:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

.hidden {
    display: none !important;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
    width: 100%;
}

/* Header */
.app-header {
    background-color: var(--card-bg);
    padding: 16px 20px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.branding {
    display: flex;
    align-items: center;
    gap: 12px;
}

.title-group h1 {
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.version {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
    background: var(--border-color);
    padding: 2px 6px;
    border-radius: 8px;
}

.subtitle { font-size: 0.85rem; color: var(--text-muted); margin: 0; }

.icon-btn {
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
}
.icon-btn:hover { background-color: var(--border-color); }

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}
.card h3 { margin-top: 0; margin-bottom: 16px; font-size: 1.1rem; }

/* Upload Section */
.upload-section {
    border: 2px dashed var(--primary-color);
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}
.upload-section.dragover { background-color: rgba(0, 122, 255, 0.1); }
.hidden-input { display: none; }

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.upload-icon { color: var(--primary-color); }
.format-hint { font-size: 0.8rem; color: var(--text-muted); margin: 0; }

/* Buttons */
.btn {
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s, background-color 0.2s;
    width: 100%;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    vertical-align: middle;
}
@media (min-width: 600px) { .btn { width: auto; } }
.btn:active { opacity: 0.8; }
.btn-primary { background: var(--primary-color); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--border-color); color: var(--text-main); }
.btn-secondary.text-btn { font-size: 0.95rem; font-weight: 500; }
.btn-danger { background: var(--danger-color); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-share { background: var(--share-color); color: #fff; }
.btn-share:hover { background: var(--share-hover); }

/* Warteschlange (Queue System) */
.queue-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 260px;
    overflow-y: auto;
    margin-bottom: 16px;
    padding-right: 4px;
}

.queue-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-color);
    border-radius: 10px;
    gap: 12px;
}

.queue-item-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
}

.queue-thumb {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--card-bg);
    flex-shrink: 0;
}

.queue-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
    min-width: 0; /* Verhindert das Zerstören der Container-Breite durch Flex-Children */
}

.queue-name {
    font-size: 0.9rem;
    font-weight: 500;
    /* Erlaubt Zeilenumbruch auf Desktop */
    word-break: break-word;
    overflow-wrap: anywhere;
    min-width: 0;
    width: 100%;
}

/* Auf mobilen Endgeräten auf 2 Zeilen limitieren inkl. Ellipsis (...) */
@media (max-width: 599px) {
    .queue-name {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

.queue-size { font-size: 0.8rem; color: var(--text-muted); }

.btn-remove-single {
    background: none;
    border: none;
    color: var(--danger-color);
    font-size: 1.4rem;
    cursor: pointer;
    min-width: 36px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}
.btn-remove-single:hover { background: rgba(255, 59, 48, 0.1); }

.queue-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    flex-wrap: wrap;
}
.queue-actions .btn { width: 100%; }
@media (min-width: 480px) { .queue-actions .btn { width: auto; } }

/* Segmented Control */
.segmented-control {
    display: flex;
    background: var(--border-color);
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
    margin-bottom: 16px;
}

.segment {
    flex: 1;
    padding: 10px;
    border: none;
    min-height: 44px;
    background: transparent;
    color: var(--text-main);
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, box-shadow 0.2s;
}
.segment.active {
    background: var(--card-bg);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-color);
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-top: 14px;
    margin-bottom: 14px;
    gap: 16px;
}

.toggle-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
    user-select: none;
    flex: 1;
}

.switch {
    position: relative;
    display: inline-block;
    width: 51px;
    height: 31px;
    flex-shrink: 0;
    cursor: pointer;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
    -webkit-appearance: none;
    appearance: none;
}

.slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--border-color);
    border-radius: 31px;
    transition: background-color 0.25s ease;
}

.slider:before {
    content: "";
    position: absolute;
    height: 27px;
    width: 27px;
    left: 2px;
    bottom: 2px;
    background-color: #ffffff;
    border-radius: 50%;
    transition: transform 0.25s cubic-bezier(0.25, 0.1, 0.25, 1);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

input:checked + .slider { background-color: var(--success-color); }
input:checked + .slider:before { transform: translateX(20px); }

/* Settings Inputs */
.setting-group { margin-bottom: 16px; }
.setting-group label { display: block; margin-bottom: 8px; font-weight: 500; }
input[type="range"] { width: 100%; min-height: 44px; margin: 0; cursor: pointer; }

.dimensions-group {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 12px;
}
.dimension-input-wrapper { flex: 1; display: flex; flex-direction: column; }
.dimensions-group input {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-main);
    min-height: 44px;
    font-size: 1rem;
    width: 100%;
}
@media (min-width: 480px) { .dimensions-group { flex-direction: row; } }

/* Progress */
.progress-bar-container {
    width: 100%; height: 8px; background: var(--border-color);
    border-radius: 4px; overflow: hidden; margin-top: 12px;
}
.progress-bar {
    height: 100%; width: 0%; background: var(--primary-color);
    transition: width 0.3s ease;
}
.progress-text { margin-top: 8px; text-align: center; font-size: 0.9rem; }

/* Stats & Results */
.stats-card { margin-bottom: 20px; }
.stats-content { font-size: 1.1rem; font-weight: 500; margin-bottom: 16px; text-align: center; }
.action-bar { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.results-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 600px) { .results-grid { grid-template-columns: 1fr 1fr; } }

.result-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--border-color);
}
.result-info { font-size: 0.9rem; word-break: break-all; }
.result-info strong { display: block; margin-bottom: 4px; font-size: 0.95rem; color: var(--text-main); }
.result-info span { color: var(--text-muted); }

/* Info Triggers Row */
.info-trigger-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    align-items: center;
    margin-top: 10px;
}
.info-trigger-row .btn { width: 100%; }
@media (min-width: 480px) {
    .info-trigger-row { flex-direction: row; justify-content: center; }
    .info-trigger-row .btn { width: auto; flex: 1; max-width: 240px; }
}

/* Modals Architektur */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 550px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: var(--shadow);
}
.modal-content.large { max-width: 950px; width: 100%; }
.modal-content h3 { margin-bottom: 16px; font-size: 1.25rem; border-bottom: 1px solid var(--border-color); padding-bottom: 10px; }
.modal-scroll-area { overflow-y: auto; padding-right: 4px; }

.close-modal {
    position: absolute; top: 12px; right: 16px; background: none;
    border: none; font-size: 2rem; line-height: 1; color: var(--text-main);
    cursor: pointer; padding: 4px; min-width: 44px; min-height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    z-index: 10;
}
.close-modal:hover { background: var(--border-color); }

.faq-item, .release-item { margin-bottom: 18px; }
.faq-item h4, .release-item h4 { margin-bottom: 6px; font-size: 1rem; color: var(--text-main); }
.faq-item p, .release-item ul { font-size: 0.9rem; color: var(--text-muted); }
.release-item ul { padding-left: 20px; }


/* NEU: BILDVERGLEICHS-VIEWPORT STYLES (SLIDER & ZOOM) */
.comparison-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
.info-card {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
}
.info-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.info-meta {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.4;
}

.slider-viewport {
    position: relative;
    width: 100%;
    height: 55vh;
    min-height: 320px;
    background: var(--bg-color);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none; 
    user-select: none;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.6);
}
.zoom-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transform-origin: center center;
    will-change: transform;
}
.comparison-slider {
    position: relative;
    display: inline-block;
    line-height: 0;
}

.slider-img {
    max-width: 100%;
    max-height: 55vh;
    width: auto;
    height: auto;
    display: block;
    pointer-events: none;
    user-select: none;
}
#previewOrigImg {
    background-image: linear-gradient(45deg, #e5e5ea 25%, transparent 25%), linear-gradient(-45deg, #e5e5ea 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e5e5ea 75%), linear-gradient(-45deg, transparent 75%, #e5e5ea 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-color: #ffffff;
}
[data-theme="dark"] #previewOrigImg {
    background-image: linear-gradient(45deg, #2c2c2e 25%, transparent 25%), linear-gradient(-45deg, #2c2c2e 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #2c2c2e 75%), linear-gradient(-45deg, transparent 75%, #2c2c2e 75%);
    background-color: #1c1c1e;
}
#previewOptImg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    clip-path: inset(0 0 0 50%);
}

.slider-badge {
    position: absolute;
    top: 12px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.65);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 20px;
    backdrop-filter: blur(4px);
    z-index: 5;
    pointer-events: none;
    letter-spacing: 0.5px;
}
.badge-left { left: 12px; }
.badge-right { right: 12px; }

.slider-handle {
    position: absolute;
    top: 0; bottom: 0; width: 4px;
    background: #ffffff;
    cursor: ew-resize;
    z-index: 10;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.4);
    touch-action: none;
    left: 50%;
}
.handle-line {
    flex: 1;
    width: 2px;
    background: rgba(255, 255, 255, 0.8);
}
.handle-button {
    width: 44px;
    height: 44px;
    background: #ffffff;
    color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
    border: 2px solid var(--primary-color);
    cursor: ew-resize;
    transition: transform 0.12s ease;
}
.slider-handle:hover .handle-button,
.slider-handle:focus-within .handle-button {
    transform: scale(1.1);
    background: #f2f2f7;
}
.slider-handle:focus-visible { outline: none; }
.slider-handle:focus-visible .handle-button { box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.5); } 



/* ==========================================================================
   Footer
   ========================================================================== */
.app-footer {
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 0px));
    margin-top: auto;
    width: 100%;
    transition: background-color 0.3s, border-color 0.3s;
}

.footer-content {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    text-align: center;
}

.footer-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.copyright, .footer-powered { white-space: nowrap; }
.footer-divider { display: none; color: var(--border-color); user-select: none; }

.footer-powered {
    color: var(--text-muted); text-decoration: none; font-weight: 500;
    display: inline-flex; align-items: center; gap: 6px; transition: color 0.2s ease;
    min-height: 24px;
}
.footer-powered:hover { color: var(--primary-color); }
.footer-icon { opacity: 0.85; flex-shrink: 0; }

.footer-right {
    width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px;
}

.footer-support-btn, .footer-coffee-btn {
    font-family: inherit; font-size: 0.85rem; font-weight: 600;
    cursor: pointer; padding: 10px 20px; border-radius: 30px;
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px; min-height: 44px; width: 100%; max-width: 280px; text-decoration: none;
    box-sizing: border-box; transition: transform 0.1s;
}

.footer-support-btn {
    background: var(--bg-color); border: 1px solid var(--border-color); color: var(--text-main);
}
.footer-support-btn:hover { border-color: var(--text-muted); color: var(--primary-color); }

.footer-coffee-btn {
    background: #FFCC00; border: 1px solid #E6B800; color: #1C1C1E;
    box-shadow: 0 2px 8px rgba(255, 204, 0, 0.15);
}
.footer-coffee-btn:hover { background: #E6B800; border-color: #CC9900; color: #000000; box-shadow: 0 4px 12px rgba(255, 204, 0, 0.3); }
.footer-support-btn:active, .footer-coffee-btn:active { transform: scale(0.97); }

@media (min-width: 600px) {
    .footer-content { flex-direction: row; justify-content: space-between; align-items: center; text-align: left; gap: 16px; }
    .footer-left { flex-direction: row; gap: 10px; }
    .footer-divider { display: inline; }
    .footer-right { width: auto; flex-direction: row; gap: 12px; }
    .footer-support-btn, .footer-coffee-btn { width: auto; }
}

/* ==========================================================================
   GPS & Location Input Styles
   ========================================================================== */

.gps-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 6px;
    margin-top: 6px;
    font-weight: 500;
}
.gps-badge.success { background: rgba(52, 199, 89, 0.15); color: var(--success-color); }
.gps-badge.warning { background: rgba(255, 59, 48, 0.15); color: var(--danger-color); }

.queue-location-input {
    margin-top: 8px;
    width: 100%;
    padding: 8px 12px;
    font-size: 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-main);
    transition: border-color 0.2s;
}
.queue-location-input:focus {
    border-color: var(--primary-color);
    outline: none;
}

.queue-item-meta { flex-direction: column; align-items: flex-start; flex: 1; overflow: visible; gap: 0; min-width: 0; }
.queue-item-top { display: flex; align-items: center; gap: 12px; width: 100%; min-width: 0; }
.queue-item-bottom { width: 100%; padding-left: 52px; }

.global-location-container {
    margin-bottom: 16px; 
    padding: 16px; 
    background: var(--bg-color); 
    border-radius: 12px; 
    border: 1px solid var(--border-color);
}
.global-location-label {
    display: block; 
    font-size: 0.9rem; 
    font-weight: 600; 
    margin-bottom: 10px;
}
.global-location-input-group {
    display: flex; 
    gap: 10px;
    flex-wrap: wrap;
}
.global-location-input-group input {
    flex: 1; 
    padding: 10px 14px; 
    border: 1px solid var(--border-color); 
    border-radius: 8px; 
    background: var(--card-bg); 
    color: var(--text-main);
    font-size: 0.95rem;
    min-width: 200px;
}
.global-location-input-group .btn-apply {
    min-height: auto; 
    padding: 10px 20px; 
    width: auto;
    flex-shrink: 0;
}
@media (max-width: 480px) {
    .global-location-input-group .btn-apply {
        width: 100%;
    }
}
