/* 1. Tokens */
:root {
    --bg: #f6f7fb;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --line: #e5e7eb;
    --text: #172033;
    --muted: #7b8496;
    --muted-2: #a2aabd;
    --accent: #4f7cff;
    --accent-soft: #eef3ff;
    --danger: #ef4444;
    --danger-soft: #fff1f2;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    --sidebar-bg: rgba(255, 255, 255, 0.82);
    --topbar-bg: rgba(246, 247, 251, 0.82);
    --floating-bg: rgba(255, 255, 255, 0.96);
    --count-bg: rgba(15, 23, 42, 0.06);
    --active-count-bg: rgba(79, 124, 255, 0.13);
    --selected-row-bg: rgba(79, 124, 255, 0.05);
    --folder-row-bg: rgba(79, 124, 255, 0.04);
    --folder-row-hover-bg: rgba(79, 124, 255, 0.08);
    --folder-letter-bg: rgba(79, 124, 255, 0.12);
    --topbar-border: rgba(229, 231, 235, 0.7);
    --floating-border: rgba(229, 231, 235, 0.9);
    --toolbar-border: rgba(79, 124, 255, 0.18);
    --row-border: rgba(229, 231, 235, 0.86);
    --row-hover-border: rgba(79, 124, 255, 0.25);
    --row-selected-border: rgba(79, 124, 255, 0.46);
    --choice-hover-border: rgba(79, 124, 255, 0.35);
    --focus-border: rgba(79, 124, 255, 0.55);
    --focus-ring: rgba(79, 124, 255, 0.10);
    --dialog-scrim: rgba(15, 23, 42, 0.35);
    --drawer-scrim-bg: rgba(15, 23, 42, 0.28);
    --danger-hover-bg: #fff7f7;
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 12px;
    --main-x-padding: clamp(18px, 1.8vw, 28px);
    --bookmark-row-columns: 24px 42px minmax(0, 1fr) clamp(180px, 22vw, 320px) 68px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #202124;
        --panel: #25272d;
        --panel-soft: #2e323a;
        --line: #3c4043;
        --text: #e8eaed;
        --muted: #bdc1c6;
        --muted-2: #9aa0a6;
        --accent: #8ab4f8;
        --accent-soft: rgba(138, 180, 248, 0.16);
        --danger: #ff6b6b;
        --danger-soft: rgba(255, 107, 107, 0.14);
        --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
        --sidebar-bg: rgba(32, 33, 36, 0.94);
        --topbar-bg: rgba(32, 33, 36, 0.94);
        --floating-bg: rgba(37, 39, 45, 0.96);
        --count-bg: rgba(232, 237, 247, 0.08);
        --active-count-bg: rgba(138, 180, 248, 0.20);
        --selected-row-bg: rgba(138, 180, 248, 0.10);
        --folder-row-bg: rgba(138, 180, 248, 0.08);
        --folder-row-hover-bg: rgba(138, 180, 248, 0.12);
        --folder-letter-bg: rgba(138, 180, 248, 0.16);
        --topbar-border: #3c4043;
        --floating-border: #3c4043;
        --toolbar-border: rgba(138, 180, 248, 0.20);
        --row-border: #3c4043;
        --row-hover-border: #5f6368;
        --row-selected-border: rgba(138, 180, 248, 0.44);
        --choice-hover-border: rgba(138, 180, 248, 0.38);
        --focus-border: rgba(138, 180, 248, 0.62);
        --focus-ring: rgba(138, 180, 248, 0.14);
        --dialog-scrim: rgba(3, 7, 18, 0.58);
        --drawer-scrim-bg: rgba(3, 7, 18, 0.52);
        --danger-hover-bg: rgba(255, 107, 107, 0.10);
        color-scheme: dark;
    }
}

/* 2. Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input {
    font: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

/* 3. Layout */
.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px 1fr;
}

.sidebar {
    height: 100vh;
    position: sticky;
    top: 0;
    padding: 24px 18px;
    border-right: 1px solid var(--line);
    background: var(--sidebar-bg);
    backdrop-filter: blur(18px);
    overflow-y: auto;
}

.drawer-scrim,
.folder-fab {
    display: none;
}

/* 4. Sidebar */
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4f7cff, #8b5cf6);
    color: white;
    font-weight: 800;
    box-shadow: 0 12px 24px rgba(79, 124, 255, 0.25);
}

.brand-auth-btn {
    position: relative;
    width: 56px;
    height: 56px;
    flex: 0 0 56px;
    border: 0;
    padding: 0;
    border-radius: 14px;
    background: transparent;
    cursor: pointer;
}

.brand-auth-icon {
    display: block;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    object-fit: cover;
}

.brand-auth-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.brand-auth-tooltip {
    position: absolute;
    left: 50%;
    top: calc(100% + 8px);
    z-index: 20;
    min-width: 44px;
    padding: 5px 8px;
    border-radius: 8px;
    background: rgba(16, 20, 30, 0.92);
    color: #fff;
    font-size: 12px;
    line-height: 1;
    text-align: center;
    transform: translateX(-50%) translateY(-2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.brand-auth-btn.unlocked:hover .brand-auth-tooltip,
.brand-auth-btn.unlocked:focus-visible .brand-auth-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.brand-auth-ring {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    opacity: 0;
    background:
        conic-gradient(#f5c542 var(--auth-ring-progress, 0deg), rgba(245, 197, 66, 0.18) 0deg);
    box-shadow: 0 0 0 2px var(--sidebar-bg);
    transition: opacity 0.16s ease;
}

.brand-auth-ring::after {
    content: "";
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: var(--sidebar-bg);
}

.brand-auth-btn.expiring .brand-auth-ring {
    opacity: 1;
}

.brand-title {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 0.2px;
}

.brand-settings-btn {
    display: block;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    line-height: normal;
    padding: 2px 4px;
    margin: 0 0 0 -4px;
    text-align: left;
    transition: color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.brand-settings-btn:hover {
    color: var(--accent);
    background: var(--accent-soft);
}

.brand-settings-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--focus-ring);
}

body.readonly-mode .brand-settings-btn {
    pointer-events: none;
}

.brand-subtitle {
    margin-top: 2px;
    font-size: 12px;
    color: var(--muted);
}

.sidebar-section {
    margin-top: 24px;
}

.brand + .sidebar-section {
    margin-top: 0;
}

.sidebar-section-title {
    padding: 0 8px;
    margin-bottom: 10px;
    font-size: 12px;
    color: var(--muted);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* 5. Folder Tree */
.folder-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.folder-item {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text);
    border-radius: 12px;
    padding: 10px 10px;
    padding-left: calc(10px + var(--level, 0) * 18px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: default;
    transition: background 0.16s ease, color 0.16s ease;
    text-align: left;
}

.folder-item:hover {
    background: var(--panel-soft);
}

.folder-item.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.folder-item.sortable,
.bookmark-row.sortable {
    cursor: default;
}

.folder-item .folder-left,
.folder-item .folder-icon,
.folder-item .folder-name,
.folder-item .folder-count,
.bookmark-row .bookmark-letter,
.bookmark-row .bookmark-text,
.bookmark-row .bookmark-title,
.bookmark-row .bookmark-domain,
.bookmark-row .bookmark-folder {
    cursor: inherit;
}

.bookmark-list-header,
.bookmark-header-title,
.bookmark-header-folder,
.bookmark-header-actions {
    cursor: default;
}

.folder-item.sortable:active,
.bookmark-row.sortable:active {
    cursor: grabbing;
}

.folder-item.dragging,
.bookmark-row.dragging {
    opacity: 0.48;
}

.folder-item.drop-before,
.folder-item.drop-after,
.bookmark-row.drop-before,
.bookmark-row.drop-after {
    position: relative;
}

.folder-item.drop-before::before,
.folder-item.drop-after::after,
.bookmark-row.drop-before::before,
.bookmark-row.drop-after::after {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    height: 2px;
    border-radius: 999px;
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--focus-ring);
    pointer-events: none;
}

.folder-item.drop-before::before,
.bookmark-row.drop-before::before {
    top: -7px;
}

.folder-item.drop-after::after,
.bookmark-row.drop-after::after {
    bottom: -7px;
}

.folder-left {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.folder-caret {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.folder-caret {
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
    transition: transform 0.16s ease, color 0.16s ease;
}

.folder-item.has-children .folder-caret {
    cursor: pointer;
}

.folder-caret.open {
    transform: rotate(90deg);
    color: var(--accent);
}

.folder-icon {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.folder-icon svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.folder-item.active .folder-icon,
.folder-item.active .folder-caret {
    color: var(--accent);
}

.folder-name {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 14px;
    font-weight: 650;
}

.folder-right {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
}

.folder-count {
    flex: 0 0 auto;
    min-width: 26px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--count-bg);
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

.folder-item.active .folder-count {
    background: var(--active-count-bg);
    color: var(--accent);
}

.folder-actions {
    position: absolute;
    right: 100%;
    top: 50%;
    z-index: 12;
    min-width: 56px;
    min-height: 30px;
    padding: 4px;
    border: 1px solid var(--floating-border);
    border-radius: 999px;
    background: var(--floating-bg);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-50%) translateX(4px) scale(0.96);
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.folder-edit,
.folder-delete {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.16s ease, color 0.16s ease;
}

.folder-edit {
    font-size: 13px;
}

.folder-right:hover .folder-actions {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(-50%) translateX(0) scale(1);
}

.folder-edit:hover {
    background: var(--accent-soft);
    color: var(--accent);
}

.folder-delete:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

/* 6. Main Panel */
.main-panel {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* 7. Topbar And Search */
.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: 1fr minmax(260px, 420px);
    gap: 24px;
    align-items: center;
    padding: 28px 34px 18px;
    background: var(--topbar-bg);
    backdrop-filter: blur(18px);
}

.topbar::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -12px;
    height: 18px;
    pointer-events: none;
    background: linear-gradient(to bottom, var(--topbar-bg), transparent);
}

.topbar h1 {
    font-size: 26px;
    line-height: 1.2;
    font-weight: 850;
}

.topbar p {
    margin-top: 6px;
    color: var(--muted);
    font-size: 14px;
}

.topbar-actions {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(220px, 420px) 46px;
    gap: 10px;
    align-items: center;
    justify-content: end;
}

.search-wrapper {
    position: relative;
}

.search-input {
    width: 100%;
    height: 46px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
    outline: none;
    padding: 0 18px 0 46px;
    color: var(--text);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.04);
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.search-input:focus {
    border-color: var(--focus-border);
    box-shadow: 0 0 0 4px var(--focus-ring);
}

.search-icon {
    position: absolute;
    left: 17px;
    top: 50%;
    width: 18px;
    height: 18px;
    transform: translateY(-50%);
    fill: var(--muted-2);
}

.topbar-more {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

.auth-list {
    display: grid;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    overflow: hidden;
}

.auth-list-item {
    min-height: 72px;
    border-bottom: 1px solid var(--line);
    background: transparent;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
}

.auth-list-item:last-child {
    border-bottom: 0;
}

.auth-list-item.muted {
    opacity: 0.62;
}

.auth-list-main {
    min-width: 0;
    flex: 1 1 auto;
}

.auth-list .row-btn {
    min-height: 36px;
    flex: 0 0 auto;
    border: 1px solid var(--line);
    background: var(--panel-soft);
    color: var(--text);
    padding: 0 14px;
}

.auth-list-name {
    color: var(--text);
    font-size: 14px;
    font-weight: 800;
}

.auth-list-meta,
.auth-empty {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.auth-empty {
    border: 0;
    padding: 14px;
}

.auth-token-once {
    display: grid;
    gap: 10px;
}

.auth-token-note {
    color: var(--muted);
    font-size: 12px;
}

.auth-token-once code {
    display: block;
    max-width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
    font-size: 12px;
    line-height: 1.5;
    overflow-wrap: anywhere;
    padding: 10px;
}

.auth-pill {
    display: inline-flex;
    align-items: center;
    height: 18px;
    margin-left: 6px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 11px;
    padding: 0 7px;
}

.auth-pill.muted {
    background: var(--hover);
    color: var(--muted);
}

.topbar-more-btn {
    width: 46px;
    height: 46px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.04);
    transition: color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.topbar-more-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.topbar-more-btn:hover,
.topbar-more.open .topbar-more-btn {
    color: var(--accent);
    border-color: var(--focus-border);
    box-shadow: 0 0 0 4px var(--focus-ring);
}

.topbar-more-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    z-index: 30;
    min-width: 0;
    width: max-content;
    padding: 6px;
    border: 1px solid var(--floating-border);
    border-radius: 14px;
    background: var(--floating-bg);
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.14);
    backdrop-filter: blur(10px);
    display: none;
}

.topbar-more.open .topbar-more-panel {
    display: block;
}

.topbar-more-item {
    width: 100%;
    height: 38px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 8px;
    font-size: 13px;
    font-weight: 750;
    text-align: left;
}

.topbar-more-item svg {
    width: 17px;
    height: 17px;
    fill: currentColor;
}

.topbar-more-item:hover {
    background: var(--panel-soft);
    color: var(--accent);
}

.topbar-more-submenu-wrapper {
    position: relative;
}

.topbar-more-submenu-wrapper::before {
    content: "";
    position: absolute;
    top: 0;
    right: 100%;
    bottom: 0;
    width: 8px;
}

.topbar-more-submenu-trigger {
    padding-right: 8px;
}

.topbar-more-arrow {
    margin-left: auto;
    color: var(--muted-2);
    font-size: 16px;
    line-height: 1;
}

.topbar-more-submenu {
    position: absolute;
    top: 0;
    right: calc(100% + 8px);
    z-index: 31;
    min-width: 0;
    width: max-content;
    padding: 6px;
    border: 1px solid var(--floating-border);
    border-radius: 14px;
    background: var(--floating-bg);
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.14);
    backdrop-filter: blur(10px);
    display: none;
}

.topbar-more-submenu-wrapper:hover .topbar-more-submenu,
.topbar-more-submenu-wrapper.submenu-open .topbar-more-submenu {
    display: block;
}

.density-option {
    gap: 6px;
}

.density-check {
    width: 14px;
    color: var(--accent);
    font-weight: 850;
}

.density-option.active {
    color: var(--accent);
}

.density-option.active .density-check::before {
    content: "✓";
}

.content-area {
    padding: 14px 34px 110px;
}

/* Import Group Divider */
.import-group-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 18px 0 8px;
    padding: 8px 14px;
    border-radius: 11px;
    background: var(--accent-soft);
    border: 1px solid var(--toolbar-border);
}

.import-group-divider:first-child {
    margin-top: 0;
}

.import-group-select {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.import-group-select input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.import-group-name {
    flex: 1;
    min-width: 0;
    color: var(--accent);
    font-size: 13px;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.import-group-count {
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
    white-space: nowrap;
}

/* 8. List Header And Bulk Toolbar */
.bookmark-list-header {
    position: relative;
    display: none;
    grid-template-columns: var(--bookmark-row-columns);
    align-items: center;
    gap: 14px;
    min-height: 40px;
    margin-bottom: 12px;
    padding: 7px 16px;
    border: 1px solid var(--row-border);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.04);
}

.bookmark-list-header.show {
    display: grid;
}

.bulk-select-all,
.bulk-mini-select-all {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.bulk-select-all {
    justify-self: center;
    gap: 8px;
}

.bulk-select-all input,
.bulk-mini-select-all input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.bookmark-header-title,
.bookmark-header-folder,
.bookmark-header-actions {
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.bookmark-header-title {
    grid-column: 2 / 4;
}

.bookmark-header-folder {
    grid-column: 4;
}

.bookmark-header-actions {
    grid-column: 5;
    justify-self: start;
}

body.readonly-mode .bookmark-list-header,
body.readonly-mode .bookmark-row {
    grid-template-columns: 42px minmax(0, 1fr) clamp(180px, 22vw, 320px);
}

body.readonly-mode .bulk-select-all,
body.readonly-mode .bookmark-header-actions,
body.readonly-mode .bookmark-select,
body.readonly-mode .bookmark-actions {
    display: none;
}

body.readonly-mode .bookmark-header-title {
    grid-column: 2;
}

body.readonly-mode .bookmark-header-folder,
body.readonly-mode .bookmark-folder {
    grid-column: 3;
}

.bulk-move-count,
.bulk-mini-count {
    color: var(--muted);
    font-weight: 750;
    white-space: nowrap;
}

.bulk-move-count {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    clip-path: inset(50%);
}

.bulk-move-count {
    font-size: 14px;
    font-weight: 700;
}

.bulk-mini-count {
    font-size: 13px;
}

.bulk-move-count strong,
.bulk-mini-count strong {
    color: var(--accent);
    font-weight: 850;
}

.bulk-move-btn,
.bulk-export-btn,
.bulk-delete-btn,
.bulk-finish-btn {
    height: 38px;
    border: none;
    border-radius: 11px;
    padding: 0 14px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 750;
    white-space: nowrap;
}

.bulk-move-btn,
.bulk-finish-btn {
    background: var(--accent);
    color: white;
    box-shadow: 0 10px 20px rgba(79, 124, 255, 0.18);
}

.bulk-export-btn {
    background: var(--accent-soft);
    color: var(--accent);
}

.bulk-delete-btn {
    background: var(--danger-soft);
    color: var(--danger);
}

.bulk-move-btn:disabled,
.bulk-export-btn:disabled,
.bulk-delete-btn:disabled,
.bulk-select-all:has(input:disabled),
.bulk-mini-select-all:has(input:disabled) {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

.bulk-select-all:has(input:disabled) input,
.bulk-mini-select-all:has(input:disabled) input {
    cursor: not-allowed;
}

.bulk-mini-bar {
    position: fixed;
    left: 50%;
    bottom: 22px;
    z-index: 25;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 7px 8px 7px 12px;
    border: 1px solid var(--toolbar-border);
    border-radius: 999px;
    background: var(--floating-bg);
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.16);
    backdrop-filter: blur(12px);
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(16px) scale(0.98);
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.bulk-mini-select-all {
    flex: 0 0 auto;
}

.bulk-mini-bar.show {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0) scale(1);
}

.bulk-mini-btn {
    min-width: 56px;
    height: 34px;
    border: none;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    cursor: pointer;
    padding: 0 13px;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

.bulk-mini-clear {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.bulk-mini-clear:hover {
    background: var(--panel-soft);
    color: var(--text);
}

.bulk-mini-btn.danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.bulk-export-btn[hidden],
.bulk-finish-btn[hidden],
.bulk-mini-btn[hidden] {
    display: none;
}

/* 9. Folder Autocomplete */
.folder-suggestion-popup {
    position: fixed;
    z-index: 180;
    display: none;
    max-height: 248px;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--toolbar-border);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.14);
}

.folder-suggestion-popup.show {
    display: grid;
    gap: 2px;
}

.folder-suggestion-item {
    width: 100%;
    min-height: 34px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
    text-align: left;
    padding: 8px 10px;
}

.folder-suggestion-item:hover,
.folder-suggestion-item:focus {
    background: var(--panel-soft);
    outline: none;
}

/* 10. Bookmark List */
.bookmark-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bookmark-row {
    display: grid;
    grid-template-columns: var(--bookmark-row-columns);
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--panel);
    border: 1px solid var(--row-border);
    border-radius: 18px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.04);
    cursor: default;
    transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.bookmark-row:hover {
    transform: translateY(-1px);
    border-color: var(--row-hover-border);
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.07);
}

.bookmark-row.selected {
    border-color: var(--row-selected-border);
    background: var(--selected-row-bg);
}

.bookmark-select,
.bookmark-select-spacer {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.bookmark-select {
    cursor: pointer;
}

.bookmark-select input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.bookmark-letter {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 850;
    font-size: 16px;
}

.bookmark-text {
    min-width: 0;
}

.bookmark-title {
    font-size: 15px;
    font-weight: 750;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bookmark-domain {
    margin-top: 3px;
    max-width: 360px;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bookmark-folder {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    grid-column: 4;
    justify-self: start;
    max-width: 100%;
    min-height: 20px;
    padding: 2px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel-soft);
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
    line-height: 15px;
}

.dot {
    color: var(--muted-2);
}

.bookmark-actions {
    grid-column: 5;
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: flex-start;
    opacity: 0.42;
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.bookmark-row:hover .bookmark-actions,
.bookmark-row:focus-within .bookmark-actions,
.bookmark-row.selected .bookmark-actions {
    opacity: 1;
}

.row-btn {
    border: none;
    background: var(--panel-soft);
    color: var(--muted);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 650;
    transition: background 0.16s ease, color 0.16s ease;
}

.row-btn.icon-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
}

.row-btn:hover {
    background: var(--accent-soft);
    color: var(--accent);
}

.row-btn.danger:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

.state-text {
    color: var(--muted);
    text-align: center;
    padding: 60px 16px;
    background: var(--panel);
    border: 1px dashed var(--line);
    border-radius: var(--radius-lg);
}

/* 11. Folder Rows */
.folder-row {
    border-style: dashed;
    background: var(--folder-row-bg);
}

.folder-row:hover {
    background: var(--folder-row-hover-bg);
}

.folder-letter {
    background: var(--folder-letter-bg);
    color: var(--accent);
}

body[data-density="compact"] .bookmark-panel {
    overflow: hidden;
    border: 1px solid var(--row-border);
    border-radius: 18px;
    background: var(--panel);
    background: color-mix(in srgb, var(--panel) 84%, transparent);
    box-shadow: 0 18px 46px rgba(15, 23, 42, 0.07);
}

body[data-density="compact"] .bookmark-list-header {
    gap: 10px;
    margin-bottom: 0;
    border: 0;
    border-bottom: 1px solid var(--toolbar-border);
    border-radius: 0;
    background: var(--floating-bg);
    background: color-mix(in srgb, var(--floating-bg) 88%, transparent);
    box-shadow: none;
}

body[data-density="compact"] .import-group-divider {
    margin: 0;
    padding: 9px 14px;
    border: 0;
    border-bottom: 1px solid var(--row-border);
    border-radius: 0;
}

body[data-density="compact"] .bookmark-list {
    gap: 0;
}

body[data-density="compact"] .bookmark-row {
    gap: 10px;
    min-height: 54px;
    padding: 8px 14px;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--row-border);
    border-radius: 0;
    box-shadow: none;
    transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

body[data-density="compact"] .bookmark-row:last-child {
    border-bottom: 0;
}

body[data-density="compact"] .bookmark-row:hover {
    transform: none;
    background: color-mix(in srgb, var(--panel-soft) 72%, transparent);
    box-shadow: none;
}

body[data-density="compact"] .bookmark-select,
body[data-density="compact"] .bookmark-select-spacer {
    width: 22px;
    height: 22px;
}

body[data-density="compact"] .bookmark-letter {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    font-size: 14px;
}

body[data-density="compact"] .bookmark-title {
    font-size: 14px;
}

body[data-density="compact"] .state-text {
    background: transparent;
    border: 0;
    border-radius: 0;
}

body[data-density="compact"] .folder-row {
    border-style: solid;
}

/* 12. Dialogs */
.dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--dialog-scrim);
    backdrop-filter: blur(8px);
}

#settings-overlay {
    align-items: flex-start;
    overflow-y: auto;
    padding: 28px 0;
}

.dialog-box {
    width: min(92vw, 430px);
    background: var(--panel);
    border-radius: 24px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.dialog-title {
    margin-bottom: 20px;
    font-size: 19px;
    font-weight: 850;
}

.dialog-desc {
    margin: -6px 0 22px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.7;
}

.dialog-desc strong {
    color: var(--text);
    font-weight: 850;
}

.dialog-message {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.7;
    white-space: pre-line;
}

.auth-session-options {
    min-width: min(320px, 100%);
}

.auth-session-duration-field {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.auth-session-duration-field select {
    width: 100%;
    height: 44px;
    border: 1px solid var(--line);
    background: var(--panel-soft);
    border-radius: 13px;
    outline: none;
    padding: 0 12px;
    color: var(--text);
    font-size: 14px;
}

.auth-session-duration-field select:focus {
    background: var(--panel);
    border-color: var(--focus-border);
    box-shadow: 0 0 0 4px var(--focus-ring);
}

.input-group {
    margin-bottom: 18px;
}

.input-group label {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.06em;
}

.input-group input {
    width: 100%;
    height: 44px;
    border: 1px solid var(--line);
    background: var(--panel-soft);
    border-radius: 13px;
    outline: none;
    padding: 0 14px;
    color: var(--text);
    transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.input-group input:focus {
    background: var(--panel);
    border-color: var(--focus-border);
    box-shadow: 0 0 0 4px var(--focus-ring);
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

.dialog-actions button,
.btn-close,
.btn-save {
    border: none;
    border-radius: 12px;
    padding: 10px 18px;
    cursor: pointer;
    font-weight: 750;
    line-height: 1.2;
}

.btn-close {
    background: var(--panel-soft);
    color: var(--text);
}

.btn-save {
    background: var(--accent);
    color: white;
    box-shadow: 0 10px 20px rgba(79, 124, 255, 0.22);
}

.btn-save.danger {
    background: var(--danger);
    box-shadow: 0 10px 20px rgba(239, 68, 68, 0.18);
}

.app-dialog-box {
    width: min(92vw, 420px);
}

.settings-box {
    width: min(92vw, 640px);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 56px);
    overflow: hidden;
}

.settings-section {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--panel-soft);
    padding: 20px;
}

.settings-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    margin-bottom: 18px;
    padding: 5px;
    border-radius: 13px;
    background: var(--panel-soft);
    border: 1px solid rgba(60, 64, 67, 0.22);
}

.settings-tab {
    min-height: 42px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-weight: 800;
    transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.settings-tab.active {
    background: var(--panel);
    color: var(--accent);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.settings-tab:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.settings-panel[hidden] {
    display: none;
}

.settings-panel.active {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    margin-right: -10px;
    padding-right: 18px;
    scrollbar-gutter: stable;
}

.settings-status-card {
    min-height: 64px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
    padding: 14px 16px;
}

.settings-sync-state {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 14px;
}

.settings-switch {
    position: relative;
    width: 42px;
    height: 24px;
    flex: 0 0 42px;
    border-radius: 999px;
    background: var(--line);
    transition: background 0.16s ease;
}

.settings-switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
    transition: transform 0.16s ease;
}

.settings-switch.active {
    background: var(--accent);
}

.settings-switch.active::after {
    transform: translateX(18px);
}

.settings-status-title {
    color: var(--text);
    font-size: 14px;
    font-weight: 850;
}

.settings-status-subtitle,
.settings-status-meta,
.settings-section-desc {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.settings-status-meta {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 7px;
    font-weight: 700;
}

.settings-section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.settings-form-grid {
    display: grid;
    gap: 16px;
}

.settings-form-grid .input-group {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
    margin-bottom: 0;
}

.settings-form-grid .input-group label {
    margin: 13px 0 0;
}

.settings-form-grid .input-group input {
    grid-column: 2;
}

.settings-panel-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 22px;
}

.settings-secondary-actions {
    display: flex;
    gap: 10px;
    margin-right: auto;
}

.settings-section-title {
    color: var(--text);
    font-size: 18px;
    font-weight: 850;
}

.settings-section .input-group input {
    background: var(--panel);
}

.auth-management-section {
    display: grid;
    gap: 22px;
}

.auth-settings-group {
    display: grid;
    gap: 12px;
}

.auth-section-actions {
    flex: 0 0 auto;
}

.auth-danger-zone {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: end;
    margin: 2px -20px -20px;
    border-top: 1px solid rgba(239, 68, 68, 0.26);
    background: linear-gradient(180deg, rgba(239, 68, 68, 0.04), rgba(239, 68, 68, 0.08));
    padding: 20px;
}

.auth-danger-title {
    color: var(--danger);
    font-size: 16px;
    font-weight: 850;
}

.auth-danger-desc {
    margin-top: 5px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.auth-danger-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.btn-danger-outline {
    min-height: 40px;
    border: 1px solid var(--danger);
    border-radius: 10px;
    background: transparent;
    color: var(--danger);
    cursor: pointer;
    font-size: 13px;
    font-weight: 800;
    padding: 0 14px;
}

.btn-danger-outline:hover {
    background: var(--danger-hover-bg);
}

.settings-box > .dialog-actions {
    margin: 20px -28px -28px;
    padding: 16px 28px 28px;
    background: var(--panel);
    border-top: 1px solid var(--line);
}

/* 13. Folder Delete Dialog */
.folder-delete-box {
    width: min(92vw, 460px);
}

.folder-delete-choice {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 26px;
}

.choice-row {
    min-height: 48px;
    border: 1px solid var(--line);
    background: var(--panel-soft);
    color: var(--text);
    border-radius: 14px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background 0.16s ease, border-color 0.16s ease;
}

.choice-row:hover {
    background: var(--panel);
    border-color: var(--choice-hover-border);
}

.choice-row input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.choice-row span {
    font-size: 14px;
    font-weight: 700;
}

.choice-row strong {
    color: var(--accent);
    font-weight: 850;
}

.choice-row.danger:hover {
    border-color: rgba(239, 68, 68, 0.35);
    background: var(--danger-hover-bg);
}

.choice-row.danger input {
    accent-color: var(--danger);
}

/* 14. Floating Actions */
.folder-fab,
.floating-add-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transform: translateZ(0);
    transition: transform 0.18s ease;
}

.folder-fab svg,
.floating-add-btn svg {
    width: 26px;
    height: 26px;
    fill: white;
    transform-origin: center;
    transition: transform 0.18s ease;
}

.folder-fab {
    position: fixed;
    left: 30px;
    bottom: 30px;
    z-index: 20;
    display: none;
    background: linear-gradient(135deg, #14b8a6, #4f7cff);
    box-shadow: 0 10px 25px rgba(20, 184, 166, 0.28);
}

.folder-fab:hover {
    transform: translateZ(0) scale(1.06);
}

.floating-menu {
    position: fixed;
    right: 30px;
    bottom: 30px;
    z-index: 20;
    width: 60px;
    height: 60px;
}

body.readonly-mode .floating-menu,
body.readonly-mode .bulk-mini-bar {
    display: none;
}

.floating-menu::before {
    content: "";
    position: absolute;
    right: 0;
    bottom: 100%;
    width: 60px;
    height: 84px;
    pointer-events: none;
}

.floating-menu.open::before,
.floating-menu.hover::before {
    pointer-events: auto;
}

.floating-action-item {
    position: absolute;
    right: 0;
    min-width: 128px;
    height: 44px;
    border: none;
    border-radius: 999px;
    background: var(--floating-bg);
    color: var(--text);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 0 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 750;
    backdrop-filter: blur(10px);
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px) scale(0.96);
    transition: opacity 0.18s ease, transform 0.18s ease, color 0.18s ease;
}

.floating-action-item:nth-of-type(1) {
    bottom: calc(100% + 68px);
}

.floating-action-item:nth-of-type(2) {
    bottom: calc(100% + 12px);
}

.floating-action-item svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.floating-action-item:hover {
    color: var(--accent);
}

.floating-menu.open .floating-action-item,
.floating-menu.hover .floating-action-item {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.floating-add-btn {
    position: absolute;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 10px 25px rgba(118, 75, 162, 0.4);
}

.floating-add-btn:hover {
    transform: translateZ(0) scale(1.06);
}

.floating-add-btn:active {
    transform: translateZ(0) scale(0.98);
}

.floating-menu.open .floating-add-btn svg,
.floating-menu.hover .floating-add-btn svg {
    transform: rotate(45deg);
}

/* 15. Responsive */
@media (max-width: 860px) {
    :root {
        --bookmark-row-columns: 22px 32px minmax(0, 1fr);
    }

    /* Layout */
    .app-shell {
        grid-template-columns: 1fr;
    }

    /* Mobile Drawer */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 90;
        width: min(82vw, 320px);
        height: 100vh;
        border-right: 1px solid var(--line);
        border-bottom: none;
        padding: 22px 16px;
        transform: translateX(-105%);
        transition: transform 0.22s ease;
        box-shadow: 18px 0 42px rgba(15, 23, 42, 0.14);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .drawer-scrim {
        position: fixed;
        inset: 0;
        z-index: 80;
        display: block;
        background: var(--drawer-scrim-bg);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.18s ease;
    }

    .drawer-scrim.open {
        opacity: 1;
        pointer-events: auto;
    }

    /* Mobile Floating Entry */
    .folder-fab {
        display: flex;
        left: 20px;
        bottom: calc(20px + env(safe-area-inset-bottom));
        width: 52px;
        height: 52px;
    }

    .folder-list {
        flex-direction: column;
        overflow-x: visible;
        padding-bottom: 0;
    }

    .folder-item {
        width: 100%;
        min-width: 0;
    }

    /* Mobile Topbar */
    .topbar {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 16px 14px 12px;
    }

    .topbar h1 {
        font-size: 24px;
    }

    .topbar p {
        margin-top: 4px;
        font-size: 13px;
    }

    .topbar-actions {
        grid-template-columns: minmax(0, 1fr) 42px;
        gap: 8px;
    }

    .search-input,
    .topbar-more-btn {
        height: 42px;
    }

    .topbar-more-btn {
        width: 42px;
    }

    .topbar-more-panel {
        min-width: 196px;
    }

    .topbar-more-submenu-wrapper::before {
        content: none;
    }

    .topbar-more-submenu {
        position: static;
        min-width: 0;
        margin: 4px 0 6px 26px;
        padding: 4px;
        border-radius: 10px;
        box-shadow: none;
        background: var(--panel-soft);
        backdrop-filter: none;
    }

    .topbar-more-submenu-wrapper:hover .topbar-more-submenu {
        display: none;
    }

    .topbar-more-submenu-wrapper.submenu-open .topbar-more-submenu {
        display: block;
    }

    /* Mobile Settings Dialog */
    #settings-overlay {
        padding: 12px;
    }

    .settings-box {
        width: 100%;
        max-height: calc(100vh - 24px);
        padding: 22px;
        border-radius: 18px;
    }

    .settings-status-card,
    .settings-section-header,
    .settings-panel-actions,
    .auth-danger-zone {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }

    .settings-status-card {
        align-items: flex-start;
    }

    .settings-form-grid .input-group {
        grid-template-columns: 1fr;
        gap: 7px;
    }

    .settings-form-grid .input-group label {
        margin: 0;
    }

    .settings-form-grid .input-group input {
        grid-column: auto;
    }

    .settings-secondary-actions,
    .auth-danger-actions {
        width: 100%;
        margin-right: 0;
    }

    .settings-secondary-actions button,
    .auth-danger-actions button {
        flex: 1 1 0;
    }

    .auth-list-item {
        align-items: flex-start;
    }

    .settings-box > .dialog-actions {
        margin: 18px -22px -22px;
        padding: 14px 22px 22px;
    }

    /* Mobile Content And Bulk Actions */
    .content-area {
        padding: 12px 14px 160px;
    }

    .bookmark-panel {
        border-radius: 14px;
    }

    .bookmark-list-header,
    .bookmark-list-header.show {
        display: none;
    }

    .bulk-mini-bar {
        right: auto;
        left: 50%;
        width: max-content;
        max-width: calc(100vw - 32px);
        bottom: calc(16px + env(safe-area-inset-bottom));
        gap: 8px;
        justify-content: center;
        padding: 7px;
        transform: translateX(-50%) translateY(16px) scale(0.98);
    }

    .bulk-mini-bar.show {
        transform: translateX(-50%) translateY(0) scale(1);
    }

    .bulk-mini-count {
        font-size: 12px;
    }

    .bulk-mini-btn {
        min-width: 50px;
        height: 34px;
        padding: 0 11px;
    }

    .bulk-mini-clear {
        width: 32px;
        height: 32px;
    }

    /* Mobile Bookmark Rows */
    .bookmark-row {
        position: relative;
        overflow: hidden;
        grid-template-columns: var(--bookmark-row-columns);
        grid-template-rows: auto auto;
        align-items: center;
        min-height: 72px;
        padding: 10px 12px;
    }

    .bookmark-text {
        grid-column: 3;
        grid-row: 1;
    }

    .bookmark-folder {
        grid-column: 3;
        grid-row: 2;
        margin-top: 6px;
        max-width: min(100%, 260px);
    }

    body.readonly-mode .bookmark-row {
        grid-template-columns: 32px minmax(0, 1fr);
    }

    body.readonly-mode .bookmark-text,
    body.readonly-mode .bookmark-folder {
        grid-column: 2;
    }

    .bookmark-actions {
        position: absolute;
        right: 12px;
        top: 50%;
        z-index: 2;
        justify-content: flex-end;
        opacity: 1;
        pointer-events: none;
        transform: translate(calc(100% + 28px), -50%);
        transition: transform 0.18s ease;
    }

    .bookmark-row.actions-open .bookmark-actions {
        pointer-events: auto;
        transform: translate(0, -50%);
    }

    /* Mobile Add Menu */
    .floating-menu {
        right: 20px;
        bottom: calc(20px + env(safe-area-inset-bottom));
        width: 52px;
        height: 52px;
    }

    .floating-add-btn {
        width: 52px;
        height: 52px;
    }

    .floating-action-item {
        min-width: 118px;
        height: 40px;
        font-size: 13px;
    }

    .floating-action-item:nth-of-type(1) {
        bottom: calc(100% + 64px);
    }

    .floating-action-item:nth-of-type(2) {
        bottom: calc(100% + 12px);
    }

    /* Selection mode gives the bottom action bar priority. */
    body:has(.bulk-mini-bar.show) .folder-fab,
    body:has(.bulk-mini-bar.show) .floating-menu {
        opacity: 0;
        pointer-events: none;
        transform: translateY(12px) scale(0.92);
    }
}
