:root {
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --bg-main: #0f172a;
    --bg-panel: #1e293b;
    --bg-surface: #334155;

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #475569;

    --radius: 8px;
    --font-ui: 'Inter', system-ui, sans-serif;
}

[data-theme="light"] {
    --bg-main: #f8fafc;
    --bg-panel: #ffffff;
    --bg-surface: #e2e8f0;

    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #cbd5e1;
}

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

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

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary);
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 0.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.btn-icon:hover {
    color: var(--primary);
    background-color: var(--bg-surface);
}

main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Sidebar */
.controls-panel {
    width: 360px;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.control-section {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.control-section h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

textarea {
    width: 100%;
    background: var(--bg-main);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.75rem;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    outline: none;
}

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

.select-input,
.file-input {
    width: 100%;
    background: var(--bg-main);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.6rem;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
}

.color-group {
    display: flex;
    gap: 1rem;
}

.color-picker-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.color-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.25rem 0.5rem;
}

.color-input input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    background: none;
    padding: 0;
}

.color-input input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-input input[type="color"]::-webkit-color-swatch {
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.color-input span {
    font-size: 0.8rem;
    font-family: monospace;
    color: var(--text-muted);
}

.radio-group {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-main);
    padding: 0.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.radio-group label {
    flex: 1;
    text-align: center;
    position: relative;
    cursor: pointer;
}

.radio-group input[type="radio"] {
    position: absolute;
    opacity: 0;
}

.radio-group span {
    display: block;
    padding: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-main);
    border-radius: 4px;
    transition: 0.2s;
    user-select: none;
}

.radio-group input[type="radio"]:checked+span {
    background: var(--bg-surface);
    color: var(--primary);
    font-weight: 600;
}

[data-theme="light"] .radio-group input[type="radio"]:checked+span {
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Buttons */
.btn {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    border: none;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    transition: 0.2s;
}

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

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

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

.btn-secondary:hover {
    filter: brightness(1.1);
}

.w-100 {
    width: 100%;
}

.mt-2 {
    margin-top: 0.75rem;
}

.hidden {
    display: none !important;
}

/* Preview */
.preview-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    background: repeating-linear-gradient(45deg,
            rgba(255, 255, 255, 0.02) 0px,
            rgba(255, 255, 255, 0.02) 20px,
            transparent 20px,
            transparent 40px);
    align-items: center;
    justify-content: center;
}

.preview-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.qr-wrapper {
    background: #fff;
    /* QR codes need high contrast, usually white bg */
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    transition: 0.3s;
}

.action-bar {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-main);
    color: var(--bg-main);
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    font-weight: 500;
    transition: 0.3s;
    opacity: 0;
    z-index: 1000;
}

.toast.show {
    bottom: 30px;
    opacity: 1;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
}