:root {
    --bg-main: #f3f4f6;
    --bg-card: #ffffff;
    --fg-main: #1f2937;
    --fg-muted: #6b7280;
    --border: #e5e7eb;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --secondary: #e5e7eb;
    --secondary-hover: #d1d5db;
    --secondary-text: #374151;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --radius: 8px;
    --transition: 0.2s ease-in-out;
}

[data-theme="dark"] {
    --bg-main: #111827;
    --bg-card: #1f2937;
    --fg-main: #f9fafb;
    --fg-muted: #9ca3af;
    --border: #374151;
    --primary: #3b82f6;
    --secondary: #374151;
    --secondary-hover: #4b5563;
    --secondary-text: #f3f4f6;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--bg-main);
    color: var(--fg-main);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
}

.icon {
    width: 1.1rem;
    height: 1.1rem;
    fill: currentColor;
    vertical-align: middle;
    display: inline-block;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--secondary-text);
}

.btn-secondary:hover {
    background: var(--secondary-hover);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.toolbar-btn {
    background: transparent;
    border: none;
    color: var(--fg-muted);
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-family: monospace;
    font-size: 0.9rem;
}

.toolbar-btn:hover {
    background: var(--secondary);
    color: var(--fg-main);
}

.toolbar-divider {
    display: none;
    width: 2px;
    background: var(--border);
    margin: 0 4px;
    height: 30px;
}

input,
select,
textarea {
    width: 100%;
    padding: 10px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--fg-main);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--fg-muted);
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.app-header h2 {
    margin: 0;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

#app {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    padding: 15px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.meta-accordion {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 15px;
    overflow: hidden;
}

.meta-accordion-header {
    padding: 12px 15px;
    background: var(--bg-card);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.meta-accordion-header:hover {
    background: var(--secondary);
}

.meta-accordion-content {
    display: none;
    padding: 15px;
    border-top: 1px solid var(--border);
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.meta-accordion-content.show {
    display: grid;
}

.meta-accordion-content-setion {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.meta-accordion-content .full-width {
    width: 100%;
}

.meta-accordion-content textarea {
    min-height: 75px;
    height: 80px;
    max-height: 200px;
    width: 100%;
    resize: vertical;
}

.multi-select {
    position: relative;
}

.select-box {
    padding: 10px;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    cursor: pointer;
    color: var(--fg-main);
}

.dropdown-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    z-index: 10;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    white-space: nowrap;
}

.dropdown-list.show {
    display: flex;
}

.dropdown-list label {
    padding: 8px 12px;
    margin: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dropdown-list label:hover {
    background: var(--secondary);
}

.tabs-header {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 5px;
    margin-bottom: 10px;
}

.tabs-header-section {
    display: flex;
    gap: 5px;
    justify-content: center;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: var(--fg-muted);
    cursor: pointer;
    font-weight: 600;
    border-bottom: 2px solid transparent;
    font-size: small;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.pane {
    display: none;
    flex-direction: column;
    flex-grow: 1;
    min-height: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.pane.active {
    display: flex;
}

.editor-toolbar {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    padding: 8px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    align-items: center;
    justify-content: space-between;
}

#md-editor-textarea {
    flex-grow: 1;
    border: none;
    border-radius: 0;
    padding: 15px;
    resize: none;
    min-height: 400px;
    font-family: monospace;
    line-height: 1.6;
    font-size: 1rem;
}

#md-editor-textarea.drag-over {
    background: rgba(59, 130, 246, 0.1);
}

.clog-container {
    padding: 20px;
    overflow-y: auto;
    max-height: 75vh;
}

.banner-image {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.clog-title {
    margin-top: 0;
}

.clog-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
    color: var(--fg-muted);
    font-size: 0.9rem;
}

.clog-meta-bottom {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
    padding-top: 10px;
    border-top: 2px solid var(--border);
    color: var(--fg-muted);
    font-size: 0.9rem;
}

.clog-meta-bottom .tags div {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.cat-badge {
    background: var(--primary);
    color: #fff;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    margin-right: 5px;
}

mark {
    background-color: rgba(250, 204, 21, 0.4);
    color: inherit;
    padding: 0 4px;
    border-radius: 4px;
}

.json-header-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 15px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}

#json-code-block {
    padding: 15px;
    margin: 0;
    white-space: normal;
    background: var(--bg-main);
    flex-grow: 1;
}

.backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.side-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 350px;
    max-width: 100vw;
    height: 100vh;
    background: var(--bg-card);
    box-shadow: -4px 0 15px rgba(0, 0, 0, 0.1);
    z-index: 100;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.side-panel.open {
    transform: translateX(0);
}

.backdrop.open {
    display: block;
    opacity: 1;
}

.side-panel-header {
    padding: 15px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
}

.side-panel-body {
    padding: 15px;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

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

.modal {
    background: var(--bg-card);
    width: 90%;
    max-width: 400px;
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.modal-dropzone {
    border: 2px dashed var(--border);
    padding: 30px 10px;
    text-align: center;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    margin: 15px 0;
}

.modal-dropzone.drag-over {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #10b981;
    color: white;
    padding: 10px 20px;
    border-radius: 30px;
    transition: transform 0.3s;
    z-index: 2000;
    font-weight: 500;
    text-align: center;
}

.toast.error {
    background: var(--danger);
}

.toast.info {
    background: var(--primary);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}


@media (min-width: 480px) {

    .meta-accordion-content-setion,
    .tabs-header {
        flex-direction: row;
    }

    .toolbar-divider {
        display: block;
    }
}

@media (max-width: 768px) {
    .app-header h2 {
        font-size: 1rem;
    }

    .json-header-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .json-header-toolbar>div {
        display: flex;
        flex-direction: column;
    }
}

::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
    margin-block: 5px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 20px;
    cursor: grab;
}

::-webkit-scrollbar-thumb:active {
    background: var(--primary-hover);
    cursor: grabbing;
}