body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background:
        radial-gradient(circle at top, rgba(255, 153, 0, 0.2), transparent 30%),
        radial-gradient(circle at 80% 20%, rgba(0, 212, 170, 0.16), transparent 28%),
        linear-gradient(160deg, #121212 0%, #1d1d1d 48%, #111111 100%);
    color: #f4efe7;
    font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", sans-serif;
    touch-action: none;
}

body {
    display: flex;
    flex-direction: column;
    position: relative;
}

body::before,
body::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
}

body::before {
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0, rgba(255, 255, 255, 0.025) 1px, transparent 1px, transparent 72px),
        linear-gradient(rgba(255, 255, 255, 0.018) 0, rgba(255, 255, 255, 0.018) 1px, transparent 1px, transparent 72px);
    opacity: 0.35;
}

body::after {
    background: radial-gradient(circle at center, transparent 40%, rgba(0, 0, 0, 0.32) 100%);
}

.controlApp {
    min-height: 100%;
}

.appShell {
    position: relative;
    z-index: 1;
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    padding: 18px;
    gap: 16px;
}

#header {
    background:
        linear-gradient(135deg, rgba(30, 30, 30, 0.94), rgba(18, 18, 18, 0.9)),
        linear-gradient(90deg, rgba(255, 153, 0, 0.12), rgba(0, 212, 170, 0.12));
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 18px 20px;
    box-sizing: border-box;
    gap: 18px;
    flex-wrap: wrap;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 22px;
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(10px);
}

.headerCopy {
    max-width: 520px;
}

.eyebrow {
    font-size: 11px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: #ffb347;
    margin-bottom: 8px;
}

.headerCopy h1 {
    margin: 0;
    font-size: clamp(28px, 5vw, 42px);
    line-height: 0.95;
    letter-spacing: 0.02em;
}

.headerCopy p {
    margin: 10px 0 0;
    max-width: 38ch;
    color: rgba(244, 239, 231, 0.76);
    font-size: 15px;
    line-height: 1.45;
}

.headerActions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    margin-left: auto;
    align-content: center;
}

#colorPicker {
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    cursor: pointer;
    background: transparent;
}

#clearButton {
    background: linear-gradient(135deg, #f25f4c, #d9482f);
    color: white;
    border: none;
    padding: 9px 13px;
    border-radius: 999px;
    font-weight: bold;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(242, 95, 76, 0.24);
}

.secondaryButton {
    background: linear-gradient(135deg, #00b894, #008f79);
    color: white;
    border: none;
    padding: 9px 13px;
    border-radius: 999px;
    font-weight: bold;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(0, 184, 148, 0.2);
}

.colorDock,
#clearButton,
.secondaryButton,
#commsInfoDiv {
    min-height: 40px;
}

.colorDock,
#clearButton,
.secondaryButton {
    transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease, background 140ms ease;
}

.colorDock:active,
#clearButton:active,
.secondaryButton:active {
    transform: translateY(1px) scale(0.99);
}

.secondaryButton:disabled {
    opacity: 0.48;
    cursor: default;
    box-shadow: none;
}

.hiddenControl {
    display: none;
}

.colorDock {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 5px 8px 5px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #f8f3eb;
    font-size: 11px;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

#commsInfoDiv {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    font-size: 11px;
    margin-left: 2px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.84);
}

#commsInfo {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    letter-spacing: 0.04em;
}

.statusDot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ffb347;
    box-shadow: 0 0 16px rgba(255, 179, 71, 0.8);
}

#drawContainer {
    width: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.stageFrame {
    position: relative;
    width: min(100%, 920px);
    height: min(100%, 920px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    border-radius: 32px;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)),
        rgba(14, 14, 14, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow:
        0 35px 70px rgba(0, 0, 0, 0.38),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    box-sizing: border-box;
}

#drawSurface {
    background:
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.06), transparent 30%),
        radial-gradient(circle at 80% 80%, rgba(255, 179, 71, 0.08), transparent 28%),
        linear-gradient(160deg, #4e4a46, #36322f 46%, #262220 100%);
    position: relative;
    user-select: none;
    touch-action: none;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-sizing: border-box;
    border-radius: 26px;
    overflow: hidden;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        inset 0 -24px 45px rgba(0, 0, 0, 0.22);
}

#drawSurface::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(120deg, rgba(255, 255, 255, 0.02), transparent 24%, transparent 75%, rgba(255, 255, 255, 0.025)),
        radial-gradient(circle at center, transparent 0, transparent 42%, rgba(0, 0, 0, 0.18) 100%);
    pointer-events: none;
}

#drawSurface.motionMode {
    border-color: rgba(0, 212, 170, 0.52);
    background:
        radial-gradient(circle at center, rgba(0, 212, 170, 0.17), rgba(0, 212, 170, 0.05) 40%, transparent 75%),
        radial-gradient(circle at 80% 20%, rgba(255, 179, 71, 0.14), transparent 28%),
        linear-gradient(160deg, #28403c, #1f3330 46%, #162a27 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        inset 0 -24px 45px rgba(0, 0, 0, 0.22),
        0 0 0 1px rgba(0, 212, 170, 0.24),
        0 0 40px rgba(0, 212, 170, 0.18);
}

.surfaceLabel,
.surfaceCaption {
    z-index: 1;
    pointer-events: none;
}

.surfaceLabel {
    position: absolute;
    left: 22px;
    top: 18px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(15, 15, 15, 0.44);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(255, 245, 232, 0.8);
}

.bottomInfo {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    flex: 0 0 122px;
    min-height: 122px;
    gap: 10px;
    padding: 2px 8px 0;
    box-sizing: border-box;
}

.surfaceCaption {
    max-width: min(680px, 92vw);
    min-height: 40px;
    padding: 10px 12px;
    border-radius: 16px;
    background: rgba(15, 15, 15, 0.38);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(244, 239, 231, 0.68);
    font-size: 12px;
    line-height: 1.45;
    text-align: center;
    box-sizing: border-box;
}

#status {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px 22px;
    min-height: 62px;
    border-radius: 22px;
    background: rgba(12, 12, 12, 0.42);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 245, 232, 0.88);
    pointer-events: none;
    text-align: center;
    width: min(85%, 320px);
    line-height: 1.4;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    text-wrap: balance;
    box-sizing: border-box;
}

body.motionEnabled .statusDot {
    background: #00d4aa;
    box-shadow: 0 0 16px rgba(0, 212, 170, 0.85);
}

body.motionEnabled .secondaryButton:not(:disabled) {
    background: linear-gradient(135deg, #ff9f1c, #ff7b00);
    box-shadow: 0 10px 25px rgba(255, 123, 0, 0.24);
}

@media (hover: hover) {
    .colorDock:hover,
    #clearButton:hover,
    .secondaryButton:hover:not(:disabled) {
        transform: translateY(-1px);
        filter: brightness(1.04);
    }
}

@media (max-width: 760px) {
    .appShell {
        padding: 12px;
        gap: 12px;
    }

    #header {
        padding: 16px;
        border-radius: 20px;
    }

    .headerActions {
        justify-content: flex-start;
        margin-left: 0;
    }

    .stageFrame {
        padding: 12px;
        border-radius: 24px;
    }

    #drawSurface {
        border-radius: 20px;
    }

    .surfaceCaption {
        max-width: min(92vw, 420px);
    }

    .bottomInfo {
        flex-basis: 138px;
        min-height: 138px;
    }
}
