:root {
    --bar: #343a40;
    --red: #dc3545;
    --green: #28a745;
    --blue: #007bff;
    --panel: #e2e3e5;
    --panel-line: #d6d8db;
    --ink: #383d41;
    --ink-soft: #6c757d;
    --page: #000000;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background-color: var(--page);
    color: var(--ink);
    font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---- top bar ---- */

.topbar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.6rem 1rem;
    background: var(--bar);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: #fff;
    font-size: 1.25rem;
    text-decoration: none;
}

.dots { display: inline-flex; gap: 3px; }
.dots i { width: 9px; height: 9px; border-radius: 50%; }
.dots i:nth-child(1) { background: var(--red); }
.dots i:nth-child(2) { background: var(--green); }
.dots i:nth-child(3) { background: var(--blue); }

.topbar-tools { display: flex; align-items: center; gap: 0.75rem; margin-left: auto; }

.pill {
    padding: 0.15rem 0.7rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 0.85rem;
    white-space: nowrap;
}

.barbutton {
    padding: 0.3rem 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 0.25rem;
    background: transparent;
    color: #fff;
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
}

.barbutton:hover { background: #fff; color: var(--bar); }
.barbutton:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---- layout ---- */

.layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 22rem));
    justify-content: center;
    align-items: start;
    gap: 1.25rem;
    padding: 1.5rem 1rem 3rem;
}

.column { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; min-width: 0; }

@media (max-width: 720px) {
    .layout { grid-template-columns: minmax(0, 26rem); }
}

/* ---- channel cards ---- */

.channel {
    color: #fff;
    border-radius: 0.3rem;
    border: 1px solid rgba(255, 255, 255, 0.22);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.channel.red { background: var(--red); }
.channel.green { background: var(--green); }
.channel.blue { background: var(--blue); }

.channel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 1.1rem;
    background: rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid rgba(0, 0, 0, 0.12);
}

.channel-head label { font-size: 1.35rem; font-weight: 500; }

.channel-head input {
    width: 4.2rem;
    padding: 0.15rem 0.4rem;
    border: 1px solid transparent;
    border-radius: 0.25rem;
    background: rgba(0, 0, 0, 0.14);
    color: #fff;
    font: 600 1.15rem/1.4 var(--mono);
    text-align: right;
    -moz-appearance: textfield;
    appearance: textfield;
}

.channel-head input::-webkit-outer-spin-button,
.channel-head input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.channel-head input:focus { outline: none; border-color: #fff; }

.channel-body { padding: 1.25rem 1.1rem 1.4rem; }

/* ---- sliders ---- */

input[type=range] {
    --from: #000;
    --to: #fff;
    display: block;
    width: 100%;
    height: 1.5rem;
    margin: 0;
    background: transparent;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

input[type=range]::-webkit-slider-runnable-track {
    height: 0.7rem;
    border-radius: 1rem;
    background: linear-gradient(to right, var(--from), var(--to));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

input[type=range]::-moz-range-track {
    height: 0.7rem;
    border-radius: 1rem;
    background: linear-gradient(to right, var(--from), var(--to));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 1.4rem;
    height: 1.4rem;
    margin-top: -0.35rem;
    border: 2px solid var(--bar);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

input[type=range]::-moz-range-thumb {
    width: 1.4rem;
    height: 1.4rem;
    border: 2px solid var(--bar);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

input[type=range]:focus-visible { outline: 2px solid #fff; outline-offset: 4px; border-radius: 1rem; }
input[type=range]:disabled { cursor: default; }
input[type=range]:disabled::-webkit-slider-thumb { background: #ced4da; }
input[type=range]:disabled::-moz-range-thumb { background: #ced4da; }

/* ---- panels ---- */

.panel {
    padding: 0.9rem 1.1rem 1.1rem;
    background: var(--panel);
    border: 1px solid var(--panel-line);
    border-radius: 0.3rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.panel-title { display: block; margin-bottom: 0.5rem; font-size: 1.2rem; }

.field { display: flex; align-items: center; gap: 0.5rem; }
.field + .field, .hint + .field { margin-top: 0.5rem; }

.field input[type=text] {
    flex: 1;
    min-width: 0;
    padding: 0.45rem 0.8rem;
    border: 1px solid #ced4da;
    border-radius: 0.3rem;
    background: #fff;
    color: #212529;
    font: 1.2rem/1.5 var(--mono);
}

.field input[type=text]:focus {
    outline: none;
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.field input[type=text][aria-invalid=true] { border-color: var(--red); }
.field input[type=text]:read-only { background: #f1f3f5; }

.field.small output {
    flex: 1;
    min-width: 0;
    padding: 0.3rem 0.8rem;
    font: 0.95rem/1.5 var(--mono);
    color: var(--ink);
    overflow-wrap: anywhere;
}

.copy {
    flex: none;
    min-width: 4.4rem;
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--ink-soft);
    border-radius: 0.25rem;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}

.copy:hover { background: var(--ink-soft); color: #fff; }
.copy:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.hint { margin: 0.35rem 0 0; font-size: 0.85rem; color: var(--ink-soft); }
.hint.error { color: #a71d2a; }

/* ---- image upload ---- */

.dropzone {
    display: block;
    padding: 0.9rem 0.8rem;
    border: 1px dashed var(--ink-soft);
    border-radius: 0.3rem;
    background: #fff;
    color: var(--ink-soft);
    text-align: center;
    cursor: pointer;
    overflow-wrap: anywhere;
}

.dropzone:hover, .dragging .dropzone { border-color: var(--blue); color: var(--ink); }
.dropzone:focus-within { border-color: #80bdff; box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
.swatches:not(:empty) { margin-top: 0.75rem; }

.swatch {
    padding: 0.55rem 0;
    border: 1px solid rgba(0, 0, 0, 0.25);
    border-radius: 0.25rem;
    font: 0.8rem/1.4 var(--mono);
    cursor: pointer;
}

.swatch:hover { box-shadow: 0 0 0 2px var(--ink); }
.swatch:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.swatches .hint { grid-column: 1 / -1; margin: 0; }

/* ---- colour session ---- */

.role {
    flex: none;
    padding: 0.2rem 0.6rem;
    border-radius: 1rem;
    background: var(--bar);
    color: #fff;
    font-size: 0.8rem;
}

.join { display: flex; gap: 0.9rem; align-items: flex-start; margin-top: 0.9rem; }

.qr {
    flex: none;
    padding: 0.3rem;
    border: 1px solid var(--panel-line);
    border-radius: 0.3rem;
    background: #fff;
    line-height: 0;
    cursor: zoom-in;
}

.qr img { display: block; width: 7.5rem; height: 7.5rem; }
.qr:hover { box-shadow: 0 0 0 2px var(--ink); }
.qr:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.links { min-width: 0; font-size: 0.9rem; overflow-wrap: anywhere; }
.links p { margin: 0 0 0.45rem; }
.links a { color: #0056b3; font-family: var(--mono); font-size: 0.85rem; }
.links a.plain { display: block; margin-top: 0.5rem; font-family: inherit; }

/* ---- image pixel picker ---- */

.picker { position: relative; margin-top: 0.75rem; line-height: 0; }
.picker[hidden] { display: none; }

.picker canvas {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid rgba(0, 0, 0, 0.25);
    border-radius: 0.25rem;
    cursor: crosshair;
    touch-action: none;
}

.marker {
    position: absolute;
    width: 1.1rem;
    height: 1.1rem;
    margin: -0.55rem 0 0 -0.55rem;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px #000, inset 0 0 0 1px #000;
    pointer-events: none;
}

/* ---- big QR overlay ---- */

.overlay {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.8);
    cursor: zoom-out;
}

.overlay[hidden] { display: none; }

.overlay-card {
    padding: 1rem 1rem 0.75rem;
    border-radius: 0.5rem;
    background: #fff;
    text-align: center;
}

.overlay-card img { display: block; width: min(80vw, 62vh); height: min(80vw, 62vh); }
.overlay-card p { margin: 0.4rem 0 0; }
#qrurl { font: 1.15rem/1.4 var(--mono); color: #212529; overflow-wrap: anywhere; }

/* ---- light mode: nothing on screen but the colour ---- */

body.light { cursor: pointer; }
body.light .topbar, body.light .layout { display: none; }

.lighthint {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(2rem + env(safe-area-inset-bottom));
    color: var(--on-page, #fff);
    text-align: center;
    pointer-events: none;
    animation: fadehint 4s forwards;
}

body.light .lighthint { display: block; }

@keyframes fadehint {
    0%, 60% { opacity: 0.7; }
    100% { opacity: 0; }
}

@media (max-width: 380px) {
    .join { flex-direction: column; align-items: center; text-align: center; }
}
