/* Reset and base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Fondos - más contraste */
    --bg-primary: #F8FAFC;       /* Gris muy suave como base */
    --bg-secondary: #FFFFFF;     /* Blanco para tarjetas/secciones */
    --bg-tertiary: #E2E8F0;      /* Gris más marcado para controles */

    /* Texto */
    --text-primary: #1E293B;
    --text-secondary: #64748B;

    /* Acento azul */
    --accent: #3B82F6;
    --accent-hover: #2563EB;
    --accent-light: #DBEAFE;

    /* Estados */
    --success: #10B981;
    --warning: #F59E0B;

    /* Bordes y sombras - más visibles */
    --border: #CBD5E1;
    --shadow: rgba(0, 0, 0, 0.1);
}

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

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
}

.header-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.app-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.subtitle {
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* Upload Section */
.upload-section {
    margin-bottom: 2rem;
}

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    transition: all 0.2s ease;
    cursor: pointer;
    background: var(--bg-secondary);
    box-shadow: 0 2px 8px var(--shadow);
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-light);
}

.drop-zone-content {
    pointer-events: none;
}

.drop-zone-content p {
    pointer-events: auto;
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.link-btn {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    text-decoration: underline;
    font-size: inherit;
}

.link-btn:hover {
    color: var(--accent-hover);
}

/* Page Selection Section */
.page-selection-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px var(--shadow);
}

.page-selection-header {
    margin-bottom: 1.5rem;
}

.page-selection-header h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.page-selection-help {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.page-selection-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

/* Page Thumbnails Grid */
.page-thumbnails {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-thumbnail {
    position: relative;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    border: 3px solid var(--border);
}

.page-thumbnail:hover {
    box-shadow: 0 4px 12px var(--shadow);
}

.page-thumbnail.detect {
    border-color: var(--success);
}

.page-thumbnail.export-only {
    border-color: var(--warning);
}

.page-thumbnail.skip {
    border-color: var(--border);
    opacity: 0.6;
}

.page-thumbnail-image {
    width: 100%;
    aspect-ratio: 210 / 297;
    object-fit: cover;
    display: block;
    background: white;
}

.page-thumbnail-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.page-thumbnail:hover .page-thumbnail-overlay {
    opacity: 1;
}

.page-thumbnail-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.page-thumbnail-btn {
    padding: 0.4rem 0.8rem;
    border: none;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.page-thumbnail-btn.active {
    background: var(--success);
    color: white;
}

.page-thumbnail-btn:not(.active) {
    background: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.page-thumbnail-btn:hover {
    opacity: 0.9;
}

.page-thumbnail-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.5rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-thumbnail-number {
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
}

.page-thumbnail-badges {
    display: flex;
    gap: 4px;
}

.page-badge {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
}

.page-badge.detect {
    background: var(--success);
    color: white;
}

.page-badge.export {
    background: var(--warning);
    color: white;
}

/* Page Selection Legend */
.page-selection-legend {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 2px solid;
}

.legend-color.legend-detect {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.15);
}

.legend-color.legend-export {
    border-color: var(--warning);
    background: rgba(245, 158, 11, 0.2);
}

.legend-color.legend-skip {
    border-color: var(--border);
    background: rgba(107, 114, 128, 0.1);
}

.page-selection-continue {
    text-align: center;
}

/* Section Navigation */
.section-nav {
    margin-bottom: 1rem;
}

/* Processing Section */
.processing-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px var(--shadow);
}

.file-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.file-name {
    font-weight: 500;
    word-break: break-all;
}

/* Parameters */
.parameters {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.parameters h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

.param-group:last-child {
    margin-bottom: 0;
}

.param-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.param-group small {
    display: block;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.param-control {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.param-control input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    outline: none;
}

.param-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
}

.param-control input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--accent-hover);
}

.param-control input[type="number"] {
    width: 70px;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    text-align: center;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.param-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 0.5rem;
    accent-color: var(--accent);
    vertical-align: middle;
}

/* Preview Section */
.preview-section {
    margin-bottom: 1.5rem;
}

.preview-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.preview-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.page-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#pageIndicator {
    min-width: 120px;
    text-align: center;
    color: var(--text-secondary);
}

.preview-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    padding-bottom: 3rem;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    overflow: auto;
    position: relative;
}

.preview-placeholder {
    color: var(--text-secondary);
    text-align: center;
}

.preview-canvas-wrapper {
    position: relative;
    display: inline-block;
}

.preview-canvas {
    max-width: 100%;
    height: auto;
    display: block;
}

.system-overlay {
    position: absolute;
    left: 0;
    right: 0;
    background: rgba(59, 130, 246, 0.12);
    border-top: 2px solid var(--accent);
    border-bottom: 2px solid var(--accent);
    pointer-events: auto;
    transition: background 0.2s;
}

.system-overlay:hover {
    background: rgba(59, 130, 246, 0.2);
}

.system-overlay.dragging {
    background: rgba(59, 130, 246, 0.3);
}

.system-label {
    position: absolute;
    left: 8px;
    top: 4px;
    background: var(--accent);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    pointer-events: none;
}

/* Drag handles */
.system-handle {
    position: absolute;
    left: 0;
    right: 0;
    height: 12px;
    cursor: ns-resize;
    background: transparent;
    transition: background 0.2s;
    z-index: 10;
}

.system-handle::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: var(--accent);
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.2s;
}

.system-handle:hover::after,
.system-overlay.dragging .system-handle::after {
    opacity: 1;
}

.system-handle-top {
    top: -6px;
}

.system-handle-top::after {
    top: 4px;
}

.system-handle-bottom {
    bottom: -6px;
}

.system-handle-bottom::after {
    bottom: 4px;
}

.system-handle:hover {
    background: rgba(59, 130, 246, 0.25);
}

/* Action buttons */
.system-actions {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.system-overlay:hover .system-actions {
    opacity: 1;
}

.system-action-btn {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
    line-height: 1;
}

.system-action-btn:hover {
    background: var(--bg-tertiary);
}

.system-action-delete:hover {
    background: var(--accent);
    color: white;
}

/* Add system button */
.btn-add-system {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    background: var(--bg-primary);
    border: 1px dashed var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-add-system:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

/* Projection Graph */
.projection-container {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.projection-container h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

#projectionCanvas {
    width: 100%;
    height: 150px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px var(--shadow);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-tertiary);
    border-color: var(--text-secondary);
}

.btn-icon {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 1px 2px var(--shadow);
}

.btn-icon:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-secondary);
}

/* Progress Bar */
.progress {
    margin-top: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-bar::after {
    content: '';
    display: block;
    height: 100%;
    width: var(--progress, 0%);
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Rotation Panel */
.rotation-panel {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--accent-light);
    border-radius: 8px;
    border: 1px solid var(--accent);
}

.rotation-header {
    margin-bottom: 1rem;
}

.rotation-header h4 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.rotation-header p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.rotation-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.rotation-controls input[type="range"] {
    flex: 1;
    min-width: 120px;
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    background: linear-gradient(to right, var(--accent-hover), var(--border), var(--accent-hover));
    border-radius: 4px;
    outline: none;
    border: 1px solid var(--border);
}

.rotation-controls input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    border: 2px solid white;
}

.rotation-controls input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--accent-hover);
    transform: scale(1.1);
}

/* Firefox slider */
.rotation-controls input[type="range"]::-moz-range-track {
    height: 8px;
    background: linear-gradient(to right, var(--accent-hover), var(--border), var(--accent-hover));
    border-radius: 4px;
    border: 1px solid var(--border);
}

.rotation-controls input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.rotation-controls input[type="number"] {
    width: 60px;
    padding: 0.4rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    text-align: center;
    font-size: 0.9rem;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.rotation-unit {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.rotation-preset {
    font-size: 0.75rem;
    width: auto;
    padding: 0.3rem 0.5rem;
    min-width: 36px;
}

.rotation-preset:hover {
    background: var(--accent);
    color: white;
}

.rotation-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* Rotation mode preview */
.preview-canvas-wrapper.rotation-mode {
    position: relative;
}

.preview-canvas-wrapper.rotation-mode::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--success), var(--success), transparent);
    pointer-events: none;
    z-index: 100;
}

.preview-canvas-wrapper.rotation-mode::after {
    content: 'Línea de referencia';
    position: absolute;
    left: 50%;
    top: calc(50% + 8px);
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--success);
    background: var(--bg-primary);
    border: 1px solid var(--success);
    padding: 2px 6px;
    border-radius: 3px;
    pointer-events: none;
    z-index: 100;
}

/* Generate Section */
.generate-section {
    text-align: center;
}

/* Filename Input */
.filename-input-group {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.filename-input-group label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.filename-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    max-width: 400px;
    width: 100%;
}

.filename-input {
    flex: 1;
    padding: 0.6rem 0.75rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    min-width: 0;
}

.filename-input:focus {
    background: var(--accent-light);
}

.filename-extension {
    padding: 0.6rem 0.75rem;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.9rem;
    border-left: 1px solid var(--border);
}

/* Rotation Quick Actions */
.rotation-quick-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

/* Footer */
footer {
    margin-top: 2rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.footer-main {
    margin-bottom: 0.5rem;
}

.footer-credits {
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.footer-credits a {
    color: var(--accent);
    text-decoration: none;
}

.footer-credits a:hover {
    text-decoration: underline;
}

.footer-support {
    margin-top: 0.5rem;
}

.kofi-link {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background: #FF5E5B;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s;
}

.kofi-link:hover {
    background: #e54542;
    transform: translateY(-1px);
}


/* Utilities */
.hidden {
    display: none !important;
}

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

    h1 {
        font-size: 1.8rem;
    }

    .drop-zone {
        padding: 2rem 1rem;
    }

    .param-control {
        flex-direction: column;
        align-items: stretch;
    }

    .param-control input[type="number"] {
        width: 100%;
    }

    .page-thumbnails {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.75rem;
    }

    .page-selection-actions {
        flex-direction: column;
    }

    .page-selection-legend {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Loading spinner */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-secondary);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 0.5rem;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Crop Panel */
.crop-panel {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--accent-light);
    border-radius: 8px;
    border: 1px solid var(--accent);
}

.crop-header {
    margin-bottom: 1rem;
}

.crop-header h4 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.crop-header p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.crop-controls {
    margin-bottom: 1rem;
}

.crop-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.crop-control {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.crop-control label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.crop-input-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.crop-input-group input[type="number"] {
    flex: 1;
    padding: 0.4rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    text-align: center;
    font-size: 0.9rem;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
    min-width: 60px;
}

.crop-preset {
    font-size: 0.7rem;
    width: auto;
    padding: 0.25rem 0.4rem;
    min-width: 32px;
}

.crop-preset:hover {
    background: var(--accent);
    color: white;
}

.crop-quick-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.crop-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* Crop mode preview */
.preview-canvas-wrapper.crop-mode {
    position: relative;
}

.crop-overlay {
    position: absolute;
    background: rgba(59, 130, 246, 0.15);
    border: 2px dashed var(--accent);
    pointer-events: none;
    z-index: 50;
}

.crop-overlay-info {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--accent);
    background: var(--bg-primary);
    border: 1px solid var(--accent);
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
    margin-bottom: 4px;
}

/* Crop drag handles */
.crop-handle {
    position: absolute;
    background: var(--accent);
    pointer-events: auto;
    z-index: 60;
    transition: background 0.2s, transform 0.2s;
}

.crop-handle:hover {
    background: var(--accent-hover);
}

.crop-handle-top,
.crop-handle-bottom {
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 10px;
    cursor: ns-resize;
    border-radius: 5px;
}

.crop-handle-top {
    top: -5px;
}

.crop-handle-bottom {
    bottom: -5px;
}

.crop-handle-left,
.crop-handle-right {
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 60px;
    cursor: ew-resize;
    border-radius: 5px;
}

.crop-handle-left {
    left: -5px;
}

.crop-handle-right {
    right: -5px;
}

/* Corner handles */
.crop-handle-corner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

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

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

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

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

.crop-handle:active {
    transform: scale(1.1);
}

.crop-handle-top:active,
.crop-handle-bottom:active {
    transform: translateX(-50%) scale(1.1);
}

.crop-handle-left:active,
.crop-handle-right:active {
    transform: translateY(-50%) scale(1.1);
}

/* Mobile responsive for crop panel */
@media (max-width: 600px) {
    .crop-grid {
        grid-template-columns: 1fr;
    }

    .crop-input-group {
        justify-content: center;
    }
}

/* Watermark option */
.param-watermark {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    margin-top: 0.5rem;
}

.param-watermark label {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 2rem;
    max-width: 420px;
    width: 100%;
    text-align: center;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-icon {
    margin-bottom: 1rem;
}

.modal h3 {
    font-size: 1.3rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.modal p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.modal-note {
    font-size: 0.85rem;
    margin-bottom: 1.5rem !important;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.btn-kofi {
    background: #FF5E5B;
    color: white;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-kofi:hover {
    background: #e54542;
}

#skipDonation {
    font-size: 0.9rem;
    padding: 0.625rem 1rem;
}

/* Disclaimer */
.disclaimer {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.disclaimer p {
    margin-bottom: 0.5rem;
}

.disclaimer p:last-child {
    margin-bottom: 0;
}

.disclaimer strong {
    color: var(--text-primary);
}

/* Help Button */
.btn-help {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    margin-left: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1;
}

.btn-help:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

/* Language Selector in Header */
.language-selector-header {
    margin-left: 0.5rem;
}

.language-selector-header select {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.35rem center;
    padding-right: 1.5rem;
}

.language-selector-header select:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.language-selector-header select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}

/* Help Modal */
.modal-help {
    max-width: 600px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    text-align: left;
}

.modal-help-content {
    overflow-y: auto;
    padding-right: 0.5rem;
}

.modal-help h2 {
    font-size: 1.8rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    text-align: center;
}

.modal-help-tagline {
    text-align: center;
    color: var(--accent);
    font-weight: 500;
    margin-bottom: 1.5rem !important;
}

.modal-help section {
    margin-bottom: 1.5rem;
}

.modal-help h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-help p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-align: left;
}

.modal-help ul,
.modal-help ol {
    color: var(--text-secondary);
    margin-left: 0;
    padding-left: 1.5rem;
    margin-bottom: 0.5rem;
}

.modal-help li {
    margin-bottom: 0.5rem;
}

.modal-help li strong {
    color: var(--text-primary);
}

.modal-help-footer {
    text-align: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    margin-top: 1rem;
}

.modal-help-footer p {
    text-align: center;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.modal-help-footer a {
    color: var(--accent);
    text-decoration: none;
}

.modal-help-footer a:hover {
    text-decoration: underline;
}

/* Responsive help modal */
@media (max-width: 600px) {
    .modal-help {
        max-height: 90vh;
        padding: 1.5rem;
    }

    .modal-help h2 {
        font-size: 1.5rem;
    }
}
