:root {
    --ink:      #17111f;
    --panel:    #1e1727;
    --panel-2:  #261d31;
    --edge:     #3a2b46;
    --cream:    #f7ecdc;
    --mute:     #a08fae;
    --pumpkin:  #ff7d1f;
    --grape:    #a874ff;
    --amber:    #ffc95c;
    --moss:     #6ee7a8;
    --blood:    #ff6070;

    --radius:   12px;
    --gap:      18px;

    --display:  "Alfa Slab One", Ultra, Rockwell, "Roboto Slab", Georgia, serif;
    --ui:       "Inter Tight", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
    margin: 0;
    padding: 0 0 48px;
    background:
        radial-gradient(1100px 620px at 50% -10%, #2a1d38 0%, transparent 70%),
        var(--ink);
    color: var(--cream);
    font-family: var(--ui);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.wrap {
    max-width: 1220px;
    margin: 0 auto;
    padding: 0 22px;
}

a { color: var(--amber); }

/* ---------- top strip ---------- */

.topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px 20px;
    padding: 22px 0 20px;
    border-bottom: 1px solid var(--edge);
    margin-bottom: var(--gap);
}

.wordmark {
    font-family: var(--display);
    font-weight: 700;
    font-synthesis-weight: none;
    font-size: 26px;
    letter-spacing: .01em;
    line-height: 1;
    margin: 0;
    color: var(--cream);
}

.wordmark span { color: var(--pumpkin); }

.lamp {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--mute);
    flex: none;
}

.lamp.is-online    { background: var(--moss);   box-shadow: 0 0 0 4px rgba(110, 231, 168, .16); animation: breathe 2.6s ease-in-out infinite; }
.lamp.is-simulated { background: var(--amber);  box-shadow: 0 0 0 4px rgba(255, 201, 92, .16); }
.lamp.is-connecting{ background: var(--amber);  animation: breathe 1.1s ease-in-out infinite; }
.lamp.is-offline   { background: var(--blood);  box-shadow: 0 0 0 4px rgba(255, 96, 112, .14); }

@keyframes breathe {
    0%, 100% { opacity: 1; }
    50%      { opacity: .35; }
}

.status-line {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 500;
}

.status-detail {
    color: var(--mute);
    font-weight: 400;
}

.topbar .chips { margin-left: auto; }

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.chip {
    border: 1px solid var(--edge);
    border-radius: 999px;
    padding: 3px 11px;
    font-size: 13px;
    color: var(--mute);
    background: var(--panel);
}

.chip.warn {
    color: var(--amber);
    border-color: rgba(255, 201, 92, .45);
    background: rgba(255, 201, 92, .08);
}

a.chip-link {
    text-decoration: none;
    color: var(--mute);
}

a.chip-link:hover { color: var(--cream); border-color: var(--mute); }

.chip-word.trick { color: var(--pumpkin); border-color: rgba(255, 125, 31, .4); }
.chip-word.treat { color: var(--grape);   border-color: rgba(168, 116, 255, .4); }

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

.grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    gap: var(--gap);
    align-items: start;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--edge);
    border-radius: var(--radius);
    padding: 20px;
}

.panel + .panel { margin-top: var(--gap); }

.panel h2 {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: .01em;
}

.panel .note {
    margin: 0 0 16px;
    color: var(--mute);
    font-size: 13px;
}

/* ---------- candy bowls ---------- */

.bowl-row + .bowl-row {
    margin-top: 22px;
    padding-top: 20px;
    border-top: 1px solid var(--edge);
}

.bowl {
    display: flex;
    align-items: baseline;
    gap: 14px;
    margin-bottom: 14px;
}

.bowl-count {
    font-family: var(--display);
    font-weight: 700;
    font-synthesis-weight: none;
    font-size: clamp(38px, 5.5vw, 56px);
    line-height: .9;
    color: var(--cream);
    font-variant-numeric: tabular-nums;
}

.bowl-count.is-low   { color: var(--amber); }
.bowl-count.is-empty { color: var(--blood); }

.bowl-label {
    color: var(--mute);
    max-width: 22ch;
}

.drain {
    position: relative;
    height: 26px;
    border-radius: 999px;
    background: var(--panel-2);
    border: 1px solid var(--edge);
    overflow: hidden;
}

.drain-fill {
    height: 100%;
    width: 0;
    border-radius: 999px 0 0 999px;
    transition: width .5s ease;
}

.drain-fill.trick {
    background-image: repeating-linear-gradient(
        -45deg,
        var(--pumpkin) 0 9px,
        #e8631a 9px 18px
    );
}

.drain-fill.treat {
    background-image: repeating-linear-gradient(
        -45deg,
        var(--grape) 0 9px,
        #8b52ee 9px 18px
    );
}

.drain-legend {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 13px;
    color: var(--mute);
    font-variant-numeric: tabular-nums;
}

/* ---------- pace ---------- */

.pace {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--edge);
}

.pace-bars {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 58px;
    margin-top: 10px;
}

.pace-bar {
    flex: 1;
    height: 100%;
    display: flex;
    align-items: flex-end;
    background: rgba(247, 236, 220, .06);
    border-radius: 3px;
    overflow: hidden;
}

.pace-fill {
    width: 100%;
    height: 0;
    background: var(--grape);
    border-radius: 3px;
    transition: height .4s ease;
}

.pace-scale {
    display: flex;
    justify-content: space-between;
    margin-top: 7px;
    font-size: 12px;
    color: var(--mute);
    font-variant-numeric: tabular-nums;
}

/* ---------- channels ---------- */

.badge {
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
    padding: 2px 10px;
    border: 1px solid var(--edge);
    color: var(--mute);
    white-space: nowrap;
}

.badge.live {
    color: #0f2a1c;
    background: var(--moss);
    border-color: var(--moss);
}

.badge.closed { color: var(--mute); }

.badge.always {
    color: var(--amber);
    border-color: rgba(255, 201, 92, .4);
}

.pool-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 14px;
    margin: 12px 0 14px;
}

.pool-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.pool-count {
    font-family: var(--display);
    font-weight: 700;
    font-synthesis-weight: none;
    font-size: 24px;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.pool-count.is-low   { color: var(--amber); }
.pool-count.is-empty { color: var(--blood); }

.pool .drain { height: 8px; }

.pool-foot {
    margin-top: 6px;
    font-size: 12px;
    color: var(--mute);
    font-variant-numeric: tabular-nums;
}

.split-total { margin-left: auto; color: var(--mute); }

.channel {
    padding: 16px 0;
    border-top: 1px solid var(--edge);
}

.channel:first-of-type { border-top: 0; padding-top: 4px; }

.channel-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px 12px;
    margin-bottom: 4px;
}

.channel-name {
    font-weight: 600;
    font-size: 16px;
}

.channel-name b {
    color: var(--mute);
    font-weight: 400;
}

.channel-meta {
    color: var(--mute);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

/* Its own line: schedule text varies in length and should never push the
   overlay buttons onto a second row. */
.channel-when {
    color: var(--mute);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    margin-bottom: 2px;
}

.overlay-link { margin-left: auto; flex: 0 0 auto; white-space: nowrap; }

.split {
    display: flex;
    height: 14px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--panel-2);
}

.split span {
    transition: width .45s ease;
}

.split .trick { background: var(--pumpkin); }
.split .treat { background: var(--grape); }

.split-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 9px;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.split-legend b { font-weight: 600; }
.split-legend .trick b { color: var(--pumpkin); }
.split-legend .treat b { color: var(--grape); }

.overlay-link {
    margin-left: auto;
    display: flex;
    gap: 8px;
}

button.ghost {
    font: inherit;
    font-size: 13px;
    color: var(--mute);
    background: transparent;
    border: 1px solid var(--edge);
    border-radius: 7px;
    padding: 3px 10px;
    cursor: pointer;
}

button.ghost:hover  { color: var(--cream); border-color: var(--mute); }
button.ghost:active { transform: translateY(1px); }

a.ghost {
    font-size: 13px;
    color: var(--mute);
    border: 1px solid var(--edge);
    border-radius: 7px;
    padding: 3px 10px;
    text-decoration: none;
}

a.ghost:hover { color: var(--cream); border-color: var(--mute); }

/* ---------- live feed ---------- */

.feed {
    max-height: 620px;
    overflow-y: auto;
    margin: 0 -20px -20px;
    padding: 0 20px 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--edge) transparent;
}

.event {
    display: grid;
    grid-template-columns: 68px 1fr;
    gap: 12px;
    padding: 9px 0 9px 12px;
    border-left: 2px solid var(--edge);
    border-bottom: 1px solid rgba(58, 43, 70, .5);
}

.event.level-ok    { border-left-color: var(--moss); }
.event.level-error { border-left-color: var(--blood); }
.event.is-new      { animation: arrive .45s ease; }

@keyframes arrive {
    from { opacity: 0; transform: translateY(-5px); }
    to   { opacity: 1; transform: none; }
}

.event time {
    color: var(--mute);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.event-body { min-width: 0; }

.event-body strong { font-weight: 600; }

.event-detail {
    color: var(--mute);
    font-size: 13px;
    overflow-wrap: anywhere;
}

.code {
    color: var(--amber);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.word {
    font-weight: 600;
}

.word.trick { color: var(--pumpkin); }
.word.treat { color: var(--grape); }

/* ---------- recipients ---------- */

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th {
    text-align: left;
    font-weight: 500;
    color: var(--mute);
    padding: 0 10px 8px 0;
    border-bottom: 1px solid var(--edge);
}

td {
    padding: 9px 10px 9px 0;
    border-bottom: 1px solid rgba(58, 43, 70, .5);
    font-variant-numeric: tabular-nums;
}

td.name { font-weight: 500; }

.pill {
    font-size: 12px;
    border-radius: 999px;
    padding: 2px 9px;
    border: 1px solid var(--edge);
    color: var(--mute);
}

.pill.delivered { color: var(--moss); border-color: rgba(110, 231, 168, .35); }
.pill.failed    { color: var(--blood); border-color: rgba(255, 96, 112, .35); }

.empty {
    color: var(--mute);
    padding: 26px 0;
    text-align: center;
}

.alert {
    background: rgba(255, 96, 112, .12);
    border: 1px solid rgba(255, 96, 112, .4);
    color: #ffd2d7;
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: var(--gap);
}

.alert code {
    color: var(--amber);
    font-family: var(--ui);
    font-weight: 600;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 26px;
    transform: translateX(-50%);
    background: var(--panel-2);
    border: 1px solid var(--edge);
    border-radius: 999px;
    padding: 9px 18px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
}

.toast.show { opacity: 1; }

@media (min-width: 901px) {
    .grid > .panel { position: sticky; top: 18px; }
}

@media (max-width: 900px) {
    .grid { grid-template-columns: 1fr; }
    .topbar .chips { margin-left: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

:focus-visible {
    outline: 2px solid var(--amber);
    outline-offset: 2px;
}

/* ---------- sign in ---------- */

body.signin {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.gate {
    width: 100%;
    max-width: 380px;
    background: var(--panel);
    border: 1px solid var(--edge);
    border-radius: var(--radius);
    padding: 30px 28px 24px;
}

.gate .wordmark { font-size: 30px; margin-bottom: 14px; }

.gate-note {
    color: var(--mute);
    margin: 0 0 20px;
}

.gate-error {
    background: rgba(255, 96, 112, .12);
    border: 1px solid rgba(255, 96, 112, .4);
    color: #ffd2d7;
    border-radius: 9px;
    padding: 9px 13px;
    margin: 0 0 16px;
}

.gate-label {
    display: block;
    margin-bottom: 7px;
    font-size: 14px;
    color: var(--mute);
}

.gate-input {
    width: 100%;
    font: inherit;
    color: var(--cream);
    background: var(--panel-2);
    border: 1px solid var(--edge);
    border-radius: 9px;
    padding: 11px 13px;
}

.gate-input:focus {
    outline: 2px solid var(--amber);
    outline-offset: 1px;
}

.gate-button {
    width: 100%;
    margin-top: 14px;
    font: inherit;
    font-weight: 600;
    color: #2a1405;
    background: var(--pumpkin);
    border: 0;
    border-radius: 9px;
    padding: 11px 14px;
    cursor: pointer;
}

.gate-button:hover  { background: #ff8c39; }
.gate-button:active { transform: translateY(1px); }

.gate-hint {
    margin: 20px 0 0;
    font-size: 13px;
    color: var(--mute);
}

.gate-hint code { color: var(--amber); }
