:root {
    --cut-primary: #2563eb;
    --cut-primary-dark: #1d4ed8;
    --cut-accent: #0f766e;
    --cut-soft: #eff6ff;
    --cut-line: #dbe6f2;
    --cut-text: #0f172a;
    --cut-muted: #64748b;
    --cut-danger: #dc2626;
    --cut-success: #16a34a;
}

body {
    background: linear-gradient(180deg, #f8fafc 0%, #eff6ff 100%);
    min-height: 100vh;
}

.text-gradient {
    color: var(--cut-primary);
    background: none;
    -webkit-text-fill-color: currentColor;
}

.badge-free {
    background: linear-gradient(135deg, var(--cut-accent) 0%, #16a34a 100%);
    color: #fff;
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
    display: inline-block;
    margin-bottom: 10px;
    box-shadow: 0 8px 24px rgba(15, 118, 110, 0.24);
}

.converter-container {
    background: #fff;
    border: 1px solid var(--cut-line);
    border-radius: 8px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.converter-header {
    background: linear-gradient(135deg, var(--cut-primary) 0%, var(--cut-accent) 100%);
    color: #fff;
    padding: 22px 28px;
}

.converter-body {
    padding: 28px;
}

.upload-area {
    position: relative;
    border: 2px dashed #93c5fd;
    border-radius: 8px;
    padding: 52px 26px;
    text-align: center;
    background: linear-gradient(180deg, #f8fbff 0%, #eff6ff 100%);
    cursor: pointer;
    transition: border-color .18s ease, background-color .18s ease, transform .18s ease;
}

.upload-area:hover,
.upload-area.dragover,
.upload-area:focus-visible {
    border-color: var(--cut-primary);
    background: #eaf2ff;
    transform: translateY(-2px);
    outline: none;
}

.upload-icon {
    font-size: 3.6rem;
    color: var(--cut-primary);
    margin-bottom: 18px;
}

.file-input {
    display: none;
}

.upload-helper-actions {
    display: flex;
    justify-content: center;
    margin-top: 14px;
}

.preview-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 24px;
    margin-top: 28px;
    align-items: start;
}

.preview-stage-card {
    min-width: 0;
    border: 1px solid var(--cut-line);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.preview-stage-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--cut-line);
    background: #f8fafc;
}

.preview-stage-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.preview-stage-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 420px;
    max-height: 720px;
    padding: 18px;
    overflow: auto;
    background:
        linear-gradient(45deg, #f8fafc 25%, transparent 25%) -12px 0/24px 24px,
        linear-gradient(-45deg, #f8fafc 25%, transparent 25%) -12px 0/24px 24px,
        linear-gradient(45deg, transparent 75%, #f8fafc 75%) -12px 0/24px 24px,
        linear-gradient(-45deg, transparent 75%, #f8fafc 75%) -12px 0/24px 24px,
        #ffffff;
}

.preview-canvas {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
}

.color-picker-tip {
    position: absolute;
    top: 18px;
    left: 18px;
    z-index: 2;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.8);
    color: #fff;
    font-size: 0.88rem;
    font-weight: 600;
}

.options-panel {
    border: 1px solid var(--cut-line);
    border-radius: 8px;
    padding: 18px;
    background: #f8fafc;
}

.option-group {
    margin-bottom: 20px;
}

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

.option-label {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 10px;
}

.quality-value {
    margin-left: auto;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--cut-primary);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 700;
}

.quality-slider {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: linear-gradient(90deg, #cbd5e1 0%, #60a5fa 55%, #0f766e 100%);
    outline: none;
    -webkit-appearance: none;
}

.quality-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--cut-primary);
    box-shadow: 0 3px 12px rgba(15, 23, 42, 0.18);
    cursor: pointer;
}

.quality-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--cut-primary);
    box-shadow: 0 3px 12px rgba(15, 23, 42, 0.18);
    cursor: pointer;
}

.color-input-row {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 12px;
}

.option-select {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: var(--cut-text);
    transition: border-color .16s ease, box-shadow .16s ease;
}

.option-select:focus {
    outline: none;
    border-color: var(--cut-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.option-checks {
    display: grid;
    gap: 10px;
}

.option-check {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid #dbe6f2;
    border-radius: 8px;
    background: #fff;
    color: #334155;
    font-weight: 600;
}

.actions-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
}

.btn-action,
.btn-tool {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    transition: transform .16s ease, box-shadow .16s ease, background-color .16s ease, color .16s ease, border-color .16s ease;
}

.btn-action:hover,
.btn-tool:hover {
    transform: translateY(-1px);
}

.btn-action:disabled,
.btn-tool:disabled {
    opacity: .55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-action {
    width: 100%;
    min-height: 46px;
    padding: 12px 18px;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
}

.btn-compress {
    background: linear-gradient(135deg, var(--cut-primary) 0%, var(--cut-primary-dark) 100%);
    color: #fff;
}

.btn-download {
    background: linear-gradient(135deg, var(--cut-accent) 0%, #16a34a 100%);
    color: #fff;
}

.btn-history {
    background: linear-gradient(135deg, #0284c7 0%, var(--cut-primary) 100%);
    color: #fff;
}

.btn-tool {
    min-height: 38px;
    padding: 9px 14px;
    border: 1px solid transparent;
}

.btn-tool-secondary {
    background: var(--cut-primary-soft, #eff6ff);
    color: var(--cut-primary);
    border-color: #bfdbfe;
}

.btn-tool-ghost {
    background: #fff;
    color: #475569;
    border-color: #dbe6f2;
}

.status-bar {
    display: none;
    margin-top: 24px;
    border: 1px solid var(--cut-line);
    border-radius: 8px;
    padding: 18px;
    background: #fff;
}

.status-bar.show {
    display: block;
}

.status-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-icon {
    font-size: 1.35rem;
}

.status-text {
    color: #334155;
    font-size: 0.95rem;
}

.status-number {
    color: var(--cut-text);
    font-weight: 800;
}

.progress-container {
    display: none;
    margin-top: 22px;
}

.progress-container.show {
    display: block;
}

.progress-bar-custom {
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: #dbe6f2;
}

.progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(135deg, var(--cut-primary) 0%, var(--cut-accent) 100%);
    transition: width .2s ease;
}

.result-container {
    margin-top: 28px;
}

.result-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
}

.slice-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
    border: 1px solid var(--cut-line);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.slice-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    padding: 12px;
    background:
        linear-gradient(45deg, #f8fafc 25%, transparent 25%) -10px 0/20px 20px,
        linear-gradient(-45deg, #f8fafc 25%, transparent 25%) -10px 0/20px 20px,
        linear-gradient(45deg, transparent 75%, #f8fafc 75%) -10px 0/20px 20px,
        linear-gradient(-45deg, transparent 75%, #f8fafc 75%) -10px 0/20px 20px,
        #ffffff;
}

.slice-preview img {
    max-width: 100%;
    max-height: 220px;
    object-fit: contain;
}

.slice-body {
    display: grid;
    gap: 8px;
    padding: 14px;
}

.slice-name {
    color: var(--cut-text);
    font-weight: 700;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.slice-meta {
    color: var(--cut-muted);
    font-size: 0.88rem;
    line-height: 1.6;
}

.slice-actions {
    display: flex;
    gap: 10px;
}

.slice-actions .btn-tool {
    flex: 1;
}

.feature-card {
    height: 100%;
    border: 1px solid var(--cut-line);
    border-radius: 8px;
    padding: 24px 20px;
    text-align: center;
    background: #fff;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.feature-card:hover {
    transform: translateY(-3px);
    border-color: rgba(37, 99, 235, 0.28);
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.08);
}

.feature-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 62px;
    height: 62px;
    margin-bottom: 14px;
    border-radius: 8px;
    background: #eff6ff;
    color: var(--cut-primary);
    font-size: 1.7rem;
}

.feature-title {
    color: var(--cut-text);
    font-size: 1.08rem;
    font-weight: 800;
    margin-bottom: 10px;
}

.feature-desc {
    color: var(--cut-muted);
    font-size: 0.92rem;
    line-height: 1.7;
    margin-bottom: 0;
}

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    max-width: min(92vw, 360px);
    margin-bottom: 10px;
    padding: 14px 16px;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.18);
    border-left: 4px solid var(--cut-primary);
    animation: toastIn .2s ease;
}

.toast.success {
    border-left-color: var(--cut-success);
}

.toast.error {
    border-left-color: var(--cut-danger);
}

.toast-icon {
    font-size: 1.25rem;
}

.toast.success .toast-icon {
    color: var(--cut-success);
}

.toast.error .toast-icon {
    color: var(--cut-danger);
}

.toast-title {
    color: var(--cut-text);
    font-weight: 800;
}

.toast-message {
    color: var(--cut-muted);
    font-size: 0.9rem;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 991.98px) {
    .preview-shell {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 767.98px) {
    .converter-body {
        padding: 18px;
    }

    .upload-helper-actions .btn-tool {
        width: 100%;
    }

    .preview-stage-header,
    .result-header {
        flex-direction: column;
        align-items: stretch;
    }

    .preview-stage-actions,
    .slice-actions {
        justify-content: stretch;
    }

    .preview-stage-actions .btn-tool,
    .slice-actions .btn-tool {
        flex: 1;
    }

    .preview-stage-wrapper {
        min-height: 280px;
        padding: 12px;
    }

    .status-info {
        grid-template-columns: 1fr;
    }

    .color-input-row {
        grid-template-columns: 64px minmax(0, 1fr);
    }
}

@media (max-width: 575.98px) {
    html,
    body {
        overflow-x: clip;
    }

    .feature-badge {
        max-width: calc(50vw - 20px);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .upload-area {
        padding: 38px 18px;
    }

    .upload-icon {
        font-size: 3rem;
    }

    .result-grid {
        grid-template-columns: 1fr;
    }

    .toast-container {
        left: 12px;
        right: 12px;
        top: 12px;
    }

    .toast {
        min-width: 0;
        max-width: none;
    }
}
