:root {
    --primary: #3b82f6; /* Modern Blue */
    --primary-soft: rgba(59, 130, 246, 0.1);
    --bg-main: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-dim: #64748b;
    --border: #e2e8f0;
    --radius-lg: 32px;
    --radius-md: 20px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Montserrat', sans-serif;
    min-height: 100vh;
    padding: 3rem 1rem;
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: 1000px;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

header {
    text-align: center;
    margin-bottom: 0.5rem;
}

.back {
    display: inline-block;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    transition: color 0.15s;
}
.back:hover { color: var(--primary); }

.brand-text {
    font-size: 3rem;
    font-weight: 900;
    color: var(--text-main);
    letter-spacing: -0.05em;
    text-transform: uppercase;
}

.brand-text::after {
    content: '.';
    color: var(--primary);
}

header .subtitle {
    color: var(--text-dim);
    font-size: 1rem;
    font-weight: 500;
    margin-top: 0.5rem;
}

/* Cards & Layout */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-hover);
}

/* Settings Panel */
.settings-panel h2 {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    font-weight: 700;
    color: var(--text-main);
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 2.5rem;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.setting-item label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.setting-item input, .setting-item select {
    background: #f1f5f9;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    padding: 0.85rem 1.25rem;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
}

.setting-item input:focus, .setting-item select:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px var(--primary-soft);
}

.hint {
    font-size: 0.75rem;
    color: var(--text-dim);
}

/* Slider */
.slider-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: 4px solid white;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed #cbd5e1;
    cursor: pointer;
    text-align: center;
    padding: 5rem 2rem;
    transition: var(--transition);
}

.drop-zone.active {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.upload-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1.5rem;
    color: var(--primary);
}

.drop-zone h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.drop-zone p {
    color: var(--text-dim);
    font-weight: 500;
}

/* Results */
.results-section {
    margin-top: 1rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}

.result-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.thumbnail-container {
    width: 100%;
    aspect-ratio: 16/10;
    background: #f1f5f9;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.thumbnail-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-info {
    flex: 1;
}

.file-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.file-meta {
    font-size: 0.85rem;
    color: var(--text-dim);
    font-weight: 500;
}

.btn {
    padding: 1rem 2rem;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-family: inherit;
}

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

.btn-primary:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
    background: #f1f5f9;
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-danger {
    background: #fee2e2;
    color: #ef4444;
}

.btn-danger:hover {
    background: #fecaca;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.card-actions .btn {
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-small {
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    text-decoration: none;
    text-align: center;
}

.checkbox-row {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    font-weight: 500 !important;
    color: var(--text-dim) !important;
    cursor: pointer;
    margin-top: 0.25rem;
}
.checkbox-row input { width: 16px; height: 16px; cursor: pointer; }

.btn-crop {
    background: #ecfeff;
    color: #0e7490;
    border: 1px solid #a5f3fc;
}
.btn-crop:hover { background: #cffafe; }

/* Cropper modal */
.crop-popup {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.92);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.crop-popup[hidden] { display: none !important; }
.crop-popup-inner {
    background: #ffffff;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 980px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
    z-index: 1;
}
.cropper-header {
    flex: 0 0 auto;
    background: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.cropper-header h3 { font-size: 1.1rem; font-weight: 700; }
.cropper-stage {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    background: #0f172a;
    position: relative;
}
.cropper-stage img { display: block; max-width: 100%; }
.cropper-toolbar {
    flex: 0 0 auto;
    background: #ffffff;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
    align-items: center;
}
.cropper-readout-bar {
    flex: 0 0 auto;
    background: #f8fafc;
    padding: 0.6rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
    align-items: center;
}
.readout-group, .smart-crop { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.readout {
    font-family: 'Courier New', monospace;
    font-weight: 700;
    color: var(--primary);
    background: #fff;
    border: 1px solid var(--border);
    padding: 0.25rem 0.6rem;
    border-radius: 8px;
    font-size: 0.85rem;
}
.smart-crop input[type=number] {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.4rem 0.6rem;
    font-family: inherit;
    font-size: 0.85rem;
    width: 75px;
    color: var(--text-main);
}
.smart-crop input[type=number]:focus { outline: none; border-color: var(--primary); }
.smart-crop select {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.4rem 0.6rem;
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--text-main);
    cursor: pointer;
}
.ratio-group { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.ratio-group .hint { margin-right: 0.25rem; }
.ratio-btn { padding: 0.5rem 0.85rem !important; font-size: 0.8rem !important; }
.ratio-btn.active { background: var(--primary) !important; color: #fff !important; border-color: var(--primary) !important; }
.cropper-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.cropped-badge {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.1rem 0.4rem;
    border-radius: 6px;
    background: #ecfeff;
    color: #0e7490;
    font-size: 0.65rem;
    font-weight: 700;
    vertical-align: middle;
}

@media (max-width: 640px) {
    .app-container { padding: 0 1rem; }
    header h1 { font-size: 2rem; }
    .cropper-stage { max-height: 45vh; }
}
