/* V03 presentation and lifetime bindings. Reference materials remain unchanged;
   the shared message toolbar has one active layout below. */
:root { --page: var(--bg); --selected: var(--inset); --hover: var(--inset); --accent-ink: var(--surface); --danger: #b84d5f; }
html, body { width: 100%; height: 100%; }
button:disabled { opacity: .45; }
[hidden] { display: none !important; }
.field input, .field textarea, .field select, .post-edit textarea { color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; min-width: 0; }
.form-dialog .dialog-heading { padding: 0; }
.channel-row { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 34px; text-align: left; color: var(--muted); padding: 0 12px; font-size: 12px; }
.channel-row svg { width: 17px; height: 17px; }
#nav-scroll > .nav-heading { padding: 12px; }
#nav-scroll > form, #nav-scroll > .empty-state { margin: 12px; }
.community-cover-avatar { display: flex; width: 48px; height: 56px; align-items: center; justify-content: center; border-radius: 8px; background: var(--inset); font-weight: 650; flex-shrink: 0; }
.community-cover > div .community-description { font-size: 10px; color: var(--muted); margin: 5px 0 0; }
#community-icons .community-icon:not(:has(img)) { display: flex; align-items: center; justify-content: center; background: var(--raised); color: var(--ink); }
#nav-profile-bar { cursor: pointer; }
#conversation-surfaces { height: 100%; min-height: 0; flex: 1; position: relative; }
.channel-context { position: absolute; inset: 0; display: flex; flex-direction: column; }
.feed-scroll.chat-history { min-height: 0; height: 100%; padding-top: var(--edge-space); }
.feed-stack { display: flex; flex-direction: column; min-height: 100%; }
.feed-rows { margin-top: auto; }
.message.post { position: relative; }
.message.post:not(.has-header) { margin-block: 0 6px; }
.message.post .message-body { flex: 1; }
.post-images { display: flex; gap: 8px; max-width: 100%; overflow-x: auto; align-items: flex-start; }
.post-images .asset-frame { width: 180px; max-width: 100%; flex: 0 0 auto; }
.post-images .asset-image { width: 100%; height: auto; }
.asset-frame { position: relative; min-width: 0; overflow: hidden; background: var(--inset); }
.asset-image { display: block; width: 100%; height: auto; visibility: hidden; }
.image-ready > .asset-image { visibility: visible; }
.image-ready { background: transparent; }
.asset-frame > .image-status { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; font-size: 11px; color: var(--muted); }
.pin .asset-frame { width: 100%; }
.pin-overlay { display: contents; }
.pin-download { position: absolute; bottom: 8px; right: 8px; background: var(--surface); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; opacity: 0; }
.pin:hover .pin-download, .pin:focus-within .pin-download { opacity: 1; }
.pin-caption > span { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pin-caption > .icon-button { margin-left: auto; }
.message-list[data-history-mode=compact] .post-images { display: none; }
.message-list:not([data-history-mode=compact]) .compact-media-summary { display: none; }
.activity-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; margin: 0 0 14px 47px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.activity-row summary { cursor: pointer; color: var(--ink); }
.activity-details { display: grid; grid-template-columns: minmax(70px,auto) minmax(0,1fr); gap: 3px 8px; font-size: 10px; }
.activity-details dt { color: var(--muted); }
.activity-details dd { margin: 0; overflow-wrap: anywhere; }
.attachment-tray { position: absolute; bottom: calc(8px + var(--composer-extra,0px)); left: 8px; right: 8px; height: 124px; display: flex; gap: 8px; overflow-x: auto; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; z-index: 4; }
.has-attachments .channel-context { bottom: 140px; }
.draft-image { position: relative; flex: 0 0 auto; width: 110px; height: 106px; }
.draft-image > img, .draft-image .asset-frame, .draft-image .asset-image { width: 110px; height: 88px; object-fit: contain; }
.draft-image > .icon-button { position: absolute; right: 2px; top: 2px; background: var(--surface); border-radius: 50%; z-index: 1; }
.draft-image-status { display: block; font-size: 10px; white-space: nowrap; color: var(--muted); }
.reply-bar { position: absolute; bottom: calc(8px + var(--composer-extra,0px)); left: 8px; right: 8px; z-index: 3; display: flex; align-items: center; gap: 6px; min-height: 30px; background: var(--surface); padding: 3px 8px; font-size: 11px; border-radius: 5px; }
.reply-bar > span { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.has-reply .channel-context { bottom: 44px; }
.has-reply.has-attachments .channel-context { bottom: 176px; }
.has-attachments .reply-bar { bottom: calc(140px + var(--composer-extra,0px)); }
.typing-indicator { position: absolute; bottom: var(--composer-extra,0px); left: 8px; font-size: 10px; color: var(--muted); pointer-events: none; }
.file-drag-over::after { content: "Drop images into this message"; position: absolute; inset: 8px; display: grid; place-items: center; pointer-events: none; background: var(--surface); opacity: .9; border: 1px dashed var(--accent); z-index: 20; }
@media(pointer:coarse) { .post-actions { position: static; opacity: 1; pointer-events: auto; background: transparent; box-shadow: none; border: 0; } .post-actions .icon-button { width: 30px; height: 30px; } .pin-download { opacity: 1; } }
.post-actions { position: absolute; top: -9px; right: 0; display: flex; gap: 1px; padding: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 5px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; }
.post:hover .post-actions, .post:focus-within .post-actions { opacity: 1; pointer-events: auto; }
.post-actions .icon-button { width: 25px; height: 25px; padding: 4px; }
.post-actions svg { width: 16px; height: 16px; }
.post-edit { display: grid; gap: 6px; }
.post-edit textarea { min-height: 74px; width: 100%; }
.form-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }
.post-edited { display: block; text-align: right; font-size: 10px; color: var(--muted); }

.empty-state { color: var(--muted); font-size: 13px; line-height: 1.6; padding: 12px 0; margin: 0; }
.workspace-empty { display: flex; align-items: center; justify-content: center; height: 100%; padding: 32px; }
.workspace-empty > div { max-width: 390px; }
.welcome-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 18px; }
.primary-button { background: var(--accent); color: var(--accent-ink); min-height: 34px; padding: 7px 13px; font-weight: 600; }
.primary-button:hover { background: var(--accent); filter: brightness(1.08); }
.secondary-button { background: var(--toolbar); border: 1px solid var(--line); min-height: 34px; }
.danger { color: var(--danger); }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; margin: 12px 0; }
.field input, .field select { width: 100%; min-height: 36px; }
.field textarea { min-height: 80px; }
.form-error { color: var(--danger); line-height: 1.5; font-size: 12px; min-height: 18px; margin: 8px 0; }
.form-note { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 8px 0; }
.auth-card { max-width: 380px; width: 100%; }
.auth-card h2 { font-size: 25px; letter-spacing: -.04em; margin-bottom: 8px; }
.auth-tabs { display: flex; gap: 4px; margin: 18px 0 10px; }
.auth-tabs button[aria-pressed="true"] { background: var(--selected); }
.auth-code { font-size: 22px; letter-spacing: .4em; font-variant-numeric: tabular-nums; text-align: center; }
.form-dialog { width: min(420px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); padding: 18px; box-shadow: 0 12px 70px #0003; }
.form-dialog::backdrop { background: #19253255; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; }
.dialog-heading h2 { margin: 0; font-size: 17px; }
.dialog-heading .icon-button { width: 28px; height: 28px; padding: 4px; }
.notice { position: fixed; left: 50%; bottom: 62px; transform: translateX(-50%); padding: 10px 14px; max-width: min(90vw, 520px); background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 7px; box-shadow: var(--shadow); z-index: 20; font-size: 12px; }
.notice[data-error="true"] { border-color: var(--danger); }
.boot-status { display: grid; place-items: center; height: 100%; color: var(--muted); }

.people-list, .board-list { display: grid; gap: 4px; }
.people-list { padding: 8px 12px; }
.nav-content .search-form, .nav-content .search-results { margin: 12px; }
.person-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; font-size: 13px; }
.section-list { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0 12px; }
.section-list button { font-size: 12px; background: var(--toolbar); }
.section-list button[aria-pressed="true"] { background: var(--selected); }

.save-dialog { width: min(320px, calc(100vw - 24px)); padding: 16px; border-radius: 14px; }
.save-dialog::backdrop { background: #19253220; }
@media (prefers-reduced-motion: reduce) { .pin-overlay { transition: none; } }
.draft-image .asset-frame { height: 88px; width: 110px; min-height: 88px; }
.draft-image .asset-image { height: 88px; width: 110px; object-fit: contain; }
.draft-image .image-status { padding: 8px; font-size: 9px; }

/* Compact contextual management belongs to the navigation column. */
.management-content { padding: 10px 12px; min-width: 0; }
.management-content > .primary-button { margin-bottom: 10px; }
.management-row { display: flex; align-items: center; gap: 5px; min-height: 40px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.management-label { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 12px; }
.management-label > .form-note { font-size: 10px; margin: 3px 0 0; }
.row-controls { display: flex; gap: 2px; flex: 0 0 auto; }
.row-controls .icon-button { width: 25px; height: 25px; padding: 4px; }
.row-controls svg { width: 16px; height: 16px; }
.compact-form .field { margin: 9px 0; }
.management-content .field > input, .management-content .field > select { min-height: 31px; padding: 5px 7px; }
.management-content .field { gap: 3px; }
.permission-list { padding: 7px; margin: 8px 0; border: 1px solid var(--line); border-radius: 5px; display: grid; gap: 7px; }
.permission-list label { display: flex; gap: 7px; align-items: center; font-size: 12px; }
.permission-list input { margin: 0; }
.permission-matrix { display: grid; gap: 5px; margin: 8px 0; }
.permission-matrix label { display: grid; grid-template-columns: minmax(0,1fr) 100px; gap: 5px; align-items: center; font-size: 11px; }
.permission-matrix select { min-height: 29px; padding: 4px; }
.community-cover { position: relative; }
.community-options { position: absolute; right: 4px; top: 4px; width: 26px; height: 26px; padding: 4px; }
.channel-item { display: flex; align-items: center; min-width: 0; }
.channel-item > .channel-row { flex: 1; min-width: 0; }
.channel-options { width: 24px; height: 24px; margin-right: 5px; padding: 4px; opacity: .55; }
.channel-item:hover .channel-options, .channel-options:focus-visible { opacity: 1; }
.channel-options svg, .category-heading .icon-button svg { width: 14px; height: 14px; }

.category-heading .icon-button { width: 24px; height: 24px; padding: 4px; margin-right: -7px; }
.section-chip { display: inline-flex; align-items: center; background: var(--raised); border-radius: 5px; }
.section-chip .icon-button { width: 24px; height: 24px; min-width: 24px; min-height: 24px; padding: 5px; }
.section-chip .icon-button svg { width: 13px; height: 13px; }
.profile-header { display: flex; align-items: center; gap: 9px; margin: 4px 0 16px; }
.profile-header h2 { margin: 0; font-size: 17px; }
.profile-footer { margin-top: 14px; border-top: 1px solid var(--line); }
@media (pointer: coarse) { .row-controls .icon-button, .channel-options { width: 30px; height: 30px; } }

/* Media leases are one extra wrapper inside the source file-window content. */
.file-window-content > .asset-frame { width: 100%; height: 100%; background: transparent; min-height: 0; }
.file-window-content .asset-image { width: 100%; height: 100%; object-fit: contain; }
#file-windows .file-window { min-width: 0; min-height: 0; }
#file-windows .file-window-content { overflow: hidden; }
.content-window-resize { display: none; position: absolute; touch-action: none; user-select: none; z-index: 2; }
.is-floating .content-window-resize { display: block; }
.content-window-resize-n, .content-window-resize-s { left: 10px; right: 10px; height: 8px; cursor: ns-resize; }
.content-window-resize-n { top: -4px; } .content-window-resize-s { bottom: -4px; }
.content-window-resize-e, .content-window-resize-w { top: 10px; bottom: 10px; width: 8px; cursor: ew-resize; }
.content-window-resize-e { right: -4px; } .content-window-resize-w { left: -4px; }
.content-window-resize-ne, .content-window-resize-se, .content-window-resize-sw, .content-window-resize-nw { width: 14px; height: 14px; }
.content-window-resize-ne { top: -5px; right: -5px; cursor: nesw-resize; }
.content-window-resize-se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.content-window-resize-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.content-window-resize-nw { top: -5px; left: -5px; cursor: nwse-resize; }

/* Server media leases add one nonvisual ownership wrapper to the source tile. */
#board-assets .shelf-image-preview > .asset-frame {
    position: relative;
    width: 100%; height: 100%; min-height: 0;
    aspect-ratio: auto !important;
}
#board-assets .shelf-image-preview .image-status {
    position: absolute; inset: 0;
    display: grid; place-items: center;
    margin: 0; padding: 8px;
    font-size: 10px; color: var(--muted);
}
#board-assets .shelf-image-preview .asset-image { visibility: hidden; }
#board-assets .shelf-image-preview .image-ready > .asset-image { visibility: visible; }

/* The source right-click menu also needs a keyboard and touch entry point. */
#board-assets .world-item-menu {
    position: absolute; right: 3px; bottom: 7px;
    width: 1px; height: 1px; padding: 0;
    overflow: hidden; clip-path: inset(50%);
}
#board-assets .world-item-menu:focus-visible {
    width: 24px; height: 24px; clip-path: none;
    border-radius: 3px; background: var(--surface);
}
@media (pointer: coarse) {
    #board-assets .world-item-menu {
        width: 24px; height: 24px; clip-path: none;
        border-radius: 3px; background: var(--surface);
    }
}

/* Only private-media lease wrappers and finite API controls bridge the unchanged ZIP CSS. */
.pin-open > .asset-frame { position: relative; display: block; width: 100%; }
.pin-open .asset-image { display: block; width: 100%; height: auto; }
.discover-pin-media > .asset-frame { position: relative; width: 100%; height: 100%; min-width: 0; min-height: 0; }
.discover-pin-media > .asset-frame > .asset-image { width: 100%; height: 100%; object-fit: contain; }
.pin-open .image-status, .discover-pin-media .image-status { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 8px; font-size: 11px; color: var(--muted); background: var(--inset); }
.image-status[hidden] { display: none !important; }
.discover-search-submit { display: flex; align-items: center; justify-content: center; padding: 0; width: 19px; height: 19px; border: 0; background: transparent; color: inherit; }
.discover-search-submit svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.discover-scope { max-width: 86px; min-width: 0; border: 0; padding: 3px; background: transparent; color: var(--muted); font: inherit; font-size: 10px; }
.discover-scope option { background: var(--surface); color: var(--ink); }
.discover-board-choice { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); padding: 7px 0; font-size: 11px; text-align: left; }
.discover-board-choice > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.discover-more { display: flex; margin: 20px auto; }
/* A second instance in the nav column has no duplicate global IDs. These are
   the source #search-form rules, scoped to that otherwise identical instance. */
.v03-discover-compact .world-search-form { display: flex; align-items: center; width: 100%; max-width: none; height: 44px; min-height: 44px; margin: 0; padding: 0 14px; gap: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); box-shadow: 0 2px 8px #00000018; }
.v03-discover-compact .world-search-form input { flex: 1; min-width: 0; height: 100%; background: transparent; color: var(--ink); font-size: 13px; border: 0; outline: 0; }
.v03-discover-compact .world-search-form:focus-within { outline: 1px solid var(--accent); outline-offset: 2px; }
.v03-discover-compact .world-search-icon { display: flex; color: var(--muted); }

/* Retained lifetimes add no visible shell panel. */
#v03-conversation-surface { position: relative; flex: 1; min-height: 0; height: 100%; }
#v03-chat-page { height: 100%; }
#nav-scroll > .nav-heading { display: flex; align-items: center; gap: 5px; }
#nav-scroll > .nav-heading h2 { margin-right: auto; font-size: 15px; }
#nav-scroll > .nav-heading .icon-button { width: 28px; height: 28px; }
#toast[data-error=true] { border: 1px solid var(--danger); }

/* Inventory files continue the same material as the toolbar and drawer navigation. */
#lower-drawer #board-browser-scroll,
body:not(.nav-open) #lower-drawer #board-browser-scroll {
    background: var(--shelf-surface);
    border-radius: 6px;
    box-shadow: inset 0 1px 4px #00000024;
}

/* Chat presentation belongs beside appearance, not over the conversation. */
#topbar .channel-history-controls {
    position: static;
    padding: 0;
    gap: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}
@media (min-width: 761px) {
    body #menu, body #mobile-navigation { display: none !important; }
}

/* Discovery names its admitted saving location without adding another card. */
.pin > .discover-origin,
.discover-pin-info > .discover-origin {
    margin: 4px 2px 0;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.4;
    overflow-wrap: anywhere;
}


/* Keyboard focus follows the theme's ink, without blue selection boxes. */
#app :is(button, a, [role="button"], [role="separator"], [tabindex]):not(input, textarea, select):focus-visible {
    outline: none !important;
    box-shadow: inset 0 0 0 1px var(--muted) !important;
}
#app :is(input, textarea, select):is(:focus, :focus-visible) { outline: none !important; box-shadow: none !important; }
#app :is(#search-form, .world-search-form):focus-within {
    outline: none;
    border-color: var(--muted);
}
#app .file-window:focus-within { box-shadow: 0 12px 35px #0005, 0 0 0 1px var(--line); }
#app .shelf-drop-target { outline-color: var(--muted) !important; }

/* One permanently mounted message toolbar for chat and Discovery. */
#app #bottom-bar {
    height: var(--composer-height, 48px);
    min-height: var(--composer-height, 48px);
    /* The content scrollbar stops above this full-width row. */
    margin-right: calc(-1 * var(--scroll-width));
    padding: 0;
    gap: 0;
    align-items: stretch;
}
#app.signed-in:not(.in-community) #bottom-bar { margin-left: var(--nav-width); }
#app.signed-in #nav-profile-bar { display: flex; background: transparent; box-shadow: none; }
#app #bottom-bar > .chat-composer {
    position: relative;
    visibility: visible;
    display: flex;
    flex: 1;
    min-width: 0;
    height: var(--composer-height, 48px);
    min-height: 48px;
    margin: 0;
    padding: 0 32px;
    align-items: center;
    background: transparent;
    box-shadow: none;
}
#app #bottom-bar .composer-box {
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 34px;
    padding: 0 5px;
    border-radius: 5px;
    background: var(--surface);
    align-items: flex-end;
    box-shadow: inset 0 1px 2px #0000000a;
}
#app #bottom-bar textarea { min-height: 32px; max-height: 160px; line-height: 16px; padding: 8px 4px; }
#app #bottom-bar .composer-box > .icon-button { margin-bottom: 1px; }
#app #bottom-bar .composer-pull {
    position: absolute;
    top: 0;
    height: 100%;
    width: 32px;
    min-width: 32px;
    color: var(--muted);
    background: transparent;
    filter: none !important;
    outline: none !important;
    box-shadow: none !important;
    user-select: none;
    -webkit-user-select: none;
}
#app #bottom-bar .composer-pull-left { left: 0; right: auto; }
#app #bottom-bar .composer-pull-right { left: auto; right: 0; }
#app #bottom-bar .composer-pull:after {
    width: 12px;
    height: 14px;
    opacity: .65;
    background: repeating-linear-gradient(90deg,currentColor 0 1px,transparent 1px 5px);
}
body.drawer-dragging { cursor: ns-resize; user-select: none; }
#app #bottom-bar .composer-expanded {
    background-color: var(--toolbar-crown);
    background-image: linear-gradient(var(--toolbar-cap),var(--toolbar-crown)),var(--toolbar-gloss);
    background-position: center top,center bottom;
    background-size: 100% 12px,100% 48px;
    background-repeat: no-repeat;
}
/* The same reply/attachment surface stays above the same message row. */
#app #bottom-bar .composer-context {
    position: absolute;
    bottom: 100%;
    left: 32px;
    right: 32px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: min(40dvh,200px);
    padding-bottom: 6px;
    overflow-y: auto;
    overscroll-behavior: contain;
}
#app #bottom-bar .composer-context > :is(.reply-bar,.attachment-tray) {
    position: relative;
    inset: auto;
    width: 100%;
    margin: 0;
    flex-shrink: 0;
}
@media (max-width: 760px) {
    #app.signed-in #bottom-bar, #app.signed-in:not(.in-community) #bottom-bar { margin-left: 48px; }
    #app #bottom-bar > .chat-composer { padding-inline: 26px; }
    #app #bottom-bar .composer-pull { width: 26px; min-width: 26px; }
    #app #bottom-bar .composer-context { left: 26px; right: 26px; }
    #app.signed-in:not(.nav-open) #nav-profile-bar { display: flex !important; left: 0; width: 48px; padding: 6px; }
    body:not(.nav-open) #nav-profile-bar > span:not(.avatar) { display: none; }
}
/* Signed-out visitors get one participation prompt and no drawer controls. */
#app.signed-out #bottom-bar { padding: 0; margin-left: 0; height: 48px; min-height: 48px; }
#app.signed-out #bottom-bar > :not(.participation-cta) { display: none !important; }
#app.signed-out #bottom-bar > .participation-cta {
    display: flex;
    visibility: visible;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 48px;
    margin: 0;
    color: var(--ink);
    font-weight: 600;
}
#app.signed-out :is(#profile,#nav-profile-bar) { display: none !important; }
#app.signed-out [data-drawer="lower"] { pointer-events: none; cursor: default; }
#app.signed-in :is(#profile,#nav-profile-bar) { box-shadow: none; }
