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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
    color: #333;
    padding: 20px;
    transition: background 0.3s, color 0.3s;
}

body.dark-mode {
    background: #1a1a2e;
    color: #eee;
}

body.dark-mode .container {
    background: #16213e;
}

body.dark-mode .button-row-editor {
    background: #0f3460;
}

body.dark-mode .button-item {
    background: #1a1a2e;
    border-color: #0f3460;
}

body.dark-mode .field-group label {
    color: #aaa;
}

body.dark-mode .field-group input,
body.dark-mode .field-group select {
    background: #2d2d44;
    border-color: #0f3460;
    color: #eee;
}

body.dark-mode .output {
    background: #0f0f23;
    color: #8bc34a;
}

body.dark-mode .preview-btn.style-0 { background: #333; color: #ccc; }
body.dark-mode .preview-btn.style-1 { background: #5a9fd4; }
body.dark-mode .preview-btn.style-2 { background: #6a3d8c; }
body.dark-mode .preview-btn.style-3 { background: #8c2c2c; }
body.dark-mode .preview-btn.style-4 { background: #1a3a4a; }
body.dark-mode .import-section { background: #0f3460; }
body.dark-mode .global-config { background: #0f3460; }

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: background 0.3s;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid #e0e0e0;
}

body.dark-mode .header {
    border-bottom-color: #0f3460;
}

h1 {
    font-size: 1.8rem;
    color: #5a9fd4;
}

body.dark-mode h1 {
    color: #7ab8e8;
}

.theme-btn {
    background: #5a9fd4;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
}

.theme-btn:hover {
    background: #4a8fc4;
}

.tab-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 8px;
}

body.dark-mode .tab-bar {
    border-bottom-color: #0f3460;
}

.tab-btn {
    padding: 8px 24px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    border-radius: 20px;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: #e0e0e0;
}

body.dark-mode .tab-btn:hover {
    background: #0f3460;
}

.tab-btn.active {
    background: #5a9fd4;
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.toolbar {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-group label {
    font-weight: 500;
}

.toolbar-group select {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #ccc;
    background: white;
}

body.dark-mode .toolbar-group select {
    background: #2d2d44;
    border-color: #0f3460;
    color: #eee;
}

.global-config {
    background: #f0f0f0;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    border: none;
}

body.dark-mode .global-config {
    background: #0f3460;
}

.global-config summary {
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 12px;
}

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

.config-grid label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
}

.config-grid input,
.config-grid select {
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #ccc;
}

body.dark-mode .config-grid input,
body.dark-mode .config-grid select {
    background: #2d2d44;
    border-color: #0f3460;
    color: #eee;
}

.button-row-editor {
    background: #f0f0f0;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

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

.row-header strong {
    font-size: 1rem;
    background: #5a9fd4;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
}

.button-item {
    background: white;
    border-radius: 8px;
    padding: 12px;
    margin: 10px 0;
    border: 1px solid #ddd;
}

.button-editor-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.field-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.field-group label {
    font-weight: 500;
    font-size: 0.85rem;
    color: #555;
}

.field-group input,
.field-group select {
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #ccc;
    font-size: 0.85rem;
}

body.dark-mode .field-group label {
    color: #aaa;
}

.row-footer {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px dashed #ccc;
    display: flex;
    justify-content: flex-end;
}

.btn {
    background: #5a9fd4;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.btn:hover {
    background: #4a8fc4;
}

.btn.secondary {
    background: #6c757d;
}

.btn.secondary:hover {
    background: #5a6268;
}

.btn.danger {
    background: #dc3545;
}

.btn.danger:hover {
    background: #c82333;
}

.btn.small {
    padding: 4px 12px;
    font-size: 0.8rem;
}

.action-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin: 20px 0;
    flex-wrap: wrap;
}

.hint {
    color: #666;
    font-size: 0.85rem;
}

.success-tip {
    background: #28a745;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.success-tip.show {
    opacity: 1;
}

.error-text {
    color: #dc3545;
    margin: 10px 0;
    min-height: 24px;
}

.output {
    background: #1e1e1e;
    color: #d4d4d4;
    border-radius: 8px;
    padding: 16px;
    font-family: monospace;
    font-size: 0.85rem;
    overflow-x: auto;
    white-space: pre-wrap;
    margin-top: 16px;
}

.import-section {
    background: #f0f0f0;
    border-radius: 12px;
    padding: 20px;
}

.import-section h3 {
    margin-bottom: 16px;
    color: #5a9fd4;
}

.import-section textarea {
    width: 100%;
    height: 200px;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #ccc;
    font-family: monospace;
    margin-bottom: 16px;
    resize: vertical;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.preview-header h3 {
    color: #5a9fd4;
}

.preview-buttons {
    background: #e8e8e8;
    border-radius: 12px;
    padding: 20px;
    min-height: 200px;
}

body.dark-mode .preview-buttons {
    background: #0f0f23;
}

.preview-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.preview-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.preview-btn.style-0 { background: #e0e0e0; color: #333; border: 1px solid #ccc; }
.preview-btn.style-1 { background: #5a9fd4; color: white; border: none; }
.preview-btn.style-2 { background: #6a3d8c; color: white; border: none; position: relative; padding-left: 30px; }
.preview-btn.style-2::before { content: "●"; position: absolute; left: 12px; font-size: 12px; }
.preview-btn.style-3 { background: #8c2c2c; color: white; border: none; }
.preview-btn.style-4 { background: #1a3a4a; color: white; border: none; }

.preview-hint {
    margin-top: 16px;
    font-size: 12px;
    color: #666;
    text-align: center;
}

body.dark-mode .preview-hint {
    color: #aaa;
}

.preview-empty {
    text-align: center;
    color: #999;
    padding: 40px;
}

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

.modal-box {
    background: white;
    border-radius: 12px;
    padding: 24px;
    min-width: 280px;
    max-width: 90%;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

body.dark-mode .modal-box {
    background: #1a1a2e;
    color: #eee;
}

.modal-box p {
    margin-bottom: 20px;
    font-size: 16px;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-btn {
    padding: 8px 20px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 14px;
}

.modal-btn.confirm {
    background: #5a9fd4;
    color: white;
}

.modal-btn.cancel {
    background: #e0e0e0;
    color: #333;
}

body.dark-mode .modal-btn.cancel {
    background: #333;
    color: #eee;
}

@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
    
    .button-editor-row {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .field-group {
        width: 100%;
    }
    
    .field-group input,
    .field-group select {
        flex: 1;
    }
}