/* Layout styles for Sacra application */

.document--card.sacra-feed-card {
    margin-bottom: 24px;
    border-color: #e3e3df;
}

.sacra-feed-card .desktop-company-tabs {
    margin-bottom: 10px;
}

.sacra-feed-card .preview-window h2 {
    margin-bottom: 6px;
    line-height: 1.35;
    font-size: 20px;
}

/* Image dimensions cannot depend on the headline or the source image's ratio.
 * Keep the thumbnail in normal flow, with the action footer below both columns. */
.sacra-feed-card .sacra-feed-preview {
    display:grid;
    grid-template-columns:minmax(0,1fr);
    grid-template-rows:auto 1fr;
    align-items:start;
}

.sacra-feed-card .sacra-feed-preview--image {
    grid-template-columns: minmax(0, 1fr) 160px;
    column-gap: 16px;
    align-items: start;
}

.sacra-feed-thumbnail {
    display: block;
    width: 160px;
    height: 100px;
    margin-top: 32px;
    grid-column:2;
    grid-row:1 / span 2;
    overflow: hidden;
    border-radius: 4px;
    background: #f7f7f5;
}

.sacra-feed-thumbnail img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

@media (max-width: 767px) {
    .sacra-feed-card .preview-window h2 { font-size:18px; }
    .sacra-feed-card .sacra-feed-preview--image {
        grid-template-columns: minmax(0, 1fr) 96px;
        column-gap: 12px;
    }

    .sacra-feed-thumbnail {
        width: 96px;
        height: 60px;
    }
}

.sacra-feed-card .sacra-feed-company-header {
    margin-bottom: 16px;
}

.sacra-feed-card .sacra-feed-company-metrics {
    margin-bottom: 0;
    row-gap: 12px;
}

.sacra-feed-company-header > div:first-child {
    width: 56px !important;
    min-width: 56px !important;
    height: 56px !important;
    margin-right: 12px;
}

/* The footer is also used by previews, mentions, highlights, and questions. */
div.sacra-feed-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin-top: 12px;
    padding: 12px 0;
    border-top: 1px solid #eeeeec;
}

.sacra-feed-card .sacra-feed-footer {
    padding-bottom: 0;
}

.document--card .sacra-feed-footer-block {
    padding-bottom: 0;
}

.sacra-feed-card .preview-window .pb-4 {
    padding-bottom: 0;
}

.document--card.sacra-feed-card > div:first-child {
    padding: 16px 20px;
}

.sacra-feed-footer .sacra-feed-status {
    background: transparent;
    padding: 0;
    margin: 0;
    gap: 6px;
    color: #737373;
    font-size: 12px;
    font-weight: 400;
}

.sacra-feed-status svg {
    width: 12px;
    height: 12px;
}

.sacra-feed-status .text-sm {
    font-size: inherit;
    color: inherit;
}

.sacra-feed-footer .sacra-feed-continue,
.sacra-feed-footer .sacra-feed-unlock {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 160px;
    width: 160px;
    min-height: 34px;
    padding: 6px 12px;
    border: 1px solid #dededb;
    border-radius: 7px;
    background: #fff;
    color: #3f3f3f;
    font-size: 13px;
    font-weight: 500;
    line-height: 20px;
    text-decoration: none;
    margin-left: auto;
    flex-shrink: 0;
    white-space: nowrap;
}

.sacra-feed-continue .text-sm {
    font-size: inherit;
    font-weight: inherit;
}

.sacra-feed-footer .sacra-feed-continue > :not(template) ~ :not(template),
.sacra-feed-footer .sacra-feed-status > :not(template) ~ :not(template) {
    margin-left: 0;
}

.sacra-feed-continue svg {
    width: 14px;
    height: 14px;
}

.sacra-feed-footer .sacra-feed-unlock {
    background: #fff4cf;
    border-color: #efdb9c;
    color: #5c491b;
}

.sacra-feed-footer .sacra-feed-continue:hover {
    background: #f7f7f5;
}

.sacra-feed-footer .sacra-feed-unlock:hover {
    background: #ffedb2;
}

.sacra-feed-footer :is(.sacra-feed-continue, .sacra-feed-unlock):focus-visible {
    outline: 2px solid #a88626;
    outline-offset: 3px;
}

/* Intentionally uncapped: rails stay at the viewport edges on wide screens.
 * Only the content canvas is capped; the right rail includes its outer inset. */
.sacra-standard-layout {
    --sacra-content-max-width: 800px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
}

.sacra-standard-layout > .sacra-sidebar-column,
.sacra-standard-layout > .sacra-right-column {
    display: none;
}

.sacra-standard-layout > .sacra-main-column {
    min-width: 0;
}

.sacra-content-canvas {
    max-width: var(--sacra-content-max-width);
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

.sacra-standard-layout > .sacra-right-column {
    max-width: var(--sacra-sidebar-width);
}

/* Shared desktop shell: edge-aligned rails, a bounded content canvas, and
 * breathing room both between columns and outside the right rail. */
@media (min-width: 1024px) {
    .sacra-standard-layout {
        grid-template-columns: var(--sacra-sidebar-width) minmax(0, 1fr) var(--sacra-sidebar-width);
    }

    .sacra-standard-layout > .sacra-sidebar-column,
    .sacra-standard-layout > .sacra-right-column {
        display: block;
    }

    .sacra-standard-layout > .sacra-main-column {
        padding-left: 16px;
        padding-right: 16px;
    }

    .sacra-standard-layout > .sacra-right-column {
        box-sizing: border-box;
        padding-right: 24px;
        min-width: 0;
    }
}

@media (min-width: 1280px) {
    .sacra-standard-layout > .sacra-main-column {
        padding-left: 40px;
        padding-right: 40px;
    }
}

/* Shared sidebar typography and interaction tokens. All product rails use the
 * same sans-serif face and a compact 12/13/14/15px hierarchy. */
:root {
    --sacra-sidebar-width: 280px;
    --sacra-sidebar-font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --sacra-sidebar-text: #3f3f3f;
    --sacra-sidebar-muted: #737373;
    --sacra-sidebar-label: #737373;
    --sacra-sidebar-border: #e5e7eb;
    --sacra-sidebar-surface: #fafafa;
    --sacra-sidebar-hover: rgba(35, 31, 32, 0.055);
    --sacra-sidebar-active: rgba(248, 190, 41, 0.16);
    --sacra-settings-content-surface: #f7f7f7;
    --sacra-sidebar-meta-size: 12px;
    --sacra-sidebar-label-size: 13px;
    --sacra-sidebar-secondary-size: 14px;
    --sacra-sidebar-item-size: 15px;
}

.sacra-sidebar-column,
.sacra-sidebar-shell {
    width: var(--sacra-sidebar-width);
    min-width: var(--sacra-sidebar-width);
}

.sacra-sidebar-shell {
    box-sizing: border-box;
    border-right: 1px solid var(--sacra-sidebar-border);
    background: var(--sacra-sidebar-surface);
    color: var(--sacra-sidebar-text);
    font-family: var(--sacra-sidebar-font);
}

/* Sticky elements within columns */
.sticky-column {
    position: sticky;
    top: 80px; /* Below header */
}

/* Global product sidebar */
.sacra-left-gutter {
    --sacra-sidebar-highlight: var(--sacra-sidebar-active);
    position: sticky;
    top: 65px;
    height: calc(100vh - 65px);
    height: calc(100dvh - 65px);
    display: flex;
    min-height: 0;
    flex-direction: column;
    padding: 14px 14px 16px 8px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #c8c8c8 transparent;
}

.sacra-sidebar-shell a:focus,
.sacra-sidebar-shell button:focus {
    outline: 2px solid rgba(35, 31, 32, 0.35) !important;
    outline-offset: 2px;
}

.sacra-sidebar-shell a:focus-visible,
.sacra-sidebar-shell button:focus-visible {
    outline: none !important;
    box-shadow: 0 0 0 2px rgba(35, 31, 32, 0.18) !important;
}

@supports selector(:focus-visible) {
    .sacra-sidebar-shell a:focus:not(:focus-visible),
    .sacra-sidebar-shell button:focus:not(:focus-visible) {
        outline: none !important;
    }
}

.sacra-sidebar-nav-item {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 12px;
    color: #323232;
    text-decoration: none;
}

.sacra-sidebar-nav-item {
    min-height: 36px;
    border-radius: 9px;
}

.sacra-sidebar-nav-item {
    gap: 10px;
    padding: 6px 10px;
    color: var(--sacra-sidebar-text);
    font-size: var(--sacra-sidebar-item-size);
    font-weight: 500;
    line-height: 20px;
}

.sacra-sidebar-nav-item:hover,
.sacra-sidebar-nav-item:focus-visible,
.sacra-sidebar-nav-item.is-active {
    background: var(--sacra-sidebar-active);
}

.sacra-sidebar-subnav-link {
    display: flex;
    overflow: hidden;
    align-items: center;
    gap: 10px;
    min-height: 36px;
    padding: 7px 10px;
    border-radius: 9px;
    color: var(--sacra-sidebar-text);
    font-size: var(--sacra-sidebar-item-size);
    font-weight: 500;
    line-height: 1.25;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sacra-sidebar-subnav-link svg {
    width: 16px;
    height: 16px;
    flex: none;
}

.sacra-sidebar-subnav-link span {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Compact grouped product navigation. */
.sacra-left-gutter .sacra-sidebar-nav-item svg,
.sacra-left-gutter .sacra-sidebar-subnav-link svg {
    width: 17px;
    height: 17px;
    color: #666;
}

.sacra-left-gutter .sacra-sidebar-nav-item:hover,
.sacra-left-gutter .sacra-sidebar-nav-item:focus-visible,
.sacra-left-gutter .sacra-sidebar-subnav-link:hover,
.sacra-left-gutter .sacra-sidebar-subnav-link:focus-visible {
    background: var(--sacra-sidebar-highlight);
    color: #231f20;
}

.sacra-left-gutter .sacra-sidebar-nav-item.is-active,
.sacra-left-gutter .sacra-sidebar-subnav-link.is-active {
    background: var(--sacra-sidebar-highlight);
    color: #231f20;
    font-weight: 600;
}

.sacra-left-gutter .sacra-sidebar-nav-item.is-active svg,
.sacra-left-gutter .sacra-sidebar-subnav-link.is-active svg {
    color: #333;
}

.sacra-left-gutter .sacra-recent-chats {
    margin-top: 16px;
    padding-top: 0;
    border: 0;
}

.sacra-left-gutter .sacra-recent-chats-toggle {
    gap: 6px;
    color: var(--sacra-sidebar-label);
    font-size: var(--sacra-sidebar-label-size);
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
}

.sacra-left-gutter .sacra-recent-chats-chevron {
    width: 14px;
    height: 14px;
    color: #777;
}

.sacra-left-gutter .sacra-recent-chat-list {
    padding-right: 0;
}

.sacra-left-gutter .sacra-recent-chat-row {
    min-height: 34px;
}

.sacra-left-gutter .sacra-recent-chat-link {
    padding: 7px 10px;
    color: var(--sacra-sidebar-text);
    font-size: var(--sacra-sidebar-item-size);
}

.sacra-left-gutter .sacra-sidebar-group {
    margin-top: 14px;
}

.sacra-left-gutter .space-y-1 > :not(template) ~ :not(template) {
    margin-top: 0;
    margin-bottom: 0;
}

.sacra-sidebar-group-label {
    margin: 0;
    padding: 0 10px 5px;
    color: var(--sacra-sidebar-label);
    font-size: var(--sacra-sidebar-label-size);
    font-weight: 500;
    line-height: 1.25;
}

.sacra-recent-chats-toggle {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 8px;
    border: 0;
    background: transparent;
    color: #606060;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.025em;
    text-transform: uppercase;
    cursor: pointer;
}

.sacra-recent-chats-toggle span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sacra-recent-chats-chevron {
    width: 16px;
    height: 16px;
    flex: none;
    transition: transform 160ms ease;
}

.sacra-recent-chats-toggle[aria-expanded="true"] .sacra-recent-chats-chevron {
    transform: rotate(180deg);
}

.sacra-sidebar-subnav-link:hover,
.sacra-sidebar-subnav-link:focus-visible,
.sacra-sidebar-subnav-link.is-active {
    background: rgba(0, 0, 0, 0.045);
    color: #231f20;
}

.sacra-recent-chat-list {
    margin: 0;
    padding: 0 4px 8px 0;
    list-style: none;
}

.sacra-recent-chat-list > li {
    position: relative;
}

.sacra-recent-chat-row {
    position: relative;
    display: flex;
    min-width: 0;
    align-items: center;
    margin: 1px 0;
    border-radius: 9px;
}

.sacra-recent-chat-row:hover,
.sacra-recent-chat-row:focus-within,
.sacra-recent-chat-row.is-active,
.sacra-recent-chat-row.is-menu-open,
.sacra-recent-chat-row.is-delete-pending {
    background: var(--sacra-sidebar-highlight);
}

.sacra-recent-chat-link {
    display: block;
    min-width: 0;
    flex: 1;
    overflow: hidden;
    padding: 9px 12px;
    border-radius: 9px;
    color: #444;
    font-size: 15px;
    line-height: 1.25;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sacra-thread-actions-button {
    display: inline-flex;
    width: 30px;
    height: 30px;
    margin-right: 4px;
    flex: none;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #555;
    cursor: pointer;
    opacity: 0;
}

.sacra-thread-actions-button svg {
    width: 18px;
    height: 18px;
}

.sacra-recent-chat-row:hover .sacra-thread-actions-button,
.sacra-recent-chat-row:focus-within .sacra-thread-actions-button,
.sacra-thread-actions-button[aria-expanded="true"] {
    opacity: 1;
}

.sacra-thread-actions-button:hover,
.sacra-thread-actions-button:focus-visible {
    background: transparent;
    color: #181818;
}

.sacra-thread-actions-menu {
    position: fixed;
    z-index: 1000;
    width: 184px;
    padding: 7px;
    border: 1px solid #dedede;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
}

.sacra-thread-actions-menu button {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 10px;
    padding: 10px 11px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #e11d48;
    font-size: 15px;
    line-height: 1.25;
    text-align: left;
    cursor: pointer;
}

.sacra-thread-actions-menu button svg {
    width: 20px;
    height: 20px;
    flex: none;
}

.sacra-thread-actions-menu button:hover,
.sacra-thread-actions-menu button:focus-visible {
    background: #fff1f0;
}

.sacra-thread-actions-menu button:focus {
    outline: none;
    box-shadow: none;
}

.sacra-thread-delete-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.5);
}

.sacra-thread-delete-modal[hidden] {
    display: none;
}

.sacra-thread-delete-dialog {
    width: min(448px, 100%);
    padding: 32px;
    border-radius: 12px;
    background: #fff;
    color: #292929;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.sacra-thread-delete-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.sacra-thread-delete-dialog h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.25;
}

.sacra-thread-delete-close {
    display: inline-flex;
    width: 24px;
    height: 24px;
    flex: none;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
}

.sacra-thread-delete-close:hover,
.sacra-thread-delete-close:focus-visible {
    color: #4b5563;
}

.sacra-thread-delete-close:focus,
.sacra-thread-delete-buttons button:focus {
    outline: none;
}

.sacra-thread-delete-close svg {
    width: 24px;
    height: 24px;
}

.sacra-thread-delete-content {
    margin-bottom: 16px;
}

.sacra-thread-delete-dialog p {
    margin: 0;
    color: #3f3f46;
    font-size: 16px;
    line-height: 1.55;
}

.sacra-thread-delete-dialog [data-thread-delete-title] {
    display: block;
    margin-top: 4px;
    color: #18181b;
}

.sacra-thread-delete-dialog .sacra-thread-delete-warning {
    margin-top: 12px;
    color: #dc2626;
    font-size: 16px;
}

.sacra-thread-delete-dialog .sacra-thread-delete-error {
    margin-top: 14px;
    padding: 10px 12px;
    border: 1px solid #fecaca;
    border-radius: 8px;
    background: #fef2f2;
    color: #b42318;
    font-size: 14px;
}

.sacra-thread-delete-buttons {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.sacra-thread-delete-buttons button {
    min-width: 0;
    flex: 1;
    padding: 8px 16px;
    border: 1px solid #d4d4d4;
    border-radius: 8px;
    background: #fff;
    color: #374151;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
}

.sacra-thread-delete-buttons button:hover,
.sacra-thread-delete-buttons button:focus-visible {
    background: #f3f4f6;
}

.sacra-thread-delete-buttons button.is-danger {
    border-color: #dc2626;
    background: #dc2626;
    color: #fff;
}

.sacra-thread-delete-buttons button.is-danger:hover,
.sacra-thread-delete-buttons button.is-danger:focus-visible {
    border-color: #b91c1c;
    background: #b91c1c;
}

.sacra-thread-delete-buttons button:disabled {
    cursor: wait;
    opacity: 0.6;
}

.sacra-thread-delete-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 7px;
    vertical-align: -3px;
    animation: sacra-thread-spin 800ms linear infinite;
}

@keyframes sacra-thread-spin {
    to { transform: rotate(360deg); }
}

@media (hover: none) {
    .sacra-thread-actions-button {
        opacity: 1;
    }
}

.sacra-recent-chat-link:hover,
.sacra-recent-chat-link:focus-visible,
.sacra-recent-chat-link.is-active {
    background: transparent;
    color: #181818;
}

.sacra-recent-chat-link.is-active {
    font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
    .sacra-recent-chats-chevron {
        transition: none;
    }
}

/* Right-hand discovery rail on /dashboard/.
 *
 * Goal: scroll with the feed, then hold still once the rail's last row reaches
 * the bottom of the viewport, so passing the end of the rail doesn't leave a
 * column of dead whitespace beside a long feed.
 *
 * `position: sticky; bottom: 0` does NOT do this. That constraint stops the box
 * dropping *below* the viewport bottom, so it binds while scrolling up; scrolling
 * down, the rail sails out of view exactly as if it were static. Pinning on the
 * way down needs `top`, offset upward by however much the rail overhangs the
 * viewport -- hence the negative value.
 *
 * min() keeps the short-rail case sane: when the whole rail fits on screen the
 * offset clamps to a top-pinned position, instead of a positive `top` shoving it
 * down the page on load. It clamps to the header height and not to 0, because
 * the site header is itself `sticky top-0 z-30` -- pinning to 0 parks the rail
 * underneath it and swallows the heading and the first ranked row.
 *
 * Both variables are measured and kept current by the dashboard's inline
 * observer. The fallbacks only have to survive the first paint before it runs;
 * note that the 71px header fallback matches neither the 80px nor the 65px
 * offset hardcoded elsewhere in this file, which is exactly why it is measured
 * rather than typed in a fourth time.
 */
.sacra-sticky-rail {
    position: sticky;
    top: min(
        var(--sacra-header-height, 71px),
        calc(100vh - var(--sacra-rail-height, 1200px))
    );
}

/* Shared visual language for dashboard/category ranking rails. */
.sacra-ranking-sidebar {
    color: var(--sacra-sidebar-text);
    font-family: var(--sacra-sidebar-font);
}

.sacra-ranking-sidebar .sacra-sidebar-module-title {
    color: #323232;
    font-size: var(--sacra-sidebar-item-size);
    font-weight: 600;
    line-height: 20px;
}

.sacra-ranking-sidebar .sacra-sidebar-module-qualifier,
.sacra-ranking-sidebar .sacra-sidebar-meta {
    color: var(--sacra-sidebar-muted);
    font-size: var(--sacra-sidebar-meta-size);
    line-height: 16px;
}

.sacra-ranking-sidebar .sacra-sidebar-item-title {
    color: var(--sacra-sidebar-text);
    font-size: var(--sacra-sidebar-secondary-size);
    font-weight: 500;
    line-height: 20px;
}

.sacra-ranking-sidebar .sacra-sidebar-module-action {
    color: #555;
    font-size: var(--sacra-sidebar-label-size);
    font-weight: 500;
    line-height: 20px;
    text-decoration: none;
}

.sacra-ranking-sidebar .sacra-sidebar-module-action:hover,
.sacra-ranking-sidebar .sacra-sidebar-module-action:focus-visible {
    color: #231f20;
    text-decoration: underline;
}

/* Settings uses the same scale, surface and interaction states as the product
 * sidebar, while retaining its full-height takeover layout. */
.sacra-settings-page,
.sacra-settings-content {
    background: var(--sacra-settings-content-surface);
}

.sacra-settings-sidebar .sacra-settings-nav {
    padding: 14px 14px 16px 8px;
}

.sacra-settings-sidebar .sacra-settings-section {
    margin-top: 14px;
}

.sacra-settings-sidebar .space-y-1 > :not(template) ~ :not(template) {
    margin-top: 0;
    margin-bottom: 0;
}

.sacra-settings-sidebar .sacra-settings-org-selector {
    display: flex;
    width: 100%;
    min-height: 36px;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 9px;
    color: var(--sacra-sidebar-text);
    font-size: var(--sacra-sidebar-item-size);
    font-weight: 500;
    line-height: 20px;
    background: #f1f1f1;
    box-shadow: none;
}

.sacra-settings-sidebar .sacra-settings-org-selector:hover,
.sacra-settings-sidebar .sacra-settings-org-selector:focus-visible {
    background: var(--sacra-sidebar-hover);
    color: #231f20;
}

.sacra-settings-sidebar .sacra-settings-nav-item.is-muted:not(.is-active) {
    color: var(--sacra-sidebar-muted);
}

.sacra-settings-sidebar .sacra-settings-nav-item.is-danger {
    color: #c53030;
}

.sacra-settings-sidebar .sacra-settings-nav-item.is-danger:hover,
.sacra-settings-sidebar .sacra-settings-nav-item.is-danger:focus-visible {
    background: #fff5f5;
    color: #9b2c2c;
}

.sacra-settings-sidebar .sacra-settings-back-link {
    color: var(--sacra-sidebar-muted);
    font-size: var(--sacra-sidebar-label-size);
    font-weight: 500;
    line-height: 20px;
    letter-spacing: 0;
    text-transform: none;
}

.sacra-settings-sidebar .sacra-settings-back-link:hover,
.sacra-settings-sidebar .sacra-settings-back-link:focus-visible {
    color: #231f20;
}

.sacra-settings-sidebar .sacra-settings-nav-item > svg:first-child {
    width: 17px;
    height: 17px;
    margin-right: 0;
    color: #666;
}

.sacra-settings-sidebar .sacra-settings-org-selector-mark {
    margin-right: 0;
    font-size: var(--sacra-sidebar-meta-size);
}

@media (max-width: 767px) {
    .sacra-settings-sidebar {
        width: min(var(--sacra-sidebar-width), calc(100vw - 32px));
        min-width: 0;
    }
}

/* Shared report shells: the save control is a sibling, never the padding owner. */
.document--card.sacra-feed-card > .report-card-content { padding:24px 20px 16px; }
.report-card-content > .sacra-feed-footer { margin-top:20px; }
.report-card-text { min-width:0;grid-column:1;grid-row:2; }
/* Only the first text row needs the corner-control clearance, never the thumbnail column. */
.sacra-feed-preview .report-card-companies { grid-column:1 / -1;grid-row:1;padding-right:32px; }
.sacra-feed-preview:not(.sacra-feed-preview--image) .report-card-companies:empty + .report-card-text h2 { padding-right:32px; }
.report-card-companies,.report-card-categories { display:flex;flex-wrap:wrap;align-items:center;gap:8px; }
/* Reserve the quiet-corner save slot; keep two tags and the count on one line. */
.sacra-feed-card .report-card-companies { justify-content:flex-start;flex-direction:row;flex-wrap:nowrap;min-width:0;gap:6px; }
.report-card-companies > .report-card-company { flex:0 1 auto;min-width:0;gap:4px;padding:4px; }
.report-card-company-others { flex:none;white-space:nowrap;font-size:11px;color:#6b7063; }
.report-card-companies:empty,.report-card-categories:empty { display:none; }
.report-card-company { display:inline-flex;align-items:center;gap:8px;padding:8px;border:1px solid #d1d5db;border-radius:999px;max-width:100%;font-size:12px;font-weight:500;line-height:18px; }
.report-card-company img { width:18px;height:18px;flex:none;border-radius:50%;object-fit:contain; }
.report-card-company span { min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap; }
.report-card-categories { color:#4a5568;font-size:12px;line-height:18px; }
.report-card-context { display:flex;align-items:center;gap:6px;color:#6b7063;font-size:12px;line-height:20px;margin:0 0 10px 2px; }
.report-card-passage { display:block;border-left:2px solid #deded8;padding-left:16px;margin:18px 0 0;color:#575e50;text-decoration:none; }
.report-card-passage blockquote { margin:0;font-family:inherit;font-size:15px;line-height:1.7;font-weight:400;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:5;overflow:hidden;white-space:pre-line;overflow-wrap:anywhere; }
.report-card-passage mark,.report-card-passage em { background:#fbf3db;color:inherit;font-style:normal;font-weight:inherit;box-decoration-break:clone;-webkit-box-decoration-break:clone; }
.sacra-feed-footer .sacra-feed-status { display:inline-flex;align-items:center;line-height:16px;gap:6px; }
.sacra-feed-status svg { display:block;flex:0 0 12px; }
/* Image passages flow beside the thumbnail, then reclaim its width below it.
 * Keep the tag row full-width and the thumbnail's established Save clearance. */
.sacra-feed-preview > .report-card-passage { grid-column:1 / -1;grid-row:3; }
.sacra-feed-preview--image:has(> .report-card-passage) { display:flow-root;position:relative; }
.sacra-feed-preview--image:has(> .report-card-passage) > .sacra-feed-thumbnail { float:right;margin-left:16px;margin-bottom:12px; }
.sacra-feed-preview--image:has(> .report-card-passage) > .report-card-companies { position:absolute;top:0;left:0;right:0; }
.sacra-feed-preview--image:has(> .report-card-passage) > .report-card-companies:not(:empty) + .report-card-text { padding-top:38px; }
/* overflow:clip preserves float wrapping; hidden and -webkit-box create a separate formatting context. */
.sacra-feed-preview--image > .report-card-passage blockquote { display:block;overflow:clip;max-height:8.5em; }
/* Saves is a collection of selected passages, so none may be hidden by the
 * shared feed preview's line, image-height, or outer container limit. */
#saves .sacra-feed-preview { max-height:none;overflow:visible; }
#saves .sacra-feed-preview:has(> .report-card-passage) { display:flow-root; }
#saves .report-card-passage blockquote { display:block;-webkit-line-clamp:unset;max-height:none;overflow:visible; }
#saves .saves-entry > .report-card-passage + h2 { margin-top:20px; }
@media(max-width:767px) { .sacra-feed-preview--image:has(> .report-card-passage) > .sacra-feed-thumbnail { margin-left:12px; } }
.report-card-passage:focus-visible { outline:2px solid #657b4e;outline-offset:4px; }
@media(max-width:767px) { .report-card-passage { padding-left:13px;margin:16px 0 0; } }
.passage-arrival { scroll-margin-top:90px;animation:passage-arrival 3s ease-out; }
@keyframes passage-arrival { from { background-color:#fbf0cb; } to { background-color:transparent; } }
@media(prefers-reduced-motion:reduce) { .passage-arrival { animation:none;outline:2px solid #e8d080;outline-offset:4px; } }

/* Company documents share the report shell; Follow stays beside the name. */
.report-card-content > .sacra-feed-company-header { display:flex;align-items:flex-start;gap:12px;padding-right:32px;margin-bottom:0; }
.report-card-content > .sacra-feed-company-metrics { margin-top:16px; }
.company-card-logo { flex:0 0 48px;width:48px;height:48px;overflow:hidden;border-radius:50%; }
.company-card-logo img { width:100%;height:100%;object-fit:contain; }
.company-card-details { flex:1;min-width:0; }
.company-card-name-row { display:flex;align-items:center;justify-content:flex-start;gap:10px;flex-wrap:wrap;min-height:48px;margin-bottom:0; }
.company-card-name-row > a { overflow-wrap:anywhere; }
.company-card-name-row button { flex:none;white-space:nowrap; }
.sacra-feed-company-description { margin-top:14px;line-height:1.6;overflow-wrap:anywhere; }
.sacra-feed-company-description:empty { display:none; }
.sacra-feed-company-description + .report-card-categories { margin-top:10px; }
.report-card-content > .sacra-feed-company-metrics { display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px 12px; }
@media(max-width:479px) { .report-card-content > .sacra-feed-company-metrics { grid-template-columns:repeat(2,minmax(0,1fr)); } }
.company-profile-follow { display:flex;align-items:center;gap:10px; }

/* Quiet company Follow action; the existing state classes remain authoritative. */
.company-card-name-row button,
.company-profile-follow button,
.company-profile-follow a { padding:5px 9px;font-size:12px;gap:4px;background:#fff;border:1px solid #222;color:#222; }
.company-card-name-row button .mx-2,
.company-profile-follow .mx-2 { margin:0; }
.company-card-name-row button svg,
.company-profile-follow svg { width:12px;height:12px; }
.company-card-name-row button.bg-yellow-800,
.company-profile-follow .bg-yellow-800 { background:#faf2cf;border-color:#e8dca9;color:#514b35; }
.company-card-name-row button.bg-yellow-800:hover,
.company-profile-follow .bg-yellow-800:hover { background:#f5e9b9;border-color:#d9c989;color:#393524; }

.report-card-context-icon { flex:none;color:#8a8d80; }

.sacra-sidebar-group-link {
    color: inherit;
    text-decoration: none;
}

.sacra-sidebar-group-link:hover,
.sacra-sidebar-group-link:focus-visible {
    color: #3f3f3f;
}

.sacra-recent-chat-add {
    display: inline-flex;
    height: 28px;
    width: 28px;
    flex: none;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: #858585;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.25;
    text-decoration: none;
}

/* Keep linked section labels and their separate toggles beside one another. */
.sacra-sidebar-section-heading { display: flex; align-items: center; gap: 6px; padding: 0 12px 5px; }
.sacra-sidebar-section-heading .sacra-sidebar-group-label { padding: 0; }
.sacra-sidebar-section-toggle { padding: 0; }
