/* The virtual whiteboard: the editor (js/whiteboard*.js) and the page around it (Pages/Whiteboards).
   Chrome follows the app's tokens; the paper itself is chosen per board. */

.wb {
    --wb-accent: var(--rl-accent);
    --wb-chrome: var(--rl-surface);
    --wb-line: var(--rl-border);
    --wb-shadow: 0 6px 22px rgba(15, 23, 42, .18), 0 1px 3px rgba(15, 23, 42, .12);
    position: relative;
    flex: 1;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    outline: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    color: var(--rl-text);
}

.wb__stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; overscroll-behavior: none; }
.wb__cv, .wb__ov { position: absolute; left: 0; top: 0; display: block; touch-action: none; }
.wb__cursors { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

.wb__cursor { position: absolute; left: 0; top: 0; transition: opacity .4s; will-change: transform; }
.wb__cursor span {
    position: absolute; left: 14px; top: 14px; padding: 1px 7px; border-radius: 8px; color: #fff;
    font: 600 11px/18px system-ui, sans-serif; white-space: nowrap; box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}

.wb__edit {
    position: absolute; z-index: 3; resize: none; border: 1.5px dashed var(--wb-accent); outline: none; overflow: hidden;
    transform-origin: center; margin: 0; box-sizing: border-box; user-select: text; -webkit-user-select: text;
    border-radius: 4px; white-space: pre-wrap;
}

/* ---- floating panels ---- */
.wb__tools, .wb__ctx, .wb__top, .wb__layers, .wb__pop, .wb__status {
    position: absolute; z-index: 5;
    background: var(--wb-chrome); border: 1px solid var(--wb-line); box-shadow: var(--wb-shadow);
}

.wb__tools {
    left: 10px; top: 62px; padding: 6px; border-radius: 16px;
    display: flex; flex-direction: column; gap: 3px; max-height: calc(100% - 130px); overflow-y: auto;
}
.wb-t {
    position: relative; width: 46px; height: 46px; flex: none; display: grid; place-items: center; padding: 0;
    border: 0; border-radius: 12px; background: transparent; color: var(--rl-text); cursor: pointer;
    transition: background .12s;
}
.wb-t:hover { background: var(--rl-surface-sunken); }
.wb-t.is-on { background: var(--wb-accent); color: var(--rl-accent-contrast); }
.wb-t:focus-visible, .wb-b:focus-visible, .wb-gb:focus-visible, .wb-mi:focus-visible { outline: 2px solid var(--wb-accent); outline-offset: 1px; }
.wb-t__sep { height: 1px; margin: 3px 6px; background: var(--wb-line); flex: none; }
.wb--readonly .wb__tools { opacity: 0.95; }
.wb-t__sep--h { width: 1px; height: 22px; margin: 0 4px; }
.wb-t__caret {
    position: absolute; right: 2px; bottom: 2px; width: 14px; height: 14px; border-radius: 4px;
}
.wb-t__caret::after {
    content: ""; position: absolute; right: 3px; bottom: 3px; border: 4px solid transparent;
    border-right-color: currentColor; border-bottom-color: currentColor; opacity: .55;
}

.wb__ctx {
    left: 10px; top: 10px; right: var(--wb-topw, 470px); min-height: 42px; padding: 4px 10px; border-radius: 14px;
    display: flex; align-items: center; gap: 12px; overflow-x: auto; overflow-y: hidden; white-space: nowrap;
    scrollbar-width: none;
}
.wb__ctx::-webkit-scrollbar { display: none; }
.wb__ctx:empty { display: none; }
.wb-ctx__name { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: .85rem; flex: none; }
.wb-ctx__hint { color: var(--rl-text-muted); font-size: .78rem; white-space: normal; max-width: 34rem; line-height: 1.25; }
.wb-ctx__group { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.wb-ctx__lab { font-size: .75rem; color: var(--rl-text-muted); }
.wb-ctx__sep { width: 1px; height: 22px; background: var(--wb-line); flex: none; }
.wb-emoji { font-size: 1.15rem; }

.wb-sw { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.wb-sw__b {
    width: 24px; height: 24px; border-radius: 50%; padding: 0; background: var(--c); cursor: pointer; flex: none;
    border: 2px solid var(--rl-surface); box-shadow: 0 0 0 1px var(--wb-line);
}
.wb-sw__b.is-on { box-shadow: 0 0 0 2px var(--wb-accent); }
.wb-sw__none { background: linear-gradient(135deg, transparent 45%, #dc2626 45%, #dc2626 55%, transparent 55%), var(--rl-surface); }
.wb-sw__recent { width: 18px; height: 18px; }
.wb-sw__sep { width: 1px; height: 16px; background: var(--wb-line); margin: 0 2px; }
.wb-sw__custom {
    width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; flex: none;
}

.wb-sl { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; color: var(--rl-text-muted); flex: none; }
.wb-sl input[type=range] { width: 96px; accent-color: var(--wb-accent); height: 24px; }
.wb-sl output { min-width: 3.1em; color: var(--rl-text); font-variant-numeric: tabular-nums; }

.wb-seg { display: inline-flex; border: 1px solid var(--wb-line); border-radius: 9px; overflow: hidden; flex: none; }
.wb-seg button {
    border: 0; background: transparent; padding: 4px 9px; font-size: .78rem; color: var(--rl-text); cursor: pointer;
    min-height: 30px; display: inline-flex; align-items: center;
}
.wb-seg button + button { border-left: 1px solid var(--wb-line); }
.wb-seg button.is-on { background: var(--wb-accent); color: var(--rl-accent-contrast); }

.wb-b {
    display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 38px; height: 38px; padding: 0 6px;
    border: 0; border-radius: 10px; background: transparent; color: var(--rl-text); cursor: pointer; flex: none;
}
.wb-b:hover:not(:disabled) { background: var(--rl-surface-sunken); }
.wb-b:disabled { opacity: .35; cursor: default; }
.wb-b.is-on { background: var(--rl-surface-sunken); box-shadow: inset 0 0 0 1.5px var(--wb-accent); }
.wb-b--danger:hover:not(:disabled) { color: var(--rl-danger); }
.wb-b__t { font-size: .78rem; }
.wb-select { max-width: 11rem; font-size: .8rem; padding: 4px 6px; border-radius: 8px; border: 1px solid var(--wb-line); background: var(--rl-surface); color: var(--rl-text); flex: none; }

.wb-i { display: inline-flex; line-height: 0; }

/* ---- top bar ---- */
.wb__top {
    right: 10px; top: 10px; padding: 3px 6px; border-radius: 14px; display: flex; align-items: center; gap: 1px; max-width: calc(100% - 20px);
}
.wb-zoom { border: 0; background: transparent; color: var(--rl-text); min-width: 52px; height: 38px; border-radius: 10px; font-variant-numeric: tabular-nums; cursor: pointer; font-size: .82rem; }
.wb-zoom:hover { background: var(--rl-surface-sunken); }
.wb__peers { display: flex; margin-right: 6px; }
.wb__peers:empty { display: none; }
.wb-peer {
    width: 28px; height: 28px; border-radius: 50%; background: var(--c, #64748b); color: #fff; font: 700 .75rem/28px system-ui, sans-serif;
    text-align: center; border: 2px solid var(--wb-chrome); margin-left: -6px;
}
.wb-peer:first-child { margin-left: 0; }
.wb-peer--more { background: var(--rl-surface-sunken); color: var(--rl-text); font-size: .68rem; }

/* ---- layers ---- */
.wb__layers {
    right: 10px; top: 62px; width: 300px; max-height: calc(100% - 130px); overflow-y: auto; padding: 8px; border-radius: 14px;
}
.wb-lh { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 0 2px 6px; }
.wb-lh .wb-b { height: 32px; }
.wb-ll { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.wb-l {
    display: grid; grid-template-columns: auto auto 1fr auto auto auto auto; align-items: center; gap: 0 2px;
    padding: 4px; border-radius: 10px; border: 1px solid transparent; background: var(--rl-surface-raised);
}
.wb-l.is-active { border-color: var(--wb-accent); }
.wb-l.is-off .wb-l__name { opacity: .55; }
.wb-l .wb-b { min-width: 30px; height: 30px; }
.wb-l__name { border: 0; background: transparent; text-align: left; color: var(--rl-text); padding: 4px 6px; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.wb-l__edit { grid-column: 3; min-width: 0; font-size: .85rem; padding: 3px 5px; border-radius: 6px; border: 1px solid var(--wb-accent); background: var(--rl-surface); color: var(--rl-text); }
.wb-l__op { grid-column: 1 / -1; width: 100%; height: 14px; accent-color: var(--wb-accent); margin: 2px 0 0; }
.wb-l__confirm { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 2px 2px; font-size: .78rem; }

/* ---- popovers ---- */
.wb__pop { z-index: 6; border-radius: 14px; padding: 8px; min-width: 190px; max-width: 320px; max-height: 70%; overflow-y: auto; }
.wb__pop[hidden], .wb__layers[hidden], .wb__dialog[hidden] { display: none; }
.wb__tools, .wb__top { scrollbar-width: none; }
.wb__tools::-webkit-scrollbar, .wb__top::-webkit-scrollbar { display: none; }
.wb-pen {
    display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border: 0;
    border-radius: 10px; background: transparent; color: var(--rl-text); cursor: pointer; text-align: left; min-height: 44px;
}
.wb-pen:hover { background: var(--rl-surface-sunken); }
.wb-pen.is-on { background: var(--rl-surface-sunken); box-shadow: inset 0 0 0 1.5px var(--wb-accent); }
.wb-pen__n { font-size: .85rem; }
.wb-pen__s { line-height: 0; color: var(--rl-text); }
.wb-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.wb-grid--stamps { grid-template-columns: repeat(4, 1fr); }
.wb-gb { height: 48px; border: 0; border-radius: 10px; background: transparent; color: var(--rl-text); cursor: pointer; display: grid; place-items: center; }
.wb-gb:hover { background: var(--rl-surface-sunken); }
.wb-gb.is-on { background: var(--rl-surface-sunken); box-shadow: inset 0 0 0 1.5px var(--wb-accent); }
.wb-gb--emoji { font-size: 1.6rem; }
.wb-tabs { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 6px; }
.wb-tabs button { border: 0; background: transparent; color: var(--rl-text-muted); padding: 4px 8px; border-radius: 8px; font-size: .78rem; cursor: pointer; }
.wb-tabs button.is-on { background: var(--rl-surface-sunken); color: var(--rl-text); font-weight: 600; }
.wb-mine { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: .85rem; }
.wb-mine span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wb-hint { margin: 8px 2px 2px; font-size: .75rem; color: var(--rl-text-muted); line-height: 1.35; white-space: normal; }
.wb__pop--more { right: 10px; width: 330px; max-width: calc(100% - 20px); }
.wb-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 2px; font-size: .82rem; }
.wb-menu { border-top: 1px solid var(--wb-line); margin-top: 6px; padding-top: 6px; display: flex; flex-direction: column; }
.wb-mi { display: flex; align-items: center; gap: 10px; padding: 8px; border: 0; border-radius: 9px; background: transparent; color: var(--rl-text); cursor: pointer; text-align: left; font-size: .85rem; }
.wb-mi:hover { background: var(--rl-surface-sunken); }

/* ---- status and toast ---- */
.wb__status {
    left: 10px; bottom: 10px; padding: 4px 10px; border-radius: 999px; display: flex; gap: 10px; align-items: center;
    font-size: .74rem; color: var(--rl-text-muted); pointer-events: none;
}
.wb-st--error, .wb-st--offline { color: var(--rl-danger); }
.wb-live { color: var(--rl-ok); font-weight: 600; }
.wb-live--off { color: var(--rl-text-muted); font-weight: 500; }
.wb__toast {
    position: absolute; left: 50%; bottom: 22px; transform: translate(-50%, 12px); z-index: 8; padding: 8px 16px; border-radius: 10px;
    background: #0f172a; color: #fff; font-size: .85rem; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 90%;
}
.wb__toast.is-on { opacity: .96; transform: translate(-50%, 0); }

/* ---- dialogs ---- */
.wb__dialog { position: absolute; inset: 0; z-index: 9; background: rgba(15, 23, 42, .45); display: grid; place-items: center; padding: 16px; }
.wb-dlg {
    width: min(860px, 100%); max-height: 100%; overflow: auto; background: var(--rl-surface); color: var(--rl-text);
    border: 1px solid var(--wb-line); border-radius: 16px; box-shadow: var(--wb-shadow); padding: 14px 16px 18px; outline: none;
}
.wb-dlg__h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.wb-tpls { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-top: 8px; }
.wb-tpl {
    display: flex; flex-direction: column; gap: 3px; text-align: left; padding: 8px; border: 1px solid var(--wb-line); border-radius: 12px;
    background: var(--rl-surface-raised); color: var(--rl-text); cursor: pointer;
}
.wb-tpl:hover { border-color: var(--wb-accent); }
.wb-tpl__cv { width: 100%; aspect-ratio: 3 / 2; border-radius: 8px; border: 1px solid var(--wb-line); }
.wb-tpl span { font-size: .75rem; color: var(--rl-text-muted); }
.wb-help { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; font-size: .84rem; }
.wb-help h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--rl-text-muted); margin: 0 0 6px; }
.wb-help table { border-collapse: collapse; width: 100%; }
.wb-help td { padding: 2px 6px 2px 0; vertical-align: top; }
.wb-help td:first-child { white-space: nowrap; }
.wb-help kbd { background: var(--rl-surface-sunken); border: 1px solid var(--wb-line); border-radius: 5px; padding: 0 5px; font-size: .75rem; }
.wb-help ul { margin: 0; padding-left: 1.1rem; }

/* ---- the page around the editor ---- */
.wbp { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.wbp__head { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem .75rem; padding: .6rem 1rem .6rem 1.25rem; border-bottom: 1px solid var(--rl-border); background: var(--rl-surface); }
/* Only a phone hides the sidebar outright; on a desktop the icon rail stays put. */
@media (max-width: 780px) { :root[data-sidebar="collapsed"] .wbp__head { padding-left: 3.4rem; } }
.wbp__crumbs { display: flex; align-items: center; gap: .4rem; font-size: .82rem; color: var(--rl-text-muted); }
.wbp__crumbs a { color: inherit; text-decoration: none; }
.wbp__crumbs a:hover { color: var(--rl-accent); text-decoration: underline; }
.wbp__title { margin: 0; font-size: 1.15rem; font-weight: 650; cursor: text; }
.wbp__titleInput { font-size: 1.15rem; font-weight: 650; padding: 2px 6px; border-radius: 8px; border: 1px solid var(--rl-accent); background: var(--rl-surface); color: var(--rl-text); min-width: 14rem; }
.wbp__actions { margin-left: auto; display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.wbp__live { display: inline-flex; align-items: center; gap: .4rem; font-size: .82rem; color: var(--rl-text-muted); }
.wbp__live input { accent-color: var(--rl-accent); width: 1.1rem; height: 1.1rem; }
.wbp__panel { padding: .9rem 1.25rem; border-bottom: 1px solid var(--rl-border); background: var(--rl-surface-raised); max-height: 45%; overflow-y: auto; }
.wbp__panel h2 { font-size: 1rem; margin: 0 0 .5rem; }
.wbp__members { list-style: none; margin: .5rem 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; font-size: .88rem; }
.wbp__members li { display: flex; align-items: center; gap: .5rem; }
.wbp__editor { position: relative; flex: 1; min-height: 0; display: flex; }

/* ---- the index (/whiteboards): groups of kit tiles (ui-kit.css) under a small heading each ---- */
.wbi-group { display: flex; flex-direction: column; gap: .65rem; margin: 0 0 1.5rem; min-width: 0; }
.wbi-group > * { margin: 0; }
.wbi-group__title { display: flex; align-items: center; gap: .55rem; font-size: 1rem; font-weight: 650; }

/* A project's tile wears its banner along the top, the icon sitting half on it, in place of the kit's hue band. The
   row is positioned so the icon paints over the banner (itself positioned) rather than under it; only the icon rises. */
.wbi-ptile { padding-top: 0; overflow: hidden; }
.wbi-ptile::before { display: none; }
.wbi-ptile__banner { height: 4.5rem; margin: 0 -1rem; }
.wbi-ptile__top { position: relative; align-items: flex-start; }
.wbi-ptile__top .proj-icon { margin-top: -1.35rem; box-shadow: 0 0 0 2px var(--rl-surface), 0 3px 8px rgb(0 0 0 / .3); }
.wbi-ptile__top .ui-tile__name { padding-top: .2rem; }

/* ---- narrow screens: the rail drops to the bottom edge, everything scrolls sideways ---- */
@media (max-width: 860px) {
    .wb__ctx { top: 62px; right: 10px; }
    .wb__tools {
        left: 8px; right: 8px; top: auto; bottom: 8px; flex-direction: row; max-height: none; overflow-x: auto; overflow-y: hidden; padding: 4px; border-radius: 14px;
    }
    .wb-t__sep { width: 1px; height: 26px; margin: 8px 3px; }
    .wb__status { bottom: 72px; }
    .wb__toast { bottom: 80px; }
    .wb__layers { top: 108px; right: 8px; width: min(300px, calc(100% - 16px)); max-height: calc(100% - 200px); }
    .wb__top { overflow-x: auto; }
    .wb__pop { left: 8px !important; right: 8px; bottom: 72px; top: auto !important; max-width: none; width: auto; max-height: 55%; }
}
