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

:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #252525;
    --bg-tertiary: #303030;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --accent: #4a9eff;
    --accent-hover: #6bb3ff;
    --border: #404040;
    --success: #4ade80;
    --error: #f87171;
}

html, body {
    height: 100%;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar Controls */
.controls {
    width: 320px;
    min-width: 320px;
    background-color: var(--bg-secondary);
    padding: 24px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    border-right: 1px solid var(--border);
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
    line-height: 1.5;
}

/* Form Styles */
#poster-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

input[type="text"],
select {
    padding: 12px 14px;
    font-size: 1rem;
    font-family: inherit;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.2);
}

input[type="text"]::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a0a0a0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

/* Range Slider */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.distance-hints {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 14px 20px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--accent);
    color: white;
    margin-top: 8px;
}

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

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-secondary:hover:not(:disabled) {
    background-color: var(--border);
}

.btn-secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Status Messages */
.status {
    margin-top: 16px;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.875rem;
    line-height: 1.5;
    min-height: 44px;
}

.status:empty {
    display: none;
}

.status.loading {
    background-color: rgba(74, 158, 255, 0.1);
    color: var(--accent);
}

.status.success {
    background-color: rgba(74, 222, 128, 0.1);
    color: var(--success);
}

.status.error {
    background-color: rgba(248, 113, 113, 0.1);
    color: var(--error);
}

/* Attribution */
.attribution {
    margin-top: auto;
    padding-top: 24px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

.attribution a {
    color: var(--text-secondary);
    text-decoration: underline;
}

.attribution a:hover {
    color: var(--text-primary);
}

/* Canvas Area */
.canvas-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background-color: var(--bg-primary);
    overflow: auto;
}

.canvas-wrapper {
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    overflow: hidden;
}

#poster-canvas {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 80px);
    width: auto;
    height: auto;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(26, 26, 26, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.loading-overlay.hidden {
    display: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#loading-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 900px) {
    .app-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }
    
    .controls {
        width: 100%;
        min-width: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .canvas-container {
        padding: 20px;
    }
    
    #poster-canvas {
        max-height: none;
    }
}
