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

:root {
    --primary-color: #0cec91;
    --primary-hover: #636363;
    --secondary-color: #636363;
    --success-color: #0cec91;
    --danger-color: #d8613c;
    --bg-color: #e6f8c5;
    --card-bg: #ffffff;
    --text-color: #42414f;
    --text-muted: #636363;
    --border-color: #b1c5a4;
    --active-color: #111111;
    --sage-green: #b1c5a4;
    --dark-green: #0f2f25;
    --medium-green: #7ab87a;
    --bg-secondary: #f5fbf0;
    --bg-hover: #f0f7ea;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg:
        0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

body {
    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "Roboto",
        sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    padding: clamp(1rem, 3vw, 2.5rem);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--card-bg);
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* Header */
header {
    background: #ffffff;
    color: #42414f;
    text-align: center;
    padding: 3rem 2rem;
    position: relative;
}

header h1 {
    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "Roboto",
        sans-serif;
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
    color: #42414f;
}

.lang-switcher {
    display: inline-flex;
    gap: 0.5rem;
    padding: 0.2rem;
    border-radius: 999px;
    border: 1px solid rgba(15, 47, 37, 0.2);
    background: rgba(245, 251, 240, 0.8);
    position: absolute;
    top: 1.5rem;
    right: clamp(1rem, 3vw, 2.5rem);
}

.lang-btn {
    border: none;
    background: transparent;
    color: #0f2f25;
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.lang-btn.lang-active {
    background: #0f2f25;
    color: #ffffff;
}

.lang-btn:focus-visible {
    outline: 2px solid #0cec91;
    outline-offset: 2px;
}

.badge-row {
    display: inline-flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(66, 65, 79, 0.12);
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    justify-content: center;
}

.badge-logo {
    height: 48px;
    width: auto;
    object-fit: contain;
}

.badge-separator {
    font-weight: 700;
    color: #0f2f25;
    font-size: 1.5rem;
}

.badge-text {
    font-weight: 600;
    color: #0f2f25;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
}

.intro-purpose {
    max-width: 900px;
    margin: 0 auto 1.5rem;
    font-size: 1.15rem;
    color: #42414f;
}

.intro-highlights {
    list-style: none;
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 2rem;
    color: #42414f;
    font-weight: 500;
}

.intro-highlights li {
    background: #f5fbf0;
    border-radius: 999px;
    padding: 0.5rem 1.25rem;
    border: 1px solid rgba(66, 65, 79, 0.15);
}

.intro-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.intro-step-card {
    background: #f5fbf0;
    border-radius: 1rem;
    padding: 1.25rem;
    text-align: left;
    border: 1px solid rgba(66, 65, 79, 0.1);
    box-shadow: var(--shadow-lg);
}

.intro-step-number {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.75rem;
    background: linear-gradient(135deg, #0cec91, #7ab87a);
    color: #0f2f25;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
}

.intro-step-card h3 {
    margin-bottom: 0.35rem;
    font-size: 1.1rem;
}

.intro-step-card p {
    color: #55525f;
    font-size: 0.95rem;
}

.example-section {
    padding: 2.5rem clamp(1rem, 3vw, 2.5rem);
    background: #ffffff;
    border-bottom: 1px solid rgba(66, 65, 79, 0.1);
}

.example-heading {
    text-align: center;
    max-width: 800px;
    margin: 0 auto 2rem;
}

.example-heading p {
    color: #55525f;
}

.example-heading h2 {
    font-size: 2rem;
    margin: 0.5rem 0 0.75rem;
    text-wrap: balance;
}

.example-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.example-card {
    background: #f5fbf0;
    border-radius: 1.25rem;
    padding: 1.5rem;
    border: 1px solid rgba(66, 65, 79, 0.12);
    box-shadow: var(--shadow-lg);
}

.example-card header {
    padding: 1rem 1rem;
}

.example-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #0f2f25;
    font-weight: 600;
}

.example-pair {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin: 1.25rem 0;
}

.example-pair figure {
    margin: 0;
    border-radius: 1rem;
    overflow: hidden;
    border: 1px solid rgba(66, 65, 79, 0.1);
    background: #ffffff;
}

.example-pair img {
    display: block;
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.example-pair figcaption {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #55525f;
    background: rgba(12, 236, 145, 0.08);
}

.example-caption {
    color: #42414f;
    font-weight: 500;
}

/* Main Content */
main {
    padding: clamp(1.25rem, 2.5vw, 2rem);
    position: relative;
}

.step-section {
    margin-bottom: 1.5rem;
    padding: clamp(1.25rem, 2.5vw, 2rem);
    background: #f5fbf0;
    border-radius: 1.25rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

.step-header {
    display: flex;
    gap: 1.25rem;
    align-items: center;
    flex-wrap: wrap;
}

.step-badge {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #0cec91, #7ab87a);
    color: #0f2f25;
    font-weight: 700;
    font-size: 1.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
}

.step-header h2 {
    margin-bottom: 0.25rem;
}

.step-body {
    margin-top: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

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

.upload-area {
    border: 3px dashed var(--border-color);
    border-radius: 1rem;
    padding: 3rem 2rem;
    text-align: center;
    transition: all 0.3s ease;
    background: white;
    cursor: pointer;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: #0cec91;
    background: #f0f7ea;
    transform: translateY(-2px);
}

.upload-area svg {
    color: #0cec91;
    margin-bottom: 1rem;
}

.upload-area h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.upload-area p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.tech-info-separator {
    color: var(--text-muted);
}

@media (max-width: 600px) {
    .lang-switcher {
        position: static;
        margin-bottom: 1rem;
        width: 100%;
        justify-content: center;
    }
}

/* Buttons */
.btn {
    padding: 0.6rem 1rem;
    border: none;
    border-radius: 0.33rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-block;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: #0cec91;
    color: #14343e;
}

.btn-primary:hover {
    background: #636363;
    color: #f9f9f9;
}

.btn-primary:active {
    background: #111111;
    color: #f9f9f9;
}

#cropModeBtn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 3.5rem;
}

.btn-secondary {
    background: #636363;
    color: #f9f9f9;
}

.btn-secondary:hover {
    background: #111111;
    color: #f9f9f9;
}

.btn-success {
    background: #0cec91;
    color: #14343e;
}

.btn-success:hover {
    background: #636363;
    color: #f9f9f9;
}

.btn-filter {
    background: #0cec91;
    color: #14343e;
    border: 2px solid #0cec91;
    width: 100%;
    margin-bottom: 0.5rem;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 3.5rem;
}

.slider-control .btn-primary {
    width: 100%;
    margin-bottom: 0.5rem;
}

.btn-filter:hover {
    background: #636363;
    color: #f9f9f9;
    border-color: #636363;
}

.recommended-badge {
    display: block;
    background: rgba(245, 158, 11, 0.9);
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    margin-top: 0.25rem;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* Controls Section */
.controls-section {
    margin-bottom: 0;
    padding: clamp(1.25rem, 2.5vw, 2rem);
    background: white;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
}

.control-panels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.control-panel {
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    background: #ffffff;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.control-panel summary {
    list-style: none;
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
}

.control-panel summary::-webkit-details-marker {
    display: none;
}

.panel-title {
    font-size: 1.15rem;
    margin-bottom: 0.25rem;
}

.panel-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.panel-icon {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.panel-icon::before {
    content: "⌃";
}

.control-panel[open] .panel-icon {
    transform: rotate(180deg);
}

.panel-body {
    padding: 1.25rem 1.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.control-stack {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.control-stack:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.control-stack-label {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-color);
}

.control-button-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
}

.slider-label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-color);
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #0cec91;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: var(--shadow);
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #0cec91;
    cursor: pointer;
    border: 2px solid white;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Download Section */
.download-section {
    margin-top: 0;
    padding: clamp(1.25rem, 2.5vw, 2rem);
    background: white;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
}

.download-button-container {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

/* Download Options */
.download-options {
    margin-top: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.download-options legend {
    font-weight: 600;
    padding: 0 0.5rem;
    color: var(--text-color);
}

.radio-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid #d8e3d1;
    border-radius: 0.5rem;
    background: #f5fbf0;
}

.radio-row input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
    flex-shrink: 0;
}

.radio-row div {
    display: flex;
    flex-direction: column;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.radio-row strong {
    font-size: 1rem;
    color: var(--text-color);
    margin-bottom: 0.15rem;
}

/* Images Section */
.images-section {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 2rem;
    align-items: start;
    margin-bottom: 2rem;
}

.image-container {
    background: white;
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.image-container h3 {
    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "Roboto",
        sans-serif;
    margin-bottom: 1rem;
    color: var(--text-color);
    text-align: center;
}

.image-wrapper {
    position: relative;
}

canvas {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
    display: block;
    margin: 0 auto;
    background: white;
}

.image-info {
    margin-top: 1rem;
    padding: 0.75rem;
    background: white;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-align: center;
}

.arrow {
    font-size: 2rem;
    color: #0cec91;
    align-self: center;
    font-weight: bold;
}

/* Crop Selection Overlay */
.crop-overlay {
    cursor: grab;
    z-index: 100;
    border-radius: 0.5rem;
    display: block;
    margin: 0 auto;
    background: transparent !important;
}

.crop-selection {
    border: 2px dashed #0cec91;
    background: rgba(12, 236, 145, 0.1);
    position: absolute;
}

/* Loading Overlay */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay p {
    color: white;
    margin-top: 1rem;
    font-size: 1.1rem;
}

/* Error Message */
.error-message {
    display: none;
    background: #fee2e2;
    color: #991b1b;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    border-left: 4px solid var(--danger-color);
}

.error-message.active {
    display: block;
}

/* Footer */
footer {
    background: var(--bg-color);
    padding: 2rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

footer p {
    margin-bottom: 0.5rem;
    color: #636363;
}

footer a {
    color: #0cec91;
    text-decoration: none;
    font-weight: 500;
}

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

.tech-info {
    font-size: 0.9rem;
}

.version-info {
    font-size: 0.8rem;
    color: #999;
    font-family: monospace;
    margin-top: 0.5rem;
}

/* Responsive Design */
@media (max-width: 900px) {
    .images-section {
        grid-template-columns: 1fr;
    }

    .arrow {
        display: none;
    }
}

@media (max-width: 768px) {
    header {
        padding: 1.75rem 1rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .intro-highlights {
        flex-direction: column;
        align-items: stretch;
    }

    .intro-highlights li {
        text-align: center;
    }

    .intro-steps {
        grid-template-columns: 1fr;
    }

    .example-pair {
        grid-template-columns: 1fr;
    }

    main {
        padding: 1rem;
    }

    .controls-section,
    .download-section {
        padding: 1rem;
    }

    .control-panels {
        grid-template-columns: 1fr;
    }

    .control-panel summary {
        padding: 1rem;
    }

    .panel-body {
        padding: 1rem;
    }

    .radio-row {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 640px) {
    .step-section {
        padding: 1.25rem;
    }

    .step-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .step-badge {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1.1rem;
    }

    body {
        padding: 1rem 0.5rem;
    }

    main {
        padding: 1rem;
    }

    header {
        padding: 2rem 1rem;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .badge-row {
        flex-direction: column;
        border-radius: 1rem;
    }

    .badge-logo {
        height: 40px;
    }

    .badge-separator {
        font-size: 1.25rem;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

    .action-buttons {
        flex-direction: column;
    }

    .action-buttons .btn {
        width: 100%;
    }

    .download-button-container {
        flex-direction: column;
    }

    .download-button-container .btn {
        width: 100%;
    }

    .download-options {
        padding: 1.25rem;
    }
}
