/**
 * browse-media-sibnotes.css — SibNotes, the archive mode of Browse Media (folding-sibnotes-reader S2).
 *
 * One sentence you can touch, three big kinds, the archive's people as faces, a decade strip, three quiet
 * toggles and a search. Wide (≥900px): the sentence and kinds across the top, the rest in a left rail beside
 * the grid. Narrow: the sentence pinned under the header; everything else in one in-room sheet (NOT a registered
 * BottomSheet: those evict other modals). Archive-paper accent on the room's own dark surface.
 */

.browse-media-modal.bm-sibnotes {
    --bmsn-accent: #e7c787;
    --bmsn-accent-ink: #2a2013;
    --bmsn-paper: rgba(231, 199, 135, 0.10);
    --bmsn-line: rgba(231, 199, 135, 0.28);
    --bmsn-text: rgba(255, 255, 255, 0.92);
    --bmsn-muted: rgba(255, 255, 255, 0.62);
}

.browse-media-modal.bm-sibnotes .bm-header {
    background: linear-gradient(135deg, #5a4524 0%, #3b2d18 100%);
}

/* ── the header control (both modes, both surfaces) ─────────────────────── */
.bmsn-control {
    gap: 6px;
}
.bmsn-control-glyph { font-size: calc(15px * var(--type-scale, 1)); line-height: 1; }
.bmsn-control.is-on {
    background: var(--bmsn-accent, #e7c787);
    border-color: var(--bmsn-accent, #e7c787);
    color: #2a2013;
    font-weight: 600;
}

/* ── the top band: the sentence, the paper in hand, the kinds ───────────── */
.bmsn-top {
    flex-shrink: 0;
    padding: 12px 16px 10px;
    border-bottom: 1px solid var(--bmsn-line);
    background: var(--bmsn-paper);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.bmsn-sentence {
    margin: 0;
    color: var(--bmsn-text);
    font-size: calc(18px * var(--type-scale, 1));
    line-height: 1.6;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 6px;
}
.bmsn-sentence-row { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; }
.bmsn-sentence-row .bmsn-sentence { flex: 1 1 auto; min-width: 0; }
.bmsn-sentence-sep { margin-left: -6px; }
.bmsn-phrase {
    display: inline-flex;
    align-items: baseline;
    border-radius: 8px;
}
.bmsn-phrase-btn {
    background: none;
    border: 0;
    padding: 0 2px;
    color: var(--bmsn-accent);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    text-decoration: underline dotted rgba(231, 199, 135, 0.55);
    text-underline-offset: 4px;
    min-height: 32px;
}
.bmsn-phrase:not(.is-set) .bmsn-phrase-btn { color: var(--bmsn-text); font-weight: 600; }
.bmsn-phrase-x {
    background: rgba(231, 199, 135, 0.16);
    border: 0;
    border-radius: 999px;
    color: var(--bmsn-accent);
    width: 22px;
    height: 22px;
    font-size: 11px;
    line-height: 22px;
    margin-left: 2px;
    cursor: pointer;
    align-self: center;
}
.bmsn-phrase-x:hover { background: rgba(231, 199, 135, 0.32); }
.bmsn-count { color: var(--bmsn-muted); font-weight: 500; }
.bmsn-sentence-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.bmsn-sentence-actions:empty { display: none; }
.bmsn-reset, .bmsn-sheet-open, .bmsn-suggest {
    background: transparent;
    border: 1px solid var(--bmsn-line);
    border-radius: 999px;
    color: var(--bmsn-accent);
    padding: 6px 14px;
    font-size: calc(14px * var(--type-scale, 1));
    cursor: pointer;
    min-height: 36px;
}
.bmsn-sheet-open { background: var(--bmsn-accent); color: var(--bmsn-accent-ink); border-color: var(--bmsn-accent); font-weight: 600; }

.bmsn-inhand {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px dashed var(--bmsn-line);
    color: var(--bmsn-muted);
    font-size: calc(14px * var(--type-scale, 1));
}
.bmsn-inhand-label { color: var(--bmsn-text); font-weight: 600; }
.bmsn-inhand-title {
    background: none; border: 0; padding: 0; color: var(--bmsn-accent); font: inherit; font-weight: 600;
    cursor: pointer; text-align: left;
}
.bmsn-inhand-hint { flex-basis: auto; }
.bmsn-inhand-x {
    margin-left: auto; background: none; border: 0; color: var(--bmsn-muted); cursor: pointer;
    width: 32px; height: 32px; border-radius: 999px;
}

.bmsn-kinds { display: flex; gap: 8px; flex-wrap: wrap; }
.bmsn-kind {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 18px; min-height: 44px;
    border-radius: 12px;
    border: 1px solid var(--bmsn-line);
    background: rgba(255, 255, 255, 0.04);
    color: var(--bmsn-text);
    font-size: calc(15px * var(--type-scale, 1));
    font-weight: 600;
    cursor: pointer;
}
.bmsn-kind.is-on { background: var(--bmsn-accent); color: var(--bmsn-accent-ink); border-color: var(--bmsn-accent); }
.bmsn-n {
    font-weight: 500; font-size: 0.82em; opacity: 0.75; font-variant-numeric: tabular-nums;
}

/* ── the body: rail + grid ──────────────────────────────────────────────── */
.bmsn-body {
    flex: 1;
    min-height: 0;
    display: flex;
}
.bmsn-body > .bm-grid-container { flex: 1; min-width: 0; }
.bmsn-rail {
    width: 300px;
    flex-shrink: 0;
    overflow-y: auto;
    padding: 14px 14px 24px;
    border-right: 1px solid var(--bmsn-line);
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.bmsn-section { display: flex; flex-direction: column; gap: 10px; border-radius: 12px; }
.bmsn-h {
    margin: 0; color: var(--bmsn-text); font-size: calc(13px * var(--type-scale, 1));
    text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700;
    display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.bmsn-h-hint { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--bmsn-muted); font-size: 12px; }
.bmsn-wait { margin: 0; color: var(--bmsn-muted); font-size: 14px; }
.bmsn-flash { animation: bmsn-flash 1.2s ease-out; }
@keyframes bmsn-flash {
    0% { box-shadow: 0 0 0 3px rgba(231, 199, 135, 0.75); }
    100% { box-shadow: 0 0 0 3px rgba(231, 199, 135, 0); }
}

/* faces */
.bmsn-faces {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
    gap: 10px 6px;
}
.bmsn-face {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    background: none; border: 0; padding: 4px 2px; border-radius: 12px;
    color: var(--bmsn-text); cursor: pointer; text-align: center; min-height: 44px;
}
.bmsn-face:hover { background: rgba(255, 255, 255, 0.05); }
.bmsn-face.is-dim { opacity: 0.45; }
.bmsn-face-pic {
    position: relative; width: 56px; height: 56px; border-radius: 50%;
    background: rgba(231, 199, 135, 0.18); border: 2px solid transparent; overflow: visible;
    display: block;
}
.bmsn-face-img, .bmsn-face-init {
    position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%;
}
.bmsn-face-img { object-fit: cover; }
.bmsn-face-init {
    display: flex; align-items: center; justify-content: center;
    color: var(--bmsn-accent); font-weight: 700; font-size: 18px;
}
.bmsn-face.is-from .bmsn-face-pic, .bmsn-face.is-to .bmsn-face-pic, .bmsn-face.is-about .bmsn-face-pic {
    border-color: var(--bmsn-accent);
    box-shadow: 0 0 0 3px rgba(231, 199, 135, 0.25);
}
.bmsn-face-role {
    position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%);
    background: var(--bmsn-accent); color: var(--bmsn-accent-ink);
    font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px;
}
.bmsn-face-name { font-size: 13px; font-weight: 600; margin-top: 6px; line-height: 1.2; }
.bmsn-face-kin { font-size: 11px; color: var(--bmsn-accent); line-height: 1.2; }
.bmsn-face-n { font-size: 11px; color: var(--bmsn-muted); line-height: 1.25; }

/* decades */
.bmsn-decades {
    display: flex; gap: 3px; align-items: flex-end; overflow-x: auto; padding-bottom: 4px;
    touch-action: pan-x; user-select: none; -webkit-user-select: none;
}
.bmsn-decade {
    flex: 1 0 34px; min-width: 34px;
    display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px;
    background: none; border: 0; border-radius: 8px; padding: 4px 1px;
    color: var(--bmsn-text); cursor: pointer; min-height: 72px;
}
.bmsn-decade-bar {
    width: 70%; border-radius: 4px 4px 1px 1px; background: rgba(231, 199, 135, 0.35);
}
.bmsn-decade.is-on .bmsn-decade-bar, .bmsn-decade.is-dragging .bmsn-decade-bar { background: var(--bmsn-accent); }
.bmsn-decade.is-on { background: rgba(231, 199, 135, 0.14); }
.bmsn-decade-label { font-size: 12px; font-weight: 600; }
.bmsn-decade .bmsn-n { font-size: 10px; }

/* toggles */
.bmsn-toggles { flex-direction: row; flex-wrap: wrap; gap: 8px; }
.bmsn-toggle {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px; min-height: 40px; border-radius: 999px;
    border: 1px solid var(--bmsn-line); background: transparent; color: var(--bmsn-text);
    font-size: 14px; cursor: pointer;
}
.bmsn-toggle[disabled] { opacity: 0.45; cursor: default; }
.bmsn-toggle-dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--bmsn-accent); }
.bmsn-toggle.is-on { background: rgba(231, 199, 135, 0.18); border-color: var(--bmsn-accent); }
.bmsn-toggle.is-on .bmsn-toggle-dot { background: var(--bmsn-accent); }

/* search */
.bmsn-search-label { color: var(--bmsn-muted); font-size: 13px; }
.bmsn-search-input {
    width: 100%; box-sizing: border-box; padding: 10px 12px; min-height: 44px;
    border-radius: 10px; border: 1px solid var(--bmsn-line); background: rgba(0, 0, 0, 0.25);
    color: var(--bmsn-text); font-size: 16px;
}

/* the empty state */
.bmsn-empty h3 { color: var(--bmsn-text); font-weight: 600; max-width: 34em; margin: 0 auto 12px; line-height: 1.4; }
.bmsn-empty p { margin: 0; }

/* ── narrow: the sentence pinned, everything else in the in-room sheet ──── */
@media (max-width: 899px) {
    .bmsn-top { padding: 10px 12px; gap: 8px; }
    .bmsn-sentence { font-size: calc(17px * var(--type-scale, 1)); }
    .bmsn-sheet {
        position: absolute;
        left: 0; right: 0; bottom: 0;
        max-height: 78%;
        z-index: 40;
        display: flex;
        flex-direction: column;
        background: #241d14;
        border-top: 1px solid var(--bmsn-line);
        border-radius: 18px 18px 0 0;
        box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.55);
        padding-bottom: 12px;   /* the modal already ends at the tab bar (mobile.css contract) */
    }
    .bmsn-sheet[hidden] { display: none; }
    .bmsn-sheet-head {
        display: flex; justify-content: space-between; align-items: center;
        padding: 12px 16px 8px; color: var(--bmsn-text); font-weight: 700;
    }
    .bmsn-sheet-done {
        background: var(--bmsn-accent); color: var(--bmsn-accent-ink); border: 0; border-radius: 999px;
        padding: 8px 18px; min-height: 40px; font-weight: 700; cursor: pointer;
    }
    .bmsn-sheet-body {
        overflow-y: auto; -webkit-overflow-scrolling: touch;
        padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 20px;
    }
    .bmsn-sheet .bmsn-faces { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
    .bmsn-sheet .bmsn-kind { flex: 1 1 auto; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
    .bmsn-flash { animation: none; }
}
