/* HTMX error toast */
.htmx-error-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    max-width: 400px;
    opacity: 1;
    transition: opacity 0.4s ease;
}
.htmx-error-toast-hide {
    opacity: 0;
}

/* HTMX loading states: add Bulma is-loading appearance during requests */
.htmx-loading-btn.htmx-request {
    pointer-events: none;
    color: transparent !important;
    position: relative;
}
.htmx-loading-btn.htmx-request::after {
    content: "";
    display: block;
    position: absolute;
    top: calc(50% - 0.5em);
    left: calc(50% - 0.5em);
    width: 1em;
    height: 1em;
    border: 2px solid hsl(0, 0%, 86%);
    border-top-color: transparent;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinAround 500ms infinite linear;
}
@keyframes spinAround { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.page-title {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: 100%;
}

.editable-page-title {
    max-width: 40vw;
}
@media screen and (max-width: 768px) {
    .editable-page-title {
        max-width: 70vw;
    }
}

html.full-height {
    min-height: 100vh;
    height: 100%;
}
html.full-height body {
    min-height: 100vh;
}

.search-wrapper {
    position: relative;
    z-index: 30;
}

.url-card-content {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

/* By-origin tree node links: prevent mobile font inflation */
.origin-tree-link {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    font-size: 1rem;
}

.folder-actions {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 0.25em;
}

.menu-list .folder-actions {
    top: 0;
    bottom: 0;
    transform: none;
    align-items: center;
}

.menu-list .folder-actions .button.is-small {
    height: 1.5em;
    width: 1.5em;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* .menu-label .folder-actions .button.is-small { */
/*     height: 1.75em; */
/*     width: 1.75em; */
/*     padding: 0; */
/* } */

/* Flex column layout for pages with iframes/document frames */
.main-content-column:has(.page-body),
.main-content-column:has(.iframe-page),
.main-content-column:has(.graph-page) {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 3rem);
    overflow: hidden;
}
@media screen and (max-width: 768px) {
    .main-content-column:has(.page-body),
    .main-content-column:has(.iframe-page),
    .main-content-column:has(.graph-page) {
        height: calc(100vh - 1rem);
    }
}

/* These flex rules apply at all viewports so iframes fill available space */
.graph-page {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.page-body {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* On mobile, .columns stacks children. Target only the document column. */
.page-body > #viewer-core--document-column {
    display: flex;
    flex-direction: column;
    flex: 1 1 0 !important;
    min-height: 0;
}

#viewer-core--discover-content,
.iframe-page {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
}

#viewer-core--highlightable-page {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

@media screen and (min-width: 1024px) {
    .main-content-column:has(.page-body),
    .main-content-column:has(.iframe-page),
    .main-content-column:has(.graph-page) {
        height: calc(100vh - 3rem + 24px);
    }

    /* On desktop, .page-body is a .columns flex-row; use overflow hidden */
    .page-body {
        overflow: hidden;
        flex-direction: row;
        flex-wrap: wrap;
    }

    /* Discover page: keep .page-body columnar (no side panel) */
    #viewer-core--discover-content > .page-body {
        flex-direction: column;
        flex-wrap: nowrap;
    }

    .panel-column {
        overflow: hidden;
    }

    .panel-annotations {
        flex: 0 1 auto;
        max-height: 60%;
        overflow-y: auto;
        min-height: 0;
        border-bottom: 1px solid #dbdbdb;
        padding-bottom: 0.5rem;
    }

    .panel-links {
        flex: 1 1 0;
        overflow-y: auto;
        min-height: 0;
        padding-top: 0.5rem;
    }
}

.document-frame {
    width: 100%;
    border: 1px solid #ccc;
    flex: 1 1 0;
    min-height: 40vh;
}

.search-result-title {
    -webkit-line-clamp: 1;
    overflow: hidden;
    line-height: 1.5;
    -webkit-box-orient: vertical;
    display: -webkit-box;
}

/* Search results page: keep pagination aligned with sidebar footer (log out) */
.search-results-page .pagination {
    margin-top: 0.5rem;
    margin-bottom: 0;
}

.url-card {
    display: flex;
    flex-direction: column;
    height: 8em;
    min-height: 8em;
    max-height: 8em;
    border: 1px solid hsl(0, 0%, 86%);
    box-shadow: 0 0.125em 0.25em rgba(10, 10, 10, 0.05);
}
@media screen and (max-width: 768px) {
    .url-card {
        height: 10em;
        min-height: 10em;
        max-height: 10em;
    }
    .url-card-content {
        font-size: 0.95rem;
    }
    .fixed-grid .grid {
        gap: 0.5rem;
    }
}
.url-card > .card-content {
    padding: 0.75rem 1rem;
}
@media (prefers-color-scheme: dark) {
    .url-card {
        border-color: hsl(0, 0%, 29%);
        box-shadow: 0 0.125em 0.25em rgba(0, 0, 0, 0.2);
    }
}

.folder-card {
    background: hsl(48, 60%, 95%);
    border-color: hsl(40, 40%, 75%);
    position: relative;
    border-top-left-radius: 0;
    height: calc(8em - 1rem);
    min-height: calc(8em - 1rem);
    max-height: calc(8em - 1rem);
}
@media screen and (max-width: 768px) {
    .folder-card {
        height: calc(10em - 1rem);
        min-height: calc(10em - 1rem);
        max-height: calc(10em - 1rem);
    }
}
.folder-card::before {
    content: "";
    position: absolute;
    top: -1rem;
    left: -1px;
    width: 40%;
    height: 1rem;
    background: hsl(48, 60%, 95%);
    border: 1px solid hsl(40, 40%, 75%);
    border-bottom: none;
    border-radius: 0.35rem 0.35rem 0 0;
}
@media (prefers-color-scheme: dark) {
    .folder-card {
        background: hsl(40, 15%, 20%);
        border-color: hsl(40, 20%, 35%);
    }
    .folder-card::before {
        background: hsl(40, 15%, 20%);
        border-color: hsl(40, 20%, 35%);
    }
}

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    z-index: 30;
}

.search-dropdown a.panel-block.is-active {
    background-color: hsl(217, 71%, 95%);
    outline: none;
}
@media (prefers-color-scheme: dark) {
    .search-dropdown a.panel-block.is-active {
        background-color: hsl(217, 30%, 25%);
    }
}

.full-search-result {
    text-decoration: none;
}

.pending-url-card {
    border: 2px dashed hsl(204, 86%, 53%);
    background: hsl(204, 86%, 97%);
    opacity: 0.75;
    transition: opacity 0.2s ease, box-shadow 0.2s ease;
}
.pending-url-card:hover {
    opacity: 1;
    box-shadow:
        0 0.5em 1em -0.125em rgba(10, 10, 10, 0.15),
        0 0px 0 1px rgba(10, 10, 10, 0.02);
}

@media (prefers-color-scheme: dark) {
    .pending-url-card {
        background: hsl(204, 40%, 15%);
        border-color: hsl(204, 60%, 40%);
    }
}

.is-dragging {
    opacity: 0.5;
    cursor: grabbing;
    border: 2px dashed hsl(217, 71%, 53%);
}
.url-card:hover {
    box-shadow:
        0 0.5em 1em -0.125em rgba(10, 10, 10, 0.2),
        0 0px 0 1px rgba(10, 10, 10, 0.02);
}
.folder-drop-target {
    transition:
        background-color 0.2s ease,
        padding-left 0.2s ease;
}

/* Sidebar menu: scrollable on desktop and tablet, free-flowing on mobile */
@media screen and (min-width: 769px) {
    .sidebar-scroll {
        overflow-y: auto;
    }
}

/* Keep sidebar .level items in a row on all viewports */
.sidebar .level {
    flex-direction: row;
}
.sidebar .level-left,
.sidebar .level-right {
    flex-direction: row;
}
.sidebar .level-left .level-item {
    justify-content: flex-start;
}

/* Prevent long folder names from overflowing the sidebar */
.menu-list .level {
    flex-wrap: nowrap;
    min-width: 0;
}
.menu-list .level-left {
    min-width: 0;
    flex-shrink: 1;
}
.menu-list .level-left .level-item {
    min-width: 0;
    word-break: break-word;
    white-space: normal;
    flex-shrink: 1;
}
.folder-drop-target.has-background-info-light {
    padding-left: 1.5em;
}

.highlight {
    background-color: yellow;
    cursor: pointer;
    /* Ensure highlight spans don't affect layout */
    display: inline;
    margin: 0;
    padding: 0;
    border: 0;
    font: inherit;
    vertical-align: baseline;
    line-height: inherit;
}
.highlight-hover {
    background-color: #ffd700;
}

@media (prefers-color-scheme: dark) {
    .highlight {
        background-color: rgba(202, 174, 0, 0.35);
        color: #f5f5f5;
    }
    .highlight-hover {
        background-color: rgba(202, 174, 0, 0.55);
    }
}
/* ── Highlight toolbar (replaces standalone delete button) ── */
.highlight-toolbar {
    position: absolute;
    display: flex;
    gap: 2px;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    user-select: none;
}
.highlight-toolbar.is-visible {
    opacity: 1;
    pointer-events: auto;
}
.highlight-toolbar button {
    color: #fff;
    border: none;
    border-radius: 3px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
}
.highlight-annotate-btn { background: #4a90d9; }
.highlight-annotate-btn:hover { background: #357abd; }
.highlight-delete-btn { background: #ff4444; }
.highlight-delete-btn:hover { background: #cc0000; }

/* ── Annotation popover ── */
.highlight-annotation-popover {
    position: absolute;
    z-index: 10001;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    width: 280px;
    display: none;
}
.highlight-annotation-popover.is-open { display: block; }
.annotation-input {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 6px;
    font-size: 13px;
    resize: vertical;
    font-family: inherit;
    box-sizing: border-box;
}
.annotation-input:focus {
    outline: none;
    border-color: #4a90d9;
    box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.2);
}
.annotation-popover-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 6px;
}
.annotation-save-btn {
    background: #4a90d9;
    color: #fff;
    border: none;
    border-radius: 3px;
    padding: 4px 12px;
    font-size: 12px;
    cursor: pointer;
}
.annotation-save-btn:hover { background: #357abd; }
.annotation-cancel-btn {
    background: #eee;
    color: #333;
    border: none;
    border-radius: 3px;
    padding: 4px 12px;
    font-size: 12px;
    cursor: pointer;
}
.annotation-cancel-btn:hover { background: #ddd; }

@media (prefers-color-scheme: dark) {
    .highlight-annotation-popover { background: #2a2a2a; border-color: #555; }
    .annotation-input { background: #333; border-color: #555; color: #f5f5f5; }
    .annotation-cancel-btn { background: #444; color: #ddd; }
}

/* ── Highlight flash animation (scroll-to-highlight) ── */
.highlight-flash { animation: highlight-flash 1s ease; }
@keyframes highlight-flash {
    0%, 100% { background-color: yellow; }
    50% { background-color: #ff9900; }
}
@media (prefers-color-scheme: dark) {
    @keyframes highlight-flash {
        0%, 100% { background-color: rgba(202, 174, 0, 0.35); }
        50% { background-color: rgba(255, 153, 0, 0.5); }
    }
}

/* ── Annotation indicator on highlights ── */
.highlight.has-annotation { border-bottom: 2px dotted #888; }
@media (prefers-color-scheme: dark) {
    .highlight.has-annotation { border-bottom-color: #aaa; }
}

/* ── Notes sidebar panel ── */
.notes-panel {
    height: 80vh;
    overflow-y: auto;
    border: 1px solid #dbdbdb;
    border-radius: 6px;
    padding: 1rem;
    font-size: 0.9rem;
}
@media (prefers-color-scheme: dark) {
    .notes-panel { border-color: #555; }
}
.notes-panel-section-title {
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    color: #888;
}
.highlight-entry {
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}
.highlight-entry:last-child { border-bottom: none; }
.highlight-entry:hover { background: rgba(0, 0, 0, 0.02); }
@media (prefers-color-scheme: dark) {
    .highlight-entry { border-bottom-color: #444; }
    .highlight-entry:hover { background: rgba(255, 255, 255, 0.03); }
}
.highlight-entry-text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.85rem;
    color: #b58900;
    font-style: italic;
}
.highlight-entry-annotation {
    font-size: 0.85rem;
    margin-top: 0.25rem;
    color: #555;
}
@media (prefers-color-scheme: dark) {
    .highlight-entry-annotation { color: #aaa; }
}
.notes-panel-toggle {
    /* Button lives in the header actions bar; no special positioning needed */
}

/* On narrow layouts, hide the notes panel by default and show it as an overlay */
@media screen and (max-width: 1023px) {
    #viewer-core--panel-column {
        display: none;
        position: fixed;
        top: 0;
        right: 0;
        width: 85vw;
        max-width: 380px;
        height: 100vh;
        z-index: 100;
        background: var(--bulma-scheme-main, #fff);
        box-shadow: -2px 0 12px rgba(0, 0, 0, 0.15);
        padding: 1rem;
        overflow-y: auto;
    }
    #viewer-core--panel-column.is-open {
        display: block !important;
    }
    #viewer-core--panel-column .notes-panel {
        height: auto;
        max-height: calc(100vh - 2rem);
        border: none;
    }
    .highlight-entry {
        padding: 0.75rem 0.5rem;
    }
    .textarea.is-small {
        font-size: 1rem;
    }
}

/* Panel overlay backdrop (notes panel) */
.panel-overlay {
    display: none !important;
}
@media screen and (max-width: 1023px) {
    .panel-overlay:not(.is-hidden) {
        display: block !important;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.4);
        z-index: 99;
        cursor: pointer;
    }
}

/* Panel close button */
.panel-close-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 5;
}

@media (prefers-color-scheme: dark) {
    @media screen and (max-width: 1023px) {
        #viewer-core--panel-column {
            background: var(--bulma-scheme-main, #1a1a2e);
            box-shadow: -2px 0 12px rgba(0, 0, 0, 0.4);
        }
    }
}
.note-content-preview {
    white-space: pre-wrap;
    font-size: 0.85rem;
    line-height: 1.5;
}

/* ── Tablet toolbar (769-1023px) ── */
.tablet-header {
    margin-bottom: 0.75rem;
}

.tablet-toolbar {
    display: none;
    margin-top: 0.5rem;
}

.tablet-toolbar.is-open {
    display: block;
}

.tablet-header .dropdown-menu {
    z-index: 31;
}

/* ── Mobile hamburger menu ── */
@media screen and (max-width: 768px) {
    /* Hide sidebar by default on mobile */
    .sidebar {
        display: none !important;
    }

    /* Show sidebar when toggled open */
    .sidebar.is-open {
        display: block !important;
        position: fixed;
        top: 0;
        left: 0;
        width: 85vw;
        max-width: 360px;
        height: 100vh;
        z-index: 100;
        background: var(--bulma-scheme-main, #fff);
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
        overflow-y: auto;
        padding: 1rem;
    }

    /* On mobile, let menu content flow naturally instead of pinning logout to bottom */
    .sidebar.is-open .menu {
        height: auto !important;
    }
    .sidebar.is-open .sidebar-scroll {
        overflow-y: visible;
    }

    /* Make main content full width on mobile */
    .main-content-column {
        width: 100% !important;
        flex: 1 1 auto !important;
    }

    /* Mobile header adjustments */
    .mobile-header {
        margin-bottom: 0.75rem;
    }

    /* Hide page title on mobile for iframe pages to maximize document space */
    .main-content-column:has(.page-body) .mobile-header .page-title {
        display: none;
    }

    .mobile-header .page-title {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        min-width: 0;
        flex-shrink: 1;
    }

    .mobile-header .dropdown-menu {
        z-index: 31;
    }

    /* Constrain notification dropdown to viewport on mobile */
    .mobile-header .dropdown .dropdown-menu {
        position: fixed;
        top: auto;
        right: 0.5rem;
        left: 0.5rem;
        width: auto;
    }
    .mobile-header .dropdown .dropdown-content {
        min-width: 0 !important;
    }
}

/* Overlay backdrop for mobile sidebar */
.sidebar-overlay {
    display: none !important;
}
@media screen and (max-width: 768px) {
    .sidebar-overlay:not(.is-hidden) {
        display: block !important;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.4);
        z-index: 99;
        cursor: pointer;
    }
}

@media (prefers-color-scheme: dark) {
    @media screen and (max-width: 768px) {
        .sidebar.is-open {
            background: var(--bulma-scheme-main, #1a1a2e);
            box-shadow: 2px 0 12px rgba(0, 0, 0, 0.4);
        }
    }
}

/* ── Log stream ── */
#viewer-observability--log-stream {
    background: #1a1a2e;
    color: #e0e0e0;
    font-family: 'SF Mono', 'Consolas', 'Liberation Mono', 'Menlo', monospace;
    font-size: 0.8rem;
    max-height: 60vh;
    overflow-y: auto;
    padding: 0.5rem;
    border-radius: 4px;
}

.log-entry {
    display: flex;
    gap: 0.75em;
    padding: 2px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    white-space: nowrap;
}

.log-entry:hover {
    background: rgba(255, 255, 255, 0.05);
}

.log-ts {
    color: #888;
    flex-shrink: 0;
    width: 24ch;
    overflow: hidden;
}

.log-level {
    flex-shrink: 0;
    width: 5ch;
    text-transform: uppercase;
    font-weight: 600;
    text-align: center;
    border-radius: 2px;
    padding: 0 4px;
}

.log-ns {
    color: #8be9fd;
    flex-shrink: 0;
    max-width: 30ch;
    overflow: hidden;
    text-overflow: ellipsis;
}

.log-msg {
    color: #f8f8f2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.log-data {
    color: #bd93f9;
    font-size: 0.75rem;
    margin: 2px 0 2px 4ch;
    padding: 4px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 2px;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Level colours */
.level-trace .log-level { color: #6272a4; background: rgba(98, 114, 164, 0.15); }
.level-debug .log-level { color: #8be9fd; background: rgba(139, 233, 253, 0.15); }
.level-info  .log-level { color: #50fa7b; background: rgba(80, 250, 123, 0.15); }
.level-warn  .log-level { color: #f1fa8c; background: rgba(241, 250, 140, 0.15); }
.level-error .log-level { color: #ff5555; background: rgba(255, 85, 85, 0.15); }
.level-fatal .log-level { color: #ff79c6; background: rgba(255, 121, 198, 0.15); }

/* Client-side level filter: hide entries below selected level */
.log-entry.log-hidden { display: none; }

/* Safe-area insets for notched/rounded screens */
body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
}

/* Tighten global layout so pages use almost the full viewport */
.section {
    padding: 0.5rem 0.75rem;
}
@media screen and (min-width: 769px) {
    .section {
        padding: 1.5rem 0.75rem;
    }
}
.container.is-fluid {
    margin-left: 0.75rem;
    margin-right: 0.75rem;
}
@media screen and (min-width: 769px) {
    .container.is-fluid {
        margin-left: 8px;
        margin-right: 8px;
    }
}

/* Link graph panels */
.links-panel {
    height: 80vh;
    overflow-y: auto;
    border: 1px solid #dbdbdb;
    border-radius: 6px;
    padding: 1rem;
    font-size: 0.9rem;
}
@media (prefers-color-scheme: dark) {
    .links-panel { border-color: #555; }
}
.links-panel-toggle {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 5;
}
/* Link graph container */
.graph-container {
    width: 100%;
    flex: 1 1 0;
    min-height: 400px;
    position: relative;
    border: 1px solid hsl(0, 0%, 86%);
    border-radius: 6px;
    background: hsl(0, 0%, 98%);
}
@media (prefers-color-scheme: dark) {
    .graph-container {
        border-color: #363636;
        background: #1a1a2e;
    }
}
#viewer-link-graph--graph-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.backlinks-panel ul, .outbound-panel ul {
    list-style-type: none;
    margin-left: 0;
}
.backlinks-panel li, .outbound-panel li {
    padding: 0.25em 0;
}

/* Log stream on mobile: horizontal scroll */
@media screen and (max-width: 768px) {
    #viewer-observability--log-stream {
        overflow-x: auto;
    }
    .log-entry {
        min-width: 80ch;
    }
}

/* URL card wrapper */
.url-card-wrapper {
    position: relative;
}
.url-card-wrapper:has(.folder-card) {
    padding-top: 1rem;
    overflow: visible;
}
.url-card-wrapper:has(.folder-card) > .card-actions {
    top: 1rem;
}

/* Vertical action bar on the right side of URL cards */
.card-actions {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.15rem;
    padding: 0.25rem;
    z-index: 2;
}
/* On hover-capable devices, hide until hovered */
@media (hover: hover) {
    .card-actions {
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.15s;
    }
    .url-card-wrapper:hover .card-actions {
        opacity: 1;
        pointer-events: auto;
    }
}
.card-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    background: hsla(0, 0%, 100%, 0.85);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
    font-size: 0.7rem;
    color: hsl(0, 0%, 48%);
    transition: color 0.1s, background 0.1s;
}
@media (prefers-color-scheme: dark) {
    .card-action-btn {
        background: hsla(0, 0%, 20%, 0.85);
        color: hsl(0, 0%, 65%);
    }
}
.card-action-btn:hover {
    color: hsl(0, 0%, 29%);
    background: hsla(0, 0%, 0%, 0.08);
}
@media (prefers-color-scheme: dark) {
    .card-action-btn:hover {
        color: hsl(0, 0%, 86%);
        background: hsla(0, 0%, 100%, 0.1);
    }
}
.card-action-btn.is-danger {
    color: hsl(348, 86%, 61%);
}
.card-action-btn.is-danger:hover {
    color: hsl(348, 86%, 43%);
    background: hsla(348, 86%, 61%, 0.1);
}
.card-action-btn.is-active-favorite {
    color: hsl(44, 100%, 48%);
}
.card-action-btn.is-active-favorite:hover {
    color: hsl(44, 100%, 40%);
}
.card-action-btn.is-active-readlater {
    color: hsl(204, 71%, 53%);
}
.card-action-btn.is-active-readlater:hover {
    color: hsl(204, 71%, 40%);
}

/* Pin icon (still used standalone in folder grid for pin-reorder DnD) */
.pin-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    border-radius: 4px;
    font-size: 0.7rem;
    color: hsl(0, 0%, 71%);
}
.pin-icon::before {
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    content: "\f08d";
}
.pin-icon.is-pinned {
    color: hsl(44, 100%, 48%);
}
.pin-icon:hover {
    color: hsl(44, 100%, 40%);
    background: hsla(0, 0%, 0%, 0.05);
}

/* Legacy .remove-icon kept for folder.clj folder-card remove buttons */
.remove-icon {
    position: absolute;
    top: 0.35rem;
    left: 0.35rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.2rem;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 1;
    color: hsl(348, 86%, 61%);
    font-size: 0.75rem;
}
.url-card-wrapper:hover .remove-icon {
    opacity: 1;
}
.remove-icon:hover {
    opacity: 1;
    color: hsl(348, 86%, 43%);
    background: hsla(348, 86%, 61%, 0.1);
}

/* Pin reorder drag indicators */
.url-card-wrapper.pin-dragging {
    opacity: 0.5;
}
.url-card-wrapper.pin-drop-before {
    box-shadow: -3px 0 0 0 hsl(44, 100%, 48%);
}
.url-card-wrapper.pin-drop-after {
    box-shadow: 3px 0 0 0 hsl(44, 100%, 48%);
}

/* Folder card as drop target */
.folder-card.folder-drop-hover {
    outline: 2px solid hsl(217, 71%, 53%);
    outline-offset: -2px;
    background: hsl(217, 71%, 96%);
}
@media (prefers-color-scheme: dark) {
    .folder-card.folder-drop-hover {
        outline-color: hsl(217, 71%, 60%);
        background: hsl(217, 30%, 25%);
    }
}

/* ── Mobile form stacking: stack .has-addons input+button vertically ── */
/* Excludes .has-addons-inline which should always stay horizontal */
@media screen and (max-width: 768px) {
    .field.has-addons:not(.has-addons-inline) {
        flex-direction: column;
    }
    .field.has-addons:not(.has-addons-inline) .control {
        width: 100%;
    }
    .field.has-addons:not(.has-addons-inline) .control .input {
        border-radius: 4px;
        border-right: 1px solid hsl(0, 0%, 86%);
    }
    .field.has-addons:not(.has-addons-inline) .control .button {
        border-radius: 4px;
        width: 100%;
        margin-top: 0.5rem;
    }
}

/* ── Mobile/tablet horizontally-scrollable action bar ── */
.mobile-action-bar {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.25rem;
}
.mobile-action-bar::-webkit-scrollbar {
    display: none;
}
.mobile-action-bar .button,
.mobile-action-bar .dropdown {
    flex-shrink: 0;
}

/* ── Back-to-folder FAB ── */
.back-to-folder-fab {
    position: fixed;
    bottom: 1.5rem;
    left: 1.5rem;
    z-index: 30;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background: hsl(48, 60%, 90%);
    color: hsl(40, 40%, 45%);
    border: 1px solid hsl(40, 40%, 75%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    text-decoration: none;
}
.back-to-folder-fab:hover {
    background: hsl(48, 60%, 85%);
    color: hsl(40, 40%, 35%);
}
.back-to-folder-fab:active {
    transform: scale(0.95);
}
@media (prefers-color-scheme: dark) {
    .back-to-folder-fab {
        background: hsl(40, 15%, 25%);
        color: hsl(40, 30%, 65%);
        border-color: hsl(40, 20%, 35%);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    }
    .back-to-folder-fab:hover {
        background: hsl(40, 15%, 30%);
        color: hsl(40, 30%, 75%);
    }
}

/* ── Discover floating action button (mobile/tablet) ── */
.discover-fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 30;
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 0.5rem;
}
.discover-fab-trigger {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background: hsl(171, 100%, 41%);
    color: #fff;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.discover-fab-trigger:active {
    transform: scale(0.95);
}
.discover-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: hsl(204, 86%, 53%);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 1.25rem;
    height: 1.25rem;
    line-height: 1.25rem;
    border-radius: 0.625rem;
    text-align: center;
    padding: 0 0.3em;
}
.discover-fab-actions {
    display: none;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}
.discover-fab.is-open .discover-fab-actions {
    display: flex;
}
.discover-fab-action {
    border-radius: 1.5rem !important;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
@media (prefers-color-scheme: dark) {
    .discover-fab-trigger {
        background: hsl(171, 70%, 35%);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    }
    .discover-fab-action {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
}

/* tom-select Bulma integration */
.ts-wrapper.is-fullwidth { width: 100%; }
.ts-wrapper.disabled .ts-control { opacity: 0.6; }

/* Scraper liveness indicator */
.scraper-liveness-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    min-width: 10px;
    min-height: 10px;
    border-radius: 50%;
    vertical-align: middle;
    cursor: default;
    flex-shrink: 0;
}
.scraper-liveness-green { background-color: #48c78e; }
.scraper-liveness-yellow { background-color: #ffe08a; animation: liveness-pulse 3s ease-in-out infinite; }
.scraper-liveness-red { background-color: #f14668; animation: liveness-pulse 3s ease-in-out infinite; }
.scraper-liveness-grey { background-color: #b5b5b5; }

@keyframes liveness-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
