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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #ffffff;
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 2800px;
    margin: 0 auto;
    background: white;
    border: 4px solid #000000;
    border-radius: 0;
    box-shadow: 0 0 0 rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: #000000;
    color: white;
    padding: 30px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.nav-bar {
    display: flex;
    gap: 20px;
}

.nav-btn {
    padding: 10px 20px;
    border: 2px solid #ffffff;
    background: transparent;
    color: #ffffff;
    border-radius: 0;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s;
}

.nav-btn:hover {
    background: #ffffff;
    color: #000000;
}

.nav-btn.active {
    background: #ffffff;
    color: #000000;
}

.header-title {
    text-align: left;
}

header h1 {
    font-size: 2em;
    margin-bottom: 8px;
}

header p {
    opacity: 0.9;
    font-size: 1em;
}

.language-switch {
    display: flex;
    gap: 5px;
    background: #000000;
    border: 2px solid #000000;
    border-radius: 0;
    padding: 4px;
}

.lang-btn {
    padding: 8px 16px;
    border: 2px solid #000000;
    background: #ffffff;
    color: #000000;
    cursor: pointer;
    border-radius: 0;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
}

.lang-btn:hover {
    background: #f0f0f0;
}

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

.upload-section {
    padding: 40px;
}

.upload-area {
    border: 3px dashed #000000;
    border-radius: 0;
    padding: 60px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #ffffff;
}

.upload-area:hover {
    border-color: #000000;
    background: #f0f0f0;
}

.upload-area.dragover {
    border-color: #764ba2;
    background: #e8ebff;
    transform: scale(1.01);
}

.upload-icon {
    font-size: 4em;
    margin-bottom: 16px;
}

.upload-area p {
    font-size: 1.2em;
    color: #555;
    margin-bottom: 8px;
}

.upload-hint {
    font-size: 0.9em;
    color: #888;
}

.workspace {
    padding: 30px;
}

.preview-section {
    display: flex;
    gap: 30px;
    margin-bottom: 30px;
    background: #f8f9fa;
    border-radius: 0;
    padding: 20px;
    border: 4px dashed #000000;
}

.preview-left {
    flex: 1;
}

.preview-right {
    flex: 0 0 420px;
}

.controls-section {
    background: white;
    border-radius: 12px;
    padding: 25px;
    height: 100%;
}

.global-actions {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    padding-top: 25px;
    border-top: 2px solid #e9ecef;
}

.preview-panel {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
}

.preview-panel h3 {
    margin-bottom: 16px;
    color: #333;
    font-size: 1.1em;
}

.canvas-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #e9ecef;
    border-radius: 8px;
    overflow: hidden;
    min-height: 200px;
}

canvas {
    max-width: 100%;
    height: auto;
    display: block;
    image-rendering: pixelated;
}

.size-info {
    margin-top: 12px;
    text-align: center;
    color: #666;
    font-size: 0.9em;
}

.controls {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 25px;
}

.control-group {
    margin-bottom: 30px;
}

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

.control-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 1em;
}

.control-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #000000;
    border-radius: 0;
    font-size: 1em;
}

input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 0;
    background: #ffffff;
    outline: none;
    -webkit-appearance: none;
    border: 2px solid #000000;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 0;
    background: #000000;
    cursor: pointer;
    border: 2px solid #000000;
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 0;
    background: #000000;
    cursor: pointer;
    border: 2px solid #000000;
}

.size-inputs {
    display: flex;
    gap: 20px;
}

.size-inputs > div {
    flex: 1;
}

.size-inputs label {
    display: inline-block;
    margin-bottom: 6px;
    font-weight: normal;
}

.size-inputs input[type="number"] {
    width: 120px;
    padding: 8px 12px;
    border: 2px solid #000000;
    border-radius: 0;
    font-size: 1em;
    margin-right: 6px;
    transition: border-color 0.3s;
    background: #ffffff;
}

.size-inputs input[type="number"]:focus {
    outline: none;
    border-color: #000000;
    background: #f0f0f0;
}

.color-count-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-count-inputs input[type="range"] {
    flex: 1;
}

.color-count-inputs input[type="number"] {
    width: 70px;
    padding: 8px 10px;
    border: 2px solid #000000;
    border-radius: 0;
    font-size: 1em;
    transition: border-color 0.3s;
    background: #ffffff;
}

.color-count-inputs input[type="number"]:focus {
    outline: none;
    border-color: #000000;
    background: #f0f0f0;
}

.preset-sizes {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.preset-btn {
    padding: 10px 20px;
    border: 2px solid #000000;
    background: #ffffff;
    color: #000000;
    border-radius: 0;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    transition: all 0.3s;
}

.preset-btn:hover {
    background: #000000;
    color: #ffffff;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #000000;
}

.action-buttons {
    display: flex;
    gap: 15px;
    margin-top: 30px;
    padding-top: 25px;
    border-top: 2px solid #e9ecef;
}

.btn {
    flex: 1;
    padding: 14px 24px;
    border: 2px solid #000000;
    border-radius: 0;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    background: #ffffff;
    color: #000000;
}

.btn-primary {
    background: #ffffff;
    color: #000000;
    border: 2px solid #000000;
}

.btn-primary:hover {
    background: #000000;
    color: #ffffff;
}

.btn-secondary {
    background: #ffffff;
    color: #000000;
    border-color: #000000;
}

.btn-secondary:hover {
    background: #f0f0f0;
    color: #000000;
}

.btn-danger {
    background: #ffffff;
    color: #dc3545;
    border-color: #dc3545;
}

.btn-danger:hover {
    background: #dc3545;
    color: #ffffff;
    transform: translateY(0);
    box-shadow: 0 0 0 rgba(220, 53, 69, 0.4);
}

select {
    padding: 10px 15px;
    border: 2px solid #000000;
    border-radius: 0;
    font-size: 1em;
    background: #ffffff;
    cursor: pointer;
    transition: border-color 0.3s;
    color: #000000;
}

select:focus {
    outline: none;
    border-color: #000000;
    background: #f0f0f0;
}

input[type="color"] {
    width: 60px;
    height: 40px;
    border: 2px solid #000000;
    border-radius: 0;
    cursor: pointer;
    padding: 2px;
    transition: border-color 0.3s;
}

input[type="color"]:hover {
    border-color: #000000;
}

input[type="color"]:focus {
    outline: none;
    border-color: #000000;
}

.color-usage-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    margin-bottom: 6px;
    background: white;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    transition: all 0.2s;
}

.color-usage-item:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.color-usage-item.selected {
    border-color: #667eea;
    background: #f0f2ff;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 2px solid #ddd;
    flex-shrink: 0;
}

.color-info {
    flex: 1;
    min-width: 0;
}

.color-count {
    font-weight: 600;
    color: #333;
    font-size: 0.9em;
}

.color-percentage {
    font-size: 0.8em;
    color: #888;
    margin-left: 8px;
}

.color-rgb {
    font-size: 0.75em;
    color: #999;
    font-family: monospace;
}

.color-action-btn {
    padding: 4px 8px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    color: #666;
    transition: all 0.2s;
    flex-shrink: 0;
}

.color-action-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.color-action-btn.remove {
    border-color: #dc3545;
    color: #dc3545;
}

.color-action-btn.remove:hover {
    background: #dc3545;
    color: white;
}

.sort-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.sort-btn {
    padding: 6px 12px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    color: #666;
    transition: all 0.2s;
}

.sort-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.sort-btn.active {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.edit-tools {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.edit-tool-btn {
    padding: 8px 16px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    color: #666;
    transition: all 0.2s;
    flex: 1;
    min-width: 60px;
}

.edit-tool-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.edit-tool-btn.active {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.current-color-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.current-color-wrapper input[type="color"] {
    width: 50px;
    height: 40px;
}

#currentColorValue {
    font-family: monospace;
    font-size: 0.95em;
    color: #666;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    margin: 15% auto;
    padding: 40px;
    border: 2px solid #000000;
    width: 80%;
    max-width: 700px;
    border-radius: 0;
    box-shadow: 0 0 0 rgba(0, 0, 0, 0.3);
}

.form-group {
    margin-bottom: 30px;
}

.form-group label {
    display: block;
    margin-bottom: 12px;
    font-weight: 600;
    color: #000000;
    font-size: 1.5em;
}

.form-group input {
    width: 100%;
    padding: 20px;
    border: 2px solid #000000;
    border-radius: 0;
    font-size: 1.5em;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #e9ecef;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5em;
    color: #000000;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2em;
    cursor: pointer;
    color: #999;
    transition: color 0.2s;
    line-height: 1;
}

.close-btn:hover {
    color: #333;
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
}

.optimization-summary {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.summary-item:last-child {
    margin-bottom: 0;
}

.summary-label {
    color: #666;
}

.summary-value {
    font-weight: 600;
    color: #333;
}

.suggestions-list {
    max-height: 300px;
    overflow-y: auto;
}

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.suggestion-item.accepted {
    border-color: #28a745;
    background: #e6f9e9;
}

.suggestion-item.rejected {
    border-color: #dc3545;
    background: #ffe6e8;
    opacity: 0.6;
}

.color-swatch-small {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 2px solid #ddd;
    flex-shrink: 0;
}

.suggestion-info {
    flex: 1;
    min-width: 0;
}

.suggestion-text {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.suggestion-text .arrow {
    color: #667eea;
    font-weight: bold;
}

.suggestion-beans {
    font-size: 0.85em;
    color: #888;
    margin-top: 4px;
}

.suggestion-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.suggestion-action-btn {
    padding: 6px 12px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.2s;
}

.suggestion-action-btn.accept {
    border-color: #28a745;
    color: #28a745;
}

.suggestion-action-btn.accept:hover {
    background: #28a745;
    color: white;
}

.suggestion-action-btn.reject {
    border-color: #dc3545;
    color: #dc3545;
}

.suggestion-action-btn.reject:hover {
    background: #dc3545;
    color: white;
}

.suggestion-action-btn.preview {
    border-color: #667eea;
    color: #667eea;
}

.suggestion-action-btn.preview:hover {
    background: #667eea;
    color: white;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 20px 25px;
    border-top: 1px solid #e9ecef;
}

.modal-footer .btn {
    flex: 1;
    padding: 14px 24px;
    font-size: 1em;
}

#perlerContent {
    display: flex;
    flex-direction: column;
}

#perlerChartArea {
    display: flex;
    flex-direction: column;
}

.perler-chart-wrapper {
    display: flex;
    flex-direction: column;
}

#colorLegendArea {
    display: flex;
    justify-content: center;
}

#colorLegendArea.horizontal {
    flex-direction: row;
    justify-content: flex-start;
}

#colorLegend {
    display: flex;
    justify-content: center;
}

.timer-section {
    padding: 40px;
}

.timer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #000000;
}

.timer-header h2 {
    font-size: 2em;
    color: #000000;
}

.timers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.timer-card {
    border: 2px solid #000000;
    border-radius: 0;
    padding: 20px;
    background: #ffffff;
    box-shadow: 0 0 0 rgba(0, 0, 0, 0.3);
}

.timer-title {
    font-size: 1.2em;
    font-weight: 600;
    text-align: center;
    margin-bottom: 15px;
    color: #000000;
}

.timer-display {
    font-size: 3em;
    font-weight: bold;
    text-align: center;
    margin-bottom: 20px;
    color: #000000;
    font-family: monospace;
}

.timer-settings {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
}

.timer-settings input {
    width: 60px;
    padding: 8px;
    border: 2px solid #000000;
    border-radius: 0;
    font-size: 1em;
    font-weight: 600;
    text-align: center;
}

.timer-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.timer-btn.btn-danger {
    background: #ff0000;
    color: #ffffff;
}

.timer-btn.btn-danger:hover {
    background: #cc0000;
    color: #ffffff;
}

.timer-btn {
    padding: 10px 20px;
    border: 2px solid #000000;
    background: #ffffff;
    color: #000000;
    border-radius: 0;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s;
}

.timer-btn:hover {
    background: #000000;
    color: #ffffff;
}

.timer-btn.active {
    background: #000000;
    color: #ffffff;
}

#colorLegend.horizontal {
    justify-content: flex-start;
}

#colorLegend canvas {
    max-width: none;
}

@media (max-width: 768px) {
    .perler-layout-horizontal {
        flex-direction: column;
    }
}

@media (max-width: 1400px) {
    .preview-section {
        flex-direction: column;
    }

    .preview-right {
        flex: none;
        width: 100%;
    }
}

@media (max-width: 768px) {
    .size-inputs {
        flex-direction: column;
    }

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

    .global-actions {
        flex-direction: column;
    }
}
