:root {
    --bg: #ffffff;
    --panel: #f3f2ee;
    --ink: #17171a;
    --muted: #6d6b66;
    --grid: #ebe9e4;
    --line: #d9d6cf;
    --accent: #2f5fd0;
    --accent-ink: #ffffff;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #141517;
        --panel: #1f2124;
        --ink: #f0efeb;
        --muted: #a09c94;
        --grid: #232529;
        --line: #3a3d42;
        --accent: #7ea2ff;
        --accent-ink: #10131a;
    }
    .lg-openai { filter: invert(1); }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--sans); }

.app {
    display: grid; grid-template-columns: 270px minmax(0, 620px); gap: 48px;
    justify-content: center; align-items: start;
    padding: 32px 20px 48px;
}

/* ---------- side panel ---------- */
.side { position: sticky; top: 24px; }
h1 { margin: 0; font-size: 34px; font-weight: 800; letter-spacing: -0.03em; }
h2 { margin: 22px 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.sub { margin: 6px 0 0; color: var(--muted); }
.notice { margin-top: 16px; padding: 14px; border-radius: 8px; background: var(--panel); }
.how { margin: 18px 0 0; padding: 0; list-style: none; font-size: 14px; }
.how li { margin-bottom: 8px; }

.tray {
    display: flex; flex-direction: column; gap: 8px;
    min-height: 56px; padding: 10px; border-radius: 10px; background: var(--panel);
}
.tray:empty::before { content: "Everyone is placed. Submit when you are happy."; color: var(--muted); font-size: 14px; }

.legend { margin: 22px 0 0; padding: 0; list-style: none; font-size: 14px; }
.legend li { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.k { flex: none; width: 22px; height: 22px; display: grid; place-items: center; }
.k::before { content: ""; border-radius: 50%; }
.k-med::before { width: 20px; height: 20px; background: var(--muted); }
.k-pt::before { width: 10px; height: 10px; background: var(--muted); opacity: 0.75; }
.k-self::before { width: 10px; height: 10px; background: var(--muted); outline: 2px solid var(--ink); outline-offset: 2px; }

button {
    margin-top: 18px; width: 100%; padding: 11px 16px;
    font: inherit; font-weight: 700; border: 0; border-radius: 8px;
    background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
button:disabled { opacity: 0.35; cursor: default; }
.readout { margin: 10px 0 0; min-height: 3em; color: var(--muted); font-size: 14px; }

/* ---------- plane ---------- */
.stage { user-select: none; -webkit-user-select: none; }
.pole { padding: 18px 0; text-align: center; font-size: 13px; color: var(--muted); }
.pole b, .pole-in b { display: block; font-size: 15px; color: var(--ink); }

.field {
    position: relative; aspect-ratio: 1 / 1; margin: 0 12px;
    background-color: var(--bg);
    background-image:
        linear-gradient(to right, var(--grid) 1px, transparent 1px),
        linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
    background-size: calc(100% / 18) 100%, 100% calc(100% / 20);
    border-right: 1px solid var(--grid); border-bottom: 1px solid var(--grid);
}

.axis { position: absolute; background: var(--ink); pointer-events: none; }
.axis::before, .axis::after { content: ""; position: absolute; border: 7px solid transparent; }
.axis.x { left: -10px; right: -10px; top: 50%; height: 3px; margin-top: -1.5px; }
.axis.x::before { left: -7px; top: -5.5px; border-left: 0; border-right-color: var(--ink); }
.axis.x::after { right: -7px; top: -5.5px; border-right: 0; border-left-color: var(--ink); }
.axis.y { top: -10px; bottom: -10px; left: 50%; width: 3px; margin-left: -1.5px; }
.axis.y::before { top: -7px; left: -5.5px; border-top: 0; border-bottom-color: var(--ink); }
.axis.y::after { bottom: -7px; left: -5.5px; border-bottom: 0; border-top-color: var(--ink); }

.tk { position: absolute; font: 12px var(--mono); color: var(--muted); pointer-events: none; white-space: nowrap; }
.tk.x { top: 50%; padding-top: 17px; transform: translateX(-50%); text-align: center; line-height: 1.25; }
/* vendor logo sitting on the axis as the landmark's marker */
.lg {
    position: absolute; left: 50%; top: -13px; margin-left: -13px;
    width: 26px; height: 26px; padding: 4px; border-radius: 50%;
    background: var(--bg); border: 1.5px solid var(--ink);
}
.tk.x b { display: block; font: 600 12px var(--sans); color: var(--ink); }
.tk.y { left: 50%; margin-left: 10px; transform: translateY(-50%); }
.tk.y.start { transform: translateY(-100%); margin-top: -4px; }
.tk.y.end { transform: none; margin-top: 4px; }

.pole-in { position: absolute; bottom: 50%; margin-bottom: 8px; pointer-events: none; }
.pole-in.left { left: 4px; }
.pole-in.right { right: 4px; text-align: right; }

.quad {
    position: absolute; width: 50%; height: 50%; padding: 12px;
    display: flex; flex-direction: column; font-size: 12px; line-height: 1.35;
    color: var(--muted); opacity: 0.75; pointer-events: none;
}
.q-tl { left: 0; top: 0; }
.q-tr { right: 0; top: 0; text-align: right; }
.q-bl { left: 0; bottom: 0; justify-content: flex-end; }
.q-br { right: 0; bottom: 0; justify-content: flex-end; text-align: right; }


/* crosshair: reads the dragged or selected person off both axes */
.guide { position: absolute; pointer-events: none; border: 0 dashed var(--accent); }
.guide.v { top: 0; bottom: 0; border-left-width: 1px; }
.guide.h { left: 0; right: 0; border-top-width: 1px; }
.gval {
    position: absolute; z-index: 3; pointer-events: none; white-space: nowrap;
    padding: 2px 6px; border-radius: 4px; font: 700 12px var(--mono);
    background: var(--accent); color: var(--accent-ink);
}
.gval.gx { top: 50%; margin-top: -16px; transform: translate(-50%, -100%); }   /* above the axis, clear of the logos */
.gval.gy { left: 50%; transform: translate(-50%, -50%); }

/* ---------- tokens ---------- */
.tok { display: flex; align-items: center; gap: 8px; cursor: grab; touch-action: none; font-weight: 600; }
.tok .dot {
    width: 32px; height: 32px; border-radius: 50%; flex: none;
    display: grid; place-items: center;
    background: var(--c); color: #fff; font-size: 12px; font-weight: 700;
    border: 2px solid var(--bg); box-shadow: 0 1px 4px rgb(0 0 0 / 0.35);
}
.tok.me .dot { outline: 2px solid var(--ink); outline-offset: 1px; }
.field .tok, .tok.drag { position: absolute; transform: translate(-50%, -50%); z-index: 2; }
.field .tok .nm, .tok.drag .nm {
    position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
    margin-top: 2px; padding: 0 4px; border-radius: 3px;
    font-size: 12px; white-space: nowrap; pointer-events: none; background: var(--bg);
}
.tok.drag { position: fixed; z-index: 10; cursor: grabbing; }
.field.results .tok { cursor: pointer; }
.field.locked .tok { cursor: default; }
.field.focus .tok:not(.on) { opacity: 0.15; }

.pt { position: absolute; transform: translate(-50%, -50%); border-radius: 50%; z-index: 1; width: 10px; height: 10px; background: var(--c); opacity: 0.8; }
.pt.self { opacity: 1; outline: 2px solid var(--ink); outline-offset: 2px; }
/* a signed vote, shown for the selected person */
.pt.big {
    width: 24px; height: 24px; opacity: 1; z-index: 4;
    display: grid; place-items: center; color: #fff; font-size: 10px; font-weight: 700;
    border: 1.5px solid var(--bg); cursor: default;
}
/* the median marker is a ringed token, so it reads differently from the votes */
.tok.med .dot { box-shadow: 0 0 0 2px var(--c), 0 1px 4px rgb(0 0 0 / 0.35); }
/* selected: a hollow ring, so it cannot be mistaken for one of the signed votes */
.tok.med.on .dot { background: transparent; color: transparent; border: 3px solid var(--c); box-shadow: none; }

/* ---------- results table ---------- */
.board { width: 100%; margin-top: 16px; border-collapse: collapse; font-size: 13px; user-select: text; }
.board th, .board td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
.board th { color: var(--muted); font-weight: 400; }
.board td:nth-child(n+3) { font-family: var(--mono); font-size: 12px; }
.board tbody tr { cursor: pointer; }
.board tbody tr.on { background: var(--panel); }
.board .sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: 6px; }

@media (max-width: 860px) {
    .app { grid-template-columns: minmax(0, 620px); gap: 8px; padding: 20px 12px 40px; }
    .side { position: static; }
    .tray { flex-direction: row; flex-wrap: wrap; gap: 8px 16px; }
    .readout { min-height: 1.5em; }
    .quad { font-size: 11px; padding: 8px; }
    .tk.x, .tk.x b { font-size: 10px; }
    .lg { top: -11px; margin-left: -11px; width: 22px; height: 22px; padding: 3px; }
    .tk.x { padding-top: 14px; }
    .board th:last-child, .board td:last-child { display: none; }
}
