* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
    min-height: 100vh;
}

header {
    background-color: #2c3e50;
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
}

header nav a {
    color: white;
    text-decoration: none;
    margin-left: 1rem;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

header nav a:hover {
    background-color: #34495e;
}

main {
    padding: 2rem;
}

.workflow-container {
    display: flex;
    gap: 2rem;
    min-height: 600px;
}

.controls-column {
    flex: 0 0 35%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.grids-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

section h2 {
    margin: 0 0 1rem 0;
    font-size: 1.25rem;
    color: #2c3e50;
}

.word-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem 0;
    min-height: 50px;
}

.word-list:empty::after {
    content: 'No words yet. Add words to get started.';
    display: block;
    padding: 1rem;
    text-align: center;
    color: #95a5a6;
    font-style: italic;
}

.word-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: #ecf0f1;
    border-radius: 4px;
    cursor: move;
    transition: background-color 0.2s;
}

.word-item:hover {
    background: #d5dbdb;
}

.word-item.dragging {
    opacity: 0.5;
}

.word-item.drag-over {
    border-top: 3px solid #3498db;
}

.word-drag-handle {
    color: #95a5a6;
    cursor: grab;
    user-select: none;
}

.word-value {
    flex: 1;
    font-weight: 600;
    font-family: monospace;
    font-size: 1.1rem;
}

.add-word-controls {
    display: flex;
    gap: 0.5rem;
}

.add-word-controls input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    font-size: 1rem;
}

.add-word-controls button,
.remove-word-btn,
#start-generation-btn {
    padding: 0.5rem 1rem;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
}

.add-word-controls button:hover,
.remove-word-btn:hover,
#start-generation-btn:hover {
    background-color: #2980b9;
}

.add-word-controls button:disabled,
.remove-word-btn:disabled,
#start-generation-btn:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
}

.remove-word-btn {
    background-color: #e74c3c;
}

.remove-word-btn:hover {
    background-color: #c0392b;
}

.grid-size-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.grid-size-controls label {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.grid-size-controls input {
    padding: 0.5rem;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    font-size: 1rem;
}

.grid-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.grid-options label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#start-generation-btn {
    width: 100%;
    padding: 0.75rem;
    font-weight: 600;
}

.message-area {
    padding: 1rem;
    background: #e8f4f8;
    border-left: 4px solid #3498db;
    border-radius: 4px;
    white-space: pre-line;
}

.progress-bar {
    padding: 1rem;
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    border-radius: 4px;
    font-weight: 600;
}

.candidate-thumbnails {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.candidate-thumbnail {
    cursor: pointer;
    padding: 0.5rem;
    border: 2px solid transparent;
    border-radius: 4px;
    transition: border-color 0.2s;
}

.candidate-thumbnail:hover {
    border-color: #3498db;
}

.candidate-thumbnail.focused {
    border-color: #2ecc71;
    background: #e8f8f5;
}

.thumbnail-label {
    text-align: center;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.word-grid {
    display: grid;
    gap: 1px;
    background: #bdc3c7;
    border: 2px solid #95a5a6;
    margin: 0 auto;
    width: fit-content;
}

.grid-cell {
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-family: monospace;
    user-select: none;
}

.thumbnail-grid .grid-cell {
    width: 12px;
    height: 12px;
    font-size: 8px;
}

.focused-grid .grid-cell {
    width: 50px;
    height: 50px;
    font-size: 24px;
}

.word-grid:not(.thumbnail-grid):not(.focused-grid) .grid-cell {
    width: 35px;
    height: 35px;
    font-size: 18px;
}

.grid-cell.black-cell {
    background: #2c3e50;
}

.selection-buttons {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.selection-buttons button {
    flex: 1;
    padding: 0.75rem;
    background-color: #27ae60;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background-color 0.2s;
}

.selection-buttons button:hover {
    background-color: #229954;
}

.legacy-container {
    max-width: 800px;
    margin: 0 auto;
}

.items-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem 0;
}

.items-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: #ecf0f1;
    border-radius: 4px;
}

.add-item-controls {
    display: flex;
    gap: 0.5rem;
}

.add-item-controls input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    font-size: 1rem;
}

.remove-btn {
    padding: 0.5rem 1rem;
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.remove-btn:hover {
    background-color: #c0392b;
}
