* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: #f5f7fa;
    padding: 5px;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.page-header {
    text-align: center;
    margin: 15px 0 20px 0;
    padding: 0 10px;
}

.page-header h1 {
    color: #2d3748;
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 8px 0;
    padding: 0;
}

.page-header .subtitle {
    color: #718096;
    font-size: 14px;
    margin: 0;
    opacity: 0.9;
    line-height: 1.5;
}

.container {
    display: flex;
    flex-direction: column;
    min-height: calc(100% - 90px);
    gap: 5px;
}

.top-section {
    display: flex;
    height: 65%;
    gap: 5px;
}

.bottom-section {
    display: flex;
    flex-direction: column;
    height: 35%;
    background: white;
    border-radius: 8px;
    padding: 5px;
    display: none;
}

.images-panel {
    flex: 2;
    background: white;
    border-radius: 8px;
    padding: 5px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
}

.settings-panel {
    flex: 3;
    background: white;
    border-radius: 8px;
    padding: 5px;
    overflow-y: auto;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
}

.preview-panel {
    flex: 3;
    background: white;
    border-radius: 8px;
    padding: 5px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
}

.thumbnails-container {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    overflow-y: auto;
    padding: 5px;
    background: #f8fafc;
    border-radius: 6px;
    align-content: flex-start;
}

.thumbnail-item {
    width: 80px;
    height: 80px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
}

.thumbnail-item:hover {
    border-color: #cbd5e0;
    transform: translateY(-1px);
}

.thumbnail-item.active {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

.thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnail-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(45, 55, 72, 0.85);
    color: white;
    font-size: 10px;
    padding: 2px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thumbnail-count {
    position: absolute;
    top: 2px;
    left: 2px;
    background: rgba(45, 55, 72, 0.85);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
}

.thumbnail-delete {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    background: #e53e3e;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    z-index: 10;
}

.thumbnail-delete:hover {
    opacity: 1;
}

.settings-content {
    display: block;
    padding: 5px;
}

.option-group {
    margin: 8px 0;
}

.option-group label {
    display: block;
    margin: 0 0 3px 0;
    color: #4a5568;
    font-weight: 600;
    font-size: 14px;
}

.settings-panel > div > div[style*="display: flex"],
.crop-method-row,
.settings-panel .ratio-buttons,
.settings-panel .custom-mode-buttons,
.settings-panel .ico-size-buttons,
.settings-panel .rename-options.active {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 2px;
}

.settings-panel > div > div[style*="display: flex"] .option-group,
.crop-method-row .option-group {
    flex: 1;
    min-width: 120px;
    margin: 2px 0;
}

.settings-panel .ratio-buttons,
.settings-panel .custom-mode-buttons,
.settings-panel .ico-size-buttons {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 2px;
    width: 100%;
    margin: 8px 0;
}

.settings-panel .ratio-btn,
.settings-panel .mode-btn,
.settings-panel .ico-size-btn,
.action-btn,
.form-control,
.text-input,
.number-input,
select,
.dimension-controls input {
    font-size: 13px;
}

.settings-panel .ratio-btn,
.settings-panel .mode-btn,
.settings-panel .ico-size-btn {
    flex: 1;
    min-width: 50px;
    padding: 5px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    text-align: center;
    color: #4a5568;
    white-space: nowrap;
}

.settings-panel .ratio-btn:hover,
.settings-panel .mode-btn:hover,
.settings-panel .ico-size-btn:hover {
    background: #f7fafc;
}

.settings-panel .ratio-btn.active,
.settings-panel .mode-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.settings-panel .ico-size-btn.active {
    background: #805ad5;
    color: white;
    border-color: #805ad5;
}

.settings-panel > div > div[style*="display: flex"] .form-control,
.settings-panel > div > div[style*="display: flex"] .text-input,
.settings-panel > div > div[style*="display: flex"] .number-input,
.settings-panel > div > div[style*="display: flex"] select,
.crop-method-row .form-control,
.crop-method-row select {
    width: 80%;
    margin: 0;
}

#customNameGroup .form-control,
#caseConvertGroup .form-control {
    width: 100%;
}

#icoSizeSelectGroup {
    flex: 0.8;
}

.preview-info {
    display: flex !important;
    justify-content: flex-start;
    gap: 2px;
    font-size: 11px;
    color: #718096;
    margin: 2px 0;
    padding: 0;
    background: transparent;
    border-radius: 0;
}

.preview-info div {
    flex: 0 1 auto;
    text-align: left;
    white-space: nowrap;
    padding: 0 2px;
}

.crop-method-row {
    display: flex !important;
    gap: 2px;
    margin: 8px 0;
    flex-wrap: nowrap !important;
    width: 100%;
}

.crop-method-container {
    flex: 3;
    min-width: 0;
}

.crop-method-container:first-child,
.crop-method-container:nth-child(2) {
    flex: 3;
}

.crop-dimension-container {
    flex: 4;
    min-width: 0;
}

.dimension-controls {
    display: flex;
    align-items: center;
    gap: 5px;
    width: 100%;
}

.dimension-controls input {
    flex: 1;
    min-width: 0;
    text-align: center;
}

.dimension-controls span {
    flex: 0 0 auto;
}

.form-control,
.text-input,
.number-input,
select,
.dimension-controls input {
    width: 100%;
    padding: 5px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    transition: all 0.3s ease;
    margin: 0;
    text-align: center;
    background: white;
    color: #2d3748;
}

.form-control:focus,
.text-input:focus,
.number-input:focus,
select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.number-input:read-only {
    background-color: #f7fafc;
    color: #a0aec0;
    cursor: not-allowed;
}

.preview-container {
    width: 100%;
    height: 400px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    position: relative;
    overflow: hidden;
    background: #f8fafc;
    margin: 2px 0;
}

.preview-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.preview-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    flex-direction: column;
    color: #2d3748;
    font-size: 14px;
}

.spinner {
    border: 3px solid #f3f4f6;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.message {
    position: fixed;
    top: 20px;
    right: 20px;
    min-width: 300px;
    padding: 15px;
    border-radius: 8px;
    text-align: left;
    font-weight: bold;
    display: none;
    font-size: 14px;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.error {
    background: #fff5f5;
    color: #c53030;
    border: 1px solid #feb2b2;
}

input[type="range"] {
    width: 100%;
    margin: 5px 0;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.file-input {
    display: none;
}

.empty-state {
    color: #a0aec0;
    font-size: 14px;
    text-align: center;
}

.settings-header,
.section-label,
.preview-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.settings-header {
    color: #2d3748;
    margin: 0 0 8px 0;
    padding: 0 0 5px 0;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-label {
    color: #4a5568;
    margin-bottom: 8px;
    padding-left: 5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2px;
}

.preview-header h3 {
    color: #2d3748;
    margin: 0;
    line-height: 30px;
}

.action-buttons {
    display: flex;
    gap: 2px;
    align-items: center;
}

.action-btn {
    border: none;
    border-radius: 4px;
    padding: 4px 7px;
    cursor: pointer;
    white-space: nowrap;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
}

.select-btn {
    background: #38a169;
    color: white;
}

.clear-btn {
    background: #e53e3e;
    color: white;
}

.reset-btn {
    background: #718096;
    color: white;
}

.process-btn {
    background: #667eea;
    color: white;
}

.download-btn {
    display: none;
    background: #ed8936;
    color: white;
}

.rename-options {
    display: none;
    gap: 2px;
    margin-top: 8px;
}

.rename-options.active {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 2px;
}

.rename-options.active .option-group {
    flex: 1;
    min-width: 120px;
}

.cropper-view-box,
.cropper-face {
    border-radius: 4px;
}

.cropper-view-box {
    outline: 2px solid #667eea;
    outline-color: rgba(102, 126, 234, 0.75);
}

.cropper-line,
.cropper-point {
    background-color: #667eea;
}

.cropper-point.point-se {
    background-color: #667eea;
}

.cropper-dashed {
    border-color: rgba(102, 126, 234, 0.5);
}

.cropper-modal {
    background-color: rgba(0, 0, 0, 0.5);
}

.cropper-bg {
    background-image: none;
}

.disabled-control {
    opacity: 0.6;
    pointer-events: none;
    cursor: not-allowed;
}

@media (max-width: 1024px) {
    body {
        overflow-y: auto;
        height: auto;
        min-height: 100vh;
    }
    
    .container {
        height: auto;
        min-height: calc(100vh - 90px);
    }
    
    .top-section {
        display: flex;
        flex-direction: column;
        height: auto;
        gap: 8px;
    }
    
    .settings-panel > div > div[style*="display: flex"] .option-group,
    .crop-method-row .option-group,
    .rename-options.active .option-group {
        min-width: 100px;
    }
    
    #icoSizeSelectGroup {
        flex: 1;
    }
    
    .images-panel {
        height: 250px;
    }
}

@media (max-width: 820px) {
    .page-header h1 {
        font-size: 24px;
    }
    
    .thumbnail-item {
        width: 70px;
        height: 70px;
    }
    
    .images-panel {
        height: 230px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 3px;
    }
    
    .page-header h1 {
        font-size: 22px;
    }
    
    .settings-panel, .preview-panel, .images-panel {
        padding: 5px;
    }
    
    .images-panel {
        height: 220px;
    }
}

@media (max-width: 600px) {
    .settings-panel .ratio-btn,
    .settings-panel .mode-btn,
    .settings-panel .ico-size-btn {
        min-width: 40px;
        padding: 4px 2px;
    }
}

@media (max-width: 450px) {
    .page-header h1 {
        font-size: 20px;
    }
    
    .settings-panel > div > div[style*="display: flex"] .option-group,
    .crop-method-row .option-group,
    .rename-options.active .option-group {
        min-width: 140px;
        flex: 0 1 auto;
    }
    
    .settings-panel .ratio-btn,
    .settings-panel .mode-btn,
    .settings-panel .ico-size-btn {
        min-width: 70px;
        flex: 0 1 auto;
    }
    
    .preview-info div {
        white-space: normal;
        word-break: break-word;
    }
    
    .thumbnail-item {
        width: 60px;
        height: 60px;
    }
    
    .images-panel {
        height: 200px;
    }
    
    .action-btn {
        height: 28px;
    }
    
    #icoSizeSelectGroup {
        flex: 0 1 auto;
        min-width: 140px;
    }
}

@media (max-width: 350px) {
    .page-header h1 {
        font-size: 18px;
    }
    
    .settings-panel .ratio-btn,
    .settings-panel .mode-btn,
    .settings-panel .ico-size-btn {
        min-width: 60px;
    }
    
    .thumbnail-item {
        width: 50px;
        height: 50px;
    }
    
    .thumbnail-name {
        font-size: 10px;
        padding: 1px;
    }
    
    .thumbnail-count {
        font-size: 10px;
        padding: 1px 4px;
    }
    
    .thumbnail-delete {
        width: 14px;
        height: 14px;
        font-size: 10px;
    }
    
    .images-panel {
        height: 180px;
    }
    
    .settings-panel, .preview-panel, .images-panel {
        padding: 4px;
    }
    
    .action-btn {
        height: 26px;
    }
}

@media (max-width: 320px) {
    .settings-panel .ratio-btn,
    .settings-panel .mode-btn,
    .settings-panel .ico-size-btn {
        min-width: 50px;
    }
}