body {
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background-color: #f4f4f4;
    margin: 0;
}

.container {
    background-color: white;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    max-width: 1100px;
    width: 92%;
    border: 2px dashed transparent;
    transition: border-color 0.3s, background-color 0.3s;
}

.container.dragover {
    border-color: #007aff;
    background-color: #f0f8ff;
}

h1 {
    text-align: center;
    margin-top: 8px;
    font-size: 1.4em;
}

.navigation-links {
    margin-bottom: 8px;
    font-size: 0.9em;
}

.navigation-links a {
    color: #007aff;
    text-decoration: none;
}

.navigation-links a:hover {
    text-decoration: underline;
}

details summary {
    cursor: pointer;
    font-weight: bold;
}

details ol {
    padding-left: 1.5em;
    line-height: 1.7;
}

.upload-area {
    border: 2px dashed #bbb;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    margin: 16px 0;
    background: #fafafa;
}

.upload-area p {
    margin: 8px 0 0;
    color: #666;
    font-size: 0.9em;
}

.controls {
    margin: 12px 0 20px;
    padding: 14px;
    background: #f7f7f7;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.control-row .control-label {
    font-weight: bold;
}

.control-row label {
    font-size: 0.95em;
}

.control-row select,
.control-row input[type="color"] {
    margin-left: 4px;
}

.device-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.device-filters label {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.85em;
    cursor: pointer;
    user-select: none;
}

.device-filters input {
    margin-right: 4px;
    vertical-align: middle;
}

.device-filters label.required {
    border-color: #007aff;
    color: #005bbf;
}

button {
    padding: 8px 14px;
    cursor: pointer;
    border: none;
    border-radius: 6px;
    background-color: #007aff;
    color: white;
    font-size: 0.9em;
    transition: background-color 0.2s;
}

button:hover:not(:disabled) {
    background-color: #005bbf;
}

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

button.secondary {
    background-color: #888;
}

button.secondary:hover:not(:disabled) {
    background-color: #666;
}

input[type="color"] {
    width: 36px;
    height: 28px;
    border: 1px solid #ccc;
    padding: 0;
    vertical-align: middle;
    border-radius: 4px;
}

select {
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
    font-size: 0.9em;
}

.image-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.image-row {
    border: 1px solid #e3e3e3;
    border-radius: 8px;
    padding: 14px;
    background: #fff;
}

.image-row-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.image-thumb {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border-radius: 4px;
    background: #f0f0f0;
    border: 1px solid #ddd;
}

.image-row-header .name {
    font-weight: bold;
    word-break: break-all;
    flex: 1;
}

.image-row-header .meta {
    color: #666;
    font-size: 0.85em;
}

.image-row-header .remove {
    background: #d33;
    padding: 4px 10px;
    font-size: 0.8em;
}

.image-row-header .remove:hover:not(:disabled) {
    background: #a22;
}

.size-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.size-cell {
    border: 1px solid #eee;
    border-radius: 6px;
    padding: 8px;
    text-align: center;
    background: #fafafa;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.size-cell.hidden {
    display: none;
}

.size-cell .preview {
    background-image:
            linear-gradient(45deg, #ddd 25%, transparent 25%),
            linear-gradient(-45deg, #ddd 25%, transparent 25%),
            linear-gradient(45deg, transparent 75%, #ddd 75%),
            linear-gradient(-45deg, transparent 75%, #ddd 75%);
    background-size: 12px 12px;
    background-position: 0 0, 0 6px, 6px -6px, -6px 0;
    border-radius: 4px;
    width: 100%;
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.size-cell .preview canvas {
    max-width: 100%;
    max-height: 100%;
    display: block;
}

.size-cell .label {
    font-size: 0.85em;
    margin-top: 6px;
    line-height: 1.3;
}

.size-cell .label .device {
    font-weight: bold;
    display: block;
}

.size-cell .label .px {
    color: #666;
    font-size: 0.85em;
    display: block;
}

.size-cell button {
    margin-top: 6px;
    width: 100%;
    background-color: #34c759;
    font-size: 0.8em;
    padding: 6px 8px;
}

.size-cell button:hover:not(:disabled) {
    background-color: #28a745;
}

.empty-message {
    color: #888;
    text-align: center;
    padding: 24px;
    font-size: 0.95em;
}
