body {
    font-family: sans-serif;
    padding: 20px;
    max-width: 660px;
    margin: 0 auto;
}

#toolbar {
    margin-bottom: 16px;
}

#toolbar button {
    font-size: 0.9em;
    padding: 5px 14px;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid #ccc;
    color: #555;
}

.card {
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 12px;
}

.card-hidden {
    opacity: 0.45;
}

.card-header {
    font-size: 0.8em;
    color: #888;
    margin-bottom: 8px;
}

.card-preview {
    margin-bottom: 8px;
}

.card-preview img {
    max-width: 100%;
    height: auto;
}

.card-actions {
    display: flex;
    gap: 6px;
}

.card-actions button {
    font-size: 0.9em;
    padding: 4px 12px;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid #ccc;
}

.btn-toggle {
    color: #666;
}

#modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    justify-content: center;
    align-items: center;
}

#modal-overlay.active {
    display: flex;
}

#modal {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    width: 480px;
    max-width: 90%;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    max-height: 90vh;
    overflow-y: auto;

}

#modal h2 {
    margin: 0 0 16px 0;
    font-size: 1em;
    color: #555;
}

#modal-fields label {
    display: block;
    font-size: 0.85em;
    color: #666;
    margin-bottom: 4px;
    margin-top: 12px;
}

#modal-fields input[type="text"] {
    width: 100%;
    padding: 6px 8px;
    font-size: 0.95em;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

#modal-actions {
    margin-top: 20px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

#modal-actions button {
    padding: 6px 16px;
    font-size: 0.9em;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid #ccc;
}

#modal-save {
    background: #4a90d9;
    color: white;
    border-color: #4a90d9;
}

#output {
    color: green;
    font-size: 0.9em;
}

.richtext-field {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 6px 8px;
}

.richtext-preview {
    flex: 1;
    font-size: 0.85em;
    color: #888;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-richtext {
    font-size: 0.8em;
    padding: 3px 10px;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid #4a90d9;
    color: #4a90d9;
    background: #fff;
    white-space: nowrap;
}

#richtext-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

#richtext-overlay.active {
    display: flex;
}

#richtext-modal {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    width: 640px;
    max-width: 95%;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

#richtext-modal h2 {
    margin: 0 0 16px 0;
    font-size: 1em;
    color: #555;
}

#richtext-actions {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
}

#richtext-close {
    padding: 6px 16px;
    font-size: 0.9em;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid #ccc;
    background: #fff;
}

/* Image field */
.image-field {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 6px 8px;
}

.image-thumb-wrap {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
}

.image-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-thumb-empty {
    font-size: 0.75em;
    color: #aaa;
}

.btn-image {
    font-size: 0.8em;
    padding: 3px 10px;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid #4a90d9;
    color: #4a90d9;
    background: #fff;
    white-space: nowrap;
}

/* Image picker modal */
#imagepicker-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

#imagepicker-overlay.active {
    display: flex;
}

#imagepicker-modal {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    width: 640px;
    max-width: 95%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

#imagepicker-modal h2 {
    margin: 0 0 16px 0;
    font-size: 1em;
    color: #555;
}

#imagepicker-external label {
    display: block;
    font-size: 0.85em;
    color: #666;
    margin-bottom: 4px;
}

#imagepicker-url-row {
    display: flex;
    gap: 8px;
}

#imagepicker-url {
    flex: 1;
    padding: 6px 8px;
    font-size: 0.95em;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

#imagepicker-url-confirm {
    padding: 6px 12px;
    font-size: 0.85em;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid #4a90d9;
    color: #4a90d9;
    background: #fff;
    white-space: nowrap;
}

#imagepicker-divider {
    text-align: center;
    font-size: 0.8em;
    color: #aaa;
    margin: 16px 0;
}

#imagepicker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.imagepicker-thumb {
    position: relative;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    text-align: center;
    transition: border-color 0.15s;
}

.imagepicker-thumb:hover {
    border-color: #4a90d9;
}

.imagepicker-thumb img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    display: block;
}

.imagepicker-thumb span {
    display: block;
    font-size: 0.7em;
    color: #666;
    padding: 3px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.imagepicker-empty {
    font-size: 0.85em;
    color: #aaa;
    text-align: center;
    padding: 20px 0;
}

#imagepicker-actions {
    display: flex;
    justify-content: flex-end;
}

#imagepicker-cancel {
    padding: 6px 16px;
    font-size: 0.9em;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid #ccc;
    background: #fff;
}

#imagepicker-upload {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

#imagepicker-upload-status {
    font-size: 0.85em;
    color: #c00;
}

.imagepicker-thumb-highlight {
    outline: 3px solid #4a90e2;
}

.btn-move {
    padding: 4px 8px;
    font-size: 0.9em;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid #ccc;
    background: #fff;
}

.btn-move:disabled {
    opacity: 0.3;
    cursor: default;
}

.btn-delete {
    padding: 4px 8px;
    font-size: 0.9em;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid #c00;
    background: #fff;
    color: #c00;
}

.btn-delete:hover {
    background: #c00;
    color: #fff;
}

.btn-add {
    padding: 4px 8px;
    font-size: 0.9em;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid #4a90e2;
    background: #fff;
    color: #4a90e2;
}

.btn-add:hover {
    background: #4a90e2;
    color: #fff;
}

#typepicker-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

#typepicker-overlay.active {
    display: flex;
}

#typepicker-modal {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    width: 360px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
}

#typepicker-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 16px 0;
}

.typepicker-type-btn {
    padding: 10px 14px;
    font-size: 0.95em;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid #ccc;
    background: #fff;
    text-align: left;
}

.typepicker-type-btn:hover {
    background: #f0f0f0;
}

#typepicker-actions {
    display: flex;
    justify-content: flex-end;
}

#typepicker-cancel {
    padding: 6px 16px;
    font-size: 0.9em;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid #ccc;
    background: #fff;
}

#imagepicker-clear {
    padding: 6px 16px;
    font-size: 0.9em;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid #ccc;
    background: #fff;
    color: #888;
    margin-right: auto;
}

.imagepicker-thumb-delete {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 20px;
    height: 20px;
    padding: 0;
    font-size: 0.7em;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    border-radius: 50%;
    border: none;
    background: rgba(180, 0, 0, 0.75);
    color: #fff;
}

.imagepicker-thumb-delete:hover {
    background: #c00;
}
