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

:root {
    --primary-color: #2196F3;
    --secondary-color: #4CAF50;
    --danger-color: #f44336;
    --text-color: #333;
    --bg-color: #f5f5f5;
    --card-bg: #ffffff;
    --border-radius: 12px;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 12px rgba(0,0,0,0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary-color), #1976D2);
    color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.95;
}

main {
    flex: 1;
}

/* Buttons */
.btn {
    padding: 16px 24px;
    font-size: 1.1em;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
    font-weight: 600;
    width: 100%;
    margin: 8px 0;
    touch-action: manipulation;
}

.btn:active {
    transform: scale(0.98);
}

.quasselo-link {
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #1976D2;
    box-shadow: var(--shadow-hover);
}

.btn-secondary {
    background-color: #757575;
    color: white;
}

.btn-secondary:hover {
    background-color: #616161;
    box-shadow: var(--shadow-hover);
}

.btn-success {
    background-color: var(--secondary-color);
    color: white;
}

.btn-success:hover {
    background-color: #45a049;
    box-shadow: var(--shadow-hover);
}

.button-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 20px 0;
}

@media (max-width: 600px) {
    .button-group {
        grid-template-columns: 1fr;
    }
}

/* Sections */
.upload-section,
.preview-section,
.progress-section,
.result-section,
.info-section {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.hidden {
    display: none !important;
}

/* Bildvorschau */
.image-wrapper {
    position: relative;
    display: inline-block;
    margin: 20px auto;
    max-width: 100%;
}

#previewCanvas {
    display: block;
    max-width: 100%;
    max-height: 500px;
    width: auto;
    height: auto;
    background: #000;
    border-radius: 8px;
}

/* Crop Overlay */
.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.crop-overlay.hidden {
    display: none;
}

.crop-box {
    position: absolute;
    border: 3px solid #4CAF50;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
    cursor: move;
    min-width: 30px;
    min-height: 30px;
    pointer-events: auto;
    box-sizing: border-box;
}

.crop-handle {
    position: absolute;
    width: 28px;
    height: 28px;
    background: #4CAF50;
    border: 3px solid white;
    border-radius: 50%;
    z-index: 11;
    pointer-events: auto;
}

.crop-handle.top-left {
    top: -14px;
    left: -14px;
    cursor: nwse-resize;
}

.crop-handle.top-right {
    top: -14px;
    right: -14px;
    cursor: nesw-resize;
}

.crop-handle.bottom-left {
    bottom: -14px;
    left: -14px;
    cursor: nesw-resize;
}

.crop-handle.bottom-right {
    bottom: -14px;
    right: -14px;
    cursor: nwse-resize;
}

/* Edit Controls */
.edit-controls {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: var(--border-radius);
    margin: 1rem 0;
}

.control-group {
    margin-bottom: 1rem;
}

.control-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #333;
    font-size: 1em;
}

.control-group input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #2196F3;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #2196F3;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.control-group .hint {
    display: block;
    font-size: 0.85em;
    color: #666;
    margin-top: 0.25rem;
    font-weight: normal;
}

.button-group-small {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-small {
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
    min-width: 140px;
}

/* Fortschrittsanzeige */
.progress-section {
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    margin: 20px auto;
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#progressText {
    font-size: 1.1em;
    margin: 15px 0;
    color: var(--primary-color);
    font-weight: 600;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background-color: #e0e0e0;
    border-radius: 15px;
    overflow: hidden;
    margin-top: 20px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    width: 0%;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

/* Ergebnis */
.text-result {
    margin: 20px 0;
}

#resultText {
    width: 100%;
    min-height: 200px;
    padding: 16px;
    font-size: 1em;
    border: 2px solid #ddd;
    border-radius: var(--border-radius);
    resize: vertical;
    font-family: inherit;
    line-height: 1.6;
}

#resultText:focus {
    outline: none;
    border-color: var(--primary-color);
}

.feedback {
    margin-top: 15px;
    padding: 12px;
    background-color: var(--secondary-color);
    color: white;
    border-radius: var(--border-radius);
    text-align: center;
    font-weight: 600;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Info-Bereich */
.info-section details {
    cursor: pointer;
}

.info-section summary {
    font-size: 1.1em;
    font-weight: 600;
    padding: 12px;
    background: var(--bg-color);
    border-radius: var(--border-radius);
    user-select: none;
}

.info-section summary:hover {
    background: #e8e8e8;
}

.info-section ul {
    margin-top: 15px;
    padding-left: 20px;
}

.info-section li {
    margin: 8px 0;
    line-height: 1.5;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    margin-top: 40px;
    color: #666;
    font-size: 0.9em;
}

.small {
    font-size: 0.85em;
    margin-top: 5px;
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 15px;
    }

    header h1 {
        font-size: 2em;
    }

    .btn {
        padding: 14px 20px;
        font-size: 1em;
    }

    #previewImage {
        max-height: 300px;
    }
}

/* Touch-Verbesserungen */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 50px;
    }
}
