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

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-input: #0d1117;
    --accent: #58a6ff;
    --accent-hover: #79b8ff;
    --accent-light: #1f3d5c;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --border: #30363d;
    --success: #3fb950;
    --warning: #d29922;
    --info: #58a6ff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 2px 4px rgba(0,0,0,0.4);
    --radius-sm: 4px;
    --radius: 6px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    font-size: 13px;
    line-height: 1.4;
}

.container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    padding: 8px;
}

.row {
    width: 100%;
}

.top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background-color: var(--bg-secondary);
    border-radius: var(--radius);
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.logo h1 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.ad-placeholder {
    background-color: var(--bg-tertiary);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 11px;
}

.middle-row {
    display: flex;
    gap: 8px;
    flex: 1;
}

.panel {
    background-color: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.left-panel {
    flex: 2;
}

.right-panel {
    flex: 1;
    min-width: 260px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}

.panel h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--accent);
    display: inline-block;
}

.image-container {
    min-height: 150px;
    max-height: calc(100vh - 180px);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--bg-primary);
    padding: 10px;
}

.image-wrapper {
    text-align: center;
    width: 100%;
    position: relative;
    display: inline-block;
}

.image-wrapper img {
    max-width: 100%;
    max-height: calc(100vh - 220px);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    display: block;
    position: relative;
    z-index: 1;
}

#crop-overlay {
    z-index: 10;
    pointer-events: none;
}

#crop-overlay > div {
    pointer-events: auto;
}

.crop-handle {
    position: absolute;
    width: 16px;
    height: 16px;
    background: #ff0000;
    border: 2px solid white;
    border-radius: 50%;
    z-index: 20;
}

.crop-handle-nw { top: -8px; left: -8px; cursor: nw-resize; }
.crop-handle-ne { top: -8px; right: -8px; cursor: ne-resize; }
.crop-handle-sw { bottom: -8px; left: -8px; cursor: sw-resize; }
.crop-handle-se { bottom: -8px; right: -8px; cursor: se-resize; }

.filename {
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 12px;
}

.image-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 6px;
}

.upload-zone {
    text-align: center;
    padding: 30px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    min-height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-tertiary);
}

.upload-zone:hover,
.upload-zone.dragover {
    background-color: var(--accent-light);
    border-color: var(--accent);
}

.upload-zone p {
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 14px;
}

.upload-label {
    display: inline-block;
    padding: 8px 16px;
    background-color: var(--accent);
    color: #0d1117;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    font-weight: 600;
    font-size: 13px;
}

.upload-label:hover {
    background-color: var(--accent-hover);
}

.control-group {
    margin-bottom: 8px;
    padding: 10px;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.control-group h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.control-group label {
    display: block;
    margin-bottom: 4px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
}

.resize-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.resize-row label {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 0;
    color: var(--text-secondary);
    font-size: 12px;
}

.resize-row input[type="number"] {
    width: 70px;
    padding: 6px 8px;
}

.resize-row select {
    padding: 6px 8px;
    min-width: 80px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
    cursor: pointer;
}

.control-group input[type="number"],
.control-group select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background-color: var(--bg-input);
    color: var(--text-primary);
    transition: border-color 0.2s;
}

.control-group input[type="number"]:focus,
.control-group select:focus {
    outline: none;
    border-color: var(--accent);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 12px;
    background-color: var(--accent);
    color: #0d1117;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    margin-right: 4px;
    margin-top: 4px;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-reset {
    background-color: var(--warning);
    color: #0d1117;
}

.btn-reset:hover {
    background-color: #e3b341;
}

.btn-confirm {
    background-color: #f472b6;
    color: #0d1117;
}

.btn-confirm:hover {
    background-color: #ec4899;
}

.btn-save {
    background-color: var(--success);
    color: #0d1117;
}

.btn-save:hover {
    background-color: #56d364;
}

.bottom-row {
    margin-top: 8px;
    padding: 10px;
    background-color: var(--bg-secondary);
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.bottom-row p {
    color: var(--text-muted);
    font-size: 11px;
}

/* Scrollbar styling */
.right-panel::-webkit-scrollbar {
    width: 4px;
}

.right-panel::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.right-panel::-webkit-scrollbar-thumb {
    background: var(--border);
}

@media (max-width: 768px) {
    .middle-row {
        flex-direction: column;
    }
    
    .left-panel,
    .right-panel {
        flex: none;
        width: 100%;
    }
    
    .top-row {
        flex-direction: column;
        gap: 6px;
    }
    
    .image-container {
        min-height: 150px;
    }
}

body.crop-mode .control-group:not(#crop-controls) {
    opacity: 0.3;
    pointer-events: none;
}

body.crop-mode #crop-controls {
    border-color: var(--accent);
    background: var(--accent-light);
}

.btn-cancel {
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-cancel:hover {
    background-color: var(--danger);
    color: white;
    border-color: var(--danger);
}
