/* Step 757 - additive UI navigation, beta.247 only. */
.sb-trio-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    padding: 5px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,.12);
    background: rgba(0,0,0,.14);
}
.sb-trio-tab {
    min-width: 0;
    min-height: 38px;
    padding: 8px 4px;
    border-radius: 9px;
    border: 1px solid transparent;
    background: transparent;
    color: #bbc8bd;
    font: inherit;
    font-size: clamp(.59rem, .65vw, .72rem);
    font-weight: 800;
    text-align: center;
    cursor: pointer;
}
.sb-trio-tab:hover:not(:disabled),
.sb-trio-tab:focus-visible:not(:disabled) {
    background: rgba(200,170,109,.08);
    color: #f3e6ca;
    outline: 2px solid rgba(200,170,109,.2);
    outline-offset: -2px;
}
.sb-trio-tab.active,
.sb-trio-tab[aria-selected="true"] {
    border-color: rgba(215,184,110,.38);
    background: linear-gradient(135deg, #d7bd84, #a78952);
    color: #17140d;
}
.sb-trio-tab:disabled {
    opacity: .33;
    cursor: not-allowed;
    filter: grayscale(1);
}
.sb-trio-stage[hidden] { display: none !important; }
.sb-trio-lobby > .sb-trio-tabs { margin: -2px 0 13px; }
.sb-trio-lobby > .sb-trio-stage-lobby { min-width: 0; }
.sb-trio-lobby > .sb-trio-stage-private,
.sb-trio-lobby > .sb-trio-stage-table {
    position: relative;
    height: clamp(380px, 53dvh, 570px);
    min-height: 0;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 11px;
    background: #0f1611;
}
.sb-trio-lobby .sb-trio-stage-private #private-chat-drawer,
.sb-trio-lobby .sb-trio-stage-private #private-chat-conversation-drawer {
    position: absolute !important;
    inset: 0 !important;
    top: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    transform: none !important;
    transition: none !important;
    box-shadow: none !important;
    border: 0 !important;
}
.sb-trio-lobby .sb-trio-stage-private #private-chat-drawer {
    padding: 12px;
    gap: 8px;
    overflow-y: auto;
    z-index: 1 !important;
}
.sb-trio-lobby .sb-trio-stage-private #private-chat-conversation-drawer {
    z-index: 2 !important;
}
.sb-trio-lobby .sb-trio-stage-private #private-chat-conversation-drawer[aria-hidden="true"] {
    visibility: hidden;
    pointer-events: none;
}
.sb-trio-lobby .sb-trio-stage-private #private-chat-drawer .drawer-header,
.sb-trio-lobby .sb-trio-stage-private #close-private-chat,
.sb-trio-lobby .sb-trio-stage-private #close-private-chat-conversation {
    display: none !important;
}
.sb-trio-lobby .sb-trio-stage-private .private-chat-tabs button { font-size: .67rem; }
.sb-trio-chat-frame { display: block; width: 100%; height: 100%; border: 0; }
/* Table page: reuse the existing private chat drawer; never touch table.js. */
body.table-page #sb-chat-drawer.sb-trio-table-drawer {
    grid-template-rows: auto auto minmax(0,1fr) !important;
}
.sb-trio-table-switcher { padding: 10px 12px; min-width: 0; }
.sb-trio-table-drawer > .sb-trio-stage {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    position: relative;
}
.sb-trio-table-drawer .sb-trio-stage-private:not([hidden]) {
    display: flex;
    flex-direction: column;
}
.sb-trio-table-drawer .sb-trio-stage-private > .sb-chat-content {
    flex: 1;
}
.sb-trio-table-drawer .sb-trio-stage-table:not([hidden]) { display: flex; }
.sb-trio-table-drawer .sb-trio-stage-table > .table-chat-card {
    display: flex !important;
    flex-direction: column;
    flex: 1;
    width: 100%;
    min-height: 0 !important;
    margin: 0;
    border: 0;
    border-radius: 0;
    padding: 12px;
    overflow: hidden;
}
.sb-trio-table-drawer .sb-trio-stage-table .chat-list {
    flex: 1;
    min-height: 120px;
    height: auto;
}
.sb-trio-table-drawer .sb-trio-stage-table .chat-form { flex-shrink: 0; }
.sb-trio-table-drawer .sb-trio-stage-private > #sb-chat-conversation {
    position: absolute !important;
    inset: 0 !important;
    top: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 2 !important;
    transition: none;
    border: 0;
    box-shadow: none;
}
.sb-trio-table-drawer .sb-trio-stage-private > #sb-chat-conversation:not(.open) {
    visibility: hidden;
    pointer-events: none;
}
.sb-trio-table-drawer .sb-trio-stage-private > #sb-chat-conversation.open {
    transform: none;
}
.sb-trio-table-drawer .sb-trio-stage-private > #sb-chat-conversation [data-sb-conversation-close] {
    display: none;
}
/* Same chat-client.js inside a single-purpose frame (no extra API). */
body.sb-trio-embedded-page {
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #121814;
}
.sb-trio-embedded {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    min-height: 0;
    padding: 12px;
    color: #ecf0e9;
}
.sb-trio-embedded .chat-list {
    flex: 1;
    min-height: 50px;
    height: auto;
}
.sb-trio-embedded .chat-form { flex-shrink: 0; }
.sb-trio-embedded-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.sb-trio-embedded .chat-filters { flex-shrink: 0; }
@media (max-width: 560px) {
    .sb-trio-tab { font-size: .59rem; }
    .sb-trio-lobby > .sb-trio-stage-private,
    .sb-trio-lobby > .sb-trio-stage-table { height: min(65dvh, 570px); }
}

/* STEP815: restore the original four-row Lobby grid within the STEP759 tab stage. */
.app-shell .chat-panel.sb-trio-lobby {
    display: grid !important;
    grid-template-rows: auto minmax(0, 1fr) !important;
    overflow: hidden !important;
}
.app-shell .chat-panel.sb-trio-lobby > .sb-trio-stage-lobby:not([hidden]) {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}
.app-shell .chat-panel.sb-trio-lobby > .sb-trio-stage-lobby .chat-list {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
}
.app-shell .chat-panel.sb-trio-lobby > .sb-trio-stage-lobby .chat-form {
    min-width: 0;
    align-self: end !important;
}
@media (max-width: 820px) {
    .app-shell .chat-panel.sb-trio-lobby {
        height: clamp(420px, calc(100dvh - 110px), 620px) !important;
        min-height: 0 !important;
    }
}

/* STEP821: expand the private conversation drawer so the iframe keeps the composer responsive at the bottom. */
.sb-trio-lobby .sb-trio-stage-private #private-chat-conversation-drawer {
    display: flex !important;
    flex-direction: column !important;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
}
.sb-trio-lobby .sb-trio-stage-private #private-chat-conversation-drawer .private-chat-conversation-drawer-header {
    flex: 0 0 auto;
}
.sb-trio-lobby .sb-trio-stage-private #private-chat-frame {
    display: block;
    width: 100%;
    height: auto !important;
    min-height: 0;
    flex: 1 1 auto;
    border: 0;
}

/* STEP826: private stage fills its available grid row, including short viewports. */
.app-shell .chat-panel.sb-trio-lobby > .sb-trio-stage-private:not([hidden]) {
    height: 100% !important;
    max-height: none !important;
    min-height: 0 !important;
    align-self: stretch;
}

/* STEP830: visible chat navigation on the pre-table/table sidebar. */
body.table-page .sb-pretable-chat-launchers {
    position: sticky;
    top: 6px;
    z-index: 3;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 8px;
    border: 1px solid rgba(215,184,110,.25);
    border-radius: 12px;
    background: #131d17;
}
body.table-page .sb-pretable-chat-launchers > button {
    min-width: 0;
    min-height: 42px;
    padding: 7px 4px;
    border-radius: 9px;
    border: 1px solid rgba(215,184,110,.23);
    background: rgba(215,184,110,.08);
    color: #f0e6d3;
    font: inherit;
    font-size: clamp(.72rem, .9vw, .86rem);
    font-weight: 800;
    text-align: center;
    cursor: pointer;
}
body.table-page .sb-pretable-chat-launchers > button:hover,
body.table-page .sb-pretable-chat-launchers > button:focus-visible {
    color: #16140f;
    background: #d7bd84;
    outline: 2px solid #ecd9b1;
}
/* STEP830: the iframe lacks .app-shell, which previously scoped the readable chat-line styling. */
body.sb-trio-embedded-page .sb-trio-embedded .chat-message {
    padding: 6px 7px !important;
    margin: 0 !important;
    border: 0 !important;
    border-bottom: 1px solid rgba(234,215,170,.11) !important;
    border-radius: 0 !important;
    background: transparent !important;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-line {
    display: block;
    margin: 0 !important;
    font-size: clamp(.83rem, 1.3vw, .93rem) !important;
    line-height: 1.5 !important;
    font-weight: 650;
    overflow-wrap: anywhere;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-line time {
    display: inline-block;
    min-width: 36px;
    color: #69df9f;
    font-size: .76rem;
    font-weight: 800;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-line > .chat-nickname-button,
body.sb-trio-embedded-page .sb-trio-embedded .chat-line > strong {
    display: inline-block;
    color: #ebcb8b;
    font-size: inherit;
    font-weight: 850;
    overflow-wrap: anywhere;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-line > .chat-text {
    color: #f0f3ed;
    font-size: inherit;
    line-height: inherit;
    overflow-wrap: anywhere;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-filters > * {
    max-width: 100%;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-list {
    overflow-y: auto;
    min-height: 0;
}
html:has(body.sb-trio-embedded-page),
body.sb-trio-embedded-page {
    min-width: 0 !important;
    width: 100%;
    max-width: 100%;
}

/* STEP849: make the embedded Lobby chat readable inside the pre-table sidebar. */
body.sb-trio-embedded-page .sb-trio-embedded {
    gap: 8px;
    padding: 10px;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-heading {
    margin-bottom: 0 !important;
    padding-inline: 2px;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-filters {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px !important;
    align-items: center;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-filters > button {
    min-width: 0;
    white-space: nowrap;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-filter-nickname {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 8px;
    width: 100%;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-filter-nickname > input {
    min-width: 0;
    width: 100%;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-include-mine {
    justify-self: end;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-nickname-suggestions {
    grid-column: 1 / -1;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-status {
    margin: 0;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 2px;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-message {
    padding: 8px 10px !important;
    margin: 0 !important;
    border: 1px solid rgba(234,215,170,.12) !important;
    border-radius: 12px !important;
    background: rgba(20,28,22,.92) !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-line {
    font-size: clamp(.84rem, 1.08vw, .93rem) !important;
    line-height: 1.45 !important;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 6px;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-form {
    margin-top: 4px;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-form textarea {
    min-height: 56px;
}

/* STEP851 QA: restore actual usable width to the pre-table chat drawer. */
body.table-page:not(:has(.game-stage.playing)) #sb-chat-drawer.sb-trio-table-drawer {
    width: min(500px, calc(100vw - 36px)) !important;
    max-width: none !important;
    box-shadow: -16px 0 42px rgba(0,0,0,.38) !important;
}
body.table-page .sb-trio-table-drawer .sb-trio-tab {
    font-size: .83rem;
    min-height: 44px;
    padding: 10px 7px;
}
body.sb-trio-embedded-page .sb-trio-embedded {
    padding: 14px 16px;
    gap: 10px;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-heading .eyebrow {
    font-size: .78rem;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-filters > button {
    min-height: 38px;
    border-radius: 8px;
    font-size: .83rem;
    font-weight: 700;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-filter-nickname > input {
    min-height: 38px;
    font-size: .85rem;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-include-mine {
    position: relative;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(234,215,170,.24);
    border-radius: 9px;
    background: rgba(255,255,255,.035);
    cursor: pointer;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-include-mine > input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-include-mine > span {
    color: rgba(234,215,170,.35);
    font-size: .88rem;
    font-weight: 900;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-include-mine:has(input:checked) {
    border-color: rgba(116,211,141,.7);
    background: rgba(116,211,141,.13);
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-include-mine:has(input:checked) > span {
    color: #74d38d;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-message {
    padding: 10px 12px !important;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-line,
body.sb-trio-embedded-page .sb-trio-embedded .chat-text {
    font-size: .87rem !important;
    line-height: 1.5 !important;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-message-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 7px;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-message-actions button {
    font-size: .74rem;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-empty {
    font-size: .84rem;
    line-height: 1.5;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-form textarea {
    min-height: 66px;
    font-size: .86rem;
    line-height: 1.5;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-form-footer small {
    font-size: .75rem;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-form-footer button {
    min-height: 38px;
    padding: 8px 19px;
    font-size: .82rem;
}
@media (max-width: 760px) {
    body.table-page:not(:has(.game-stage.playing)) #sb-chat-drawer.sb-trio-table-drawer {
        width: 100vw !important;
        right: 0 !important;
    }
}

/* STEP853 QA: reserve a docked chat column in the pre-table screen.
   Never cover seats/invite controls. Preserve the original in-game layout. */
@media (min-width: 1000px) {
    body.table-page:not(:has(.game-stage.playing)):has(#sb-chat-drawer.open) .table-layout {
        grid-template-columns: minmax(0, 1fr) clamp(370px, 36vw, 500px) !important;
    }
    body.table-page:not(:has(.game-stage.playing)):has(#sb-chat-drawer.open) #sb-chat-drawer.sb-trio-table-drawer {
        width: clamp(370px, 36vw, 500px) !important;
    }
}

/* STEP855 QA: compact pre-table Lobby filter buttons, as in beta.247.
   Only the public chat embedded frame is affected; do not resize the table or drawer. */
body.sb-trio-embedded-page .sb-trio-embedded .chat-filters {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: flex-start !important;
    align-items: center !important;
    gap: 6px !important;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-filters > button {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 0 !important;
    min-height: 30px !important;
    padding: 5px 10px !important;
    font-size: .76rem !important;
    line-height: 1.2 !important;
    white-space: nowrap;
}
body.sb-trio-embedded-page .sb-trio-embedded .chat-filters > .chat-filter-nickname {
    flex: 1 1 100%;
    min-width: 0;
    width: 100%;
}
