:root {
    --footer-height: 40px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 10px rgba(0, 0, 0, 0.08);
    --handle-color: #da3d2e; 
}
* { 
    box-sizing: border-box; 
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--c-bg);
    color: var(--c-text);
    transition: background-color 0.3s, color 0.3s;
}
.hidden { 
    display: none !important; 
}
.app-container {
    display: flex;
    flex-grow: 1;
    gap: clamp(10px, 2vw, 20px);
    padding: clamp(10px, 2vw, 20px);
    height: calc(100vh - var(--footer-height));
    overflow: hidden;
}
.settings-panel {
    flex: 0 0 280px;
    background-color: var(--c-panel-bg);
    border-radius: var(--radius-lg);
    padding: 25px;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--c-border);
    transition: background-color 0.3s, border-color 0.3s;
    overflow-y: auto;
}
.settings-panel h3 { 
    margin: 0 0 20px 0; 
    text-align: center; 
    font-weight: 600; 
    font-size: 1.2em; 
    color: var(--c-text-header); 
}
.settings-group { 
    padding: 0; 
    margin: 0 0 20px 0; 
}
.settings-group:not(:first-of-type) { 
    border-top: 1px solid var(--c-border); 
    padding-top: 20px; 
}
#settings-wrapper.disabled { 
    opacity: 0.4; 
    pointer-events: none; 
}
.settings-group-title {
    font-weight: 600; 
    font-size: 1em; 
    color: var(--c-text-header);
    margin: 0 0 20px 0;
}
.setting-item { 
    margin-bottom: 20px; 
}
.setting-item:last-child { 
    margin-bottom: 0; 
}
.setting-item label { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 10px; 
    font-weight: 500; 
    font-size: 14px; 
}
.select-wrapper { 
    position: relative; 
}
.select-wrapper::after { 
    content: '▾'; 
    font-size: 16px; 
    position: absolute; 
    right: 12px; 
    top: 50%; 
    transform: translateY(-50%); 
    pointer-events: none; 
    color: var(--c-text-light); 
}
.setting-item select, .setting-item input[type="number"] {
    width: 100%; 
    padding: 10px 12px; 
    border-radius: var(--radius-md); 
    font-size: 14px;
    -webkit-appearance: none; 
    appearance: none;
    cursor: pointer;
    border: 1px solid var(--c-border);
    background-color: var(--c-input-bg);
    color: inherit;
    transition: border-color 0.25s ease-out;
}
.setting-item select:hover { 
    border-color: var(--primary-color); 
}
.slider-container { 
    display: flex; 
    align-items: center; 
    gap: 15px; 
}
input[type="range"] { 
    -webkit-appearance: none; 
    appearance: none; 
    width: 100%; 
    height: 6px; 
    border-radius: 3px; 
    outline: none; 
    cursor: pointer; 
    background: var(--c-input-bg); 
    border: 1px solid var(--c-border); 
}
input[type="range"]::-webkit-slider-thumb { 
    -webkit-appearance: none; 
    appearance: none; 
    width: 18px; 
    height: 18px; 
    border-radius: 50%; 
    cursor: pointer; 
    border: 3px solid var(--c-panel-bg); 
    box-shadow: 0 1px 3px rgba(0,0,0,0.2); 
    margin-top: -7px; 
    background: var(--primary-color); 
}
#quality-value { 
    font-weight: 600; 
    color: var(--primary-color); 
}
#preview-size-display { 
    font-size: 12px; 
    color: var(--c-text-light); 
}
.action-buttons { 
    display: flex; 
    gap: 10px; 
}
.action-buttons button { 
    flex: 1; 
    padding: 10px; 
    border-radius: var(--radius-md); 
    border: 1px solid; 
    font-weight: 500; 
    cursor: pointer; 
    transition: all 0.25s ease-out; 
}
.secondary-btn { 
    border-color: #ccc; 
    color: var(--c-text); 
    background-color: var(--c-panel-bg); 
}
.danger-btn { 
    border-color: var(--danger-color); 
    color: white; 
    background-color: var(--danger-color); 
}
.action-buttons button:hover:not(:disabled) { 
    transform: translateY(-2px); 
    box-shadow: var(--shadow-soft); 
}
.workspace { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    min-width: 0; 
}
#landing-view { 
    display: flex; 
    flex-direction: column; 
    height: 100%; 
    justify-content: center; 
    align-items: center; 
    text-align: center; 
}
.app-title { 
    font-weight: 700; 
    margin: 0 0 40px 0; 
    color: var(--c-text-header); 
    font-size: clamp(2em, 8vw, 2.8em); 
}
#main-drop-zone { 
    width: 80%; 
    max-width: 600px; 
    flex-grow: 1; 
    max-height: 40vh; 
    border: 2px dashed var(--c-border); 
    border-radius: var(--radius-lg); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    cursor: pointer; 
    transition: all 0.2s; 
    font-size: 1.2em; 
    color: var(--c-text-light); 
}
#main-drop-zone:hover, #main-drop-zone.highlight { 
    border-color: var(--primary-color); 
    background-color: var(--c-drop-zone-hover-bg); 
}
#app-view { 
    display: flex; 
    flex-direction: column; 
    gap: clamp(10px, 2vw, 20px); 
    height: 100%; 
    overflow: hidden; 
}
.queue-container { 
    flex-shrink: 0; 
    background-color: var(--c-panel-bg); 
    border-radius: var(--radius-lg); 
    padding: 10px; 
    box-shadow: var(--shadow-soft); 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    border: 1px solid var(--c-border); 
}
#add-more-zone { 
    height: 60px; 
    width: 60px; 
    border: 2px dashed var(--c-border); 
    border-radius: var(--radius-md); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    cursor: pointer; 
    color: var(--c-text-light); 
    font-size: 30px; 
    font-weight: 300; 
    flex-shrink: 0; 
    transition: all 0.2s; 
}
#add-more-zone:hover { 
    border-color: var(--primary-color); 
    color: var(--primary-color); 
}
#queue-list-wrapper { 
    display: flex; 
    flex-grow: 1; 
    gap: 10px; 
    overflow-x: auto; 
    padding: 5px 0; 
}
.queue-item { 
    position: relative; 
    cursor: pointer; 
    text-align: center; 
    flex-shrink: 0; 
    transition: transform 0.2s ease-out; 
}
.queue-item:hover { 
    transform: translateY(-2px) scale(1.05); 
}
.queue-item.dragging { 
    opacity: 0.5; 
}
.queue-item img { 
    width: 100px; 
    height: 56.25px; 
    object-fit: cover; 
    border-radius: 6px; 
    border: 3px solid transparent; 
    transition: border-color 0.2s; 
    display: block; 
}
.queue-item.selected img { 
    border-color: var(--primary-color); 
}
.queue-item .item-number { 
    position: absolute; 
    top: 4px; 
    left: 4px; 
    background-color: rgba(0,0,0,0.6); 
    color: white; 
    border-radius: 4px; 
    padding: 1px 4px; 
    font-size: 11px; 
    font-weight: bold; 
}
.delete-btn { 
    position: absolute; 
    top: -8px; 
    right: -8px; 
    width: 20px; 
    height: 20px; 
    background-color: var(--danger-color); 
    color: white; 
    border: 2px solid var(--c-panel-bg); 
    border-radius: 50%; 
    text-align: center; 
    line-height: 16px; 
    font-weight: bold; 
    cursor: pointer; 
    opacity: 0; 
    transition: all 0.2s; 
    transform: scale(0.5); 
    z-index: 2; 
}
.queue-item:hover .delete-btn { 
    opacity: 1; 
    transform: scale(1); 
}
.core-area { 
    flex-grow: 1; 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: clamp(10px, 2vw, 20px); 
    min-height: 0; 
}
.live-preview-panel, .editor-wrapper { 
    display: flex; 
    flex-direction: column; 
    background-color: var(--c-panel-bg); 
    border-radius: var(--radius-lg); 
    padding: clamp(15px, 2vw, 20px); 
    box-shadow: var(--shadow-soft); 
    border: 1px solid var(--c-border); 
    overflow: hidden; 
}
.live-preview-panel h4, .editor-wrapper h4 { 
    margin: 0 0 15px 0; 
    text-align: center; 
    color: var(--c-text-header); 
    font-weight: 600; 
    border-bottom: 1px solid var(--c-border); 
    padding-bottom: 15px; 
}
#live-preview-content { 
    flex-grow: 1; 
    display: flex; 
    align-items: flex-start; 
    justify-content: center; 
    background-color: var(--c-bg); 
    border-radius: var(--radius-md); 
    overflow-y: auto; 
    padding: 10px; 
}
#live-preview-content img { 
    max-width: 100%; 
    height: auto; 
    object-fit: contain; 
    border-radius: var(--radius-md); 
}
#editor-panel { 
    flex-grow: 1; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    position: relative; 
}
#editor-panel p { 
    color: var(--c-text-light); 
}
#editor-container { 
    position: relative; 
    max-width: 100%; 
    max-height: 100%; 
    line-height: 0; 
}
#editor-image { 
    display: block; 
    max-width: 100%; 
    max-height: 100%; 
    object-fit: contain; 
}
.drag-handle { 
    position: absolute; 
    left: 0; 
    width: 100%; 
    height: 2px; 
    background-color: var(--handle-color); 
    cursor: ns-resize; 
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.7); 
    z-index: 10; 
}
.drag-handle::after { 
    content: ''; 
    position: absolute; 
    top: 50%; 
    right: -4px; 
    transform: translateY(-50%); 
    width: 12px; 
    height: 12px; 
    background-color: var(--handle-color); 
    border: 2px solid var(--c-panel-bg); 
    border-radius: 50%; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.3); 
}
#download-button { 
    width: 100%; 
    padding: 12px; 
    font-size: 16px; 
    font-weight: bold; 
    color: #fff; 
    border: none; 
    border-radius: var(--radius-md); 
    cursor: pointer; 
    margin-top: 20px; 
    flex-shrink: 0; 
    background-color: var(--primary-color); 
    transition: all 0.25s ease-out; 
}
#download-button:hover:not(:disabled) { 
    background-color: var(--primary-color-hover); 
    transform: translateY(-2px); 
    box-shadow: var(--shadow-soft); 
}
#download-button:disabled { 
    background-color: #ccc; 
    cursor: not-allowed; 
}
#footer-container { 
    position: fixed; 
    bottom: 0; 
    left: 0; 
    width: 100%; 
    z-index: 20; 
}
.title-bar {
    height: var(--footer-height); 
    background-color: var(--c-panel-bg); 
    color: var(--c-text-light); 
    display: flex;
    align-items: center; 
    justify-content: space-between; 
    padding: 0 20px;
    border-top: 1px solid var(--c-border);
}
.title-bar h3 { 
    margin: 0; 
    font-size: 14px; 
    font-weight: 500; 
}
.footer-actions { 
    display: flex; 
    gap: 10px; 
}
.footer-btn { 
    background: none; 
    border: 1px solid var(--c-border); 
    color: var(--c-text-light); 
    border-radius: 6px; 
    padding: 4px 8px; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    transition: all 0.25s ease-out; 
}
.footer-btn:hover { 
    background-color: var(--c-bg); 
    color: var(--c-text); 
}
.footer-btn svg { 
    stroke: currentColor; 
}
@media (max-width: 900px) {
    body {
        height: auto;
        overflow-y: auto;
    }
    .app-container {
        flex-direction: column;
        height: auto;
    }
    .settings-panel {
        flex: 1 1 auto;
        overflow-y: visible;
    }
    .core-area {
        grid-template-columns: 1fr;
        min-height: auto;
    }
    .live-preview-panel, .editor-wrapper {
        min-height: 40vh;
    }
    #landing-view {
        min-height: 50vh;
    }
    .drag-handle {
        height: 10px;
        background-color: transparent;
        position: relative;
        transform: translateY(-50%);
    }
    .drag-handle::before {
        content: '';
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 100%;
        height: 2px;
        background-color: var(--handle-color);
    }
    .drag-handle::after {
        width: 16px;
        height: 16px;
    }
}
@media (max-width: 480px) {
    #app-view, .app-container {
        gap: 10px;
        padding: 10px;
    }
    .settings-panel {
        padding: 15px;
    }
    #app-title-footer {
        display: none;
    }
    .title-bar {
        justify-content: flex-end;
    }
}