:root {
    --bg: #0f1115;
    --card: #181b22;
    --text: #e6e8ee;
    --muted: #9aa0b4;
    --accent: #4f7cff;
    --accent-hover: #6a90ff;
    --border: #2a2f3a;
    --radius: 14px;
    --def-width: min(1100px, 80vw);
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at top, #1a1f2b, var(--bg));
    font-family: Inter, system-ui, sans-serif;
    color: var(--text);
    padding: 40px 0;
}

#toast-container {
    padding: 24px;
    z-index: 20;
    pointer-events: none;
    width: var(--def-width);
}

.toast {
    background: oklch(62.7% 0.194 149.214);
    color: #e6e8ee;
    padding: 12px 20px;
    border-radius: 14px;
    font-size: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transform: translateY(-10px);
    animation: toast-in 0.25s ease forwards;
}

@keyframes toast-in {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .toast {
        font-size: 15px;
        padding: 14px 22px;
    }
}

.card {
    width: var(--def-width);
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.title {
    font-size: 22px;
    font-weight: 600;
}

.subtitle {
    color: var(--muted);
    font-size: 14px;
}

.controls {
    display: flex;
    gap: 12px;
}

button {
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    transition: .2s;
    background: var(--accent);
    border: none;
    color: #fff;
}

button:hover {
    background: var(--accent-hover);
}

button.disabled {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    opacity: .6;
    cursor: not-allowed;
}

/* #region Advanced settings */
.advanced {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s, padding 0.3s;
    opacity: 0;
    padding: 0 20px;
}

.advanced.show {
    max-height: 2000px;
    opacity: 1;
    padding: 20px;
}

.advanced-title {
    align-items: center;
    background: #1f2129;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 16px;
    margin-bottom: 10px;
    position: relative;
    transition: background 0.2s;
    text-align: center;
}

.advanced-row {
    display: flex;
    align-items: center;
    background: #1f2129;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 16px;
    margin-bottom: 10px;
    position: relative;
    transition: background 0.2s;
}

.advanced-row:hover {
    background: rgba(79, 124, 255, 0.15);
}

.adv-brushes-settings {
    padding: 12px 0;
}

.adv-brush-settings {
    padding: 4px 0;
}

.adv-label {
    font-weight: 500;
    cursor: help;
    flex: 1;
    position: relative;
}

.adv-tooltip {
    display: none;
    position: absolute;
    top: 110%;
    left: 0;
    background: rgba(32, 35, 42, 0.95);
    color: #e6e8ee;
    padding: 8px;
    border-radius: 8px;
    font-size: 13px;
    width: 300px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.adv-label:hover .adv-tooltip {
    display: block;
}

.adv-input-span {
    display: flex;
    align-items: center;
}

.adv-input {
    width: 120px;
    padding: 10px 12px;
    border-radius: 8px;
    border: none;
    background: #181b22;
    color: #e6e8ee;
    font-size: 16px;
    text-align: right;
}

.adv-input:focus {
    outline: 2px solid var(--accent);
}

/* hide native checkbox */
.adv-toggle {
    appearance: none;
    -webkit-appearance: none;
    width: 44px;
    height: 24px;
    background: #2a2d38;
    border-radius: 999px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s ease;
}

/* knob */
.adv-toggle::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: #9aa0b4;
    border-radius: 50%;
    transition: transform 0.2s ease, background 0.2s ease;
}

/* checked state */
.adv-toggle:checked {
    background: var(--accent);
}

.adv-toggle:checked::before {
    transform: translateX(20px);
    background: white;
}

/* focus (keyboard accessibility) */
.adv-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.unit {
    margin-left: 6px;
    width: 20px;
    color: #9aa0b4;
}

#advancedControls {
    flex-direction: row;
    justify-content: center;
}

#advancedControls > * {
    flex: max-content;
}

/* #endregion */

.upload {
    display: flex;
    align-items: center;
    justify-content: center;

    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 28px;
    text-align: center;
    color: var(--muted);
    margin-bottom: 16px;
    transition: .2s;
}

.upload:hover {
    border-color: var(--accent);
    background: rgba(79, 124, 255, .1);
    color: #fff;
}

.upload input {
    display: none;
}

#dropOverlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 21, .6);
    backdrop-filter: blur(6px);
    z-index: 999;
    display: none;
    align-items: center;
    justify-content: center;
}

#dropOverlay.active {
    display: flex;
}

.dropHint {
    width: 95vw;
    height: 95vh;
    border: 3px dashed var(--accent);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: var(--text);
    background: rgba(79, 124, 255, .08);
}

.progress-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

progress {
    width: 100%;
    margin-top: 10px;
    height: 12px;
    border-radius: 999px;
    overflow: hidden;
}

progress::-webkit-progress-bar {
    background: var(--border);
}

progress::-webkit-progress-value {
    background: linear-gradient(90deg, var(--accent), #8aa3ff);
}

#canvas-wrap {
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    background: #000;
}

canvas {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 12px;
}

.hidden {
    display: none;
}

@media (max-width: 768px) {

    body {
        font-size: 16px;
    }

    h1 {
        font-size: 24px;
    }

    #advancedControls,
    .controls {
        flex-direction: column;
        gap: 12px;
    }

    button {
        width: 100%;
        font-size: 16px;
        padding: 14px 16px;
        border-radius: 12px;
    }

    .progress {
        font-size: 15px;
    }

    .advanced {
        padding: 12px;
    }

    .advanced-row {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    .adv-label {
        font-size: 15px;
    }

    .adv-input-span {
        width: 100%;
    }

    .adv-input {
        width: 100%;
        font-size: 16px;
        padding: 12px;
    }

    .unit {
        font-size: 14px;
    }
}
