/* ===== BookStark Shared Components ===== */
/* Shared administration tabs. */
.admin-tabs { overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; scroll-snap-type: x proximity; }
.admin-tabs .tab-btn { flex: 1 0 max-content; min-width: max-content; white-space: nowrap; scroll-snap-align: start; }
.admin-tabs .tab-btn { position: relative; padding: 8px 16px; font-size: 13px; font-weight: 500; border-radius: var(--radius-lg) var(--radius-lg) 0 0; cursor: pointer; transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease; }
.admin-tabs .tab-btn.active { background: var(--color-bg-card); color: var(--color-primary); box-shadow: var(--surface-shadow-hover); }
.admin-tabs .tab-btn:not(.active) { background: transparent; color: var(--color-text-secondary); }
.admin-tabs .tab-btn:not(.active):hover { color: var(--color-text); background: var(--color-bg-hover); }
.admin-tabs .tab-btn:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; }
/* Shared segmented switch, used by notes and personal home. */
.main-tabs { display: inline-flex; border: 1px solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; }
.main-tab { padding: 6px 14px; font-size: 13px; font-weight: 500; border: 0; background: var(--color-bg-card); color: var(--color-text-secondary); cursor: pointer; transition: background-color 0.15s ease, color 0.15s ease; display: flex; align-items: center; justify-content: center; gap: var(--spacing-xs); }
.main-tab.active { background: var(--color-primary); color: var(--color-on-primary); }
.main-tab:hover:not(.active) { background: var(--color-bg-hover); color: var(--color-text); }
.main-tab:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -3px; }
@media (prefers-reduced-motion: reduce) { .main-tab { transition: none; } }
/* Extracted & unified from bookmarks.css design system */

button.is-submitting {
    opacity: 0.65;
    cursor: not-allowed;
}

/* --- Unified empty/error state --- */
.bs-state {
    padding: 56px 20px;
    text-align: center;
    color: var(--color-text-muted);
}
.bs-state i {
    display: block;
    margin-bottom: 14px;
    color: var(--color-gray-300);
    font-size: 36px;
}
.bs-state-title {
    color: var(--color-text-secondary);
    font-size: 14px;
    font-weight: 600;
}
.bs-state-message {
    margin-top: 6px;
    color: var(--color-text-muted);
    font-size: 12px;
    line-height: 1.5;
}
.bs-state-action {
    margin-top: 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-card);
    color: var(--color-primary);
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
}
.bs-state-action:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

/* --- List Container --- */
.list-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* --- List Row (card-style) --- */
.list-row {
    display: flex;
    align-items: flex-start;
    padding: 12px 16px;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-left: 3px solid transparent;
    border-radius: 10px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    gap: 8px;
}
.list-row:hover { border-left-color: var(--color-primary); box-shadow: 0 2px 8px rgba(0,0,0,0.04); }

/* --- Tag Badge --- */
.tag-badge {
    display: inline-block;
    background: var(--color-gray-100);
    color: var(--color-gray-600);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
}
[data-theme="dark"] .tag-badge {
    background: var(--color-gray-200);
    color: var(--color-gray-600);
    border: 1px solid var(--color-border);
}
.tag-badge-clickable {
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.tag-badge-clickable:hover {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

/* --- Pagination --- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 16px 0; }
.page-btn {
    min-width: 32px;
    height: 32px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-bg-card);
    color: var(--color-gray-600);
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
    padding: 0 8px;
}
.page-btn:hover { border-color: var(--color-primary); color: var(--color-primary); background: var(--color-primary-light); }
.page-btn.active { background: var(--color-primary); color: var(--color-white); border-color: var(--color-primary); cursor: default; }
.page-btn:disabled { color: var(--color-gray-300); border-color: var(--color-gray-100); cursor: not-allowed; background: var(--color-bg-card); }
.page-btn:disabled:hover { border-color: var(--color-gray-100); color: var(--color-gray-300); background: var(--color-bg-card); }
@media (max-width: 640px) { .page-btn { padding: 0 6px; min-width: 28px; height: 28px; font-size: 12px; } }
.page-btn-compact { min-width: 28px; height: 28px; font-size: 12px; padding: 0 4px; }
.page-btn-info { font-size: 12px; color: var(--color-gray-500); margin: 0 8px; }
@media (max-width: 768px) { .page-ellipsis, .page-btn-info { display: none; } }

/* --- Search Input --- */
.search-input {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 13px;
    transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--color-focus); box-shadow: 0 0 0 2px var(--color-focus-ring); }

/* --- Dialog Input (unified style for all modal/popup inputs) --- */
.dialog-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-gray-300);
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
    background: var(--color-white);
    color: var(--color-text);
    outline: none;
    transition: border-color 0.15s;
}
.dialog-input:focus {
    border-color: var(--color-focus);
    box-shadow: 0 0 0 2px var(--color-focus-ring);
}
.dialog-input::placeholder {
    color: var(--color-text-placeholder);
}
[data-theme="dark"] .dialog-input {
    background: var(--color-gray-100);
    border-color: var(--color-gray-300);
    color: var(--color-text);
}

/* --- Row Action --- */
.bs-form-dialog {
    width: min(620px, calc(100% - 32px));
    max-height: 90dvh;
    overflow: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin: auto;
    background: var(--color-bg-card);
    color: var(--color-text);
}
.bs-form-dialog::backdrop { background: color-mix(in srgb, var(--color-text) 40%, transparent); }
.bs-form-dialog-head { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.bs-form-dialog-head h2 { font-size: 20px; font-weight: 600; }
.bs-form-dialog-head button { padding: 0 8px; }
@media (max-width: 640px) { .bs-form-dialog { padding: 16px; } }

.row-action {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-gray-500);
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 12px;
    transition: color 0.15s ease, background-color 0.15s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
.row-action:hover { color: var(--color-primary); background: var(--color-gray-100); }
.row-action.del:hover { color: var(--color-danger); background: var(--color-danger-light); }

/* --- Shared Action Dropdown --- */
.bs-action-dropdown {
    position: relative;
    display: inline-flex;
    vertical-align: middle;
}
.bs-action-dd-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 8px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    border: 1px solid var(--color-border);
    background: var(--color-bg-card);
    color: var(--color-gray-600);
    white-space: nowrap;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}
.bs-action-dd-btn:hover,
.bs-action-dropdown.open .bs-action-dd-btn {
    border-color: var(--color-primary);
    color: var(--color-primary);
}
.bs-action-dd-btn i:first-child {
    font-size: 11px;
}
.bs-action-dd-arrow {
    font-size: 9px;
    margin-left: 1px;
    transition: transform 0.15s ease;
}
.bs-action-dropdown.open .bs-action-dd-arrow {
    transform: rotate(180deg);
}
.bs-action-dd-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    min-width: 150px;
    z-index: 60;
    padding: 4px 0;
}
.bs-action-dropdown.open .bs-action-dd-menu {
    display: block;
}
.bs-action-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: none;
    font-size: 13px;
    color: var(--color-gray-700);
    cursor: pointer;
    text-align: left;
    transition: background-color 0.12s ease;
}
.bs-action-menu-item:hover {
    background: var(--color-bg-hover);
}
.bs-action-menu-item:disabled,
.bs-action-menu-item[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}
.bs-action-menu-item:disabled:hover,
.bs-action-menu-item[aria-disabled="true"]:hover {
    background: none;
}
.bs-action-menu-item i,
.bs-action-menu-item img {
    width: 16px;
    text-align: center;
    font-size: 12px;
    color: var(--color-gray-500);
}
.bs-action-menu-item img {
    height: 16px;
    object-fit: contain;
}
.bs-action-menu-item-danger {
    color: var(--color-danger-hover);
}
.bs-action-menu-item-danger i {
    color: var(--color-danger-hover);
}
.bs-action-menu-item-danger:hover {
    background: var(--color-danger-light);
}
.bs-action-menu-sep {
    height: 1px;
    margin: 4px 0;
    background: var(--color-border);
}
.bs-action-submenu {
    position: relative;
}
.bs-action-submenu-trigger {
    justify-content: flex-start;
}
.bs-action-submenu-arrow {
    margin-left: auto;
    font-size: 10px !important;
}
.bs-action-submenu-panel {
    display: none;
    position: absolute;
    top: -5px;
    right: 100%;
    margin-right: 4px;
    min-width: 140px;
    padding: 4px 0;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg-card);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    z-index: 61;
}
.bs-action-submenu.open > .bs-action-submenu-panel,
.bs-action-submenu:hover > .bs-action-submenu-panel,
.bs-action-submenu:focus-within > .bs-action-submenu-panel {
    display: block;
}

/* --- List Row Title --- */
.list-row-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-gray-800);
    line-height: 1.5;
}
.list-row-title:hover {
    color: var(--color-primary);
}

/* --- Skeleton Loading --- */
@keyframes skeleton-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}
/* Individual pieces: solid blocks, no animation */
.skeleton {
    background: var(--color-gray-200);
    border-radius: var(--radius-sm);
}
[data-theme="dark"] .skeleton {
    background: var(--color-gray-200);
}

/* Shimmer sweeps across the entire card/row as one unit */
.skeleton-card,
.skeleton-row,
.skeleton-bm-row {
    position: relative;
    overflow: hidden;
}
.skeleton-card::after,
.skeleton-row::after,
.skeleton-bm-row::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.55) 50%, transparent 100%);
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    pointer-events: none;
}
[data-theme="dark"] .skeleton-card::after,
[data-theme="dark"] .skeleton-row::after,
[data-theme="dark"] .skeleton-bm-row::after {
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.08) 50%, transparent 100%);
}
@media (prefers-reduced-motion: reduce) {
    .skeleton-card::after,
    .skeleton-row::after,
    .skeleton-bm-row::after { display: none; }
}

/* Skeleton row (blogs / shares) - matches .list-row structure */
.skeleton-row {
    display: flex;
    align-items: flex-start;
    padding: 12px 16px;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    gap: 8px;
}
.skeleton-row-num {
    width: 28px;
    height: 24px;
    flex-shrink: 0;
}
.skeleton-row-body {
    flex: 1;
    min-width: 0;
}
.skeleton-row-title {
    height: 16px;
    width: 60%;
    margin-bottom: 6px;
}
.skeleton-row-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}
.skeleton-row-time {
    height: 12px;
    width: 100px;
}
.skeleton-row-tag {
    height: 16px;
    width: 40px;
    border-radius: 4px;
}
@media (max-width: 640px) {
    .skeleton-row-num { display: none; }
}

/* Skeleton card (books) - matches .book-card structure */
.skeleton-card {
    background: var(--color-bg-card);
    border-radius: 10px;
    padding: 18px;
    min-height: 150px;
    border: 2px solid transparent;
}
.skeleton-card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.skeleton-card-icon {
    width: 18px;
    height: 18px;
    border-radius: 50%;
}
.skeleton-card-title {
    height: 16px;
    width: 55%;
}
.skeleton-card-meta {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
}
.skeleton-card-meta-item {
    height: 12px;
    width: 48px;
}
.skeleton-card-desc {
    height: 12px;
    width: 80%;
    margin-bottom: 4px;
}
.skeleton-card-desc2 {
    height: 12px;
    width: 50%;
}
.skeleton-card-labels {
    display: flex;
    gap: 4px;
    margin-top: 10px;
}
.skeleton-card-tag {
    height: 18px;
    width: 44px;
    border-radius: 4px;
}

/* Skeleton bookmark row - matches .bm-row structure */
.skeleton-bm-row {
    display: flex;
    align-items: flex-start;
    padding: 8px 12px;
    border-bottom: 1px solid var(--color-gray-100);
    gap: 8px;
    background: var(--color-bg-card);
    border-radius: 4px;
    margin-bottom: 2px;
}
.skeleton-bm-body {
    flex: 1;
    min-width: 0;
}
.skeleton-bm-top {
    display: flex;
    align-items: center;
    gap: 6px;
}
.skeleton-bm-favicon {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    flex-shrink: 0;
}
.skeleton-bm-title {
    height: 16px;
    width: 50%;
}
.skeleton-bm-second {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    padding-left: 22px;
}
.skeleton-bm-desc {
    height: 12px;
    width: 35%;
}
.skeleton-bm-tag {
    height: 14px;
    width: 36px;
    border-radius: 4px;
}

/* --- Tag Input Component --- */
.tag-input-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    align-content: center;
    gap: 6px;
    box-sizing: border-box;
    padding: 8px 12px;
    border: 1px solid var(--color-gray-300, #cbd5e1);
    border-radius: 6px;
    min-height: 38px;
    background: var(--color-bg-card, #fff);
    color: var(--color-text);
}
.tag-input-container:focus-within {
    border-color: var(--color-focus, #2563eb);
    box-shadow: 0 0 0 2px var(--color-focus-ring, rgba(37,99,235,0.25));
}
[data-theme="dark"] .tag-input-container {
    background: var(--color-gray-100);
    border-color: var(--color-gray-300);
    color: var(--color-text);
}
.tag-input-selected {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    align-content: center;
    gap: 6px;
    flex: 1 1 100%;
    max-width: 100%;
    min-height: 0;
    overflow: visible;
}
.tag-input-selected:not(.empty) {
    min-height: 22px;
}
.tag-input-selected.expanded {
    flex-wrap: wrap;
}
.tag-input-chip {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 3px;
    max-width: 180px;
    background: var(--color-primary-light, #eff6ff);
    color: var(--color-primary, #2563eb);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
}
.tag-input-chip-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tag-input-more {
    flex: 0 0 auto;
    min-height: 22px;
    padding: 1px 8px;
    border: 1px dashed var(--color-gray-300, #cbd5e1);
    border-radius: 999px;
    background: transparent;
    color: var(--color-gray-500, #64748b);
    font-size: 12px;
    cursor: pointer;
}
.tag-input-more:hover {
    border-color: var(--color-primary, #2563eb);
    color: var(--color-primary, #2563eb);
}
.tag-input-remove {
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    color: var(--color-primary, #2563eb);
}
.tag-input-remove:hover {
    color: var(--color-danger, #dc2626);
}
.tag-input-search-row {
    display: flex;
    align-items: center;
    flex: 1 1 120px;
    min-width: 80px;
    min-height: 20px;
}
.tag-input-field {
    box-sizing: border-box;
    border: 0;
    outline: 0;
    font-size: 12px;
    width: 100%;
    flex: 1;
    min-width: 80px;
    height: 20px;
    padding: 0;
    background: transparent;
    color: inherit;
    display: block;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    line-height: 20px;
}
.tag-input-container .tag-input-field:focus,
.tag-input-container .tag-input-field:focus-visible {
    border: 0;
    outline: 0;
    box-shadow: none;
}
.tag-input-field[data-empty="true"]::before {
    content: attr(data-placeholder);
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    height: 20px;
    line-height: 20px;
    color: var(--color-gray-400, #94a3b8);
    font-size: 12px;
    overflow: hidden;
    pointer-events: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tag-input-dropdown {
    position: fixed;
    background: var(--color-bg-card, #fff);
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    max-height: 200px;
    overflow-y: auto;
    z-index: 10000;
}
.tag-input-dropdown.hidden { display: none; }
.tag-input-dd-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    font-size: 12px;
    cursor: pointer;
    color: var(--color-gray-700, #334155);
}
.tag-input-dd-item:hover,
.tag-input-dd-item:focus,
.tag-input-dd-item.active {
    background: var(--color-primary-light, #eff6ff);
    outline: none;
}
.tag-input-dd-create {
    color: var(--color-primary, #2563eb);
}
.tag-input-dd-count {
    color: var(--color-gray-500, #64748b);
    font-size: 11px;
    margin-left: 8px;
}
.tag-input-sheet-root.hidden {
    display: none;
}
.tag-input-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.38);
    z-index: 10020;
}
.tag-input-sheet {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    z-index: 10021;
    display: flex;
    flex-direction: column;
    max-height: min(72vh, 620px);
    padding: max(12px, env(safe-area-inset-top)) 14px 14px;
    border-radius: 0 0 14px 14px;
    background: var(--color-bg-card, #fff);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
    animation: tag-input-sheet-slide-down 0.18s ease-out;
}
@keyframes tag-input-sheet-slide-down {
    from { opacity: 0; transform: translateY(-16px); }
    to { opacity: 1; transform: translateY(0); }
}
.tag-input-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
.tag-input-sheet-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text, #0f172a);
}
.tag-input-sheet-done {
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid var(--color-primary, #2563eb);
    border-radius: 8px;
    background: var(--color-primary, #2563eb);
    color: var(--color-white, #fff);
    font-size: 13px;
    cursor: pointer;
}
.tag-input-sheet-search {
    margin-bottom: 10px;
}
.tag-input-sheet-field {
    width: 100%;
    box-sizing: border-box;
    min-height: 42px;
    padding: 9px 12px;
    border: 1px solid var(--color-gray-300, #cbd5e1);
    border-radius: 9px;
    outline: none;
    background: var(--color-bg-card, #fff);
    color: var(--color-text, #0f172a);
    font-size: 16px;
    line-height: 22px;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
}
.tag-input-sheet-field[data-empty="true"]::before {
    content: attr(data-placeholder);
    position: absolute;
    left: 12px;
    top: 9px;
    right: 12px;
    height: 22px;
    line-height: 22px;
    color: var(--color-gray-400, #94a3b8);
    font-size: inherit;
    overflow: hidden;
    pointer-events: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tag-input-sheet-field:focus {
    border-color: var(--color-focus, #2563eb);
    box-shadow: 0 0 0 2px var(--color-focus-ring, rgba(37, 99, 235, 0.25));
}
.tag-input-sheet-selected-title {
    margin: 2px 0 6px;
    color: var(--color-gray-500, #64748b);
    font-size: 12px;
}
.tag-input-sheet-selected {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    min-height: 26px;
    margin-bottom: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
    scrollbar-width: thin;
}
.tag-input-sheet-results {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    border-top: 1px solid var(--color-border, #e2e8f0);
    padding-top: 6px;
}
.tag-input-sheet-item {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    padding: 8px 2px;
    border: none;
    border-bottom: 1px solid var(--color-border, #e2e8f0);
    background: transparent;
    color: var(--color-gray-700, #334155);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}
.tag-input-sheet-item:last-child {
    border-bottom: none;
}
.tag-input-sheet-item.selected {
    color: var(--color-primary, #2563eb);
}
.tag-input-sheet-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    color: var(--color-primary, #2563eb);
    font-size: 13px;
    font-weight: 600;
}
.tag-input-sheet-item.selected .tag-input-sheet-check {
    background: var(--color-primary-light, #eff6ff);
}
.tag-input-sheet-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tag-input-sheet-count {
    color: var(--color-gray-500, #64748b);
    font-size: 12px;
}
.tag-input-sheet-empty {
    padding: 18px 4px;
    color: var(--color-gray-400, #94a3b8);
    font-size: 13px;
}
body.tag-input-sheet-open {
    overflow: hidden;
}

/* Shared editor-style tag popover, reused by mobile TagInput sheets. */
.tag-popover-overlay {
    display: none; position: fixed; inset: 0;
    z-index: 10020;
}
.tag-popover-overlay.active { display: block; }
.tag-popover {
    display: none;
    position: absolute;
    top: 44px;
    right: 12px;
    width: 280px;
    background: var(--color-white);
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-xl);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 10021;
    overflow: hidden;
    animation: none;
}
.tag-popover.active { display: block; }
.tag-popover-header {
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.tag-popover-title { font-size: 13px; font-weight: 600; color: var(--color-text); }
.tag-popover-close {
    width: 20px; height: 20px; border-radius: var(--radius-sm); border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    color: var(--color-gray-400);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    min-height: 0;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.tag-popover-close:hover { background: var(--color-gray-100); color: var(--color-gray-600); }
.tag-popover-body { padding: 10px 14px; }
.tag-popover-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 10px;
    min-height: 4px;
    overflow: visible;
    padding: 0;
}
.tag-popover-chips:empty { margin-bottom: 0; }
.tag-popover .tag-chip {
    display: inline-flex; align-items: center; gap: 3px;
    background: #eff6ff; color: #2563eb; border: 1px solid #dbeafe;
    padding: 1px 8px; border-radius: var(--radius-md); font-size: 12px;
    white-space: nowrap; cursor: default; line-height: 20px;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.tag-popover .tag-chip:hover { background: #dbeafe; border-color: #bfdbfe; }
.tag-popover .tag-chip .tag-remove {
    display: inline-flex; align-items: center; justify-content: center;
    width: 14px; height: 14px; border-radius: 9999px; font-size: 11px;
    cursor: pointer; color: #2563eb; line-height: 1;
    opacity: 0.5; transition: opacity 0.15s ease, color 0.15s ease;
}
.tag-popover .tag-chip .tag-remove:hover { opacity: 1; color: var(--color-danger); }
.tag-input-wrap {
    display: flex; align-items: center; gap: 4px;
    padding: 5px 8px; border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-md); background: var(--color-white);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.tag-popover .tag-input-sheet-search {
    margin-bottom: 0;
}
.tag-input-wrap:focus-within { border-color: var(--color-focus); box-shadow: 0 0 0 2px var(--color-focus-ring); }
.tag-input-icon { color: var(--color-gray-400); font-size: 11px; flex-shrink: 0; }
.tag-input {
    border: none; outline: none; font-size: 12px; flex: 1; min-width: 60px;
    background: transparent; color: var(--color-text); line-height: 20px;
}
.tag-popover .tag-input-sheet-field {
    width: auto;
    height: 20px;
    min-height: 0;
    max-height: 20px;
    padding: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    outline: none;
    line-height: 20px;
    white-space: nowrap;
    overflow: hidden;
}
.tag-popover .tag-input-sheet-field:focus,
.tag-popover .tag-input-sheet-field:focus-visible {
    border: none;
    box-shadow: none;
    outline: none;
}
.tag-popover .tag-input-sheet-field[data-empty="true"]::before {
    left: 0;
    top: 0;
    right: 0;
    height: 20px;
    line-height: 20px;
}
.tag-popover-dropdown {
    border-top: 1px solid var(--color-gray-100);
    max-height: 160px;
    overflow-y: auto;
}
.tag-dropdown-item {
    padding: 7px 14px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    min-height: 0;
    border: none;
    background: transparent;
    text-align: left;
    transition: background-color 0.1s ease;
}
.tag-dropdown-item:hover,
.tag-dropdown-item:focus,
.tag-dropdown-item.active {
    background: var(--color-primary-light);
    outline: none;
}
.tag-dropdown-item.selected { color: var(--color-primary); }
.tag-dropdown-item .tag-item-name {
    color: var(--color-text);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tag-dropdown-item .tag-item-count {
    flex: 0 0 auto;
    color: var(--color-gray-400);
    font-size: 11px;
}
.tag-dropdown-empty {
    padding: 8px 14px;
    font-size: 12px;
    color: var(--color-gray-400);
}
[data-theme="dark"] .tag-popover-overlay.active {
    background: rgba(0, 0, 0, 0.5);
}
@media (max-width: 768px) {
    .tag-popover-overlay.active {
        background: rgba(0, 0, 0, 0.25);
    }
    .tag-popover {
        position: fixed;
        top: 0;
        right: 0; bottom: auto; left: 0;
        width: 100%;
        max-width: 100%;
        border-radius: 0 0 16px 16px;
        max-height: calc(var(--bs-vvh, 100dvh) - 8px);
        overflow-y: auto;
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.16);
        transform: translateY(-100%);
        transition: transform 0.25s ease-out;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .tag-popover.active {
        display: block;
        transform: translateY(0);
    }
    .tag-popover::before {
        content: none;
        display: none;
    }
    .tag-popover-header {
        padding-top: 10px;
    }
    .tag-popover-body {
        padding: 10px 16px;
    }
    .tag-input {
        font-size: 16px;
    }
    .tag-popover::-webkit-scrollbar,
    .tag-popover *::-webkit-scrollbar {
        display: none;
    }
    .tag-popover-dropdown {
        max-height: min(120px, calc(var(--bs-vvh, 100dvh) - 180px));
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .tag-dropdown-item {
        padding: 9px 16px;
    }
    .tag-dropdown-empty {
        padding: 10px 16px;
    }
}

/* Shared bookmark/nav edit form fields. */
.bm-form-group {
    margin-bottom: 14px;
}
.bm-tag-hint {
    margin-top: 4px;
    font-size: 11px;
    color: var(--color-gray-400);
}
.bm-form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-gray-700);
    margin-bottom: 4px;
}
.bm-form-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--color-gray-300);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 14px;
    background: var(--color-white);
    color: var(--color-text);
    outline: none;
}
[data-theme="dark"] .bm-form-input {
    background: var(--color-gray-100);
    border-color: var(--color-gray-300);
    color: var(--color-text);
}
.bm-form-input:focus {
    border-color: var(--color-focus);
    box-shadow: 0 0 0 2px var(--color-focus-ring, rgba(37, 99, 235, 0.25));
}
.bm-form-input-err {
    border-color: var(--color-danger) !important;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15) !important;
}
.bm-form-err {
    font-size: 12px;
    color: var(--color-danger);
    margin-top: 3px;
    min-height: 0;
}
[data-theme="dark"] .tag-input-dropdown {
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
[data-theme="dark"] .tag-input-sheet-backdrop {
    background: rgba(0, 0, 0, 0.55);
}
[data-theme="dark"] .tag-input-sheet {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
@media (max-width: 640px) {
    .tag-input-dropdown {
        max-height: 45vh;
        border-radius: 8px;
    }
    .tag-input-container {
        cursor: pointer;
        min-height: 40px;
    }
    .tag-input-selected {
        overflow: visible;
        scrollbar-width: thin;
    }
    .tag-input-selected.expanded {
        flex-wrap: wrap;
    }
    .tag-input-chip {
        min-height: 24px;
        max-width: 160px;
    }
    .tag-input-container .tag-input-remove {
        display: none;
    }
    .tag-input-field {
        cursor: pointer;
        font-size: 16px;
    }
}
@media (prefers-reduced-motion: reduce) {
    .tag-input-container:focus-within { transition: none; }
    .tag-input-sheet { animation: none; }
}

/* ===== Shared asset-style modal ===== */
.asset-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(15, 23, 42, 0.5);
    display: none;
    padding: 18px;
    overflow: auto;
}
.asset-modal-backdrop.open,
.asset-modal-backdrop.active {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    place-items: center;
}
.asset-modal {
    width: min(560px, 100%);
    max-height: calc(100vh - 36px);
    overflow: auto;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    color: var(--color-text);
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.22);
}
.asset-modal-wide {
    width: min(720px, 100%);
}
@keyframes asset-slide-down {
    from { opacity: 0; transform: translateY(-18px); }
    to { opacity: 1; transform: translateY(0); }
}
.asset-modal-head {
    min-height: 52px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.asset-modal-title,
.asset-modal-head h2 {
    margin: 0;
    color: var(--color-text);
    font-size: 15px;
    font-weight: 700;
}
.asset-modal-body {
    padding: 14px;
    overflow-y: auto;
    overflow-wrap: anywhere;
}
.asset-modal-foot {
    padding: 12px 14px;
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
@media (max-width: 640px) {
    .asset-modal-backdrop {
        padding: 0;
        align-items: start;
        overflow-y: auto;
    }
    .asset-modal-backdrop.open,
    .asset-modal-backdrop.active {
        place-items: start center;
    }
    .asset-modal {
        width: 100%;
        max-height: calc(var(--bs-vvh, 100dvh) - 8px);
        overflow-y: auto;
        box-sizing: border-box;
        justify-self: stretch;
        border-top: 0;
        border-radius: 0 0 var(--radius-xl) var(--radius-xl);
        box-shadow: 0 4px 20px rgba(15, 23, 42, 0.14);
        animation: asset-slide-down .2s ease-out;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .asset-modal::-webkit-scrollbar,
    .asset-modal *::-webkit-scrollbar {
        display: none;
    }
    .asset-modal-foot {
        position: sticky;
        bottom: 0;
        background: var(--color-bg-card);
    }
}
@media (prefers-reduced-motion: reduce) {
    .asset-modal-backdrop *,
    .asset-modal {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* ===== AI compose dialog ===== */
.ai-dlg-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,0.45);
    z-index: 10000; display: flex; align-items: center; justify-content: center;
    animation: ai-dlg-fade .12s ease-out;
}
@keyframes ai-dlg-fade { from { opacity: 0; } to { opacity: 1; } }
.ai-dlg-box {
    background: var(--color-bg-card, #fff);
    border-radius: var(--radius-xl, 10px);
    /* Desktop: nearly fullscreen so streamed output has plenty of room. */
    width: 98vw; height: 98vh;
    max-width: 98vw; max-height: 98vh;
    display: flex; flex-direction: column;
    box-shadow: 0 16px 48px rgba(0,0,0,0.18);
    animation: ai-dlg-pop .15s ease-out;
}
@keyframes ai-dlg-pop {
    from { opacity: 0; transform: translateY(-6px) scale(.98); }
    to { opacity: 1; transform: none; }
}
.ai-dlg-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid var(--color-border, #e2e8f0);
}
.ai-dlg-title { font-size: 14px; font-weight: 600; color: var(--color-text); }
.ai-dlg-title i { color: #8b5cf6; margin-right: 4px; }
.ai-dlg-close {
    background: none; border: none; font-size: 22px; line-height: 1;
    color: var(--color-gray-400, #94a3b8); cursor: pointer; padding: 0 4px;
}
.ai-dlg-close:hover { color: var(--color-text); }
.ai-dlg-body { padding: 14px 18px; overflow-y: auto; flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.ai-dlg-body > .ai-dlg-prompt { flex: 0 0 auto; }
.ai-dlg-body > .ai-dlg-quick-row { flex: 0 0 auto; }
.ai-dlg-body > .ai-dlg-ctx { flex: 0 0 auto; }
.ai-dlg-hint {
    margin-bottom: 10px; padding: 8px 12px;
    background: var(--color-warning-light, #fef3c7);
    border: 1px solid #fde68a;
    border-radius: var(--radius-md, 6px);
    color: var(--color-warning, #b45309); font-size: 12px;
    flex: 0 0 auto;
}
.ai-dlg-ctx-label { font-size: 11px; color: var(--color-gray-500, #64748b); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.05em; }
.ai-dlg-ctx {
    background: var(--color-bg, #f8fafc); border: 1px solid var(--color-border, #e2e8f0);
    border-radius: var(--radius-md, 6px); padding: 8px 10px;
    font-size: 12px; line-height: 1.5; color: var(--color-text);
    max-height: 120px; overflow: auto; margin-bottom: 12px;
    white-space: pre-wrap; word-break: break-word;
}
.ai-dlg-prompt {
    width: 100%; box-sizing: border-box;
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: var(--radius-md, 6px);
    padding: 10px 12px; font-size: 14px; line-height: 1.55;
    font-family: inherit; resize: vertical; min-height: 64px;
    color: var(--color-text); background: var(--color-bg-card, #fff);
    outline: none; transition: border-color .15s, box-shadow .15s;
}
.ai-dlg-prompt:focus {
    border-color: var(--color-focus, #2563eb);
    box-shadow: 0 0 0 2px var(--color-focus-ring, rgba(37,99,235,0.25));
}
.ai-dlg-prompt:disabled { background: var(--color-gray-100, #f1f5f9); cursor: not-allowed; }
.ai-dlg-quick-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ai-dlg-quick {
    background: var(--color-gray-100, #f1f5f9); border: 1px solid transparent;
    border-radius: var(--radius-md, 6px); padding: 4px 10px; font-size: 12px;
    color: var(--color-gray-700, #334155); cursor: pointer;
}
.ai-dlg-quick:hover { background: var(--color-primary-light, #eff6ff); color: var(--color-primary, #2563eb); }
.ai-dlg-output {
    margin-top: 12px; min-height: 120px; flex: 1 1 auto; overflow: auto;
    border: 1px dashed var(--color-border, #e2e8f0);
    border-radius: var(--radius-md, 6px); padding: 10px 12px;
    font-size: 13px; line-height: 1.6; color: var(--color-text);
    background: var(--color-bg, #f8fafc); white-space: pre-wrap; word-break: break-word;
}
.ai-dlg-output-active { border-style: solid; }
.ai-dlg-output-err { color: var(--color-danger, #dc2626); border-color: var(--color-danger, #dc2626); }
.ai-dlg-footer {
    display: flex; gap: 8px; justify-content: flex-end;
    padding: 12px 18px; border-top: 1px solid var(--color-border, #e2e8f0);
}
.ai-dlg-btn {
    border: 1px solid transparent; border-radius: var(--radius-md, 6px);
    padding: 6px 14px; font-size: 13px; cursor: pointer; transition: background .12s;
}
.ai-dlg-btn-cancel { background: var(--color-gray-100, #f1f5f9); color: var(--color-gray-700, #334155); }
.ai-dlg-btn-cancel:hover { background: var(--color-gray-200, #e2e8f0); }
.ai-dlg-btn-stop { background: var(--color-warning-light, #fef3c7); color: var(--color-warning, #b45309); }
.ai-dlg-btn-go { background: var(--color-primary, #2563eb); color: #fff; }
.ai-dlg-btn-go:hover { background: var(--color-primary-hover, #1d4ed8); }
.ai-dlg-btn-replace { background: var(--color-bg-card); border-color: var(--color-primary, #2563eb); color: var(--color-primary, #2563eb); }
.ai-dlg-btn-replace:hover { background: var(--color-primary-light, #eff6ff); }
.ai-dlg-btn-append { background: var(--color-primary, #2563eb); color: #fff; }
.ai-dlg-btn-append:hover { background: var(--color-primary-hover, #1d4ed8); }
.compose-btn-ai i { color: var(--color-primary, #2563eb); }
.compose-btn-ai:hover i { color: var(--color-primary-hover, #1d4ed8); }
.toolbar-btn-ai i { color: #8b5cf6; }
.toolbar-btn-ai:hover { color: #7c3aed; }
.bk-ai-row { margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
.bk-ai-row-inline { flex-direction: row; align-items: center; flex-wrap: wrap; }
.bk-ai-row-inline .bk-ai-input { flex: 1; min-width: 120px; }
.bk-ai-label { font-size: 12px; color: var(--color-gray-500, #64748b); }
.bk-ai-input { box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--color-border, #e2e8f0); border-radius: var(--radius-md, 6px); font-size: 13px; color: var(--color-text); background: var(--color-bg-card, #fff); outline: none; transition: border-color .15s, box-shadow .15s; }
.bk-ai-input:focus { border-color: var(--color-focus, #2563eb); box-shadow: 0 0 0 2px var(--color-focus-ring, rgba(37,99,235,0.25)); }
.bk-ai-input-sm { width: 80px; flex: 0 0 80px; }
.bk-ai-preview { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid var(--color-border); border-radius: var(--radius-md); font-family: 'SF Mono','Fira Code',Consolas,monospace; font-size: 13px; line-height: 1.6; resize: vertical; min-height: 180px; color: var(--color-text); background: var(--color-bg-card); outline: none; }
.bk-ai-preview:focus { border-color: var(--color-focus); box-shadow: 0 0 0 2px var(--color-focus-ring); }
.bk-ai-parent-banner {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; margin-bottom: 12px;
    background: var(--color-primary-light, #eff6ff);
    border: 1px solid var(--color-primary-border, #bfdbfe);
    border-radius: var(--radius-md, 6px);
    color: var(--color-primary, #2563eb); font-size: 12px;
}
.bk-ai-parent-banner i { color: var(--color-primary, #2563eb); }
.bk-ai-scope {
    display: flex; gap: 4px; padding: 4px;
    background: var(--color-gray-100, #f1f5f9);
    border-radius: var(--radius-md, 6px);
    margin-bottom: 12px;
}
.bk-ai-scope-btn {
    flex: 1 1 0; padding: 6px 12px; border: 1px solid transparent;
    border-radius: var(--radius-md, 6px);
    background: transparent; color: var(--color-gray-600, #475569);
    font-size: 12px; cursor: pointer;
    transition: background-color .12s, color .12s;
    text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bk-ai-scope-btn:hover:not(:disabled) { color: var(--color-text); }
.bk-ai-scope-btn.active {
    background: var(--color-bg-card, #fff); color: var(--color-primary, #2563eb);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    font-weight: 600;
}
.bk-ai-scope-btn:disabled { color: var(--color-gray-400, #94a3b8); cursor: not-allowed; }
[data-theme="dark"] .ai-dlg-overlay { background: rgba(0,0,0,0.6); }
@keyframes ai-dlg-slide-down {
    from { opacity: 0; transform: translateY(-24px); }
    to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 640px) {
    .ai-dlg-overlay { align-items: flex-start; overflow-y: auto; }
    .ai-dlg-box {
        width: 100%; max-width: none; max-height: calc(var(--bs-vvh, 100dvh) - 8px);
        overflow: hidden;
        border-radius: 0 0 var(--radius-xl,10px) var(--radius-xl,10px);
        align-self: flex-start;
        animation: ai-dlg-slide-down 0.2s ease-out;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .ai-dlg-body { min-height: 0; scrollbar-width: none; -ms-overflow-style: none; }
    .ai-dlg-box::-webkit-scrollbar,
    .ai-dlg-body::-webkit-scrollbar,
    .ai-dlg-body *::-webkit-scrollbar { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .ai-dlg-box, .ai-dlg-overlay { animation: none !important; }
}

.bs-dialog-description { margin:var(--spacing-md) 0; color:var(--color-text-secondary); font-size:14px; white-space:pre-line; }
