body {
    font-family: sans-serif;
    color: black;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

.main-wrapper {
    display: flex;
    flex-direction: row;
    gap: 20px;
    width: 100%;
    align-items: flex-start;
}

/* Common container style */
.container {
    background: white;
    padding: 2rem;
    border: 1px solid #000;
    text-align: left;
}

.generator-panel {
    flex: 1;
    max-width: 400px;
    position: sticky;
    top: 20px;
    height: fit-content; /* Ensure it doesn't stretch if align-items changes */
}

.search-panel {
    flex: 2;
    display: flex;
    flex-direction: column;
    min-width: 300px;
}

@media (max-width: 850px) {
    .main-wrapper {
        flex-direction: column;
        align-items: center;
    }
    
    .generator-panel, .search-panel {
        width: 100%;
        max-width: 500px;
        flex: none;
        position: static;
    }

    .search-panel {
        height: 600px;
    }
}

h1, h2 {
    margin-bottom: 1rem;
    margin-top: 0;
    font-size: 1.5rem;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
    text-align: left;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.search-row {
    display: flex;
    gap: 1rem;
}

.search-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-weight: 500;
    font-size: 0.9rem;
    color: dimgray;
}

.checkbox-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

input[type="text"] {
    width: 100%;
    box-sizing: border-box;
    padding: 10px;
    border: 1px solid #000;
    border-radius: 0;
    text-align: left;
}

#keywordInput {
    max-width: 300px;
}

#codepointInput {
    max-width: 7em;
}

.color-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

input[type="color"] {
    width: 60px;
    height: 40px;
    padding: 0;
    border: 1px solid #000;
    cursor: pointer;
    background: none;
    border-radius: 0;
}

#hexInput, #bgHexInput {
    flex-grow: 1;
    padding: 10px;
    font-family: monospace;
    border: 1px solid #000;
    border-radius: 0;
    text-transform: uppercase;
    text-align: left;
}

input[type="range"] {
    width: 100%;
    cursor: pointer;
}

.preview-section {
    margin-bottom: 2rem;
}

.canvas-container {
    width: 128px;
    height: 128px;
    margin: 0;
    border: 1px solid #000;
    background-image: linear-gradient(45deg, #eee 25%, transparent 25%), 
                      linear-gradient(-45deg, #eee 25%, transparent 25%), 
                      linear-gradient(45deg, transparent 75%, #eee 75%), 
                      linear-gradient(-45deg, transparent 75%, #eee 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    border-radius: 0;
    overflow: hidden;
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.codepoint-display {
    font-family: monospace;
    font-size: 0.85rem;
    color: dimgray;
    margin-top: 0.5rem;
}

.link-button {
    background: none;
    border: none;
    color: blue;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
    width: auto;
}

.link-button:hover {
    background: none;
    color: darkblue;
}

button {
    background-color: #000;
    color: white;
    border: 1px solid #000;
    padding: 12px 24px;
    border-radius: 0;
    cursor: pointer;
    transition: background-color 0.2s;
    width: 100%;
}

button:hover {
    background-color: #333;
}

button:disabled {
    background-color: #999;
    border-color: #999;
    cursor: not-allowed;
}

/* Filter Controls */
.filter-controls {
    margin-bottom: 1rem;
    height: 120px;
    min-height: 80px;
    overflow-y: auto;
    border: 1px solid #000;
    padding: 10px;
    border-radius: 0;
    text-align: left;
    resize: vertical;
}

.block-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.block-filter-item {
    display: flex;
    align-items: center;
    font-size: 0.8rem;
}

/* Search Results Grid */
.search-results {
    flex-grow: 1;
    border: 1px solid #000;
    padding: 10px;
    border-radius: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    align-content: start; /* Don't stretch items to fill height */
}

.result-item {
    border: 1px solid #eee;
    border-radius: 0;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.1s;
    height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.result-item:hover {
    background-color: #f0f0f0;
    border-color: #000;
}

.result-item:hover .result-name {
    overflow: visible;
    -webkit-line-clamp: unset;
}

.result-char {
    font-size: 2rem;
    display: block;
    margin-bottom: 5px;
    line-height: 1;
}

.result-name {
    font-size: 0.7rem;
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    width: 100%;
}

.placeholder-text {
    grid-column: 1 / -1;
    text-align: center;
    color: #999;
    margin-top: 2rem;
}
