/* --- Reset & Variables --- */
:root {
    /* --- FIXED POSTER DIMENSIONS --- */
    --poster-width: 842px; 
    --poster-height: 1191px;
    
    /* --- Defaults --- */
    --base-height: 91px; 
    --vertical-gap: 15px; 
    --block-overlap: 100px;
    --number-offset-x: -13px;
    --text-offset-x: -108px;
    
    /* Typography */
    --main-title-size: 60px;
    --main-title-spacing: 13;
    
    --block-title-size: 27px;
    --block-title-y: 0px; /* Restored */
    
    --block-desc-size: 16px;
    --block-desc-y: 0px; /* Restored */
    
    --page-padding-top: 50px; 
    --title-spacing: 38px; /* Restored */
    
    /* Colors */
    --poster-bg: #EAE8E3;
    --text-color: #FFFFFF;
    --title-color: #333333;

    /* --- UI THEME --- */
    --ui-bg-body: #121212;
    --ui-bg-preview: #0a0a0a;
    --ui-glass-bg: rgba(30, 30, 30, 0.60);
    --ui-glass-border: rgba(255, 255, 255, 0.08);
    --ui-text: #f0f0f0;
    --ui-text-muted: #aaaaaa;
    --ui-input-bg: rgba(0,0,0,0.3);
    --ui-input-border: #444;
    --primary-color: #3498db;
    --success-color: #27ae60;
}

body.light-mode {
    --ui-bg-body: #f0f2f5;
    --ui-bg-preview: #e4e7eb;
    --ui-glass-bg: rgba(255, 255, 255, 0.75);
    --ui-glass-border: rgba(0, 0, 0, 0.1);
    --ui-text: #333;
    --ui-text-muted: #666;
    --ui-input-bg: rgba(255,255,255,0.6);
    --ui-input-border: #ccc;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Montserrat', sans-serif; }

body {
    background: var(--ui-bg-body);
    color: var(--ui-text);
    height: 100vh;
    display: flex; flex-direction: column; 
    overflow: hidden;
    transition: background 0.3s;
}

/* --- Layout --- */
.app-layout {
    display: flex; width: 100%; height: 100%;
    overflow: hidden; position: relative;
}

/* --- Sidebar --- */
.controls {
    width: 360px;
    background: var(--ui-glass-bg);
    border-right: 1px solid var(--ui-glass-border);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    display: flex; flex-direction: column;
    z-index: 50; flex-shrink: 0;
}

.controls-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--ui-glass-border);
    display: flex; justify-content: space-between; align-items: center;
}
.logo { font-weight: 900; font-size: 1.2rem; color: var(--ui-text); text-decoration: none; }
.logo-highlight { color: var(--primary-color); }
.theme-btn { background: none; border: none; font-size: 1.5rem; cursor: pointer; }
body:not(.light-mode) .icon-sun { display: none; }
body.light-mode .icon-moon { display: none; }

.controls-content { padding: 20px; overflow-y: auto; flex: 1; scrollbar-width: thin; }

.controls h3 { font-size: 0.8rem; color: var(--ui-text-muted); text-transform: uppercase; margin: 15px 0 10px; border-bottom: 1px solid var(--ui-glass-border); padding-bottom: 5px; }
.control-group { margin-bottom: 12px; }
.label-row { display: flex; justify-content: space-between; font-size: 0.8rem; margin-bottom: 4px; color: var(--ui-text-muted); }

input[type="range"] { width: 100%; cursor: pointer; accent-color: var(--primary-color); }
textarea, select { width: 100%; background: var(--ui-input-bg); border: 1px solid var(--ui-input-border); color: var(--ui-text); padding: 8px; border-radius: 6px; }

.btn-group { display: flex; gap: 8px; margin-top: 5px; }
.btn { flex: 1; padding: 10px; border: none; border-radius: 6px; font-weight: 600; cursor: pointer; transition: 0.2s; }
.btn:hover { opacity: 0.9; transform: translateY(-1px); }
.primary { background: var(--primary-color); color: white; }
.secondary { background: #7f8c8d; color: white; }
.success { background: var(--success-color); color: white; }
.full-width { width: 100%; margin-top: 5px; }

.color-grid { display: flex; gap: 10px; }
.color-input { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 0.7rem; }
input[type="color"] { width: 100%; height: 35px; border: none; border-radius: 4px; background: none; cursor: pointer; }

.highlight-group { background: rgba(52, 152, 219, 0.1); padding: 10px; border-radius: 8px; border: 1px solid rgba(52, 152, 219, 0.3); }
.debug-area { margin-top: 20px; padding: 10px; background: rgba(0,0,0,0.5); font-family: monospace; font-size: 0.7rem; border-radius: 4px; color: #ccc; word-break: break-all; }

/* --- Preview Area --- */
.preview-area {
    flex: 1;
    background: var(--ui-bg-preview);
    display: flex; justify-content: center; align-items: center;
    padding: 20px; overflow: hidden;
    position: relative;
}

.poster-scaler {
    width: var(--poster-width);
    height: var(--poster-height);
    transform-origin: center center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    background: white; flex-shrink: 0; 
}

.poster-canvas {
    width: 100%; height: 100%;
    background-color: var(--poster-bg);
    display: flex; flex-direction: column;
    padding: var(--page-padding-top) 50px 50px 50px;
    position: relative; overflow: hidden; 
}

.poster-title {
    width: 100%; text-align: center;
    color: var(--title-color); 
    font-size: var(--main-title-size);
    font-weight: 900; line-height: 1.2;
    margin-bottom: var(--title-spacing); /* Uses slider value */
    text-transform: uppercase;
    letter-spacing: calc(var(--main-title-spacing) * 1px);
    outline: none; border: 1px dashed transparent;
}
.poster-title:hover { border-color: rgba(100,100,100,0.2); }

.items-wrapper { display: flex; flex-direction: column; width: 100%; }
.items-wrapper.wide-layout .item-content { padding-left: calc(var(--block-overlap) + 90px + var(--text-offset-x)); }

.poster-item {
    display: flex; align-items: center; width: 100%; 
    margin-bottom: var(--vertical-gap);
    position: relative;
}

.item-number {
    width: 140px; height: var(--base-height);
    position: relative; z-index: 10; flex-shrink: 0;
    display: flex; justify-content: center; align-items: center;
    transform: translateX(var(--number-offset-x));
}
.number-svg { width: 100%; height: 140%; overflow: visible; }
.number-svg text { 
    font-family: 'Montserrat', sans-serif;
    font-weight: 900; 
    text-anchor: middle; 
    dominant-baseline: central; 
}

.item-content {
    flex-grow: 1;
    background-color: var(--item-color);
    color: var(--text-color);
    margin-left: calc(var(--block-overlap) * -1);
    padding-right: 30px;
    padding-left: calc(var(--block-overlap) + 40px + var(--text-offset-x));
    height: var(--base-height);
    display: flex; flex-direction: column; justify-content: center;
    border-radius: 0 4px 4px 0; 
    position: relative; z-index: 5;
}

.editable-title {
    font-size: var(--block-title-size); font-weight: 700;
    margin-bottom: 4px; line-height: 1.1; outline: none; letter-spacing: 1px;
    transform: translateY(var(--block-title-y)); /* Position Slider */
}
.editable-desc {
    font-size: var(--block-desc-size); font-weight: 400; opacity: 0.95;
    outline: none; line-height: 1.3;
    transform: translateY(var(--block-desc-y)); /* Position Slider */
}
.item-color-picker { position: absolute; right: 0; width: 30px; height: 100%; opacity: 0; cursor: pointer; }

.render-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: #fff; z-index: 200; display: none; cursor: pointer;
}
.render-overlay img { width: 100%; height: 100%; object-fit: contain; }
.overlay-msg {
    position: absolute; top: 20px; right: 20px;
    background: rgba(0,0,0,0.8); color: white; padding: 8px 12px;
    border-radius: 6px; font-size: 0.8rem; pointer-events: none;
}

@media (max-width: 900px) {
    .app-layout { flex-direction: column; overflow-y: auto; }
    .controls { width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--ui-glass-border); order: 2; }
    .preview-area { height: 50vh; width: 100%; order: 1; padding: 10px; }
}