/* Buddy editor (/buddy). Looks like the dashboard: its tokens, Mulish, flat
   cards, buttons and filter pills (see app.css) — copied, not linked,
   because app.css also styles MudBlazor. Dark by default; light when the
   dashboard's saved choice says so (theme.js sets [data-theme]) or, without
   one, when the system asks for it. Phone first: one column, the preview
   beside the wardrobe from 820 px. */

@font-face {
    font-family: "Mulish";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("/fonts/mulish-v18-latin-regular.woff2") format("woff2");
}

@font-face {
    font-family: "Mulish";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("/fonts/mulish-v18-latin-600.woff2") format("woff2");
}

@font-face {
    font-family: "Mulish";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("/fonts/mulish-v18-latin-700.woff2") format("woff2");
}

/* The dashboard's tokens (app.css), dark first. */
:root {
    color-scheme: dark;
    --bg: #101013;
    --surf: #18181d;
    --surf2: #202026;
    --bd: rgba(255, 255, 255, 0.08);
    --bd2: rgba(255, 255, 255, 0.15);
    --tx: #ededf1;
    --tx2: #a6a6b2;
    --tx3: #868691;
    --ac: #a988ff;
    --acbg: rgba(157, 107, 255, 0.14);
    --acfill: #7446e8;
    --ok: #3ecf8e;
    --dng: #f47a7a;
    --stage: #0c0c0f;                    /* stand-in for the stream picture, both themes */
    --r-control: 6px;
    --r-card: 8px;
    --font-sans: "Mulish", system-ui, "Segoe UI", sans-serif;
}

/* Light: the same values twice — once for the system setting (unless the
   dashboard's choice is dark), once for the dashboard's light choice. */
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        color-scheme: light;
        --bg: #f5f5f6;
        --surf: #ffffff;
        --surf2: #ececef;
        --bd: rgba(20, 16, 40, 0.10);
        --bd2: rgba(20, 16, 40, 0.18);
        --tx: #19181f;
        --tx2: #55535f;
        --tx3: #6c6a75;
        --ac: #6d35d9;
        --acbg: rgba(124, 58, 237, 0.09);
        --acfill: #6d35d9;
        --ok: #127a56;
        --dng: #c43535;
    }
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f5f5f6;
    --surf: #ffffff;
    --surf2: #ececef;
    --bd: rgba(20, 16, 40, 0.10);
    --bd2: rgba(20, 16, 40, 0.18);
    --tx: #19181f;
    --tx2: #55535f;
    --tx3: #6c6a75;
    --ac: #6d35d9;
    --acbg: rgba(124, 58, 237, 0.09);
    --acfill: #6d35d9;
    --ok: #127a56;
    --dng: #c43535;
}

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

[hidden] { display: none !important; }

html, body { margin: 0; }

/* Top bar, page, footer: the footer stays at the bottom on short pages. */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--tx);
    font-family: var(--font-sans);
    font-size: 13px;
    line-height: 1.5;
}

.be-app {
    flex: 1;
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 28px 32px 48px;
}

.be-icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
    flex: none;
}

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

/* As on the dashboard's public pages: the brand left, the viewer and the
   light/dark switch right; a --bd line below. */
.be-top {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--bd);
}

/* The brand as in the dashboard's side bar: the logo and "streamion.bot". */
.be-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: none;
}

.be-brand-logo {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    object-fit: cover;
}

.be-wordmark {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.be-top-end {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    margin-left: auto;
}

/* The signed-in viewer: the name, then "Sign out". */
.be-user {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.be-user-name {
    font-weight: 600;
    color: var(--tx2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 30vw;
    padding-left: 4px;
}

/* The switch like the public pages': the icon in --tx2. */
.be-theme { color: var(--tx2); }

/* --- page header ------------------------------------------------------- */

.be-header { margin-bottom: 20px; }

.be-title {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.015em;
    margin: 0;
}

.be-sub {
    max-width: 640px;
    color: var(--tx2);
    margin: 4px 0 0;
    text-wrap: pretty;
}

/* --- building blocks ---------------------------------------------------- */

/* Section card: --surf, a --bd border, 8 px corners, no shadow. */
.be-card {
    background: var(--surf);
    border: 1px solid var(--bd);
    border-radius: var(--r-card);
    padding: 18px 20px;
}

.be-section-head { margin-bottom: 12px; }

.be-section-title {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.4;
    margin: 0;
}

/* Buttons as in the dashboard: 34 px, 6 px corners, 600 weight, flat. */
.be-button {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    border: 1px solid transparent;
    border-radius: var(--r-control);
    background: transparent;
    color: var(--tx);
    padding: 0 14px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.be-primary {
    background: var(--acfill);
    color: #fff;
}

.be-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--acfill) 88%, var(--tx)); }

.be-outlined { border-color: var(--bd2); }

.be-outlined:hover:not(:disabled) { background: var(--surf2); }

.be-text { color: var(--tx2); padding: 0 10px; }

.be-text:hover:not(:disabled) { background: var(--surf2); color: var(--tx); }

.be-button:disabled {
    background: var(--surf2);
    border-color: transparent;
    color: var(--tx3);
    cursor: default;
}

.be-text:disabled { background: transparent; }

/* Icon button: no border, the icon in --tx3, --surf2 on hover. */
.be-icon-button {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: var(--r-control);
    background: transparent;
    color: var(--tx3);
    cursor: pointer;
    transition: background-color 140ms ease, color 140ms ease;
}

.be-icon-button:hover { background: var(--surf2); color: var(--tx); }

:is(.be-button, .be-icon-button, .be-pill, .be-tile):focus-visible {
    outline: 2px solid var(--ac);
    outline-offset: 2px;
}

.be-hint { color: var(--tx3); font-size: 12px; }

.be-notice {
    border: 1px solid var(--bd);
    border-radius: var(--r-card);
    background: var(--surf);
    color: var(--dng);
    font-weight: 600;
    padding: 12px 16px;
    margin: 0 0 16px;
}

.be-loading { color: var(--tx3); }

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

.be-signin { max-width: 540px; }

.be-signin p { margin: 8px 0; color: var(--tx2); }

.be-signin p.be-hint { color: var(--tx3); }

.be-signin .be-button { margin-top: 8px; }

/* --- editor ------------------------------------------------------------- */

.be-editor {
    display: grid;
    gap: 16px;
}

@media (min-width: 820px) {
    .be-editor {
        grid-template-columns: 300px 1fr;
        align-items: start;
    }

    .be-stage-card {
        position: sticky;
        top: 16px;
    }
}

.be-stage-card { padding: 12px; }

/* The stage: the buddy on the preview colour that stands in for the stream
   picture, flat and the same in both themes. */
.be-stage {
    position: relative;
    display: flex;
    justify-content: center;
    border-radius: var(--r-control);
    background: var(--stage);
    padding: 12px 0 4px;
}

/* 48 px cell × 5 — whole numbers keep the pixels square. */
.be-preview {
    width: 240px;
    height: 240px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* The turn buttons stand on the dark stage in both themes, so they carry
   the card surface to stay visible in light mode too. */
.be-turn-left,
.be-turn-right {
    position: absolute;
    bottom: 10px;
    background: var(--surf);
    color: var(--tx2);
}

.be-turn-left:hover,
.be-turn-right:hover { background: var(--surf2); color: var(--tx); }

.be-turn-left { left: 10px; }

.be-turn-right { right: 10px; }

.be-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
}

.be-save { grid-column: 1 / -1; }

.be-status {
    min-height: 1.5em;
    margin: 10px 2px 2px;
    font-size: 12px;
    font-weight: 600;
    color: var(--tx3);
}

.be-status.be-ok { color: var(--ok); }

.be-status.be-fail { color: var(--dng); }

/* --- wardrobe ----------------------------------------------------------- */

.be-wardrobe { min-width: 0; }

/* The dashboard's filter pills: 32 px, 6 px corners; the active pill
   --surf2 without a border, the others transparent with a --bd border. */
.be-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.be-pill {
    appearance: none;
    flex: none;
    display: inline-flex;
    align-items: center;
    height: 32px;
    border: 1px solid var(--bd);
    border-radius: var(--r-control);
    background: transparent;
    color: var(--tx2);
    padding: 0 12px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 140ms ease, color 140ms ease;
}

.be-pill:hover { background: var(--surf2); }

.be-pill[aria-selected="true"] {
    background: var(--surf2);
    border-color: transparent;
    color: var(--tx);
}

.be-pill.be-unavailable { color: var(--tx3); text-decoration: line-through; }

.be-slot-note { margin: -4px 2px 12px; }

/* At least 96 px wide: three across on a 375 px phone. */
.be-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 8px;
}

/* An item: a quiet tile; the chosen one on the accent area. */
.be-tile {
    appearance: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 0;
    border: 1px solid var(--bd);
    border-radius: var(--r-card);
    background: transparent;
    color: var(--tx2);
    padding: 8px 6px 10px;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 140ms ease, border-color 140ms ease;
}

.be-tile:hover:not(:disabled) { background: var(--surf2); }

.be-tile[aria-pressed="true"] {
    background: var(--acbg);
    border-color: var(--ac);
    color: var(--tx);
}

.be-tile:disabled { opacity: 0.4; cursor: default; }

/* The thumbnail's frame; editor.js sizes the canvas in whole-pixel steps. */
.be-thumb-frame {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
}

.be-thumb {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.be-tile-name {
    text-align: center;
    line-height: 1.25;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* --- footer ----------------------------------------------------------- */

/* Legal and help links: one quiet centred row, wrapping when narrow. */
.be-foot {
    padding: 12px 16px 20px;
    border-top: 1px solid var(--bd);
}

.be-foot-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 20px;
}

.be-foot-links a {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    font-size: 12px;
    color: var(--tx3);
    text-decoration: none;
}

.be-foot-links a:hover { color: var(--tx); text-decoration: underline; }

.be-foot-links a:focus-visible {
    outline: 2px solid var(--ac);
    outline-offset: 2px;
    border-radius: 2px;
}

/* --- phones ------------------------------------------------------------- */

/* Below 820 px: the phone padding, 44 px touch targets, and the pill strip
   scrolls sideways instead of wrapping (as in the dashboard). */
@media (max-width: 819.98px) {
    .be-top { padding: 4px 8px 4px 14px; gap: 8px; }

    .be-app { padding: 18px 14px 24px; }

    .be-foot { padding: 4px 12px 12px; }

    .be-foot-links { gap: 0 16px; }

    .be-foot-links a { min-height: 44px; }

    .be-card { padding: 16px; }

    .be-stage-card { padding: 12px; }

    .be-button { min-height: 44px; }

    .be-icon-button { width: 44px; height: 44px; }

    .be-pills { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }

    .be-pill { height: 44px; }
}
